From 06a124e8d22ddfa48d8140daab126230acde2b5c Mon Sep 17 00:00:00 2001 From: Hanfei Yang Date: Fri, 10 Jun 2022 16:00:11 -0700 Subject: [PATCH 1/7] Surfed through the codes --- CMakeLists.txt | 1 + Source/Core/Editor/ExampleYaml.yaml | 294 ++++++++++++++++++ Source/Core/Editor/GUI.cpp | 3 +- .../ERS_Editor_LayoutManager/CMakeLists.txt | 30 ++ .../ERS_Editor_LayoutManager.cpp | 26 ++ .../ERS_Editor_LayoutManager.h | 54 ++++ 6 files changed, 407 insertions(+), 1 deletion(-) create mode 100644 Source/Core/Editor/ExampleYaml.yaml create mode 100644 Source/Core/Editor/Utils/ERS_Editor_LayoutManager/CMakeLists.txt create mode 100644 Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp create mode 100644 Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 3daf65d0f1..e5c008ae50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,7 @@ add_subdirectory(${SRC_DIR}/Core/Editor/) add_subdirectory(${SRC_DIR}/Core/Editor/Utils/ERS_Editor_ThemeManager) add_subdirectory(${SRC_DIR}/Core/Editor/Utils/ERS_Editor_FontManager) add_subdirectory(${SRC_DIR}/Core/Editor/Utils/ERS_Editor_UserProfileManager) +add_subdirectory(${SRC_DIR}/Core/Editor/Utils/ERS_Editor_LayoutManager) add_subdirectory(${SRC_DIR}/Core/Editor/Utils/ERS_Editor_3DCursor) add_subdirectory(${SRC_DIR}/Core/Editor/Widgets) add_subdirectory(${SRC_DIR}/Core/Editor/Windows) diff --git a/Source/Core/Editor/ExampleYaml.yaml b/Source/Core/Editor/ExampleYaml.yaml new file mode 100644 index 0000000000..97ea35e0f4 --- /dev/null +++ b/Source/Core/Editor/ExampleYaml.yaml @@ -0,0 +1,294 @@ +# Store if windows are enabled or disabled +FramerateGraphEnabled: True +... + + + +# Store Info About This Layout +DisplayName: "Default Layout" +ImGuiIni: '[Window][Debug##Default] +Pos=60,60 +Size=400,400 +Collapsed=0 + +[Window][System Controls] +Pos=0,598 +Size=502,200 +Collapsed=0 +DockId=0x00000004,0 + +[Window][System Info] +Pos=0,800 +Size=502,372 +Collapsed=0 +DockId=0x00000006,0 + +[Window][TestWindow] +Pos=562,19 +Size=679,1153 +Collapsed=0 +DockId=0x00000016,0 + +[Window][Example: Console] +Pos=120,299 +Size=520,600 +Collapsed=1 + +[Window][Dear ImGui Demo] +Pos=541,593 +Size=1862,770 +Collapsed=1 + +[Window][Dear ImGui Metrics/Debugger] +Pos=283,116 +Size=712,1037 +Collapsed=0 + +[Window][Dear ImGui Style Editor] +Pos=107,164 +Size=750,1036 +Collapsed=0 + +[Window][Example: Log] +Pos=60,60 +Size=634,400 +Collapsed=1 + +[Window][DockSpace Demo] +Pos=0,20 +Size=2560,1546 +Collapsed=0 + +[Window][Example: Custom rendering] +Pos=849,297 +Size=485,414 +Collapsed=0 + +[Window][Example: Documents] +Pos=739,108 +Size=607,944 +Collapsed=0 + +[Window][Eggplant] +Pos=747,204 +Size=591,840 +Collapsed=0 + +[Window][Carrot] +Pos=747,204 +Size=591,840 +Collapsed=0 + +[Window][Lettuce] +Pos=134,237 +Size=591,840 +Collapsed=0 + +[Window][Tomato] +Pos=747,204 +Size=591,840 +Collapsed=0 + +[Window][Some Document] +Pos=467,324 +Size=591,840 +Collapsed=0 + +[Window][A Rather Long Title] +Pos=256,385 +Size=591,840 +Collapsed=0 + +[Window][DockSpaceViewport_11111111] +Pos=0,20 +Size=2014,1102 +Collapsed=0 + +[Window][TestWindow2] +Pos=1243,19 +Size=677,1153 +Collapsed=0 +DockId=0x00000008,0 + +[Window][Viewport] +Pos=444,249 +Size=1073,661 +Collapsed=0 +DockId=0x00000020,0 + +[Window][Viewport 2] +Pos=1141,249 +Size=779,440 +Collapsed=0 +DockId=0x00000020,0 + +[Window][Framerate Counter] +Pos=601,249 +Size=698,283 +Collapsed=0 +DockId=0x00000020,2 + +[Window][Rendering Settings] +Pos=601,249 +Size=698,283 +Collapsed=0 +DockId=0x00000020,1 + +[Window][Framerate Graph] +Pos=0,20 +Size=1003,227 +Collapsed=0 +DockId=0x00000015,0 + +[Window][Object Properties] +Pos=0,684 +Size=459,438 +Collapsed=0 +DockId=0x00000014,0 + +[Window][Scene Tree] +Pos=461,249 +Size=1046,873 +Collapsed=0 +DockId=0x00000020,0 + +[Window][Font Selector] +Pos=283,196 +Size=316,498 +Collapsed=0 + +[Window][System Log] +Pos=601,817 +Size=698,572 +Collapsed=0 +DockId=0x00000014,1 + +[Window][Pick Color Theme] +Pos=60,60 +Size=266,318 +Collapsed=0 + +[Window][Frame Latency Graph] +Pos=1005,20 +Size=1009,227 +Collapsed=0 +DockId=0x00000016,0 + +[Window][Viewport 1] +Pos=1509,249 +Size=505,873 +Collapsed=0 +DockId=0x00000021,0 + +[Window][Viewport 3] +Pos=1141,691 +Size=779,437 +Collapsed=0 +DockId=0x0000001B,0 + +[Window][Viewport 4] +Pos=444,691 +Size=695,437 +Collapsed=0 +DockId=0x00000009,0 + +[Window][About Dear ImGui] +Pos=60,60 +Size=589,466 +Collapsed=0 + +[Window][Asset Explorer] +Pos=0,249 +Size=459,433 +Collapsed=0 +DockId=0x00000012,0 + +[Window][Shader Editor] +Pos=0,271 +Size=599,436 +Collapsed=0 +DockId=0x00000019,0 + +[Window][Shader Tools] +Pos=0,709 +Size=599,680 +Collapsed=0 +DockId=0x00000010,0 + +[Window][RAM Graph] +Pos=0,20 +Size=599,249 +Collapsed=0 +DockId=0x00000018,0 + +[Window][Script Editor] +Pos=0,20 +Size=426,580 +Collapsed=0 +DockId=0x0000001C,0 + +[Window][Script Tools] +Pos=0,602 +Size=426,574 +Collapsed=0 +DockId=0x0000001D,0 + +[Window][Import##ImportModel] +Pos=60,60 +Size=584,364 +Collapsed=0 + +[Window][Import Model##Import Model] +Pos=60,60 +Size=435,273 +Collapsed=0 + +[Table][0x0B04C00B,4] +RefScale=14 +Column 0 Sort=0v + +[Table][0xC04A86C3,4] +RefScale=14 +Column 0 Sort=0v + +[Table][0x78ED9FB7,4] +RefScale=14 +Column 0 Sort=0v + +[Table][0x84CB98C9,4] +RefScale=14 +Column 0 Sort=0v + +[Docking][Data] +DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=0,20 Size=2014,1102 Split=X + DockNode ID=0x0000001A Parent=0x8B93E3BD SizeRef=426,1156 Split=Y + DockNode ID=0x0000001C Parent=0x0000001A SizeRef=600,200 Selected=0x02DF5741 + DockNode ID=0x0000001D Parent=0x0000001A SizeRef=600,198 Selected=0xA5B8BA00 + DockNode ID=0x0000001E Parent=0x8B93E3BD SizeRef=1492,1156 Split=X + DockNode ID=0x0000000B Parent=0x0000001E SizeRef=599,982 Split=Y + DockNode ID=0x0000000F Parent=0x0000000B SizeRef=600,200 Split=Y Selected=0x919FD48C + DockNode ID=0x00000018 Parent=0x0000000F SizeRef=599,249 Selected=0x734C7367 + DockNode ID=0x00000019 Parent=0x0000000F SizeRef=599,436 Selected=0x919FD48C + DockNode ID=0x00000010 Parent=0x0000000B SizeRef=600,198 Selected=0xECC4EA8D + DockNode ID=0x00000011 Parent=0x0000001E SizeRef=1319,982 Split=Y + DockNode ID=0x0000000C Parent=0x00000011 SizeRef=3440,227 Split=X Selected=0xE93F57AB + DockNode ID=0x00000015 Parent=0x0000000C SizeRef=738,227 Selected=0x31F26B5E + DockNode ID=0x00000016 Parent=0x0000000C SizeRef=742,227 Selected=0xE93F57AB + DockNode ID=0x00000013 Parent=0x00000011 SizeRef=3440,1127 Split=X + DockNode ID=0x00000003 Parent=0x00000013 SizeRef=502,1153 Split=Y Selected=0x8769D556 + DockNode ID=0x00000004 Parent=0x00000003 SizeRef=560,200 Selected=0xCDAE6D71 + DockNode ID=0x00000006 Parent=0x00000003 SizeRef=560,372 Selected=0x8769D556 + DockNode ID=0x00000005 Parent=0x00000013 SizeRef=1416,1153 Split=X Selected=0x42F3B5AC + DockNode ID=0x00000007 Parent=0x00000005 SizeRef=679,1153 Split=X Selected=0x995B0CF8 + DockNode ID=0x0000000D Parent=0x00000007 SizeRef=459,901 Split=Y Selected=0xF8780F64 + DockNode ID=0x00000012 Parent=0x0000000D SizeRef=442,458 Selected=0x7E9CA0E4 + DockNode ID=0x00000014 Parent=0x0000000D SizeRef=442,463 Selected=0xF8780F64 + DockNode ID=0x0000000E Parent=0x00000007 SizeRef=1031,901 Split=X Selected=0x995B0CF8 + DockNode ID=0x00000009 Parent=0x0000000E SizeRef=695,617 Selected=0x505088A2 + DockNode ID=0x0000000A Parent=0x0000000E SizeRef=779,617 Split=Y Selected=0xC959D918 + DockNode ID=0x00000017 Parent=0x0000000A SizeRef=858,440 Split=X Selected=0x505088A2 + DockNode ID=0x00000020 Parent=0x00000017 SizeRef=1046,1317 Selected=0x3875EE28 + DockNode ID=0x00000021 Parent=0x00000017 SizeRef=1051,1317 CentralNode=1 Selected=0x505088A2 + DockNode ID=0x0000001B Parent=0x0000000A SizeRef=858,437 Selected=0xBE5EE98E + DockNode ID=0x00000008 Parent=0x00000005 SizeRef=677,1153 Selected=0xC5F7A27B +' \ No newline at end of file diff --git a/Source/Core/Editor/GUI.cpp b/Source/Core/Editor/GUI.cpp index 238686102a..de1a57237e 100644 --- a/Source/Core/Editor/GUI.cpp +++ b/Source/Core/Editor/GUI.cpp @@ -104,7 +104,8 @@ void GUISystem::UpdateGUI() { ImGui::EndMainMenuBar(); } - + size_t settings_size = 0; + const char* settings = ImGui::SaveIniSettingsToMemory(&settings_size); } void GUISystem::DeferredFrameUpdate() { diff --git a/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/CMakeLists.txt b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/CMakeLists.txt new file mode 100644 index 0000000000..575012f86f --- /dev/null +++ b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/CMakeLists.txt @@ -0,0 +1,30 @@ +######################################################################## +# This file is part of the BrainGenix-ERS Environment Rendering System # +######################################################################## + + +# Create Library (Name Should Be Parent Dir Name) +add_library(ERS_Editor_LayoutManager + + # Add Source Files (.cpp) + "ERS_Editor_LayoutManager.cpp" + + # Add Header Files (.h) + "ERS_Editor_LayoutManager.h" + + ${BACKWARD_ENABLE} + ) +set_property(TARGET ERS_Editor_LayoutManager PROPERTY CXX_STANDARD 17) + +# Link 3rd Party Libs +target_link_libraries(ERS_Editor_LayoutManager + yaml-cpp + IMGUI + ) + +# Link Internal Libs +target_link_libraries(ERS_Editor_LayoutManager + ERS_CLASS_LoggingSystem + ) + +target_include_directories(ERS_Editor_LayoutManager PUBLIC ./) \ No newline at end of file diff --git a/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp new file mode 100644 index 0000000000..47a32f6acd --- /dev/null +++ b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp @@ -0,0 +1,26 @@ +//======================================================================// +// This file is part of the BrainGenix-ERS Environment Rendering System // +//======================================================================// + +#include + + +ERS_CLASS_LayoutManager::ERS_CLASS_LayoutManager(ERS_CLASS_LoggingSystem* Logger, const char* UserProfilePath) { + + Logger_ = Logger; + Logger_->Log("Initializing Layout Manager", 5); + + } + + +ERS_CLASS_LayoutManager::~ERS_CLASS_LayoutManager() { + + Logger_->Log("Layout Manager Destructor Called", 6); + +} + +bool ERS_CLASS_LayoutManager::IndexConfigs() { + + + +} \ No newline at end of file diff --git a/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.h b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.h new file mode 100644 index 0000000000..af4ede8333 --- /dev/null +++ b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.h @@ -0,0 +1,54 @@ +//======================================================================// +// This file is part of the BrainGenix-ERS Environment Rendering System // +//======================================================================// + +#pragma once + + +// Standard Libraries (BG convention: use <> instead of "") +#include + +// Third-Party Libraries (BG convention: use <> instead of "") +#include + +// Internal Libraries (BG convention: use <> instead of "") +#include + + +/** + * @brief Creates the user profile manager class. + * + */ +class ERS_CLASS_LayoutManager { + + +private: + + ERS_CLASS_LoggingSystem* Logger_; /** Date: Fri, 10 Jun 2022 16:33:46 -0700 Subject: [PATCH 2/7] Function IndexConfigs changed --- .../ERS_Editor_LayoutManager.cpp | 47 ++++++++++++++++++- .../ERS_Editor_LayoutManager.h | 15 ++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp index 47a32f6acd..ae09eeda6d 100644 --- a/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp +++ b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp @@ -3,13 +3,16 @@ //======================================================================// #include +#include -ERS_CLASS_LayoutManager::ERS_CLASS_LayoutManager(ERS_CLASS_LoggingSystem* Logger, const char* UserProfilePath) { +ERS_CLASS_LayoutManager::ERS_CLASS_LayoutManager(ERS_CLASS_LoggingSystem* Logger, const char* LayoutDirectory) { Logger_ = Logger; Logger_->Log("Initializing Layout Manager", 5); + LayoutDirectory_ = LayoutDirectory; + } @@ -21,6 +24,48 @@ ERS_CLASS_LayoutManager::~ERS_CLASS_LayoutManager() { bool ERS_CLASS_LayoutManager::IndexConfigs() { + LayoutFiles_ = *new std::vector; + + // Create List Of Files + for (const auto& Entry : std::filesystem::directory_iterator(std::string(LayoutDirectory_))) { + + // Get File Path + std::string FilePath{ Entry.path().u8string() }; + + // Load YAML::Node + YAML::Node Layout = YAML::LoadFile(FilePath.c_str()); + LayoutFiles_.push_back(Layout); + + // Parse Out Display Name From File Path + // TODO + std::string LayoutName; + + LayoutName = Layout["DisplayName"].as(); + + //FilePath = FilePath.substr(strlen(ThemePath_) + 1); + //FilePath = FilePath.substr(0, strlen(FilePath.c_str()) - 5); + + // Add To Names Vector + LayoutNames_.push_back(LayoutName); + + // Log Layout Indexed + Logger_->Log(std::string(std::string("Indexed Layout: ") + FilePath).c_str(), 1); + + } + + + Logger_->Log(std::string(std::string("Found ") + std::to_string(LayoutNames_.size()) + std::string(" Layouts")).c_str(), 1); + +} + +void ERS_CLASS_LayoutManager::SaveLayout() { + + + +} + +void ERS_CLASS_LayoutManager::LoadLayout() { + } \ No newline at end of file diff --git a/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.h b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.h index af4ede8333..24c445a37c 100644 --- a/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.h +++ b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.h @@ -27,6 +27,9 @@ class ERS_CLASS_LayoutManager { ERS_CLASS_LoggingSystem* Logger_; /** LayoutFiles_; /** LayoutNames_; /** Date: Fri, 10 Jun 2022 23:52:07 -0700 Subject: [PATCH 3/7] Update LayoutManager.h/.cpp --- .../ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp index ae09eeda6d..762608bfea 100644 --- a/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp +++ b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp @@ -37,13 +37,8 @@ bool ERS_CLASS_LayoutManager::IndexConfigs() { LayoutFiles_.push_back(Layout); // Parse Out Display Name From File Path - // TODO std::string LayoutName; - LayoutName = Layout["DisplayName"].as(); - - //FilePath = FilePath.substr(strlen(ThemePath_) + 1); - //FilePath = FilePath.substr(0, strlen(FilePath.c_str()) - 5); // Add To Names Vector LayoutNames_.push_back(LayoutName); From 6dc6d1b1d564adb6c15611aa36100ee8051c1041 Mon Sep 17 00:00:00 2001 From: allenyangcc Date: Sun, 26 Jun 2022 11:43:35 -0700 Subject: [PATCH 4/7] Update LayoutManager --- .../ERS_Editor_LayoutManager.cpp | 54 ++++++++++++++++--- .../ERS_Editor_LayoutManager.h | 39 ++++++++------ 2 files changed, 69 insertions(+), 24 deletions(-) diff --git a/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp index 762608bfea..3ed459d701 100644 --- a/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp +++ b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp @@ -4,14 +4,14 @@ #include #include +#include ERS_CLASS_LayoutManager::ERS_CLASS_LayoutManager(ERS_CLASS_LoggingSystem* Logger, const char* LayoutDirectory) { Logger_ = Logger; - Logger_->Log("Initializing Layout Manager", 5); - LayoutDirectory_ = LayoutDirectory; + Logger_->Log("Initializing Layout Manager", 5); } @@ -22,14 +22,14 @@ ERS_CLASS_LayoutManager::~ERS_CLASS_LayoutManager() { } -bool ERS_CLASS_LayoutManager::IndexConfigs() { +void ERS_CLASS_LayoutManager::LoadLayouts() { LayoutFiles_ = *new std::vector; // Create List Of Files for (const auto& Entry : std::filesystem::directory_iterator(std::string(LayoutDirectory_))) { - // Get File Path + // Get File Path std::string FilePath{ Entry.path().u8string() }; // Load YAML::Node @@ -53,14 +53,54 @@ bool ERS_CLASS_LayoutManager::IndexConfigs() { } -void ERS_CLASS_LayoutManager::SaveLayout() { +void ERS_CLASS_LayoutManager::SaveLayout(std::string LayoutName) { + + std::string IniString; + + size_t settings_size = 0; + IniString = static_cast (ImGui::SaveIniSettingsToMemory(&settings_size)); + + // Save YAML file + YAML::Node Layout; + Layout["ImGuiIni"] = IniString; + LayoutFiles_.push_back(Layout); + + // Set the layout name + Layout["DisplayName"] = LayoutName; + + // Add To Names Vector + LayoutNames_.push_back(LayoutName); + +} + +void ERS_CLASS_LayoutManager::ApplyLayout(std::string LayoutName) { + int Index; + bool HasFoundLayout = false; + for (Index = 0; (long)Index < (long)LayoutNames_.size(); Index++) { + if (LayoutNames_[Index] == std::string(LayoutName)) { + HasFoundLayout = true; + break; + } + } + if (HasFoundLayout) { + ApplyLayout(Index); + } + else { + Logger_->Log("Failed To Find Layout, Skipping", 5); + } } -void ERS_CLASS_LayoutManager::LoadLayout() { +void ERS_CLASS_LayoutManager::ApplyLayout(int LayoutID) { + // Get Layout Name + std::string LayoutName = LayoutNames_[LayoutID]; + YAML::Node LayoutNode = LayoutFiles_[LayoutID]; + Logger_->Log(std::string(std::string("Applying Layout: ") + LayoutName).c_str(), 4); -} \ No newline at end of file + ImGui::LoadIniSettingsFromMemory(LayoutNode["ImGuiIni"].as()); + +} diff --git a/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.h b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.h index 24c445a37c..270ea190da 100644 --- a/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.h +++ b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.h @@ -28,42 +28,47 @@ class ERS_CLASS_LayoutManager { std::string LayoutDirectory_; /** LayoutFiles_; /** LayoutNames_; /** LayoutNames_; /** Date: Tue, 28 Jun 2022 16:13:53 -0700 Subject: [PATCH 5/7] Update Layout Manager's Save and Load function --- Source/Core/Editor/ExampleYaml.yaml | 294 ------------------ .../ERS_Editor_LayoutManager.cpp | 24 +- .../ERS_Editor_LayoutManager.h | 3 +- 3 files changed, 24 insertions(+), 297 deletions(-) delete mode 100644 Source/Core/Editor/ExampleYaml.yaml diff --git a/Source/Core/Editor/ExampleYaml.yaml b/Source/Core/Editor/ExampleYaml.yaml deleted file mode 100644 index 97ea35e0f4..0000000000 --- a/Source/Core/Editor/ExampleYaml.yaml +++ /dev/null @@ -1,294 +0,0 @@ -# Store if windows are enabled or disabled -FramerateGraphEnabled: True -... - - - -# Store Info About This Layout -DisplayName: "Default Layout" -ImGuiIni: '[Window][Debug##Default] -Pos=60,60 -Size=400,400 -Collapsed=0 - -[Window][System Controls] -Pos=0,598 -Size=502,200 -Collapsed=0 -DockId=0x00000004,0 - -[Window][System Info] -Pos=0,800 -Size=502,372 -Collapsed=0 -DockId=0x00000006,0 - -[Window][TestWindow] -Pos=562,19 -Size=679,1153 -Collapsed=0 -DockId=0x00000016,0 - -[Window][Example: Console] -Pos=120,299 -Size=520,600 -Collapsed=1 - -[Window][Dear ImGui Demo] -Pos=541,593 -Size=1862,770 -Collapsed=1 - -[Window][Dear ImGui Metrics/Debugger] -Pos=283,116 -Size=712,1037 -Collapsed=0 - -[Window][Dear ImGui Style Editor] -Pos=107,164 -Size=750,1036 -Collapsed=0 - -[Window][Example: Log] -Pos=60,60 -Size=634,400 -Collapsed=1 - -[Window][DockSpace Demo] -Pos=0,20 -Size=2560,1546 -Collapsed=0 - -[Window][Example: Custom rendering] -Pos=849,297 -Size=485,414 -Collapsed=0 - -[Window][Example: Documents] -Pos=739,108 -Size=607,944 -Collapsed=0 - -[Window][Eggplant] -Pos=747,204 -Size=591,840 -Collapsed=0 - -[Window][Carrot] -Pos=747,204 -Size=591,840 -Collapsed=0 - -[Window][Lettuce] -Pos=134,237 -Size=591,840 -Collapsed=0 - -[Window][Tomato] -Pos=747,204 -Size=591,840 -Collapsed=0 - -[Window][Some Document] -Pos=467,324 -Size=591,840 -Collapsed=0 - -[Window][A Rather Long Title] -Pos=256,385 -Size=591,840 -Collapsed=0 - -[Window][DockSpaceViewport_11111111] -Pos=0,20 -Size=2014,1102 -Collapsed=0 - -[Window][TestWindow2] -Pos=1243,19 -Size=677,1153 -Collapsed=0 -DockId=0x00000008,0 - -[Window][Viewport] -Pos=444,249 -Size=1073,661 -Collapsed=0 -DockId=0x00000020,0 - -[Window][Viewport 2] -Pos=1141,249 -Size=779,440 -Collapsed=0 -DockId=0x00000020,0 - -[Window][Framerate Counter] -Pos=601,249 -Size=698,283 -Collapsed=0 -DockId=0x00000020,2 - -[Window][Rendering Settings] -Pos=601,249 -Size=698,283 -Collapsed=0 -DockId=0x00000020,1 - -[Window][Framerate Graph] -Pos=0,20 -Size=1003,227 -Collapsed=0 -DockId=0x00000015,0 - -[Window][Object Properties] -Pos=0,684 -Size=459,438 -Collapsed=0 -DockId=0x00000014,0 - -[Window][Scene Tree] -Pos=461,249 -Size=1046,873 -Collapsed=0 -DockId=0x00000020,0 - -[Window][Font Selector] -Pos=283,196 -Size=316,498 -Collapsed=0 - -[Window][System Log] -Pos=601,817 -Size=698,572 -Collapsed=0 -DockId=0x00000014,1 - -[Window][Pick Color Theme] -Pos=60,60 -Size=266,318 -Collapsed=0 - -[Window][Frame Latency Graph] -Pos=1005,20 -Size=1009,227 -Collapsed=0 -DockId=0x00000016,0 - -[Window][Viewport 1] -Pos=1509,249 -Size=505,873 -Collapsed=0 -DockId=0x00000021,0 - -[Window][Viewport 3] -Pos=1141,691 -Size=779,437 -Collapsed=0 -DockId=0x0000001B,0 - -[Window][Viewport 4] -Pos=444,691 -Size=695,437 -Collapsed=0 -DockId=0x00000009,0 - -[Window][About Dear ImGui] -Pos=60,60 -Size=589,466 -Collapsed=0 - -[Window][Asset Explorer] -Pos=0,249 -Size=459,433 -Collapsed=0 -DockId=0x00000012,0 - -[Window][Shader Editor] -Pos=0,271 -Size=599,436 -Collapsed=0 -DockId=0x00000019,0 - -[Window][Shader Tools] -Pos=0,709 -Size=599,680 -Collapsed=0 -DockId=0x00000010,0 - -[Window][RAM Graph] -Pos=0,20 -Size=599,249 -Collapsed=0 -DockId=0x00000018,0 - -[Window][Script Editor] -Pos=0,20 -Size=426,580 -Collapsed=0 -DockId=0x0000001C,0 - -[Window][Script Tools] -Pos=0,602 -Size=426,574 -Collapsed=0 -DockId=0x0000001D,0 - -[Window][Import##ImportModel] -Pos=60,60 -Size=584,364 -Collapsed=0 - -[Window][Import Model##Import Model] -Pos=60,60 -Size=435,273 -Collapsed=0 - -[Table][0x0B04C00B,4] -RefScale=14 -Column 0 Sort=0v - -[Table][0xC04A86C3,4] -RefScale=14 -Column 0 Sort=0v - -[Table][0x78ED9FB7,4] -RefScale=14 -Column 0 Sort=0v - -[Table][0x84CB98C9,4] -RefScale=14 -Column 0 Sort=0v - -[Docking][Data] -DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=0,20 Size=2014,1102 Split=X - DockNode ID=0x0000001A Parent=0x8B93E3BD SizeRef=426,1156 Split=Y - DockNode ID=0x0000001C Parent=0x0000001A SizeRef=600,200 Selected=0x02DF5741 - DockNode ID=0x0000001D Parent=0x0000001A SizeRef=600,198 Selected=0xA5B8BA00 - DockNode ID=0x0000001E Parent=0x8B93E3BD SizeRef=1492,1156 Split=X - DockNode ID=0x0000000B Parent=0x0000001E SizeRef=599,982 Split=Y - DockNode ID=0x0000000F Parent=0x0000000B SizeRef=600,200 Split=Y Selected=0x919FD48C - DockNode ID=0x00000018 Parent=0x0000000F SizeRef=599,249 Selected=0x734C7367 - DockNode ID=0x00000019 Parent=0x0000000F SizeRef=599,436 Selected=0x919FD48C - DockNode ID=0x00000010 Parent=0x0000000B SizeRef=600,198 Selected=0xECC4EA8D - DockNode ID=0x00000011 Parent=0x0000001E SizeRef=1319,982 Split=Y - DockNode ID=0x0000000C Parent=0x00000011 SizeRef=3440,227 Split=X Selected=0xE93F57AB - DockNode ID=0x00000015 Parent=0x0000000C SizeRef=738,227 Selected=0x31F26B5E - DockNode ID=0x00000016 Parent=0x0000000C SizeRef=742,227 Selected=0xE93F57AB - DockNode ID=0x00000013 Parent=0x00000011 SizeRef=3440,1127 Split=X - DockNode ID=0x00000003 Parent=0x00000013 SizeRef=502,1153 Split=Y Selected=0x8769D556 - DockNode ID=0x00000004 Parent=0x00000003 SizeRef=560,200 Selected=0xCDAE6D71 - DockNode ID=0x00000006 Parent=0x00000003 SizeRef=560,372 Selected=0x8769D556 - DockNode ID=0x00000005 Parent=0x00000013 SizeRef=1416,1153 Split=X Selected=0x42F3B5AC - DockNode ID=0x00000007 Parent=0x00000005 SizeRef=679,1153 Split=X Selected=0x995B0CF8 - DockNode ID=0x0000000D Parent=0x00000007 SizeRef=459,901 Split=Y Selected=0xF8780F64 - DockNode ID=0x00000012 Parent=0x0000000D SizeRef=442,458 Selected=0x7E9CA0E4 - DockNode ID=0x00000014 Parent=0x0000000D SizeRef=442,463 Selected=0xF8780F64 - DockNode ID=0x0000000E Parent=0x00000007 SizeRef=1031,901 Split=X Selected=0x995B0CF8 - DockNode ID=0x00000009 Parent=0x0000000E SizeRef=695,617 Selected=0x505088A2 - DockNode ID=0x0000000A Parent=0x0000000E SizeRef=779,617 Split=Y Selected=0xC959D918 - DockNode ID=0x00000017 Parent=0x0000000A SizeRef=858,440 Split=X Selected=0x505088A2 - DockNode ID=0x00000020 Parent=0x00000017 SizeRef=1046,1317 Selected=0x3875EE28 - DockNode ID=0x00000021 Parent=0x00000017 SizeRef=1051,1317 CentralNode=1 Selected=0x505088A2 - DockNode ID=0x0000001B Parent=0x0000000A SizeRef=858,437 Selected=0xBE5EE98E - DockNode ID=0x00000008 Parent=0x00000005 SizeRef=677,1153 Selected=0xC5F7A27B -' \ No newline at end of file diff --git a/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp index 3ed459d701..5b4e7cc65d 100644 --- a/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp +++ b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp @@ -5,6 +5,7 @@ #include #include #include +#include ERS_CLASS_LayoutManager::ERS_CLASS_LayoutManager(ERS_CLASS_LoggingSystem* Logger, const char* LayoutDirectory) { @@ -63,14 +64,35 @@ void ERS_CLASS_LayoutManager::SaveLayout(std::string LayoutName) { // Save YAML file YAML::Node Layout; Layout["ImGuiIni"] = IniString; - LayoutFiles_.push_back(Layout); // Set the layout name Layout["DisplayName"] = LayoutName; + LayoutFiles_.push_back(Layout); + // Add To Names Vector LayoutNames_.push_back(LayoutName); + // Export the YAML string + YAML::Emitter LayoutYAML; + LayoutYAML << YAML::BeginMap; + + // Set Constant Info + LayoutYAML << YAML::Key << "DisplayName" << YAML::Value << LayoutName; + LayoutYAML << YAML::Key << "ImGuiIni" << YAML::Value << IniString; + + // Stop Writing, Generate LayoutYAML + LayoutYAML << YAML::EndMap; + std::string YAMLstring = std::string(LayoutYAML.c_str()); + + // Write the string into a YAML file in the directory + std::ofstream file(std::string(LayoutDirectory_) + LayoutName + ".yaml"); + + if (!file.fail()) + file << YAMLstring; + + file.close(); + } void ERS_CLASS_LayoutManager::ApplyLayout(std::string LayoutName) { diff --git a/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.h b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.h index 270ea190da..ccef0e9912 100644 --- a/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.h +++ b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.h @@ -48,8 +48,7 @@ class ERS_CLASS_LayoutManager { /** * @brief Save the current layout the user is using. - * It will be saved to the layout dir specified in the constructor - * with the display name the user has set. + * It will return the set YAML string for the layout */ void SaveLayout(std::string LayoutName); From 29350ddb278f2515a9781ea702040c0988fd5d5b Mon Sep 17 00:00:00 2001 From: allenyangcc Date: Wed, 29 Jun 2022 21:34:30 -0700 Subject: [PATCH 6/7] Update Layout struct --- .../ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp | 7 ++++++- Source/Main.cpp | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp index 5b4e7cc65d..b5ab7bcb93 100644 --- a/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp +++ b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp @@ -7,6 +7,11 @@ #include #include +struct Layout { + int index; + std::string name; + std::string IniString; +}; ERS_CLASS_LayoutManager::ERS_CLASS_LayoutManager(ERS_CLASS_LoggingSystem* Logger, const char* LayoutDirectory) { @@ -86,7 +91,7 @@ void ERS_CLASS_LayoutManager::SaveLayout(std::string LayoutName) { std::string YAMLstring = std::string(LayoutYAML.c_str()); // Write the string into a YAML file in the directory - std::ofstream file(std::string(LayoutDirectory_) + LayoutName + ".yaml"); + std::ofstream file(std::string(LayoutDirectory_) + "/" + LayoutName + ".yaml"); if (!file.fail()) file << YAMLstring; diff --git a/Source/Main.cpp b/Source/Main.cpp index c2668ff2aa..b4efeb374d 100644 --- a/Source/Main.cpp +++ b/Source/Main.cpp @@ -156,7 +156,7 @@ int main() { // Log Logo Text - SystemUtils->Logger_->Log("Starting BrainGenix-ERS Instance", 2); + /*SystemUtils->Logger_->Log("Starting BrainGenix-ERS Instance", 2); SystemUtils->Logger_->Log("", 5); SystemUtils->Logger_->Log("---------------------------------------------------------------------------", 5); SystemUtils->Logger_->Log("\x1b[38;2;0;128;55m██████╗ ██████╗ █████╗ ██╗███╗ ██╗\x1b[38;2;130;68;208m ██████╗ ███████╗███╗ ██╗██╗██╗ ██╗", 5); @@ -170,7 +170,7 @@ int main() { SystemUtils->Logger_->Log(" +-----------------------------------------------------------------+", 4); SystemUtils->Logger_->Log(" | BrainGenix-ERS Real-Time Environment Rendering System |", 4); SystemUtils->Logger_->Log(" +-----------------------------------------------------------------+", 4); - SystemUtils->Logger_->Log("", 4); + SystemUtils->Logger_->Log("", 4);*/ // Initialize Times From 4c447a562366e8ef5f8180398f1ff6c03b6b5ade Mon Sep 17 00:00:00 2001 From: allenyangcc Date: Wed, 29 Jun 2022 22:08:54 -0700 Subject: [PATCH 7/7] Update Layout structs and Save/Load functions --- .../ERS_Editor_LayoutManager.cpp | 62 ++++++++++--------- .../ERS_Editor_LayoutManager.h | 7 +++ 2 files changed, 41 insertions(+), 28 deletions(-) diff --git a/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp index b5ab7bcb93..ab502e3b80 100644 --- a/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp +++ b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.cpp @@ -7,12 +7,6 @@ #include #include -struct Layout { - int index; - std::string name; - std::string IniString; -}; - ERS_CLASS_LayoutManager::ERS_CLASS_LayoutManager(ERS_CLASS_LoggingSystem* Logger, const char* LayoutDirectory) { Logger_ = Logger; @@ -30,8 +24,6 @@ ERS_CLASS_LayoutManager::~ERS_CLASS_LayoutManager() { void ERS_CLASS_LayoutManager::LoadLayouts() { - LayoutFiles_ = *new std::vector; - // Create List Of Files for (const auto& Entry : std::filesystem::directory_iterator(std::string(LayoutDirectory_))) { @@ -39,19 +31,30 @@ void ERS_CLASS_LayoutManager::LoadLayouts() { std::string FilePath{ Entry.path().u8string() }; // Load YAML::Node - YAML::Node Layout = YAML::LoadFile(FilePath.c_str()); - LayoutFiles_.push_back(Layout); + YAML::Node LayoutNode = YAML::LoadFile(FilePath.c_str()); + + // Build Temp Layout + ERS_STRUCT_EditorLayout Layout; + Layout.index = Index; - // Parse Out Display Name From File Path + // Parse Out Display Name From File std::string LayoutName; - LayoutName = Layout["DisplayName"].as(); + LayoutName = LayoutNode["DisplayName"].as(); + Layout.name = LayoutName; - // Add To Names Vector + // Parse Out Ini String From File + std::string IniStr; + IniStr = LayoutNode["ImGuiIni"].as(); + Layout.IniString = IniStr; + + // Add To Names and Layouts Vector LayoutNames_.push_back(LayoutName); + Layouts_.push_back(Layout); // Log Layout Indexed Logger_->Log(std::string(std::string("Indexed Layout: ") + FilePath).c_str(), 1); + Index++; } @@ -61,30 +64,33 @@ void ERS_CLASS_LayoutManager::LoadLayouts() { void ERS_CLASS_LayoutManager::SaveLayout(std::string LayoutName) { - std::string IniString; - + // Save the Ini String + std::string IniStr; size_t settings_size = 0; - IniString = static_cast (ImGui::SaveIniSettingsToMemory(&settings_size)); - - // Save YAML file - YAML::Node Layout; - Layout["ImGuiIni"] = IniString; - - // Set the layout name - Layout["DisplayName"] = LayoutName; - - LayoutFiles_.push_back(Layout); + IniStr = static_cast (ImGui::SaveIniSettingsToMemory(&settings_size)); // Add To Names Vector LayoutNames_.push_back(LayoutName); + // Construct the New Layout Struct + ERS_STRUCT_EditorLayout newLayout; + newLayout.index = Index++; + newLayout.name = LayoutName; + newLayout.IniString = IniStr; + Layouts_.push_back(newLayout); + + // Save YAML Node + YAML::Node Layout; + Layout["ImGuiIni"] = IniStr; + Layout["DisplayName"] = LayoutName; + // Export the YAML string YAML::Emitter LayoutYAML; LayoutYAML << YAML::BeginMap; // Set Constant Info LayoutYAML << YAML::Key << "DisplayName" << YAML::Value << LayoutName; - LayoutYAML << YAML::Key << "ImGuiIni" << YAML::Value << IniString; + LayoutYAML << YAML::Key << "ImGuiIni" << YAML::Value << IniStr; // Stop Writing, Generate LayoutYAML LayoutYAML << YAML::EndMap; @@ -124,10 +130,10 @@ void ERS_CLASS_LayoutManager::ApplyLayout(int LayoutID) { // Get Layout Name std::string LayoutName = LayoutNames_[LayoutID]; - YAML::Node LayoutNode = LayoutFiles_[LayoutID]; + ERS_STRUCT_EditorLayout Layout = Layouts_[LayoutID]; Logger_->Log(std::string(std::string("Applying Layout: ") + LayoutName).c_str(), 4); - ImGui::LoadIniSettingsFromMemory(LayoutNode["ImGuiIni"].as()); + ImGui::LoadIniSettingsFromMemory(Layout.IniString.c_str()); } diff --git a/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.h b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.h index ccef0e9912..87075b8313 100644 --- a/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.h +++ b/Source/Core/Editor/Utils/ERS_Editor_LayoutManager/ERS_Editor_LayoutManager.h @@ -14,6 +14,11 @@ // Internal Libraries (BG convention: use <> instead of "") #include +struct ERS_STRUCT_EditorLayout { + int index; + std::string name; + std::string IniString; +}; /** * @brief Creates the user profile manager class. @@ -28,10 +33,12 @@ class ERS_CLASS_LayoutManager { std::string LayoutDirectory_; /** LayoutFiles_; /** LayoutNames_; /** Layouts_; /**