From 3f7ae8aaa1254ca21c08dde6557e7080ff217b58 Mon Sep 17 00:00:00 2001 From: Joeyrp Date: Thu, 27 Jan 2022 15:13:20 -0500 Subject: [PATCH] Main editor panel classes created, docked in default positions --- .gitignore | 1 - docs/editor.todo | 8 +- scripts/clean.bat | 2 + src/run_modes/editor/CMakeLists.txt | 4 +- src/run_modes/editor/editor.cpp | 6 + src/run_modes/editor/panels/iPanel.h | 1 + src/run_modes/editor/panels/mainPanel.cpp | 2 +- src/run_modes/editor/panels/properties.cpp | 0 .../property.h} | 25 ++-- .../editor/panels/propertiesView.cpp | 37 +++++ .../panels/{properties.h => propertiesView.h} | 10 +- src/run_modes/editor/panels/worldTree.cpp | 7 + src/run_modes/editor/panels/worldTree.h | 2 +- src/run_modes/editor/panels/worldView.cpp | 23 ++- src/run_modes/editor/panels/worldView.h | 18 ++- test_data/imgui.ini | 138 ++++++++++++++++++ 16 files changed, 255 insertions(+), 29 deletions(-) delete mode 100644 src/run_modes/editor/panels/properties.cpp rename src/run_modes/editor/panels/{custom_properties/customProperties.h => properties/property.h} (62%) create mode 100644 src/run_modes/editor/panels/propertiesView.cpp rename src/run_modes/editor/panels/{properties.h => propertiesView.h} (68%) create mode 100644 test_data/imgui.ini diff --git a/.gitignore b/.gitignore index f3568cb..878e1fd 100644 --- a/.gitignore +++ b/.gitignore @@ -39,7 +39,6 @@ # other *.log *.zip -*.ini test_data/test_save.xml ######################## CMAKE IGNORES diff --git a/docs/editor.todo b/docs/editor.todo index 084a188..54abde9 100644 --- a/docs/editor.todo +++ b/docs/editor.todo @@ -22,12 +22,14 @@ Editor: GUI Panels: Project Overview (Tree view): - Game Viewport: - Scene View: Scene Hierarchy (Tree View): + Asset Viewer: + ☐ Put files into a table with columns for the file Properties + + Tools: Tile Map Editor: ☐ Tile map canvas ☐ Tile map pallete @@ -35,7 +37,5 @@ Editor: ☐ Stamp creater ☐ Flood Fill - Asset Viewer: - ☐ Put files into a table with columns for the file Properties Properties: \ No newline at end of file diff --git a/scripts/clean.bat b/scripts/clean.bat index 9a786e4..a4f75c0 100644 --- a/scripts/clean.bat +++ b/scripts/clean.bat @@ -6,6 +6,8 @@ IF not exist build/ ( goto END ) +xcopy /y build\Debug\imgui.ini test_data\imgui.ini + echo Removing the build directory del /s /q build rd /s /q build diff --git a/src/run_modes/editor/CMakeLists.txt b/src/run_modes/editor/CMakeLists.txt index 018d9a3..8eab76d 100644 --- a/src/run_modes/editor/CMakeLists.txt +++ b/src/run_modes/editor/CMakeLists.txt @@ -1,9 +1,11 @@ -add_library(editor editor.cpp project/project.cpp panels/iPanel.cpp panels/mainPanel.cpp panels/about.cpp panels/assetBrowser.cpp) +add_library(editor editor.cpp project/project.cpp panels/iPanel.cpp panels/mainPanel.cpp panels/about.cpp + panels/assetBrowser.cpp panels/worldTree.cpp panels/worldView.cpp panels/propertiesView.cpp) target_include_directories(editor PUBLIC "${PROJECT_BINARY_DIR}" PUBLIC ../../ PUBLIC ../../internal_libs + PUBLIC ../../run_modes PUBLIC ../../../external/glm PUBLIC ../../../external/glad/include PUBLIC ../../../external/glfw/include diff --git a/src/run_modes/editor/editor.cpp b/src/run_modes/editor/editor.cpp index f35d2af..638262b 100644 --- a/src/run_modes/editor/editor.cpp +++ b/src/run_modes/editor/editor.cpp @@ -17,6 +17,9 @@ // Panels #include "panels/about.h" #include "panels/assetBrowser.h" +#include "panels/worldTree.h" +#include "panels/worldView.h" +#include "panels/propertiesView.h" namespace lunarium { @@ -98,6 +101,9 @@ namespace editor { mPanels[PanelType::PT_ABOUT] = new AboutPanel; mPanels[PanelType::PT_ASSET_BROWSER] = new AssetBrowser(""); + mPanels[PanelType::PT_WORLD_TREE] = new WorldTree(); + mPanels[PanelType::PT_WORLD_VIEW] = new WorldView(); + mPanels[PanelType::PT_PROPERTIES_VIEW] = new PropertiesView(); } void Editor::DestoryPanels() diff --git a/src/run_modes/editor/panels/iPanel.h b/src/run_modes/editor/panels/iPanel.h index 81bdeb6..49cc872 100644 --- a/src/run_modes/editor/panels/iPanel.h +++ b/src/run_modes/editor/panels/iPanel.h @@ -20,6 +20,7 @@ namespace editor PT_WORLD_TREE, PT_WORLD_VIEW, PT_ASSET_BROWSER, + PT_PROPERTIES_VIEW, PT_CONSOLE, PT_UNKNOWN, }; diff --git a/src/run_modes/editor/panels/mainPanel.cpp b/src/run_modes/editor/panels/mainPanel.cpp index f17c121..2b04a94 100644 --- a/src/run_modes/editor/panels/mainPanel.cpp +++ b/src/run_modes/editor/panels/mainPanel.cpp @@ -70,7 +70,7 @@ namespace editor return false; } - // ImGui::DockSpace(ImGui::GetID("LEDockSpace")); + ImGui::DockSpaceOverViewport(); ImGui::PopStyleVar(); ImGui::End(); diff --git a/src/run_modes/editor/panels/properties.cpp b/src/run_modes/editor/panels/properties.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/run_modes/editor/panels/custom_properties/customProperties.h b/src/run_modes/editor/panels/properties/property.h similarity index 62% rename from src/run_modes/editor/panels/custom_properties/customProperties.h rename to src/run_modes/editor/panels/properties/property.h index 9b045b6..97b9ddc 100644 --- a/src/run_modes/editor/panels/custom_properties/customProperties.h +++ b/src/run_modes/editor/panels/properties/property.h @@ -1,5 +1,5 @@ /****************************************************************************** -* File - customProperties.h +* File - property.h * Author - Joey Pollack * Date - 2022/01/27 (y/m/d) * Mod Date - 2022/01/27 (y/m/d) @@ -9,35 +9,32 @@ #ifndef CUSTOM_PROPERTIES_H_ #define CUSTOM_PROPERTIES_H_ -namespace lunarium -{ -namespace editor +namespace lunarium { namespace editor { - class CustomProperty + class Property { public: // Custom property types - enum CType + enum Type { - CPT_INT, - CPT_FLOAT, - CPT_COLOR + PT_INT, + PT_FLOAT, + PT_COLOR }; public: - CustomProperty(CType type); + Property(Type type); - CType GetType() const; + Type GetType() const; virtual void Draw() = 0; private: - CType mType; + Type mType; }; -} -} +}} // lunarium::editor #endif // CUSTOM_PROPERTIES_H_ \ No newline at end of file diff --git a/src/run_modes/editor/panels/propertiesView.cpp b/src/run_modes/editor/panels/propertiesView.cpp new file mode 100644 index 0000000..d8f3a15 --- /dev/null +++ b/src/run_modes/editor/panels/propertiesView.cpp @@ -0,0 +1,37 @@ +/****************************************************************************** +* File - propertiesView.h +* Author - Joey Pollack +* Date - 2022/01/26 (y/m/d) +* Mod Date - 2022/01/26 (y/m/d) +* Description - Displayes the properties and components(?) of the selected +* object. +******************************************************************************/ + +#include "propertiesView.h" +#include + +namespace lunarium { namespace editor +{ + PropertiesView::PropertiesView() + : Panel(PT_PROPERTIES_VIEW, true) + { + + } + + bool PropertiesView::DoFrame() + { + if (!mIsOpen) + return false; + + if (!ImGui::Begin("Properties", &mIsOpen, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar)) + { + ImGui::End(); + return false; + } + + ImGui::End(); + return true; + } + + +}} \ No newline at end of file diff --git a/src/run_modes/editor/panels/properties.h b/src/run_modes/editor/panels/propertiesView.h similarity index 68% rename from src/run_modes/editor/panels/properties.h rename to src/run_modes/editor/panels/propertiesView.h index 9065ea7..7377643 100644 --- a/src/run_modes/editor/panels/properties.h +++ b/src/run_modes/editor/panels/propertiesView.h @@ -1,5 +1,5 @@ /****************************************************************************** -* File - properties.h +* File - propertiesView.h * Author - Joey Pollack * Date - 2022/01/26 (y/m/d) * Mod Date - 2022/01/26 (y/m/d) @@ -17,11 +17,17 @@ namespace lunarium { namespace editor { - class Properties : public Panel + class CustromProperty; + class PropertiesView : public Panel { public: + PropertiesView(); + bool DoFrame(); + + private: + std::vector mCustomProps; }; } } diff --git a/src/run_modes/editor/panels/worldTree.cpp b/src/run_modes/editor/panels/worldTree.cpp index 4c224b6..0d442a1 100644 --- a/src/run_modes/editor/panels/worldTree.cpp +++ b/src/run_modes/editor/panels/worldTree.cpp @@ -41,6 +41,13 @@ namespace editor return false; } + if (ImGui::TreeNode("World Root")) + { + // TODO: Build tree of world contents + + ImGui::TreePop(); + } + ImGui::End(); return true; } diff --git a/src/run_modes/editor/panels/worldTree.h b/src/run_modes/editor/panels/worldTree.h index c5082f5..a99f500 100644 --- a/src/run_modes/editor/panels/worldTree.h +++ b/src/run_modes/editor/panels/worldTree.h @@ -13,9 +13,9 @@ namespace lunarium { + class World; namespace editor { - class World; class WorldTree : public Panel { public: diff --git a/src/run_modes/editor/panels/worldView.cpp b/src/run_modes/editor/panels/worldView.cpp index 6c130c0..d7fd801 100644 --- a/src/run_modes/editor/panels/worldView.cpp +++ b/src/run_modes/editor/panels/worldView.cpp @@ -7,11 +7,32 @@ ******************************************************************************/ #include "worldView.h" +#include +#include namespace lunarium { namespace editor { - + WorldView::WorldView() + : Panel(PT_WORLD_VIEW, true), mpWorld(nullptr) + { + + } + + bool WorldView::DoFrame() + { + if (!mIsOpen) + return false; + + if (!ImGui::Begin("World View", &mIsOpen, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar)) + { + ImGui::End(); + return false; + } + + ImGui::End(); + return true; + } } } \ No newline at end of file diff --git a/src/run_modes/editor/panels/worldView.h b/src/run_modes/editor/panels/worldView.h index 68b28c7..acfc561 100644 --- a/src/run_modes/editor/panels/worldView.h +++ b/src/run_modes/editor/panels/worldView.h @@ -11,15 +11,25 @@ #include "iPanel.h" -namespace lunarium -{ +namespace lunarium +{ + + class World; namespace editor { class WorldView : public Panel { + public: + WorldView(); + bool DoFrame(); + + void SetWorld(World* pWorld); + World* GetWorld(); + private: + World* mpWorld; }; -} -} + +}} // lunarium::editor #endif // WORLD_VIEW_H_ \ No newline at end of file diff --git a/test_data/imgui.ini b/test_data/imgui.ini new file mode 100644 index 0000000..6c4bef4 --- /dev/null +++ b/test_data/imgui.ini @@ -0,0 +1,138 @@ +[Window][Debug##Default] +ViewportPos=278,8 +ViewportId=0x9F5F46A1 +Size=400,400 +Collapsed=0 + +[Window][Dear ImGui Demo] +ViewportPos=292,184 +ViewportId=0xE927CF2F +Size=1280,666 +Collapsed=0 + +[Window][Dear ImGui Metrics/Debugger] +ViewportPos=438,264 +ViewportId=0x4AD707D2 +Size=812,295 +Collapsed=0 + +[Window][Lunarium Editor] +Pos=0,24 +Size=1280,672 +Collapsed=0 + +[Window][LUA Console] +ViewportPos=516,220 +ViewportId=0xBCA52B8E +Size=834,396 +Collapsed=0 + +[Window][Debug Log] +Pos=0,470 +Size=1280,226 +Collapsed=0 +DockId=0x00000005,1 + +[Window][About] +ViewportPos=1450,160 +ViewportId=0x74350DE7 +Size=300,480 +Collapsed=0 + +[Window][status bar] +Pos=0,688 +Size=1280,32 +Collapsed=0 + +[Window][Example: Documents] +ViewportPos=687,626 +ViewportId=0x1FD64BEB +Size=641,176 +Collapsed=0 + +[Window][About Dear ImGui] +Pos=60,60 +Size=568,134 +Collapsed=0 + +[Window][File Browser] +Pos=620,216 +Size=600,400 +Collapsed=0 + +[Window][DockSpaceViewport_11111111] +Pos=0,24 +Size=1280,696 +Collapsed=0 + +[Window][DockSpace Demo] +Pos=0,24 +Size=1280,696 +Collapsed=0 + +[Window][DockSpaceViewport_BEB76114] +ViewportPos=100,124 +ViewportId=0xBEB76114 +Size=1280,672 +Collapsed=0 + +[Window][Asset Browser] +Pos=204,493 +Size=878,203 +Collapsed=0 +DockId=0x00000004,0 + +[Window][World Tree] +Pos=0,22 +Size=202,674 +Collapsed=0 +DockId=0x00000005,0 + +[Window][World View] +Pos=204,22 +Size=878,469 +Collapsed=0 +DockId=0x00000003,0 + +[Window][Properties] +Pos=1084,22 +Size=196,674 +Collapsed=0 +DockId=0x00000007,0 + +[Table][0xC9935533,3] +Column 0 Weight=1.0000 +Column 1 Weight=1.0000 +Column 2 Weight=1.0000 + +[Table][0x64418101,3] +RefScale=18 +Column 0 Width=60 +Column 1 Width=60 +Column 2 Width=60 + +[Table][0x47600645,3] +RefScale=18 +Column 0 Width=63 +Column 1 Width=149 +Column 2 Weight=1.0000 + +[Table][0xDE6957FF,6] +RefScale=18 +Column 0 Width=61 +Column 1 Width=193 +Column 2 Width=-1 +Column 3 Weight=1.0000 +Column 4 Weight=1.0000 +Column 5 Weight=-1.0000 + +[Docking][Data] +DockNode ID=0x00000002 Pos=314,118 Size=1280,674 Split=X + DockNode ID=0x00000001 Parent=0x00000002 SizeRef=1082,674 Split=X + DockNode ID=0x00000005 Parent=0x00000001 SizeRef=202,674 Selected=0xFD1747F8 + DockNode ID=0x00000006 Parent=0x00000001 SizeRef=878,674 Split=Y + DockNode ID=0x00000003 Parent=0x00000006 SizeRef=1280,469 Selected=0xB4D4B2AA + DockNode ID=0x00000004 Parent=0x00000006 SizeRef=1280,203 Selected=0xB04EBF39 + DockNode ID=0x00000007 Parent=0x00000002 SizeRef=196,674 Selected=0xC89E3217 +DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=314,120 Size=1280,696 CentralNode=1 +