diff options
Diffstat (limited to 'core/src/UI/UI_MainWindow.cpp')
-rw-r--r-- | core/src/UI/UI_MainWindow.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/core/src/UI/UI_MainWindow.cpp b/core/src/UI/UI_MainWindow.cpp index 1838aec..18f6731 100644 --- a/core/src/UI/UI_MainWindow.cpp +++ b/core/src/UI/UI_MainWindow.cpp @@ -3,7 +3,6 @@ #include "Model/GlobalStates.hpp" #include "Model/Project.hpp" #include "UI/Localization.hpp" -#include "UI/States.hpp" #include <IconsFontAwesome.h> #include <imgui.h> @@ -19,10 +18,9 @@ void ProjectTab_Normal() { auto ls = LocaleStrings::Instance.get(); auto& gs = GlobalStates::GetInstance(); - auto& uis = UIState::GetInstance(); if (ImGui::Button(ls->Close.Get())) { - uis.CloseCurrentProject(); + gs.SetCurrentProject(nullptr); return; } ImGui::SameLine(); @@ -30,15 +28,14 @@ void ProjectTab_Normal() // TODO } - ImGui::Text("%s%s", ls->ActiveProjectName.Get(), uis.CurrentProject->GetName().c_str()); - ImGui::Text("%s%s", ls->ActiveProjectPath.Get(), uis.CurrentProject->GetPathString().c_str()); + ImGui::Text("%s%s", ls->ActiveProjectName.Get(), gs.GetCurrentProject()->GetName().c_str()); + ImGui::Text("%s%s", ls->ActiveProjectPath.Get(), gs.GetCurrentProject()->GetPathString().c_str()); } void ProjectTab_NoProject() { auto ls = LocaleStrings::Instance.get(); auto& gs = GlobalStates::GetInstance(); - auto& uis = UIState::GetInstance(); bool openedDummy = true; bool openErrorDialog = false; @@ -90,7 +87,7 @@ void ProjectTab_NoProject() if (ImGui::Button(ls->DialogConfirm.Get(), !dirNameIsValid || projectName.empty())) { ImGui::CloseCurrentPopup(); - uis.SetCurrentProject(std::make_unique<Project>(std::move(dirPath), std::move(projectName))); + gs.SetCurrentProject(std::make_unique<Project>(std::move(dirPath), std::move(projectName))); // Dialog just got closed, reset states projectName.clear(); @@ -115,7 +112,7 @@ void ProjectTab_NoProject() try { // Project's constructor wants a path to directory containing cplt_project.json - uis.SetCurrentProject(std::make_unique<Project>(path.parent_path())); + gs.SetCurrentProject(std::make_unique<Project>(path.parent_path())); openErrorDialog = false; } catch (const std::exception& e) { openErrorDialog = true; @@ -151,7 +148,7 @@ void ProjectTab_NoProject() ImGui::SameLine(); if (ImGui::Button(ICON_FA_FOLDER_OPEN)) { try { - uis.SetCurrentProject(std::make_unique<Project>(path)); + gs.SetCurrentProject(std::make_unique<Project>(path)); openErrorDialog = false; } catch (const std::exception& e) { openErrorDialog = true; @@ -191,7 +188,7 @@ void ProjectTab_NoProject() void UI::MainWindow() { auto ls = LocaleStrings::Instance.get(); - auto& uis = UIState::GetInstance(); + auto& gs = GlobalStates::GetInstance(); auto windowSize = ImGui::GetMainViewport()->Size; ImGui::SetNextWindowSize({ windowSize.x, windowSize.y }); @@ -204,14 +201,14 @@ void UI::MainWindow() } if (ImGui::BeginTabItem(ls->ProjectTab.Get(), nullptr)) { - if (uis.CurrentProject) { + if (gs.HasCurrentProject()) { ProjectTab_Normal(); } else { ProjectTab_NoProject(); } ImGui::EndTabItem(); } - if (!uis.CurrentProject) { + if (!gs.HasCurrentProject()) { // No project open, simply skip all project specific tabs goto endTab; } |