diff --git a/SHADE_Engine/src/Editor/EditorWindow/MenuBar/SHEditorMenuBar.cpp b/SHADE_Engine/src/Editor/EditorWindow/MenuBar/SHEditorMenuBar.cpp index a364ea83..d4126123 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/MenuBar/SHEditorMenuBar.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/MenuBar/SHEditorMenuBar.cpp @@ -81,126 +81,18 @@ namespace SHADE if (ImGui::BeginMainMenuBar()) { - if (ImGui::BeginMenu("File")) - { - if(ImGui::Selectable("New Scene")) - { - SHSystemManager::GetSystem()->NewScene(); - } - if(ImGui::Selectable("Save")) - { - SHSystemManager::GetSystem()->SaveScene(); - } - if(ImGui::Selectable("Load")) - { - //SHSystemManager::GetSystem()->LoadScene() - } - ImGui::EndMenu(); - } - if(ImGui::BeginMenu("Edit")) - { - ImGui::BeginDisabled(!SHCommandManager::GetUndoStackSize()); - if(ImGui::Button(std::format("{} Undo", ICON_MD_UNDO).data())) - { - SHCommandManager::UndoCommand(); - } - ImGui::EndDisabled(); - ImGui::BeginDisabled(!SHCommandManager::GetRedoStackSize()); - if(ImGui::Button(std::format("{} Redo", ICON_MD_REDO).data())) - { - SHCommandManager::RedoCommand(); - } - ImGui::EndDisabled(); - ImGui::EndMenu(); - } - if (ImGui::BeginMenu("Scripts")) - { - if (ImGui::Selectable("Generate Visual Studio Project")) - { - auto* scriptEngine = static_cast(SHSystemManager::GetSystem()); - scriptEngine->GenerateScriptsCsProjFile(); - } - ImGui::BeginDisabled(SHSystemManager::GetSystem()->editorState != SHEditor::State::STOP); - if (ImGui::Selectable("Build Scripts - Debug")) - { - auto* scriptEngine = static_cast(SHSystemManager::GetSystem()); - SHSerialization::SerializeSceneToFile(SHSceneManager::GetCurrentSceneAssetID()); - scriptEngine->BuildScriptAssembly(true, true); - SHSceneManager::RestartScene(SHSceneManager::GetCurrentSceneAssetID()); - } - if (ImGui::Selectable("Build Scripts - Release")) - { - auto* scriptEngine = static_cast(SHSystemManager::GetSystem()); - SHSerialization::SerializeSceneToFile(SHSceneManager::GetCurrentSceneAssetID()); - scriptEngine->BuildScriptAssembly(false, true); - SHSceneManager::RestartScene(SHSceneManager::GetCurrentSceneAssetID()); - } - ImGui::EndDisabled(); - ImGui::EndMenu(); - } + DrawFileMenu(); + DrawEditMenu(); + DrawScriptsMenu(); + DrawWindowMenu(); + DrawThemeMenu(); + DrawLayoutMenu(); + DrawApplicationConfig(); - if (ImGui::BeginMenu("Window")) - { - for (const auto& window : SHEditorWindowManager::editorWindows | std::views::values) - { - if (window.get() != this) - ImGui::Checkbox(window->windowName.data(), &window->isOpen); - } - ImGui::EndMenu(); - } - if (ImGui::BeginMenu("Theme")) - { - const auto styles = rttr::type::get().get_enumeration(); - auto values = styles.get_values(); - for (auto style : values) - { - if (ImGui::Selectable(style.to_string().c_str())) - { - if (auto editor = SHSystemManager::GetSystem()) - editor->SetStyle(style.convert()); - } - } - ImGui::EndMenu(); - } - if(ImGui::BeginMenu("Layout")) - { - for(auto const& entry : layoutPaths) - { - if(ImGui::Selectable(entry.stem().string().c_str())) - { - ImGui::LoadIniSettingsFromDisk(entry.string().c_str()); - } - } - ImGui::EndMenu(); - } - - if (ImGui::BeginMenu("Application Config")) - { - auto& appConfig = SHConfigurationManager::applicationConfig; - ImGui::InputText("Window Title", &appConfig.windowTitle); - ImGui::Checkbox("Start in Fullscreen", &appConfig.startInFullScreen); - SHEditorWidgets::DragN("Window Size", { "Width", "Height" }, { &appConfig.windowSize.x, &appConfig.windowSize.y }); - //ImGui::InputScalar("Starting Scene", ImGuiDataType_U32, &appConfig.startingSceneID); - auto sceneAsset = SHAssetManager::GetData(appConfig.startingSceneID); - - if(ImGui::BeginCombo("Starting Scene", sceneAsset ? sceneAsset->name.data() : "")) - { - auto scenes = SHAssetManager::GetAllRecordOfType(AssetType::SCENE); - for(auto const& scene : scenes) - { - if(ImGui::Selectable(scene.name.data())) - { - appConfig.startingSceneID = scene.id; - } - } - ImGui::EndCombo(); - } - if (ImGui::Button("Save")) - { - SHConfigurationManager::SaveApplicationConfig(); - } - ImGui::EndMenu(); - } + std::string const sceneName{std::format("Current Scene: {}",SHSceneManager::GetSceneName().data())}; + auto const size = ImGui::CalcTextSize(sceneName.data()); + ImGui::SetCursorPosX(ImGui::GetWindowWidth() - size.x - ImGui::GetStyle().FramePadding.x); + ImGui::Text("%s", sceneName.data()); ImGui::EndMainMenuBar(); } @@ -267,4 +159,143 @@ namespace SHADE ImGui::PopStyleVar(3); } + void SHEditorMenuBar::DrawFileMenu() noexcept + { + if (ImGui::BeginMenu("File")) + { + if (ImGui::Selectable("New Scene")) + { + SHSystemManager::GetSystem()->NewScene(); + } + if (ImGui::Selectable("Save")) + { + SHSystemManager::GetSystem()->SaveScene(); + } + if (ImGui::Selectable("Load")) + { + //SHSystemManager::GetSystem()->LoadScene() + } + ImGui::EndMenu(); + } + } + void SHEditorMenuBar::DrawEditMenu() noexcept + { + if (ImGui::BeginMenu("Edit")) + { + ImGui::BeginDisabled(!SHCommandManager::GetUndoStackSize()); + if (ImGui::Button(std::format("{} Undo", ICON_MD_UNDO).data())) + { + SHCommandManager::UndoCommand(); + } + ImGui::EndDisabled(); + ImGui::BeginDisabled(!SHCommandManager::GetRedoStackSize()); + if (ImGui::Button(std::format("{} Redo", ICON_MD_REDO).data())) + { + SHCommandManager::RedoCommand(); + } + ImGui::EndDisabled(); + ImGui::EndMenu(); + } + } + void SHEditorMenuBar::DrawScriptsMenu() noexcept + { + if (ImGui::BeginMenu("Scripts")) + { + if (ImGui::Selectable("Generate Visual Studio Project")) + { + auto* scriptEngine = static_cast(SHSystemManager::GetSystem()); + scriptEngine->GenerateScriptsCsProjFile(); + } + ImGui::BeginDisabled(SHSystemManager::GetSystem()->editorState != SHEditor::State::STOP); + if (ImGui::Selectable("Build Scripts - Debug")) + { + auto* scriptEngine = static_cast(SHSystemManager::GetSystem()); + SHSerialization::SerializeSceneToFile(SHSceneManager::GetCurrentSceneAssetID()); + scriptEngine->BuildScriptAssembly(true, true); + SHSceneManager::RestartScene(SHSceneManager::GetCurrentSceneAssetID()); + } + if (ImGui::Selectable("Build Scripts - Release")) + { + auto* scriptEngine = static_cast(SHSystemManager::GetSystem()); + SHSerialization::SerializeSceneToFile(SHSceneManager::GetCurrentSceneAssetID()); + scriptEngine->BuildScriptAssembly(false, true); + SHSceneManager::RestartScene(SHSceneManager::GetCurrentSceneAssetID()); + } + ImGui::EndDisabled(); + ImGui::EndMenu(); + } + } + void SHEditorMenuBar::DrawWindowMenu() noexcept + { + if (ImGui::BeginMenu("Window")) + { + for (const auto& window : SHEditorWindowManager::editorWindows | std::views::values) + { + if (window.get() != this) + ImGui::Checkbox(window->windowName.data(), &window->isOpen); + } + ImGui::EndMenu(); + } + } + void SHEditorMenuBar::DrawThemeMenu() noexcept + { + if (ImGui::BeginMenu("Theme")) + { + const auto styles = rttr::type::get().get_enumeration(); + auto values = styles.get_values(); + for (auto style : values) + { + if (ImGui::Selectable(style.to_string().c_str())) + { + if (auto editor = SHSystemManager::GetSystem()) + editor->SetStyle(style.convert()); + } + } + ImGui::EndMenu(); + } + } + void SHEditorMenuBar::DrawLayoutMenu() noexcept + { + if (ImGui::BeginMenu("Layout")) + { + for (auto const& entry : layoutPaths) + { + if (ImGui::Selectable(entry.stem().string().c_str())) + { + ImGui::LoadIniSettingsFromDisk(entry.string().c_str()); + } + } + ImGui::EndMenu(); + } + } + void SHEditorMenuBar::DrawApplicationConfig() noexcept + { + if (ImGui::BeginMenu("Application Config")) + { + auto& appConfig = SHConfigurationManager::applicationConfig; + ImGui::InputText("Window Title", &appConfig.windowTitle); + ImGui::Checkbox("Start in Fullscreen", &appConfig.startInFullScreen); + SHEditorWidgets::DragN("Window Size", { "Width", "Height" }, { &appConfig.windowSize.x, &appConfig.windowSize.y }); + //ImGui::InputScalar("Starting Scene", ImGuiDataType_U32, &appConfig.startingSceneID); + auto sceneAsset = SHAssetManager::GetData(appConfig.startingSceneID); + + if (ImGui::BeginCombo("Starting Scene", sceneAsset ? sceneAsset->name.data() : "")) + { + auto scenes = SHAssetManager::GetAllRecordOfType(AssetType::SCENE); + for (auto const& scene : scenes) + { + if (ImGui::Selectable(scene.name.data())) + { + appConfig.startingSceneID = scene.id; + } + } + ImGui::EndCombo(); + } + if (ImGui::Button("Save")) + { + SHConfigurationManager::SaveApplicationConfig(); + } + ImGui::EndMenu(); + } + } }//namespace SHADE diff --git a/SHADE_Engine/src/Editor/EditorWindow/MenuBar/SHEditorMenuBar.h b/SHADE_Engine/src/Editor/EditorWindow/MenuBar/SHEditorMenuBar.h index e4f1d20b..77ebcf55 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/MenuBar/SHEditorMenuBar.h +++ b/SHADE_Engine/src/Editor/EditorWindow/MenuBar/SHEditorMenuBar.h @@ -17,6 +17,15 @@ namespace SHADE void DrawMainMenuBar() noexcept; void DrawSecondaryBar() const noexcept; void DrawStatusBar() const noexcept; + + void DrawFileMenu() noexcept; + void DrawEditMenu() noexcept; + void DrawScriptsMenu() noexcept; + void DrawWindowMenu() noexcept; + void DrawThemeMenu() noexcept; + void DrawLayoutMenu() noexcept; + void DrawApplicationConfig() noexcept; + float menuBarHeight = 20.0f; std::vector layoutPaths; };//class SHEditorMenuBar