From 35dc18311174d6bec933a3796edb3bda56b5a5d8 Mon Sep 17 00:00:00 2001 From: Joeyrp Date: Thu, 27 Jan 2022 13:41:03 -0500 Subject: [PATCH] Editor moved into it's own namespace within lunarium --- src/core/core.cpp | 2 +- src/internal_libs/utils/grid.h | 6 +-- src/run_modes/editor/editor.cpp | 5 ++ src/run_modes/editor/editor.h | 6 +++ src/run_modes/editor/panels/about.cpp | 3 ++ src/run_modes/editor/panels/about.h | 3 ++ src/run_modes/editor/panels/assetBrowser.cpp | 3 ++ src/run_modes/editor/panels/assetBrowser.h | 3 ++ .../custom_properties/customProperties.h | 43 +++++++++++++++++ src/run_modes/editor/panels/iPanel.cpp | 3 ++ src/run_modes/editor/panels/iPanel.h | 7 ++- src/run_modes/editor/panels/mainPanel.cpp | 3 ++ src/run_modes/editor/panels/mainPanel.h | 3 ++ src/run_modes/editor/panels/properties.cpp | 0 src/run_modes/editor/panels/properties.h | 29 +++++++++++ src/run_modes/editor/panels/sceneTree.h | 22 --------- src/run_modes/editor/panels/worldTree.cpp | 48 +++++++++++++++++++ src/run_modes/editor/panels/worldTree.h | 34 +++++++++++++ .../panels/{sceneTree.cpp => worldView.cpp} | 13 +++-- src/run_modes/editor/panels/worldView.h | 25 ++++++++++ test_data/engine_state.xml | 2 +- 21 files changed, 229 insertions(+), 34 deletions(-) create mode 100644 src/run_modes/editor/panels/custom_properties/customProperties.h create mode 100644 src/run_modes/editor/panels/properties.cpp create mode 100644 src/run_modes/editor/panels/properties.h delete mode 100644 src/run_modes/editor/panels/sceneTree.h create mode 100644 src/run_modes/editor/panels/worldTree.cpp create mode 100644 src/run_modes/editor/panels/worldTree.h rename src/run_modes/editor/panels/{sceneTree.cpp => worldView.cpp} (54%) create mode 100644 src/run_modes/editor/panels/worldView.h diff --git a/src/core/core.cpp b/src/core/core.cpp index 4576210..2c3611d 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -236,7 +236,7 @@ namespace lunarium Logger::Log(LogCategory::CORE, LogLevel::FATAL_ERROR, "The Editor is not available with this build"); return; #else - mpRunMode = new Editor; + mpRunMode = new editor::Editor; LogGui::GetInstance().SetStickToWindow(false); LuaConsole::GetInstance().SetStickToWindow(false); #endif diff --git a/src/internal_libs/utils/grid.h b/src/internal_libs/utils/grid.h index 8326713..49d04f4 100644 --- a/src/internal_libs/utils/grid.h +++ b/src/internal_libs/utils/grid.h @@ -5,8 +5,8 @@ * Mod Date - 2022/01/25 (y/m/d) * Description - A 2D fixed-size array of data. Size must be set when * this container is created and can not be changed later. -* The 0, 0 position is the center of the grid (meaning negative -* indices are valid). +* The 0, 0 position is the center of the grid (so the indices +* of a 10x10 grid go from 4, 4 to -4, -4). ******************************************************************************/ #ifndef GRID_H_ @@ -51,7 +51,7 @@ namespace lunarium { mHalfSize.Width = size.Width / 2; mHalfSize.Height = size.Height / 2; - + mGrid = new Node*[size.Width]; for (int i = 0; i < size.Width; i++) { diff --git a/src/run_modes/editor/editor.cpp b/src/run_modes/editor/editor.cpp index 0216287..f35d2af 100644 --- a/src/run_modes/editor/editor.cpp +++ b/src/run_modes/editor/editor.cpp @@ -20,6 +20,9 @@ namespace lunarium { +namespace editor +{ + Editor::Editor() : mLogCat(-1), mpMainPanel(nullptr), mpFileBrowser(nullptr), mpPath(nullptr), mDoNewProject(false), mDoOpenProject(false), mDoSaveProject(false), mDoSaveAs(false) @@ -246,4 +249,6 @@ namespace lunarium { mPanels[PanelType::PT_ABOUT]->SetOpen(true); } + +} } \ No newline at end of file diff --git a/src/run_modes/editor/editor.h b/src/run_modes/editor/editor.h index f330722..4230be4 100644 --- a/src/run_modes/editor/editor.h +++ b/src/run_modes/editor/editor.h @@ -21,6 +21,10 @@ namespace lunarium { class FileBrowser; + namespace editor + { + + class MainPanel; class Editor : public iRunMode { @@ -70,6 +74,8 @@ namespace lunarium void DestoryPanels(); void HandleMenuEvents(); }; + + } } #endif // EDITOR_H_ \ No newline at end of file diff --git a/src/run_modes/editor/panels/about.cpp b/src/run_modes/editor/panels/about.cpp index 8d4ee11..abf07ab 100644 --- a/src/run_modes/editor/panels/about.cpp +++ b/src/run_modes/editor/panels/about.cpp @@ -11,6 +11,8 @@ #include namespace lunarium +{ +namespace editor { AboutPanel::AboutPanel() : Panel(PanelType::PT_ABOUT) @@ -35,4 +37,5 @@ namespace lunarium ImGui::End(); return true; } +} } \ No newline at end of file diff --git a/src/run_modes/editor/panels/about.h b/src/run_modes/editor/panels/about.h index f04edeb..c28dbf4 100644 --- a/src/run_modes/editor/panels/about.h +++ b/src/run_modes/editor/panels/about.h @@ -12,6 +12,8 @@ #include "iPanel.h" namespace lunarium +{ +namespace editor { class Editor; class AboutPanel : public Panel @@ -23,5 +25,6 @@ namespace lunarium bool DoFrame(); }; } +} #endif // PANEL_ABOUT_H_ \ No newline at end of file diff --git a/src/run_modes/editor/panels/assetBrowser.cpp b/src/run_modes/editor/panels/assetBrowser.cpp index 8d1b4e4..bd40428 100644 --- a/src/run_modes/editor/panels/assetBrowser.cpp +++ b/src/run_modes/editor/panels/assetBrowser.cpp @@ -10,6 +10,8 @@ #include namespace lunarium +{ +namespace editor { AssetBrowser::AssetBrowser(std::filesystem::path dir) : Panel(PanelType::PT_ASSET_BROWSER, true), mAssetDirectory(dir), mTreeRoot(nullptr), mSelectedNode(nullptr) @@ -120,6 +122,7 @@ namespace lunarium return pNode; } } +} // void treeChildren(ImGuiTreeNodeFlags node_flags, bool isOpen, int index) // { diff --git a/src/run_modes/editor/panels/assetBrowser.h b/src/run_modes/editor/panels/assetBrowser.h index 7f51f72..85da9cc 100644 --- a/src/run_modes/editor/panels/assetBrowser.h +++ b/src/run_modes/editor/panels/assetBrowser.h @@ -15,6 +15,8 @@ #include namespace lunarium +{ +namespace editor { class AssetBrowser : public Panel { @@ -46,5 +48,6 @@ namespace lunarium void DoDirTree(std::filesystem::path dir); }; } +} #endif // ASSET_BROWSER_H_ \ No newline at end of file diff --git a/src/run_modes/editor/panels/custom_properties/customProperties.h b/src/run_modes/editor/panels/custom_properties/customProperties.h new file mode 100644 index 0000000..9b045b6 --- /dev/null +++ b/src/run_modes/editor/panels/custom_properties/customProperties.h @@ -0,0 +1,43 @@ +/****************************************************************************** +* File - customProperties.h +* Author - Joey Pollack +* Date - 2022/01/27 (y/m/d) +* Mod Date - 2022/01/27 (y/m/d) +* Description - Handles a custom property +******************************************************************************/ + +#ifndef CUSTOM_PROPERTIES_H_ +#define CUSTOM_PROPERTIES_H_ + +namespace lunarium +{ +namespace editor +{ + + class CustomProperty + { + public: + // Custom property types + enum CType + { + CPT_INT, + CPT_FLOAT, + CPT_COLOR + }; + + public: + CustomProperty(CType type); + + CType GetType() const; + + virtual void Draw() = 0; + + + private: + CType mType; + + }; +} +} + +#endif // CUSTOM_PROPERTIES_H_ \ No newline at end of file diff --git a/src/run_modes/editor/panels/iPanel.cpp b/src/run_modes/editor/panels/iPanel.cpp index db205d1..cb2fdb5 100644 --- a/src/run_modes/editor/panels/iPanel.cpp +++ b/src/run_modes/editor/panels/iPanel.cpp @@ -11,6 +11,8 @@ #include namespace lunarium +{ +namespace editor { Panel::Panel(PanelType type, bool isOpen) : mType(type), mIsOpen(isOpen) @@ -62,4 +64,5 @@ namespace lunarium mWidth = s.x; mHeight = s.y; } +} } \ No newline at end of file diff --git a/src/run_modes/editor/panels/iPanel.h b/src/run_modes/editor/panels/iPanel.h index 634b653..81bdeb6 100644 --- a/src/run_modes/editor/panels/iPanel.h +++ b/src/run_modes/editor/panels/iPanel.h @@ -10,13 +10,15 @@ #define PANEL_H_ namespace lunarium +{ +namespace editor { enum PanelType { PT_MAIN, PT_ABOUT, - PT_SCENE_TREE, - PT_SCENE_VIEW, + PT_WORLD_TREE, + PT_WORLD_VIEW, PT_ASSET_BROWSER, PT_CONSOLE, PT_UNKNOWN, @@ -48,5 +50,6 @@ namespace lunarium void UpdateMetaInfo(); }; } +} #endif // PANEL_H_ \ No newline at end of file diff --git a/src/run_modes/editor/panels/mainPanel.cpp b/src/run_modes/editor/panels/mainPanel.cpp index d75d155..f17c121 100644 --- a/src/run_modes/editor/panels/mainPanel.cpp +++ b/src/run_modes/editor/panels/mainPanel.cpp @@ -14,6 +14,8 @@ #include namespace lunarium +{ +namespace editor { MainPanel* MainPanel::mpInstance = nullptr; MainPanel::MainPanel() @@ -152,4 +154,5 @@ namespace lunarium ImGui::EndMainMenuBar(); } +} } \ No newline at end of file diff --git a/src/run_modes/editor/panels/mainPanel.h b/src/run_modes/editor/panels/mainPanel.h index 14d4861..4eb0504 100644 --- a/src/run_modes/editor/panels/mainPanel.h +++ b/src/run_modes/editor/panels/mainPanel.h @@ -12,6 +12,8 @@ #include "iPanel.h" namespace lunarium +{ +namespace editor { class Editor; class MainPanel : public Panel @@ -38,5 +40,6 @@ namespace lunarium void DoMainMenu(); }; } +} #endif // PANEL_MAIN_H_ \ No newline at end of file diff --git a/src/run_modes/editor/panels/properties.cpp b/src/run_modes/editor/panels/properties.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/run_modes/editor/panels/properties.h b/src/run_modes/editor/panels/properties.h new file mode 100644 index 0000000..9065ea7 --- /dev/null +++ b/src/run_modes/editor/panels/properties.h @@ -0,0 +1,29 @@ +/****************************************************************************** +* File - properties.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. +******************************************************************************/ + +#ifndef PROPERTIES_H_ +#define PROPERTIES_H_ + +#include "iPanel.h" +#include + +namespace lunarium +{ +namespace editor +{ + class Properties : public Panel + { + public: + + + }; +} +} + +#endif // PROPERTIES_H_ \ No newline at end of file diff --git a/src/run_modes/editor/panels/sceneTree.h b/src/run_modes/editor/panels/sceneTree.h deleted file mode 100644 index ee16416..0000000 --- a/src/run_modes/editor/panels/sceneTree.h +++ /dev/null @@ -1,22 +0,0 @@ -/****************************************************************************** -* File - sceneTree.h -* Author - Joey Pollack -* Date - 2021/11/04 (y/m/d) -* Mod Date - 2021/11/04 (y/m/d) -* Description - The tree view listing all objects in the scene -******************************************************************************/ - -#ifndef SCENE_TREE_H_ -#define SCENE_TREE_H_ - -#include "iPanel.h" - -namespace lunarium -{ - class SceneTree : public Panel - { - - }; -} - -#endif // SCENE_TREE_H_ \ No newline at end of file diff --git a/src/run_modes/editor/panels/worldTree.cpp b/src/run_modes/editor/panels/worldTree.cpp new file mode 100644 index 0000000..4c224b6 --- /dev/null +++ b/src/run_modes/editor/panels/worldTree.cpp @@ -0,0 +1,48 @@ +/****************************************************************************** +* File - worldTree.cpp +* Author - Joey Pollack +* Date - 2021/11/04 (y/m/d) +* Mod Date - 2021/11/04 (y/m/d) +* Description - The tree view listing all objects in the world +******************************************************************************/ + +#include "worldTree.h" +#include +#include + +namespace lunarium +{ +namespace editor +{ + WorldTree::WorldTree() + : Panel(PT_WORLD_TREE, true), mpWorld(nullptr) + { + + } + + void WorldTree::SetWorld(World* pWorld) + { + mpWorld = pWorld; + } + + World* WorldTree::GetWorld() + { + return mpWorld; + } + + bool WorldTree::DoFrame() + { + if (!mIsOpen) + return false; + + if (!ImGui::Begin("World Tree", &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/worldTree.h b/src/run_modes/editor/panels/worldTree.h new file mode 100644 index 0000000..c5082f5 --- /dev/null +++ b/src/run_modes/editor/panels/worldTree.h @@ -0,0 +1,34 @@ +/****************************************************************************** +* File - worldTree.h +* Author - Joey Pollack +* Date - 2021/11/04 (y/m/d) +* Mod Date - 2021/11/04 (y/m/d) +* Description - The tree view listing all objects in the world +******************************************************************************/ + +#ifndef WORLD_TREE_H_ +#define WORLD_TREE_H_ + +#include "iPanel.h" + +namespace lunarium +{ +namespace editor +{ + class World; + class WorldTree : public Panel + { + public: + WorldTree(); + + void SetWorld(World* pWorld); + World* GetWorld(); + + bool DoFrame(); + + private: + World* mpWorld; + }; +} +} +#endif // WORLD_TREE_H_ \ No newline at end of file diff --git a/src/run_modes/editor/panels/sceneTree.cpp b/src/run_modes/editor/panels/worldView.cpp similarity index 54% rename from src/run_modes/editor/panels/sceneTree.cpp rename to src/run_modes/editor/panels/worldView.cpp index 38395f0..6c130c0 100644 --- a/src/run_modes/editor/panels/sceneTree.cpp +++ b/src/run_modes/editor/panels/worldView.cpp @@ -1,14 +1,17 @@ /****************************************************************************** -* File - sceneTree.cpp +* File - worldView.cpp * Author - Joey Pollack -* Date - 2021/11/04 (y/m/d) -* Mod Date - 2021/11/04 (y/m/d) -* Description - The tree view listing all objects in the scene +* Date - 2022/01/26 (y/m/d) +* Mod Date - 2022/01/26 (y/m/d) +* Description - A rendered view of the world ******************************************************************************/ -#include "sceneTree.h" +#include "worldView.h" namespace lunarium { +namespace editor +{ +} } \ No newline at end of file diff --git a/src/run_modes/editor/panels/worldView.h b/src/run_modes/editor/panels/worldView.h new file mode 100644 index 0000000..68b28c7 --- /dev/null +++ b/src/run_modes/editor/panels/worldView.h @@ -0,0 +1,25 @@ +/****************************************************************************** +* File - worldView.h +* Author - Joey Pollack +* Date - 2022/01/26 (y/m/d) +* Mod Date - 2022/01/26 (y/m/d) +* Description - A rendered view of the world +******************************************************************************/ + +#ifndef WORLD_VIEW_H_ +#define WORLD_VIEW_H_ + +#include "iPanel.h" + +namespace lunarium +{ +namespace editor +{ + class WorldView : public Panel + { + + }; +} +} + +#endif // WORLD_VIEW_H_ \ No newline at end of file diff --git a/test_data/engine_state.xml b/test_data/engine_state.xml index 5cf7851..277eb02 100644 --- a/test_data/engine_state.xml +++ b/test_data/engine_state.xml @@ -1,6 +1,6 @@ data/ - +