From 562c8fa2a642b4156e352ec3d9cc393812aa84c2 Mon Sep 17 00:00:00 2001 From: Max Brun Date: Tue, 1 Apr 2025 19:09:43 +0200 Subject: [PATCH 01/12] Added Editor Layouts Management --- .../include/OvEditor/Core/EditorActions.h | 17 ++++ .../OvEditor/src/OvEditor/Core/Context.cpp | 1 + .../src/OvEditor/Core/EditorActions.cpp | 15 ++++ .../OvEditor/src/OvEditor/Panels/MenuBar.cpp | 89 ++++++++++++++++++- .../include/OvTools/Utils/PathParser.h | 6 ++ .../OvTools/src/OvTools/Utils/PathParser.cpp | 12 +++ .../OvUI/include/OvUI/Core/UIManager.h | 50 +++++++++-- .../Overload/OvUI/src/OvUI/Core/UIManager.cpp | 59 +++++++++++- 8 files changed, 240 insertions(+), 9 deletions(-) diff --git a/Sources/Overload/OvEditor/include/OvEditor/Core/EditorActions.h b/Sources/Overload/OvEditor/include/OvEditor/Core/EditorActions.h index 9894afaf3..65433a9eb 100644 --- a/Sources/Overload/OvEditor/include/OvEditor/Core/EditorActions.h +++ b/Sources/Overload/OvEditor/include/OvEditor/Core/EditorActions.h @@ -69,6 +69,23 @@ namespace OvEditor::Core */ void ResetLayout(); + /** + * Save the editor layout to the given configuration file + * @param p_fileName + */ + void SaveLayout(const std::string& p_fileName); + + /** + * Save the current editor layout to the last used configuration file + */ + void SaveCurrentLayout(); + + /** + * Set and load the editor layout from the given configuration file + * @param p_fileName + */ + void SetLayout(const std::string& p_fileName); + /** * Defines the scene view camera speed * @param p_speed diff --git a/Sources/Overload/OvEditor/src/OvEditor/Core/Context.cpp b/Sources/Overload/OvEditor/src/OvEditor/Core/Context.cpp index fff36f8bd..9d50cbb55 100644 --- a/Sources/Overload/OvEditor/src/OvEditor/Core/Context.cpp +++ b/Sources/Overload/OvEditor/src/OvEditor/Core/Context.cpp @@ -154,6 +154,7 @@ OvEditor::Core::Context::Context(const std::string& p_projectPath, const std::st ServiceLocator::Provide(*audioPlayer); ServiceLocator::Provide(*scriptEngine); ServiceLocator::Provide(*textureRegistry); + ServiceLocator::Provide(*uiManager); ApplyProjectSettings(); } diff --git a/Sources/Overload/OvEditor/src/OvEditor/Core/EditorActions.cpp b/Sources/Overload/OvEditor/src/OvEditor/Core/EditorActions.cpp index 46b6daf10..e98010936 100644 --- a/Sources/Overload/OvEditor/src/OvEditor/Core/EditorActions.cpp +++ b/Sources/Overload/OvEditor/src/OvEditor/Core/EditorActions.cpp @@ -377,6 +377,21 @@ void OvEditor::Core::EditorActions::ResetLayout() DelayAction([this]() {m_context.uiManager->ResetLayout("Config\\layout.ini"); }); } +void OvEditor::Core::EditorActions::SaveLayout(const std::string& p_fileName) +{ + DelayAction([&]() {m_context.uiManager->SaveLayout(std::ref(p_fileName)); }); +} + +void OvEditor::Core::EditorActions::SaveCurrentLayout() +{ + DelayAction([&]() {m_context.uiManager->SaveCurrentLayout(); }); +} + +void OvEditor::Core::EditorActions::SetLayout(const std::string& p_fileName) +{ + DelayAction([&]() {m_context.uiManager->SetLayout(std::ref(p_fileName)); }); +} + void OvEditor::Core::EditorActions::SetSceneViewCameraSpeed(int p_speed) { EDITOR_PANEL(Panels::SceneView, "Scene View").GetCameraController().SetSpeed((float)p_speed); diff --git a/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp b/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp index 3850dcc0b..ffeda4e2e 100644 --- a/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp +++ b/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp @@ -4,6 +4,8 @@ * @licence: MIT */ +#include + #include #include @@ -30,6 +32,7 @@ #include "OvEditor/Core/EditorActions.h" #include "OvEditor/Settings/EditorSettings.h" #include "OvEditor/Utils/ActorCreationMenu.h" +#include "OvUI/Plugins/ContextualMenu.h" using namespace OvUI::Panels; using namespace OvUI::Widgets; @@ -197,8 +200,90 @@ void OvEditor::Panels::MenuBar::CreateSettingsMenu() void OvEditor::Panels::MenuBar::CreateLayoutMenu() { - auto& layoutMenu = CreateWidget("Layout"); - layoutMenu.CreateWidget("Reset").ClickedEvent += EDITOR_BIND(ResetLayout); + auto& layoutMenuList = CreateWidget("Layout"); + + auto& saveMenuItem = layoutMenuList.CreateWidget("Save"); + saveMenuItem.ClickedEvent += EDITOR_BIND(SaveCurrentLayout); + + auto& saveNewMenuList = layoutMenuList.CreateWidget("Save New"); + auto& layoutInputText = saveNewMenuList.CreateWidget("Layout Name"); + layoutInputText.selectAllOnClick = true; + layoutInputText.EnterPressedEvent += [this](std::string p_input) + { + if (p_input.empty()) + return; + + auto& UIManager = OvCore::Global::ServiceLocator::Get(); + std::string layoutsPath = UIManager.GetLayoutsPath(); + EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::SaveLayout, &UIManager, layoutsPath + p_input + ".ini"), 1)); + }; + + auto& loadMenuList = layoutMenuList.CreateWidget("Load"); + + loadMenuList.ClickedEvent += [&] + { + loadMenuList.RemoveAllWidgets(); + + auto& UIManager = OvCore::Global::ServiceLocator::Get(); + std::string layoutsPath = UIManager.GetLayoutsPath(); + + for (const auto& entry : std::filesystem::directory_iterator(layoutsPath)) + { + if (entry.is_regular_file() && entry.path().extension() == ".ini") + { + std::shared_ptr layoutFileName = std::make_shared(entry.path().filename().string()); + + auto& layoutMenuItem = loadMenuList.CreateWidget(*layoutFileName); + layoutMenuItem.name = OvTools::Utils::PathParser::GetFileWithoutExtension(*layoutFileName); + + layoutMenuItem.ClickedEvent += [this, layoutsPath, layoutFileName] + { + auto& UIManager = OvCore::Global::ServiceLocator::Get(); + std::string layoutsPath = UIManager.GetLayoutsPath(); + EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::SetLayout, &UIManager, layoutsPath + *layoutFileName), 1)); + }; + + auto& contextualMenu = layoutMenuItem.AddPlugin(); + auto& deleteMenuItem = contextualMenu.CreateWidget("Delete"); + + deleteMenuItem.ClickedEvent += [this, layoutFileName, &layoutMenuItem] + { + //EDITOR_EXEC(ResetToDefaultLayout); + auto& UIManager = OvCore::Global::ServiceLocator::Get(); + std::string layoutsPath = UIManager.GetLayoutsPath(); + EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::DeleteLayout, &UIManager, layoutsPath + *layoutFileName), 1)); + layoutMenuItem.enabled = false; + + }; + auto& renameToMenuList = contextualMenu.CreateWidget("Rename to..."); + + auto& renameInputText = renameToMenuList.CreateWidget(""); + renameInputText.content = OvTools::Utils::PathParser::GetFileWithoutExtension(*layoutFileName); + renameInputText.selectAllOnClick = true; + + renameInputText.EnterPressedEvent += [this, layoutFileName, &contextualMenu, &layoutMenuItem](std::string p_newName) + { + if (p_newName.empty()) + return; + + layoutMenuItem.name = p_newName; + //EDITOR_EXEC(ResetToDefaultLayout); + + auto& UIManager = OvCore::Global::ServiceLocator::Get(); + std::string layoutsPath = UIManager.GetLayoutsPath(); + + std::string oldFileName = layoutsPath + *layoutFileName; + std::string newFileName = layoutsPath + p_newName + ".ini"; + EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::RenameLayout, &UIManager, oldFileName, newFileName), 1)); + + *layoutFileName = p_newName + ".ini"; + contextualMenu.Close(); + }; + } + } + }; + + layoutMenuList.CreateWidget("Reset").ClickedEvent += EDITOR_BIND(ResetLayout); } void OvEditor::Panels::MenuBar::CreateHelpMenu() diff --git a/Sources/Overload/OvTools/include/OvTools/Utils/PathParser.h b/Sources/Overload/OvTools/include/OvTools/Utils/PathParser.h index 758d21fbf..137421ccf 100644 --- a/Sources/Overload/OvTools/include/OvTools/Utils/PathParser.h +++ b/Sources/Overload/OvTools/include/OvTools/Utils/PathParser.h @@ -66,6 +66,12 @@ namespace OvTools::Utils */ static std::string GetExtension(const std::string& p_path); + /** + * Returns the file without the extension + * @param p_file + */ + static std::string GetFileWithoutExtension(const std::string& p_file); + /** * Convert the EFileType value to a string * @param p_fileType diff --git a/Sources/Overload/OvTools/src/OvTools/Utils/PathParser.cpp b/Sources/Overload/OvTools/src/OvTools/Utils/PathParser.cpp index c27b8982d..1c368a327 100644 --- a/Sources/Overload/OvTools/src/OvTools/Utils/PathParser.cpp +++ b/Sources/Overload/OvTools/src/OvTools/Utils/PathParser.cpp @@ -81,6 +81,18 @@ std::string OvTools::Utils::PathParser::GetExtension(const std::string & p_path) return result; } +std::string OvTools::Utils::PathParser::GetFileWithoutExtension(const std::string& p_file) +{ + const size_t end_pos = p_file.find_last_of('.'); + + if (end_pos > 0 && end_pos != std::string::npos) + { + return p_file.substr(0, end_pos); + } + + return p_file; +} + std::string OvTools::Utils::PathParser::FileTypeToString(EFileType p_fileType) { switch (p_fileType) diff --git a/Sources/Overload/OvUI/include/OvUI/Core/UIManager.h b/Sources/Overload/OvUI/include/OvUI/Core/UIManager.h index 1c4e44d91..7c21a5c5f 100644 --- a/Sources/Overload/OvUI/include/OvUI/Core/UIManager.h +++ b/Sources/Overload/OvUI/include/OvUI/Core/UIManager.h @@ -96,11 +96,47 @@ namespace OvUI::Core */ void EnableDocking(bool p_value); - /** - * Reset the UI layout to the given configuration file - * @param p_config - */ - void ResetLayout(const std::string & p_config) const; + /** + * Reset the UI layout to the given configuration file + * @param p_config + */ + void ResetLayout(const std::string& p_config) const; + + /** + * Load the UI layout from the given configuration file + * @param p_fileName + */ + void LoadLayout(const std::string& p_fileName); + + /** + * Save the UI layout to the given configuration file + * @param p_fileName + */ + void SaveLayout(const std::string& p_fileName); + + /** + * Save the current UI layout to the last used configuration file + */ + void SaveCurrentLayout(); + + /** + * Set and load the UI layout from the given configuration file + * @param p_fileName + */ + void SetLayout(const std::string& p_fileName); + + /** + * Delete the UI layout configuration file + * @param p_fileName + */ + void DeleteLayout(const std::string& p_fileName); + + /** + * Rename a UI layout configuration file + * @param p_fileName + * @param p_newFileName + */ + void RenameLayout(const std::string& p_fileName, const std::string& p_newFileName); /** * Return true if the docking system is enabled @@ -124,6 +160,8 @@ namespace OvUI::Core */ void Render(); + std::string GetLayoutsPath(); + private: void PushCurrentFont(); void PopCurrentFont(); @@ -133,5 +171,7 @@ namespace OvUI::Core Modules::Canvas* m_currentCanvas = nullptr; std::unordered_map m_fonts; std::string m_layoutSaveFilename = "imgui.ini"; + const std::string m_defaultLayout; + const std::string m_layoutsPath; }; } \ No newline at end of file diff --git a/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp b/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp index 6fe6ad0d1..ff8ecc2a3 100644 --- a/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp +++ b/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp @@ -6,7 +6,13 @@ #include "OvUI/Core/UIManager.h" -OvUI::Core::UIManager::UIManager(GLFWwindow* p_glfwWindow, Styling::EStyle p_style, std::string_view p_glslVersion) +#include + +#include "OvTools/Utils/SystemCalls.h" + +OvUI::Core::UIManager::UIManager(GLFWwindow* p_glfwWindow, Styling::EStyle p_style, std::string_view p_glslVersion) : +m_defaultLayout("Config\\layout.ini"), +m_layoutsPath(OvTools::Utils::SystemCalls::GetPathToAppdata() + "\\OverloadTech\\OvEditor\\") { ImGui::CreateContext(); @@ -259,6 +265,50 @@ void OvUI::Core::UIManager::ResetLayout(const std::string& p_config) const ImGui::LoadIniSettingsFromDisk(p_config.c_str()); } +void OvUI::Core::UIManager::LoadLayout(const std::string& p_fileName) +{ + ImGui::LoadIniSettingsFromDisk(p_fileName.c_str()); +} + +void OvUI::Core::UIManager::SaveLayout(const std::string& p_fileName) +{ + SetEditorLayoutSaveFilename(p_fileName); + + ImGui::SaveIniSettingsToDisk(m_layoutSaveFilename.c_str()); +} + +void OvUI::Core::UIManager::SaveCurrentLayout() +{ + if (!std::filesystem::exists(m_layoutSaveFilename)) + { + m_layoutSaveFilename = m_layoutsPath + "layout.ini"; + SetEditorLayoutSaveFilename(m_layoutSaveFilename); + } + ImGui::SaveIniSettingsToDisk(m_layoutSaveFilename.c_str()); +} + +void OvUI::Core::UIManager::SetLayout(const std::string& p_fileName) +{ + SetEditorLayoutSaveFilename(p_fileName); + + ImGui::LoadIniSettingsFromDisk(p_fileName.c_str()); +} + +void OvUI::Core::UIManager::DeleteLayout(const std::string& p_fileName) +{ + std::filesystem::remove(p_fileName); +} + +void OvUI::Core::UIManager::RenameLayout(const std::string& p_fileName, const std::string& p_newFileName) +{ + std::filesystem::rename(p_fileName, p_newFileName); + + if (m_layoutSaveFilename == p_fileName) + { + SetEditorLayoutSaveFilename(p_newFileName); + } +} + bool OvUI::Core::UIManager::IsDockingEnabled() const { return m_dockingState; @@ -285,6 +335,11 @@ void OvUI::Core::UIManager::Render() } } +std::string OvUI::Core::UIManager::GetLayoutsPath() +{ + return m_layoutsPath; +} + void OvUI::Core::UIManager::PushCurrentFont() { @@ -293,4 +348,4 @@ void OvUI::Core::UIManager::PushCurrentFont() void OvUI::Core::UIManager::PopCurrentFont() { -} \ No newline at end of file +} From 006b4ce807a905ba3b8e75aee816e3bcddd6f31a Mon Sep 17 00:00:00 2001 From: Max Brun Date: Tue, 1 Apr 2025 20:16:13 +0200 Subject: [PATCH 02/12] Removed old code --- .../OvEditor/src/OvEditor/Panels/MenuBar.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp b/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp index ffeda4e2e..9d94ee4d5 100644 --- a/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp +++ b/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp @@ -231,16 +231,16 @@ void OvEditor::Panels::MenuBar::CreateLayoutMenu() { if (entry.is_regular_file() && entry.path().extension() == ".ini") { - std::shared_ptr layoutFileName = std::make_shared(entry.path().filename().string()); + std::string layoutFileName = entry.path().filename().string(); - auto& layoutMenuItem = loadMenuList.CreateWidget(*layoutFileName); - layoutMenuItem.name = OvTools::Utils::PathParser::GetFileWithoutExtension(*layoutFileName); + auto& layoutMenuItem = loadMenuList.CreateWidget(layoutFileName); + layoutMenuItem.name = OvTools::Utils::PathParser::GetFileWithoutExtension(layoutFileName); layoutMenuItem.ClickedEvent += [this, layoutsPath, layoutFileName] { auto& UIManager = OvCore::Global::ServiceLocator::Get(); std::string layoutsPath = UIManager.GetLayoutsPath(); - EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::SetLayout, &UIManager, layoutsPath + *layoutFileName), 1)); + EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::SetLayout, &UIManager, layoutsPath + layoutFileName), 1)); }; auto& contextualMenu = layoutMenuItem.AddPlugin(); @@ -251,14 +251,14 @@ void OvEditor::Panels::MenuBar::CreateLayoutMenu() //EDITOR_EXEC(ResetToDefaultLayout); auto& UIManager = OvCore::Global::ServiceLocator::Get(); std::string layoutsPath = UIManager.GetLayoutsPath(); - EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::DeleteLayout, &UIManager, layoutsPath + *layoutFileName), 1)); + EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::DeleteLayout, &UIManager, layoutsPath + layoutFileName), 1)); layoutMenuItem.enabled = false; }; auto& renameToMenuList = contextualMenu.CreateWidget("Rename to..."); auto& renameInputText = renameToMenuList.CreateWidget(""); - renameInputText.content = OvTools::Utils::PathParser::GetFileWithoutExtension(*layoutFileName); + renameInputText.content = OvTools::Utils::PathParser::GetFileWithoutExtension(layoutFileName); renameInputText.selectAllOnClick = true; renameInputText.EnterPressedEvent += [this, layoutFileName, &contextualMenu, &layoutMenuItem](std::string p_newName) @@ -272,11 +272,10 @@ void OvEditor::Panels::MenuBar::CreateLayoutMenu() auto& UIManager = OvCore::Global::ServiceLocator::Get(); std::string layoutsPath = UIManager.GetLayoutsPath(); - std::string oldFileName = layoutsPath + *layoutFileName; + std::string oldFileName = layoutsPath + layoutFileName; std::string newFileName = layoutsPath + p_newName + ".ini"; EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::RenameLayout, &UIManager, oldFileName, newFileName), 1)); - *layoutFileName = p_newName + ".ini"; contextualMenu.Close(); }; } From 4e9697498da1f2e057a85836aed285a6fc62c355 Mon Sep 17 00:00:00 2001 From: Max Brun Date: Tue, 1 Apr 2025 20:36:40 +0200 Subject: [PATCH 03/12] Replaced ServiceLocator by EDITOR_CONTEXT and fixed include typo --- .../OvEditor/src/OvEditor/Core/Context.cpp | 1 - .../OvEditor/src/OvEditor/Panels/MenuBar.cpp | 36 +++++++++---------- .../Overload/OvUI/src/OvUI/Core/UIManager.cpp | 2 +- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/Sources/Overload/OvEditor/src/OvEditor/Core/Context.cpp b/Sources/Overload/OvEditor/src/OvEditor/Core/Context.cpp index 9d50cbb55..fff36f8bd 100644 --- a/Sources/Overload/OvEditor/src/OvEditor/Core/Context.cpp +++ b/Sources/Overload/OvEditor/src/OvEditor/Core/Context.cpp @@ -154,7 +154,6 @@ OvEditor::Core::Context::Context(const std::string& p_projectPath, const std::st ServiceLocator::Provide(*audioPlayer); ServiceLocator::Provide(*scriptEngine); ServiceLocator::Provide(*textureRegistry); - ServiceLocator::Provide(*uiManager); ApplyProjectSettings(); } diff --git a/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp b/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp index 9d94ee4d5..d27c94ece 100644 --- a/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp +++ b/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp @@ -202,31 +202,30 @@ void OvEditor::Panels::MenuBar::CreateLayoutMenu() { auto& layoutMenuList = CreateWidget("Layout"); + auto& uiManager = *EDITOR_CONTEXT(uiManager); + std::string layoutsPath = uiManager.GetLayoutsPath(); + auto& saveMenuItem = layoutMenuList.CreateWidget("Save"); saveMenuItem.ClickedEvent += EDITOR_BIND(SaveCurrentLayout); auto& saveNewMenuList = layoutMenuList.CreateWidget("Save New"); auto& layoutInputText = saveNewMenuList.CreateWidget("Layout Name"); layoutInputText.selectAllOnClick = true; - layoutInputText.EnterPressedEvent += [this](std::string p_input) + layoutInputText.EnterPressedEvent += [this, layoutsPath](std::string p_input) { if (p_input.empty()) return; - auto& UIManager = OvCore::Global::ServiceLocator::Get(); - std::string layoutsPath = UIManager.GetLayoutsPath(); - EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::SaveLayout, &UIManager, layoutsPath + p_input + ".ini"), 1)); + auto& uiManager = *EDITOR_CONTEXT(uiManager); + EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::SaveLayout, &uiManager, layoutsPath + p_input + ".ini"), 1)); }; auto& loadMenuList = layoutMenuList.CreateWidget("Load"); - loadMenuList.ClickedEvent += [&] + loadMenuList.ClickedEvent += [&, layoutsPath] { loadMenuList.RemoveAllWidgets(); - auto& UIManager = OvCore::Global::ServiceLocator::Get(); - std::string layoutsPath = UIManager.GetLayoutsPath(); - for (const auto& entry : std::filesystem::directory_iterator(layoutsPath)) { if (entry.is_regular_file() && entry.path().extension() == ".ini") @@ -238,20 +237,19 @@ void OvEditor::Panels::MenuBar::CreateLayoutMenu() layoutMenuItem.ClickedEvent += [this, layoutsPath, layoutFileName] { - auto& UIManager = OvCore::Global::ServiceLocator::Get(); - std::string layoutsPath = UIManager.GetLayoutsPath(); - EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::SetLayout, &UIManager, layoutsPath + layoutFileName), 1)); + auto& uiManager = *EDITOR_CONTEXT(uiManager); + EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::SetLayout, &uiManager, layoutsPath + layoutFileName), 1)); }; auto& contextualMenu = layoutMenuItem.AddPlugin(); auto& deleteMenuItem = contextualMenu.CreateWidget("Delete"); - deleteMenuItem.ClickedEvent += [this, layoutFileName, &layoutMenuItem] + deleteMenuItem.ClickedEvent += [this, layoutsPath, layoutFileName, &layoutMenuItem] { //EDITOR_EXEC(ResetToDefaultLayout); - auto& UIManager = OvCore::Global::ServiceLocator::Get(); - std::string layoutsPath = UIManager.GetLayoutsPath(); - EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::DeleteLayout, &UIManager, layoutsPath + layoutFileName), 1)); + + auto& uiManager = *EDITOR_CONTEXT(uiManager); + EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::DeleteLayout, &uiManager, layoutsPath + layoutFileName), 1)); layoutMenuItem.enabled = false; }; @@ -261,20 +259,18 @@ void OvEditor::Panels::MenuBar::CreateLayoutMenu() renameInputText.content = OvTools::Utils::PathParser::GetFileWithoutExtension(layoutFileName); renameInputText.selectAllOnClick = true; - renameInputText.EnterPressedEvent += [this, layoutFileName, &contextualMenu, &layoutMenuItem](std::string p_newName) + renameInputText.EnterPressedEvent += [this, layoutsPath, layoutFileName, &contextualMenu, &layoutMenuItem](std::string p_newName) { if (p_newName.empty()) return; layoutMenuItem.name = p_newName; //EDITOR_EXEC(ResetToDefaultLayout); - - auto& UIManager = OvCore::Global::ServiceLocator::Get(); - std::string layoutsPath = UIManager.GetLayoutsPath(); + auto& uiManager = *EDITOR_CONTEXT(uiManager); std::string oldFileName = layoutsPath + layoutFileName; std::string newFileName = layoutsPath + p_newName + ".ini"; - EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::RenameLayout, &UIManager, oldFileName, newFileName), 1)); + EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::RenameLayout, &uiManager, oldFileName, newFileName), 1)); contextualMenu.Close(); }; diff --git a/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp b/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp index ff8ecc2a3..3c40ec19e 100644 --- a/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp +++ b/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp @@ -8,7 +8,7 @@ #include -#include "OvTools/Utils/SystemCalls.h" +#include OvUI::Core::UIManager::UIManager(GLFWwindow* p_glfwWindow, Styling::EStyle p_style, std::string_view p_glslVersion) : m_defaultLayout("Config\\layout.ini"), From 0dbdddd3321c69117d1a962ca275f23527bb04d9 Mon Sep 17 00:00:00 2001 From: Max Brun Date: Tue, 1 Apr 2025 22:32:39 +0200 Subject: [PATCH 04/12] Replaced string to filesystem path --- .../include/OvEditor/Core/EditorActions.h | 8 ++-- .../OvEditor/src/OvEditor/Core/Context.cpp | 2 +- .../src/OvEditor/Core/EditorActions.cpp | 10 ++-- .../OvEditor/src/OvEditor/Panels/MenuBar.cpp | 33 +++++-------- .../include/OvTools/Utils/PathParser.h | 6 --- .../OvTools/src/OvTools/Utils/PathParser.cpp | 12 ----- .../OvUI/include/OvUI/Core/UIManager.h | 35 ++++++++------ .../Overload/OvUI/src/OvUI/Core/UIManager.cpp | 47 +++++++++++-------- 8 files changed, 71 insertions(+), 82 deletions(-) diff --git a/Sources/Overload/OvEditor/include/OvEditor/Core/EditorActions.h b/Sources/Overload/OvEditor/include/OvEditor/Core/EditorActions.h index 65433a9eb..d0dbac37f 100644 --- a/Sources/Overload/OvEditor/include/OvEditor/Core/EditorActions.h +++ b/Sources/Overload/OvEditor/include/OvEditor/Core/EditorActions.h @@ -71,9 +71,9 @@ namespace OvEditor::Core /** * Save the editor layout to the given configuration file - * @param p_fileName + * @param p_filePath */ - void SaveLayout(const std::string& p_fileName); + void SaveLayout(const std::filesystem::path& p_filePath); /** * Save the current editor layout to the last used configuration file @@ -82,9 +82,9 @@ namespace OvEditor::Core /** * Set and load the editor layout from the given configuration file - * @param p_fileName + * @param p_filePath */ - void SetLayout(const std::string& p_fileName); + void SetLayout(const std::filesystem::path& p_filePath); /** * Defines the scene view camera speed diff --git a/Sources/Overload/OvEditor/src/OvEditor/Core/Context.cpp b/Sources/Overload/OvEditor/src/OvEditor/Core/Context.cpp index fff36f8bd..fd0eb7986 100644 --- a/Sources/Overload/OvEditor/src/OvEditor/Core/Context.cpp +++ b/Sources/Overload/OvEditor/src/OvEditor/Core/Context.cpp @@ -124,7 +124,7 @@ OvEditor::Core::Context::Context(const std::string& p_projectPath, const std::st uiManager->EnableDocking(true); if (!std::filesystem::exists(OvTools::Utils::SystemCalls::GetPathToAppdata() + "\\OverloadTech\\OvEditor\\layout.ini")) - uiManager->ResetLayout("Config\\layout.ini"); + uiManager->ResetToDefaultLayout(); /* Audio */ audioEngine = std::make_unique(projectAssetsPath); diff --git a/Sources/Overload/OvEditor/src/OvEditor/Core/EditorActions.cpp b/Sources/Overload/OvEditor/src/OvEditor/Core/EditorActions.cpp index e98010936..f711a7519 100644 --- a/Sources/Overload/OvEditor/src/OvEditor/Core/EditorActions.cpp +++ b/Sources/Overload/OvEditor/src/OvEditor/Core/EditorActions.cpp @@ -374,12 +374,12 @@ void OvEditor::Core::EditorActions::SetActorSpawnMode(EActorSpawnMode p_value) void OvEditor::Core::EditorActions::ResetLayout() { - DelayAction([this]() {m_context.uiManager->ResetLayout("Config\\layout.ini"); }); + DelayAction([this]() {m_context.uiManager->ResetToDefaultLayout(); }); } -void OvEditor::Core::EditorActions::SaveLayout(const std::string& p_fileName) +void OvEditor::Core::EditorActions::SaveLayout(const std::filesystem::path& p_filePath) { - DelayAction([&]() {m_context.uiManager->SaveLayout(std::ref(p_fileName)); }); + DelayAction([&]() {m_context.uiManager->SaveLayout(p_filePath); }); } void OvEditor::Core::EditorActions::SaveCurrentLayout() @@ -387,9 +387,9 @@ void OvEditor::Core::EditorActions::SaveCurrentLayout() DelayAction([&]() {m_context.uiManager->SaveCurrentLayout(); }); } -void OvEditor::Core::EditorActions::SetLayout(const std::string& p_fileName) +void OvEditor::Core::EditorActions::SetLayout(const std::filesystem::path& p_filePath) { - DelayAction([&]() {m_context.uiManager->SetLayout(std::ref(p_fileName)); }); + DelayAction([&]() {m_context.uiManager->SetLayout(p_filePath); }); } void OvEditor::Core::EditorActions::SetSceneViewCameraSpeed(int p_speed) diff --git a/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp b/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp index d27c94ece..7719e85b8 100644 --- a/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp +++ b/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp @@ -203,7 +203,7 @@ void OvEditor::Panels::MenuBar::CreateLayoutMenu() auto& layoutMenuList = CreateWidget("Layout"); auto& uiManager = *EDITOR_CONTEXT(uiManager); - std::string layoutsPath = uiManager.GetLayoutsPath(); + const std::filesystem::path& layoutsPath = uiManager.GetLayoutsPath(); auto& saveMenuItem = layoutMenuList.CreateWidget("Save"); saveMenuItem.ClickedEvent += EDITOR_BIND(SaveCurrentLayout); @@ -211,13 +211,13 @@ void OvEditor::Panels::MenuBar::CreateLayoutMenu() auto& saveNewMenuList = layoutMenuList.CreateWidget("Save New"); auto& layoutInputText = saveNewMenuList.CreateWidget("Layout Name"); layoutInputText.selectAllOnClick = true; - layoutInputText.EnterPressedEvent += [this, layoutsPath](std::string p_input) + layoutInputText.EnterPressedEvent += [this, &layoutsPath](std::string p_input) { if (p_input.empty()) return; auto& uiManager = *EDITOR_CONTEXT(uiManager); - EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::SaveLayout, &uiManager, layoutsPath + p_input + ".ini"), 1)); + EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::SaveLayout, &uiManager, layoutsPath / (p_input + ".ini")), 1)); }; auto& loadMenuList = layoutMenuList.CreateWidget("Load"); @@ -230,47 +230,40 @@ void OvEditor::Panels::MenuBar::CreateLayoutMenu() { if (entry.is_regular_file() && entry.path().extension() == ".ini") { - std::string layoutFileName = entry.path().filename().string(); + auto& layoutMenuItem = loadMenuList.CreateWidget(entry.path().stem().string()); + layoutMenuItem.name = entry.path().stem().string(); - auto& layoutMenuItem = loadMenuList.CreateWidget(layoutFileName); - layoutMenuItem.name = OvTools::Utils::PathParser::GetFileWithoutExtension(layoutFileName); - - layoutMenuItem.ClickedEvent += [this, layoutsPath, layoutFileName] + layoutMenuItem.ClickedEvent += [this, entry] { auto& uiManager = *EDITOR_CONTEXT(uiManager); - EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::SetLayout, &uiManager, layoutsPath + layoutFileName), 1)); + EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::SetLayout, &uiManager, entry.path()), 1)); }; auto& contextualMenu = layoutMenuItem.AddPlugin(); auto& deleteMenuItem = contextualMenu.CreateWidget("Delete"); - deleteMenuItem.ClickedEvent += [this, layoutsPath, layoutFileName, &layoutMenuItem] + deleteMenuItem.ClickedEvent += [this, &layoutMenuItem, entry] { - //EDITOR_EXEC(ResetToDefaultLayout); - auto& uiManager = *EDITOR_CONTEXT(uiManager); - EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::DeleteLayout, &uiManager, layoutsPath + layoutFileName), 1)); + EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::DeleteLayout, &uiManager, entry.path()), 1)); layoutMenuItem.enabled = false; }; auto& renameToMenuList = contextualMenu.CreateWidget("Rename to..."); auto& renameInputText = renameToMenuList.CreateWidget(""); - renameInputText.content = OvTools::Utils::PathParser::GetFileWithoutExtension(layoutFileName); + renameInputText.content = entry.path().stem().string(); renameInputText.selectAllOnClick = true; - renameInputText.EnterPressedEvent += [this, layoutsPath, layoutFileName, &contextualMenu, &layoutMenuItem](std::string p_newName) + renameInputText.EnterPressedEvent += [this, entry, layoutsPath, &contextualMenu, &layoutMenuItem](std::string p_newName) { if (p_newName.empty()) return; layoutMenuItem.name = p_newName; - //EDITOR_EXEC(ResetToDefaultLayout); + auto& uiManager = *EDITOR_CONTEXT(uiManager); - - std::string oldFileName = layoutsPath + layoutFileName; - std::string newFileName = layoutsPath + p_newName + ".ini"; - EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::RenameLayout, &uiManager, oldFileName, newFileName), 1)); + EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::RenameLayout, &uiManager, entry, layoutsPath / (p_newName + ".ini")), 1)); contextualMenu.Close(); }; diff --git a/Sources/Overload/OvTools/include/OvTools/Utils/PathParser.h b/Sources/Overload/OvTools/include/OvTools/Utils/PathParser.h index 137421ccf..758d21fbf 100644 --- a/Sources/Overload/OvTools/include/OvTools/Utils/PathParser.h +++ b/Sources/Overload/OvTools/include/OvTools/Utils/PathParser.h @@ -66,12 +66,6 @@ namespace OvTools::Utils */ static std::string GetExtension(const std::string& p_path); - /** - * Returns the file without the extension - * @param p_file - */ - static std::string GetFileWithoutExtension(const std::string& p_file); - /** * Convert the EFileType value to a string * @param p_fileType diff --git a/Sources/Overload/OvTools/src/OvTools/Utils/PathParser.cpp b/Sources/Overload/OvTools/src/OvTools/Utils/PathParser.cpp index 1c368a327..c27b8982d 100644 --- a/Sources/Overload/OvTools/src/OvTools/Utils/PathParser.cpp +++ b/Sources/Overload/OvTools/src/OvTools/Utils/PathParser.cpp @@ -81,18 +81,6 @@ std::string OvTools::Utils::PathParser::GetExtension(const std::string & p_path) return result; } -std::string OvTools::Utils::PathParser::GetFileWithoutExtension(const std::string& p_file) -{ - const size_t end_pos = p_file.find_last_of('.'); - - if (end_pos > 0 && end_pos != std::string::npos) - { - return p_file.substr(0, end_pos); - } - - return p_file; -} - std::string OvTools::Utils::PathParser::FileTypeToString(EFileType p_fileType) { switch (p_fileType) diff --git a/Sources/Overload/OvUI/include/OvUI/Core/UIManager.h b/Sources/Overload/OvUI/include/OvUI/Core/UIManager.h index 7c21a5c5f..b619a48a2 100644 --- a/Sources/Overload/OvUI/include/OvUI/Core/UIManager.h +++ b/Sources/Overload/OvUI/include/OvUI/Core/UIManager.h @@ -6,6 +6,7 @@ #pragma once +#include #include #include @@ -77,7 +78,7 @@ namespace OvUI::Core /** * Defines a filename for the editor layout save file */ - void SetEditorLayoutSaveFilename(const std::string& p_filename); + void SetEditorLayoutSaveFilename(const std::filesystem::path& p_filePath); /** * Defines a frequency (in seconds) for the auto saving system of the editor layout @@ -96,6 +97,12 @@ namespace OvUI::Core */ void EnableDocking(bool p_value); + /** + * Reset the UI layout to the default configuration file + * @param p_config + */ + void ResetToDefaultLayout() const; + /** * Reset the UI layout to the given configuration file * @param p_config @@ -110,9 +117,9 @@ namespace OvUI::Core /** * Save the UI layout to the given configuration file - * @param p_fileName + * @param p_filePath */ - void SaveLayout(const std::string& p_fileName); + void SaveLayout(const std::filesystem::path& p_filePath); /** * Save the current UI layout to the last used configuration file @@ -121,22 +128,22 @@ namespace OvUI::Core /** * Set and load the UI layout from the given configuration file - * @param p_fileName + * @param p_filePath */ - void SetLayout(const std::string& p_fileName); + void SetLayout(const std::filesystem::path& p_filePath); /** * Delete the UI layout configuration file - * @param p_fileName + * @param p_filePath */ - void DeleteLayout(const std::string& p_fileName); + void DeleteLayout(const std::filesystem::path& p_filePath); /** * Rename a UI layout configuration file - * @param p_fileName - * @param p_newFileName + * @param p_filePath + * @param p_newFilePath */ - void RenameLayout(const std::string& p_fileName, const std::string& p_newFileName); + void RenameLayout(const std::filesystem::path& p_filePath, const std::filesystem::path& p_newFilePath); /** * Return true if the docking system is enabled @@ -160,7 +167,7 @@ namespace OvUI::Core */ void Render(); - std::string GetLayoutsPath(); + const std::filesystem::path& GetLayoutsPath() const; private: void PushCurrentFont(); @@ -170,8 +177,8 @@ namespace OvUI::Core bool m_dockingState; Modules::Canvas* m_currentCanvas = nullptr; std::unordered_map m_fonts; - std::string m_layoutSaveFilename = "imgui.ini"; - const std::string m_defaultLayout; - const std::string m_layoutsPath; + std::filesystem::path m_layoutSaveFilename = "imgui.ini"; + const std::filesystem::path m_defaultLayout; + const std::filesystem::path m_layoutsPath; }; } \ No newline at end of file diff --git a/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp b/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp index 3c40ec19e..ead6c70cb 100644 --- a/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp +++ b/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp @@ -12,7 +12,7 @@ OvUI::Core::UIManager::UIManager(GLFWwindow* p_glfwWindow, Styling::EStyle p_style, std::string_view p_glslVersion) : m_defaultLayout("Config\\layout.ini"), -m_layoutsPath(OvTools::Utils::SystemCalls::GetPathToAppdata() + "\\OverloadTech\\OvEditor\\") +m_layoutsPath(OvTools::Utils::SystemCalls::GetPathToAppdata() + "\\OverloadTech\\OvEditor\\Layouts\\") { ImGui::CreateContext(); @@ -23,6 +23,8 @@ m_layoutsPath(OvTools::Utils::SystemCalls::GetPathToAppdata() + "\\OverloadTech\ ImGui_ImplGlfw_InitForOpenGL(p_glfwWindow, true); ImGui_ImplOpenGL3_Init(p_glslVersion.data()); + + std::filesystem::create_directory(m_layoutsPath); } OvUI::Core::UIManager::~UIManager() @@ -223,7 +225,7 @@ void OvUI::Core::UIManager::UseDefaultFont() void OvUI::Core::UIManager::EnableEditorLayoutSave(bool p_value) { if (p_value) - ImGui::GetIO().IniFilename = m_layoutSaveFilename.c_str(); + ImGui::GetIO().IniFilename = m_layoutSaveFilename.string().c_str(); else ImGui::GetIO().IniFilename = nullptr; } @@ -233,11 +235,11 @@ bool OvUI::Core::UIManager::IsEditorLayoutSaveEnabled() const return ImGui::GetIO().IniFilename != nullptr; } -void OvUI::Core::UIManager::SetEditorLayoutSaveFilename(const std::string & p_filename) +void OvUI::Core::UIManager::SetEditorLayoutSaveFilename(const std::filesystem::path& p_filePath) { - m_layoutSaveFilename = p_filename; + m_layoutSaveFilename = p_filePath; if (IsEditorLayoutSaveEnabled()) - ImGui::GetIO().IniFilename = m_layoutSaveFilename.c_str(); + ImGui::GetIO().IniFilename = m_layoutSaveFilename.string().c_str(); } void OvUI::Core::UIManager::SetEditorLayoutAutosaveFrequency(float p_frequency) @@ -260,6 +262,11 @@ void OvUI::Core::UIManager::EnableDocking(bool p_value) ImGui::GetIO().ConfigFlags &= ~ImGuiConfigFlags_DockingEnable; } +void OvUI::Core::UIManager::ResetToDefaultLayout() const +{ + ImGui::LoadIniSettingsFromDisk(m_defaultLayout.string().c_str()); +} + void OvUI::Core::UIManager::ResetLayout(const std::string& p_config) const { ImGui::LoadIniSettingsFromDisk(p_config.c_str()); @@ -270,42 +277,42 @@ void OvUI::Core::UIManager::LoadLayout(const std::string& p_fileName) ImGui::LoadIniSettingsFromDisk(p_fileName.c_str()); } -void OvUI::Core::UIManager::SaveLayout(const std::string& p_fileName) +void OvUI::Core::UIManager::SaveLayout(const std::filesystem::path& p_filePath) { - SetEditorLayoutSaveFilename(p_fileName); + SetEditorLayoutSaveFilename(p_filePath); - ImGui::SaveIniSettingsToDisk(m_layoutSaveFilename.c_str()); + ImGui::SaveIniSettingsToDisk(m_layoutSaveFilename.string().c_str()); } void OvUI::Core::UIManager::SaveCurrentLayout() { if (!std::filesystem::exists(m_layoutSaveFilename)) { - m_layoutSaveFilename = m_layoutsPath + "layout.ini"; + m_layoutSaveFilename = (m_layoutsPath / "layout.ini").string(); SetEditorLayoutSaveFilename(m_layoutSaveFilename); } - ImGui::SaveIniSettingsToDisk(m_layoutSaveFilename.c_str()); + ImGui::SaveIniSettingsToDisk(m_layoutSaveFilename.string().c_str()); } -void OvUI::Core::UIManager::SetLayout(const std::string& p_fileName) +void OvUI::Core::UIManager::SetLayout(const std::filesystem::path& p_filePath) { - SetEditorLayoutSaveFilename(p_fileName); + SetEditorLayoutSaveFilename(p_filePath); - ImGui::LoadIniSettingsFromDisk(p_fileName.c_str()); + ImGui::LoadIniSettingsFromDisk(p_filePath.string().c_str()); } -void OvUI::Core::UIManager::DeleteLayout(const std::string& p_fileName) +void OvUI::Core::UIManager::DeleteLayout(const std::filesystem::path& p_filePath) { - std::filesystem::remove(p_fileName); + std::filesystem::remove(p_filePath); } -void OvUI::Core::UIManager::RenameLayout(const std::string& p_fileName, const std::string& p_newFileName) +void OvUI::Core::UIManager::RenameLayout(const std::filesystem::path& p_filePath, const std::filesystem::path& p_newFilePath) { - std::filesystem::rename(p_fileName, p_newFileName); + std::filesystem::rename(p_filePath, p_newFilePath); - if (m_layoutSaveFilename == p_fileName) + if (m_layoutSaveFilename == p_filePath) { - SetEditorLayoutSaveFilename(p_newFileName); + SetEditorLayoutSaveFilename(p_newFilePath); } } @@ -335,7 +342,7 @@ void OvUI::Core::UIManager::Render() } } -std::string OvUI::Core::UIManager::GetLayoutsPath() +const std::filesystem::path& OvUI::Core::UIManager::GetLayoutsPath() const { return m_layoutsPath; } From 7934b0b1315d8c8c965abb77b440bd20acc6584b Mon Sep 17 00:00:00 2001 From: Max Brun Date: Tue, 1 Apr 2025 22:40:31 +0200 Subject: [PATCH 05/12] Cleaned lambda captures --- .../Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp b/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp index 7719e85b8..ccd21465e 100644 --- a/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp +++ b/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp @@ -211,7 +211,7 @@ void OvEditor::Panels::MenuBar::CreateLayoutMenu() auto& saveNewMenuList = layoutMenuList.CreateWidget("Save New"); auto& layoutInputText = saveNewMenuList.CreateWidget("Layout Name"); layoutInputText.selectAllOnClick = true; - layoutInputText.EnterPressedEvent += [this, &layoutsPath](std::string p_input) + layoutInputText.EnterPressedEvent += [&layoutsPath](std::string p_input) { if (p_input.empty()) return; @@ -222,7 +222,7 @@ void OvEditor::Panels::MenuBar::CreateLayoutMenu() auto& loadMenuList = layoutMenuList.CreateWidget("Load"); - loadMenuList.ClickedEvent += [&, layoutsPath] + loadMenuList.ClickedEvent += [&] { loadMenuList.RemoveAllWidgets(); @@ -233,7 +233,7 @@ void OvEditor::Panels::MenuBar::CreateLayoutMenu() auto& layoutMenuItem = loadMenuList.CreateWidget(entry.path().stem().string()); layoutMenuItem.name = entry.path().stem().string(); - layoutMenuItem.ClickedEvent += [this, entry] + layoutMenuItem.ClickedEvent += [entry] { auto& uiManager = *EDITOR_CONTEXT(uiManager); EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::SetLayout, &uiManager, entry.path()), 1)); @@ -242,7 +242,7 @@ void OvEditor::Panels::MenuBar::CreateLayoutMenu() auto& contextualMenu = layoutMenuItem.AddPlugin(); auto& deleteMenuItem = contextualMenu.CreateWidget("Delete"); - deleteMenuItem.ClickedEvent += [this, &layoutMenuItem, entry] + deleteMenuItem.ClickedEvent += [entry, &layoutMenuItem] { auto& uiManager = *EDITOR_CONTEXT(uiManager); EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::DeleteLayout, &uiManager, entry.path()), 1)); @@ -255,7 +255,7 @@ void OvEditor::Panels::MenuBar::CreateLayoutMenu() renameInputText.content = entry.path().stem().string(); renameInputText.selectAllOnClick = true; - renameInputText.EnterPressedEvent += [this, entry, layoutsPath, &contextualMenu, &layoutMenuItem](std::string p_newName) + renameInputText.EnterPressedEvent += [entry, &layoutMenuItem, &layoutsPath, &contextualMenu](std::string p_newName) { if (p_newName.empty()) return; From db8ecd854765cf848cff34da6e9a50e0b08bbf7c Mon Sep 17 00:00:00 2001 From: Max Brun Date: Tue, 1 Apr 2025 23:58:45 +0200 Subject: [PATCH 06/12] Added latest layout in editor.ini --- .../OvEditor/include/OvEditor/Settings/EditorSettings.h | 1 + Sources/Overload/OvEditor/src/OvEditor/Core/Editor.cpp | 5 +++++ Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp | 6 ++++-- .../OvEditor/src/OvEditor/Settings/EditorSettings.cpp | 2 ++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Sources/Overload/OvEditor/include/OvEditor/Settings/EditorSettings.h b/Sources/Overload/OvEditor/include/OvEditor/Settings/EditorSettings.h index b6a31ac86..c2f7ab2f8 100644 --- a/Sources/Overload/OvEditor/include/OvEditor/Settings/EditorSettings.h +++ b/Sources/Overload/OvEditor/include/OvEditor/Settings/EditorSettings.h @@ -92,5 +92,6 @@ namespace OvEditor::Settings inline static Property TranslationSnapUnit = { 1.0f }; inline static Property RotationSnapUnit = { 15.0f }; inline static Property ScalingSnapUnit = { 1.0f }; + inline static Property LatestLayout = { "" }; }; } diff --git a/Sources/Overload/OvEditor/src/OvEditor/Core/Editor.cpp b/Sources/Overload/OvEditor/src/OvEditor/Core/Editor.cpp index 62de1f1d7..2bba8cf84 100644 --- a/Sources/Overload/OvEditor/src/OvEditor/Core/Editor.cpp +++ b/Sources/Overload/OvEditor/src/OvEditor/Core/Editor.cpp @@ -77,6 +77,11 @@ void OvEditor::Core::Editor::SetupUI() m_canvas.MakeDockspace(true); m_context.uiManager->SetCanvas(m_canvas); + + if (!Settings::EditorSettings::LatestLayout.Get().empty() && std::filesystem::exists(Settings::EditorSettings::LatestLayout.Get())) + { + m_context.uiManager->SetLayout(Settings::EditorSettings::LatestLayout.Get()); + } } void OvEditor::Core::Editor::PreUpdate() diff --git a/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp b/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp index ccd21465e..44b5c6309 100644 --- a/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp +++ b/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp @@ -237,6 +237,8 @@ void OvEditor::Panels::MenuBar::CreateLayoutMenu() { auto& uiManager = *EDITOR_CONTEXT(uiManager); EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::SetLayout, &uiManager, entry.path()), 1)); + + Settings::EditorSettings::LatestLayout = entry.path().string(); }; auto& contextualMenu = layoutMenuItem.AddPlugin(); @@ -263,8 +265,8 @@ void OvEditor::Panels::MenuBar::CreateLayoutMenu() layoutMenuItem.name = p_newName; auto& uiManager = *EDITOR_CONTEXT(uiManager); - EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::RenameLayout, &uiManager, entry, layoutsPath / (p_newName + ".ini")), 1)); - + EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::RenameLayout, &uiManager, entry.path(), layoutsPath / (p_newName + ".ini")), 1)); + contextualMenu.Close(); }; } diff --git a/Sources/Overload/OvEditor/src/OvEditor/Settings/EditorSettings.cpp b/Sources/Overload/OvEditor/src/OvEditor/Settings/EditorSettings.cpp index f648cd257..55464888d 100644 --- a/Sources/Overload/OvEditor/src/OvEditor/Settings/EditorSettings.cpp +++ b/Sources/Overload/OvEditor/src/OvEditor/Settings/EditorSettings.cpp @@ -42,6 +42,7 @@ void OvEditor::Settings::EditorSettings::Save() iniFile.Add("translation_snap_unit", TranslationSnapUnit.Get()); iniFile.Add("rotation_snap_unit", RotationSnapUnit.Get()); iniFile.Add("scaling_snap_unit", ScalingSnapUnit.Get()); + iniFile.Add("latest_layout", LatestLayout.Get()); iniFile.Rewrite(); } @@ -57,4 +58,5 @@ void OvEditor::Settings::EditorSettings::Load() LoadIniEntry(iniFile, "translation_snap_unit", TranslationSnapUnit); LoadIniEntry(iniFile, "rotation_snap_unit", RotationSnapUnit); LoadIniEntry(iniFile, "scaling_snap_unit", ScalingSnapUnit); + LoadIniEntry(iniFile, "latest_layout", LatestLayout); } From d7ad241063f2b0ac788df6f0076c73951df30b6f Mon Sep 17 00:00:00 2001 From: Max Brun Date: Wed, 2 Apr 2025 00:55:30 +0200 Subject: [PATCH 07/12] Fixed exception caused by multiple layout rename without refreshing the captured path --- .../OvEditor/src/OvEditor/Panels/MenuBar.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp b/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp index 44b5c6309..dd0e00807 100644 --- a/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp +++ b/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp @@ -233,21 +233,23 @@ void OvEditor::Panels::MenuBar::CreateLayoutMenu() auto& layoutMenuItem = loadMenuList.CreateWidget(entry.path().stem().string()); layoutMenuItem.name = entry.path().stem().string(); - layoutMenuItem.ClickedEvent += [entry] + std::shared_ptr currentPath = std::make_shared(entry.path()); + + layoutMenuItem.ClickedEvent += [currentPath] { auto& uiManager = *EDITOR_CONTEXT(uiManager); - EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::SetLayout, &uiManager, entry.path()), 1)); + EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::SetLayout, &uiManager, *currentPath), 1)); - Settings::EditorSettings::LatestLayout = entry.path().string(); + Settings::EditorSettings::LatestLayout = currentPath->string(); }; auto& contextualMenu = layoutMenuItem.AddPlugin(); auto& deleteMenuItem = contextualMenu.CreateWidget("Delete"); - deleteMenuItem.ClickedEvent += [entry, &layoutMenuItem] + deleteMenuItem.ClickedEvent += [currentPath, &layoutMenuItem] { auto& uiManager = *EDITOR_CONTEXT(uiManager); - EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::DeleteLayout, &uiManager, entry.path()), 1)); + EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::DeleteLayout, &uiManager, *currentPath), 1)); layoutMenuItem.enabled = false; }; @@ -257,7 +259,7 @@ void OvEditor::Panels::MenuBar::CreateLayoutMenu() renameInputText.content = entry.path().stem().string(); renameInputText.selectAllOnClick = true; - renameInputText.EnterPressedEvent += [entry, &layoutMenuItem, &layoutsPath, &contextualMenu](std::string p_newName) + renameInputText.EnterPressedEvent += [currentPath, &layoutMenuItem, &layoutsPath, &contextualMenu](std::string p_newName) { if (p_newName.empty()) return; @@ -265,8 +267,9 @@ void OvEditor::Panels::MenuBar::CreateLayoutMenu() layoutMenuItem.name = p_newName; auto& uiManager = *EDITOR_CONTEXT(uiManager); - EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::RenameLayout, &uiManager, entry.path(), layoutsPath / (p_newName + ".ini")), 1)); - + std::filesystem::path newPath = layoutsPath / (p_newName + ".ini"); + EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::RenameLayout, &uiManager, *currentPath, newPath), 1)); + *currentPath = newPath; contextualMenu.Close(); }; } From f7f334edb079f68fc1919fd932a8c3c2f8802a39 Mon Sep 17 00:00:00 2001 From: Max Brun Date: Wed, 2 Apr 2025 01:30:47 +0200 Subject: [PATCH 08/12] Fixed unsaved layout --- .../OvEditor/src/OvEditor/Panels/MenuBar.cpp | 7 +++++++ .../OvUI/include/OvUI/Core/UIManager.h | 2 +- .../Overload/OvUI/src/OvUI/Core/UIManager.cpp | 19 +++++++++++-------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp b/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp index dd0e00807..d1000ecc4 100644 --- a/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp +++ b/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp @@ -269,7 +269,14 @@ void OvEditor::Panels::MenuBar::CreateLayoutMenu() auto& uiManager = *EDITOR_CONTEXT(uiManager); std::filesystem::path newPath = layoutsPath / (p_newName + ".ini"); EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::RenameLayout, &uiManager, *currentPath, newPath), 1)); + + if (Settings::EditorSettings::LatestLayout.Get() == currentPath->string()) + { + Settings::EditorSettings::LatestLayout = newPath.string(); + } + *currentPath = newPath; + contextualMenu.Close(); }; } diff --git a/Sources/Overload/OvUI/include/OvUI/Core/UIManager.h b/Sources/Overload/OvUI/include/OvUI/Core/UIManager.h index b619a48a2..20fe364dc 100644 --- a/Sources/Overload/OvUI/include/OvUI/Core/UIManager.h +++ b/Sources/Overload/OvUI/include/OvUI/Core/UIManager.h @@ -177,7 +177,7 @@ namespace OvUI::Core bool m_dockingState; Modules::Canvas* m_currentCanvas = nullptr; std::unordered_map m_fonts; - std::filesystem::path m_layoutSaveFilename = "imgui.ini"; + std::string m_layoutSaveFilename = "imgui.ini"; const std::filesystem::path m_defaultLayout; const std::filesystem::path m_layoutsPath; }; diff --git a/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp b/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp index ead6c70cb..63eb12006 100644 --- a/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp +++ b/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp @@ -24,7 +24,7 @@ m_layoutsPath(OvTools::Utils::SystemCalls::GetPathToAppdata() + "\\OverloadTech\ ImGui_ImplGlfw_InitForOpenGL(p_glfwWindow, true); ImGui_ImplOpenGL3_Init(p_glslVersion.data()); - std::filesystem::create_directory(m_layoutsPath); + std::filesystem::create_directories(m_layoutsPath); } OvUI::Core::UIManager::~UIManager() @@ -225,7 +225,7 @@ void OvUI::Core::UIManager::UseDefaultFont() void OvUI::Core::UIManager::EnableEditorLayoutSave(bool p_value) { if (p_value) - ImGui::GetIO().IniFilename = m_layoutSaveFilename.string().c_str(); + ImGui::GetIO().IniFilename = m_layoutSaveFilename.c_str(); else ImGui::GetIO().IniFilename = nullptr; } @@ -237,9 +237,10 @@ bool OvUI::Core::UIManager::IsEditorLayoutSaveEnabled() const void OvUI::Core::UIManager::SetEditorLayoutSaveFilename(const std::filesystem::path& p_filePath) { - m_layoutSaveFilename = p_filePath; + m_layoutSaveFilename = p_filePath.string(); + if (IsEditorLayoutSaveEnabled()) - ImGui::GetIO().IniFilename = m_layoutSaveFilename.string().c_str(); + ImGui::GetIO().IniFilename = m_layoutSaveFilename.c_str(); } void OvUI::Core::UIManager::SetEditorLayoutAutosaveFrequency(float p_frequency) @@ -281,17 +282,19 @@ void OvUI::Core::UIManager::SaveLayout(const std::filesystem::path& p_filePath) { SetEditorLayoutSaveFilename(p_filePath); - ImGui::SaveIniSettingsToDisk(m_layoutSaveFilename.string().c_str()); + ImGui::SaveIniSettingsToDisk(m_layoutSaveFilename.c_str()); } void OvUI::Core::UIManager::SaveCurrentLayout() { if (!std::filesystem::exists(m_layoutSaveFilename)) { - m_layoutSaveFilename = (m_layoutsPath / "layout.ini").string(); - SetEditorLayoutSaveFilename(m_layoutSaveFilename); + auto path = m_layoutsPath / "layout.ini"; + m_layoutSaveFilename = path.string(); + + SetEditorLayoutSaveFilename(path); } - ImGui::SaveIniSettingsToDisk(m_layoutSaveFilename.string().c_str()); + ImGui::SaveIniSettingsToDisk(m_layoutSaveFilename.c_str()); } void OvUI::Core::UIManager::SetLayout(const std::filesystem::path& p_filePath) From 46e1496343399bb7513376d445996d72a0ce39bd Mon Sep 17 00:00:00 2001 From: Max Brun Date: Wed, 2 Apr 2025 01:35:55 +0200 Subject: [PATCH 09/12] Update Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp Co-authored-by: Adrien Givry --- Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp b/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp index 63eb12006..0d0b0d07d 100644 --- a/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp +++ b/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp @@ -12,7 +12,7 @@ OvUI::Core::UIManager::UIManager(GLFWwindow* p_glfwWindow, Styling::EStyle p_style, std::string_view p_glslVersion) : m_defaultLayout("Config\\layout.ini"), -m_layoutsPath(OvTools::Utils::SystemCalls::GetPathToAppdata() + "\\OverloadTech\\OvEditor\\Layouts\\") +m_layoutsPath(std::filesystem::path{ OvTools::Utils::SystemCalls::GetPathToAppdata() } / "OverloadTech" / "OvEditor" / "Layouts") { ImGui::CreateContext(); From 2a2ea987108953ae8604f50c668b98431c46d873 Mon Sep 17 00:00:00 2001 From: Max Brun Date: Wed, 2 Apr 2025 01:36:02 +0200 Subject: [PATCH 10/12] Update Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp Co-authored-by: Adrien Givry --- Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp b/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp index 0d0b0d07d..eb53bc311 100644 --- a/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp +++ b/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp @@ -11,7 +11,7 @@ #include OvUI::Core::UIManager::UIManager(GLFWwindow* p_glfwWindow, Styling::EStyle p_style, std::string_view p_glslVersion) : -m_defaultLayout("Config\\layout.ini"), +m_defaultLayout{ std::filesystem::path{} / "Config" / "layout.ini" } m_layoutsPath(std::filesystem::path{ OvTools::Utils::SystemCalls::GetPathToAppdata() } / "OverloadTech" / "OvEditor" / "Layouts") { ImGui::CreateContext(); From 6a5a3bcad49537777a83472bc127045fd6711826 Mon Sep 17 00:00:00 2001 From: Max Brun Date: Wed, 2 Apr 2025 01:46:47 +0200 Subject: [PATCH 11/12] Fixed Co-authored commit --- Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp b/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp index eb53bc311..29705eb30 100644 --- a/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp +++ b/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp @@ -11,8 +11,8 @@ #include OvUI::Core::UIManager::UIManager(GLFWwindow* p_glfwWindow, Styling::EStyle p_style, std::string_view p_glslVersion) : -m_defaultLayout{ std::filesystem::path{} / "Config" / "layout.ini" } -m_layoutsPath(std::filesystem::path{ OvTools::Utils::SystemCalls::GetPathToAppdata() } / "OverloadTech" / "OvEditor" / "Layouts") +m_defaultLayout{ std::filesystem::path{} / "Config" / "layout.ini" }, +m_layoutsPath(std::filesystem::path { OvTools::Utils::SystemCalls::GetPathToAppdata() } / "OverloadTech" / "OvEditor" / "Layouts") { ImGui::CreateContext(); From a202fe127786f673c7cab062ef71e7e2dab58b03 Mon Sep 17 00:00:00 2001 From: Max Brun Date: Wed, 2 Apr 2025 03:16:52 +0200 Subject: [PATCH 12/12] Updated Layout ini value --- .../OvEditor/src/OvEditor/Core/Editor.cpp | 4 ++-- .../OvEditor/src/OvEditor/Panels/MenuBar.cpp | 6 +++--- .../Overload/OvUI/include/OvUI/Core/UIManager.h | 12 ++++++------ Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp | 15 +++++++++------ 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Sources/Overload/OvEditor/src/OvEditor/Core/Editor.cpp b/Sources/Overload/OvEditor/src/OvEditor/Core/Editor.cpp index ed63c07f0..58a285985 100644 --- a/Sources/Overload/OvEditor/src/OvEditor/Core/Editor.cpp +++ b/Sources/Overload/OvEditor/src/OvEditor/Core/Editor.cpp @@ -77,9 +77,9 @@ void OvEditor::Core::Editor::SetupUI() m_canvas.MakeDockspace(true); m_context.uiManager->SetCanvas(m_canvas); - if (!Settings::EditorSettings::LatestLayout.Get().empty() && std::filesystem::exists(Settings::EditorSettings::LatestLayout.Get())) + if (!Settings::EditorSettings::LatestLayout.Get().empty()) { - m_context.uiManager->SetLayout(Settings::EditorSettings::LatestLayout.Get()); + m_context.uiManager->SetIniLayout(Settings::EditorSettings::LatestLayout.Get()); } } diff --git a/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp b/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp index 592e534e2..aa91864b8 100644 --- a/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp +++ b/Sources/Overload/OvEditor/src/OvEditor/Panels/MenuBar.cpp @@ -259,7 +259,7 @@ void OvEditor::Panels::MenuBar::CreateLayoutMenu() auto& uiManager = *EDITOR_CONTEXT(uiManager); EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::SetLayout, &uiManager, *currentPath), 1)); - Settings::EditorSettings::LatestLayout = currentPath->string(); + Settings::EditorSettings::LatestLayout = currentPath->stem().string(); }; auto& contextualMenu = layoutMenuItem.AddPlugin(); @@ -289,9 +289,9 @@ void OvEditor::Panels::MenuBar::CreateLayoutMenu() std::filesystem::path newPath = layoutsPath / (p_newName + ".ini"); EDITOR_EXEC(DelayAction(std::bind(&OvUI::Core::UIManager::RenameLayout, &uiManager, *currentPath, newPath), 1)); - if (Settings::EditorSettings::LatestLayout.Get() == currentPath->string()) + if (Settings::EditorSettings::LatestLayout.Get() == currentPath->stem().string()) { - Settings::EditorSettings::LatestLayout = newPath.string(); + Settings::EditorSettings::LatestLayout = newPath.stem().string(); } *currentPath = newPath; diff --git a/Sources/Overload/OvUI/include/OvUI/Core/UIManager.h b/Sources/Overload/OvUI/include/OvUI/Core/UIManager.h index 20fe364dc..f4272c360 100644 --- a/Sources/Overload/OvUI/include/OvUI/Core/UIManager.h +++ b/Sources/Overload/OvUI/include/OvUI/Core/UIManager.h @@ -109,12 +109,6 @@ namespace OvUI::Core */ void ResetLayout(const std::string& p_config) const; - /** - * Load the UI layout from the given configuration file - * @param p_fileName - */ - void LoadLayout(const std::string& p_fileName); - /** * Save the UI layout to the given configuration file * @param p_filePath @@ -126,6 +120,12 @@ namespace OvUI::Core */ void SaveCurrentLayout(); + /** + * Set and load the UI ini layout from the given file name + * @param p_fileName + */ + void SetIniLayout(const std::string& p_fileName); + /** * Set and load the UI layout from the given configuration file * @param p_filePath diff --git a/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp b/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp index 279cce833..e59fb04cb 100644 --- a/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp +++ b/Sources/Overload/OvUI/src/OvUI/Core/UIManager.cpp @@ -155,12 +155,7 @@ void OvUI::Core::UIManager::ResetToDefaultLayout() const void OvUI::Core::UIManager::ResetLayout(const std::string& p_config) const { - ImGui::LoadIniSettingsFromDisk(p_config.c_str()); -} - -void OvUI::Core::UIManager::LoadLayout(const std::string& p_fileName) -{ - ImGui::LoadIniSettingsFromDisk(p_fileName.c_str()); + ImGui::LoadIniSettingsFromDisk(p_config.c_str()); } void OvUI::Core::UIManager::SaveLayout(const std::filesystem::path& p_filePath) @@ -182,6 +177,14 @@ void OvUI::Core::UIManager::SaveCurrentLayout() ImGui::SaveIniSettingsToDisk(m_layoutSaveFilename.c_str()); } +void OvUI::Core::UIManager::SetIniLayout(const std::string& p_fileName) +{ + auto iniLayoutPath = m_layoutsPath / (p_fileName + ".ini"); + + if(std::filesystem::exists(iniLayoutPath)) + SetLayout(iniLayoutPath); +} + void OvUI::Core::UIManager::SetLayout(const std::filesystem::path& p_filePath) { SetEditorLayoutSaveFilename(p_filePath);