From 8e07cec621f2d12356e0f425019341793e1e3aae Mon Sep 17 00:00:00 2001 From: Joey Pollack Date: Thu, 7 Apr 2022 14:43:15 -0400 Subject: [PATCH] Panel and PanelManager refactored. Panel IDs are now handed out when added to the PanelManager. The IDs are no longer tied to the gui subsystem through enum values. --- CMakeLists.txt | 2 +- src/core/core.cpp | 33 ++++--- src/core/core.h | 10 +- src/core/core_console.cpp | 2 +- src/internal_libs/gui/console.cpp | 4 +- src/internal_libs/gui/console.h | 2 +- src/internal_libs/gui/panel.cpp | 9 +- src/internal_libs/gui/panel.h | 5 +- src/internal_libs/gui/panel_defs.h | 24 ----- src/run_modes/editor/editor.cpp | 26 +++--- src/run_modes/editor/editor.h | 12 ++- src/run_modes/editor/panel_manager.cpp | 92 +++++-------------- src/run_modes/editor/panel_manager.h | 16 ++-- src/run_modes/editor/panels/about.cpp | 2 +- src/run_modes/editor/panels/assetBrowser.cpp | 2 +- .../editor/panels/propertiesView.cpp | 2 +- src/run_modes/editor/panels/worldTree.cpp | 4 +- src/run_modes/editor/panels/worldView.cpp | 4 +- .../editor/tools/map_editor/map_editor.cpp | 14 +-- .../editor/tools/map_editor/map_editor.h | 5 + .../tools/map_editor/panels/map_canvas.cpp | 2 +- .../tools/map_editor/panels/tile_set_view.cpp | 2 +- src/run_modes/{game => player}/CMakeLists.txt | 0 .../{game => player}/object/object.h | 0 .../{game => player}/world/world.cpp | 0 src/run_modes/{game => player}/world/world.h | 0 26 files changed, 115 insertions(+), 159 deletions(-) rename src/run_modes/{game => player}/CMakeLists.txt (100%) rename src/run_modes/{game => player}/object/object.h (100%) rename src/run_modes/{game => player}/world/world.cpp (100%) rename src/run_modes/{game => player}/world/world.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0202af2..4679d8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,7 +126,7 @@ add_subdirectory(src/run_modes/tester) add_subdirectory(src/run_modes/editor) # add run mode editor -add_subdirectory(src/run_modes/game) +add_subdirectory(src/run_modes/player) target_include_directories(${PROJECT_NAME} PUBLIC "${PROJECT_BINARY_DIR}" diff --git a/src/core/core.cpp b/src/core/core.cpp index 151cdba..59901a8 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -136,13 +136,7 @@ namespace lunarium // Init the Debug log window OpRes result; - mPanels[gui::PanelType::PT_CORE_CONSOLE] = new CoreConsole; - // result = LogGui::GetInstance().Initialize(); - // if (Failed(result)) - // { - // Logger::Log(LogCategory::CORE, LogLevel::WARNING, - // "Could not initialized the debug log window: %s", result.Description); - // } + mPanelIDs.CoreConsole = AddPanel(new CoreConsole); Logger::Log(LogCategory::CORE, LogLevel::INFO, "Running Lunarium version %s", Version::GetVersion().ToString().c_str()); @@ -248,12 +242,7 @@ namespace lunarium return; #else mpRunMode = new editor::Editor; - - delete mPanels[gui::PanelType::PT_CORE_CONSOLE]; - mPanels[gui::PanelType::PT_CORE_CONSOLE] = nullptr; - // Editor has it's own console - // LogGui::GetInstance().SetStickToWindow(false); - // LuaConsole::GetInstance().SetStickToWindow(false); + FreePanel(mPanelIDs.CoreConsole); // Editor uses it's own console #endif } @@ -300,7 +289,7 @@ namespace lunarium glfwSetWindowTitle(mpWindow->GetWindow(), title.c_str()); // Get pointers to gui panels - CoreConsole* con = (CoreConsole*)mPanels[gui::PanelType::PT_CORE_CONSOLE]; + CoreConsole* con = (CoreConsole*)mPanels[mPanelIDs.CoreConsole]; // Poll input Window::PollEvents(); @@ -424,4 +413,20 @@ namespace lunarium return *mpInstance->mpInput; } + //////////////////////////////////////////////////////////// + // HELPERS + //////////////////////////////////////////////////////////// + + uint32_t Core::AddPanel(gui::Panel* p) + { + mPanels.push_back(p); + return mPanels.size() - 1; + } + + + void Core::FreePanel(uint32_t id) + { + delete mPanels[id]; + mPanels[id] = nullptr; + } } \ No newline at end of file diff --git a/src/core/core.h b/src/core/core.h index b128624..c0e0637 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -59,7 +59,11 @@ namespace lunarium bool mbShowGuiDemo; // Panels - std::map mPanels; + struct + { + uint32_t CoreConsole; + } mPanelIDs; + std::vector mPanels; // Log Files std::ofstream mMasterLogFile; @@ -78,6 +82,10 @@ namespace lunarium static IGraphics& Graphics(); static InputManager& Input(); + private: // HELPERS + uint32_t AddPanel(gui::Panel* p); + void FreePanel(uint32_t id); + private: // HIDDEN METHODS Core(); diff --git a/src/core/core_console.cpp b/src/core/core_console.cpp index ebdc8b9..aae9862 100644 --- a/src/core/core_console.cpp +++ b/src/core/core_console.cpp @@ -15,7 +15,7 @@ namespace lunarium { CoreConsole::CoreConsole() - : Console(gui::PanelType::PT_CORE_CONSOLE, "Core Console"), mDockIsInit(false) + : Console("Core Console"), mDockIsInit(false) { } diff --git a/src/internal_libs/gui/console.cpp b/src/internal_libs/gui/console.cpp index e6f3247..bd76cb4 100644 --- a/src/internal_libs/gui/console.cpp +++ b/src/internal_libs/gui/console.cpp @@ -45,8 +45,8 @@ namespace lunarium //////////////////////////////////////////////////////////// // CONSOLE //////////////////////////////////////////////////////////// - Console::Console(PanelType type, const char* name) - : Panel(type, name, gui::PanelDockZone::DDZ_NONE, false), + Console::Console(const char* name) + : Panel(name, gui::PanelDockZone::DDZ_NONE, false), mbNewCommand(false), mRecalledCommand(-1), mIsFocused(false), mListener(nullptr), mbOglDebug(false), mbInfoVerbose(false), mpListener(nullptr) { diff --git a/src/internal_libs/gui/console.h b/src/internal_libs/gui/console.h index 0b50063..f6be5b1 100644 --- a/src/internal_libs/gui/console.h +++ b/src/internal_libs/gui/console.h @@ -34,7 +34,7 @@ namespace lunarium class Console : public Panel { public: - Console(PanelType type, const char* name); + Console(const char* name); virtual ~Console(); virtual void Update(float dt); virtual bool DoFrame(); diff --git a/src/internal_libs/gui/panel.cpp b/src/internal_libs/gui/panel.cpp index 1a061b2..01f32ce 100644 --- a/src/internal_libs/gui/panel.cpp +++ b/src/internal_libs/gui/panel.cpp @@ -14,8 +14,8 @@ namespace lunarium { namespace gui { - Panel::Panel(PanelType type, std::string name, PanelDockZone dock_zone, bool isOpen) - : mType(type), mIsOpen(isOpen), mPanelName(name), mDockZone(dock_zone) + Panel::Panel(std::string name, PanelDockZone dock_zone, bool isOpen) + : mIsOpen(isOpen), mPanelName(name), mDockZone(dock_zone) { } @@ -25,11 +25,6 @@ namespace gui } - PanelType Panel::GetType() const - { - return mType; - } - const char* Panel::GetName() const { return mPanelName.c_str(); diff --git a/src/internal_libs/gui/panel.h b/src/internal_libs/gui/panel.h index b8df3a6..799db79 100644 --- a/src/internal_libs/gui/panel.h +++ b/src/internal_libs/gui/panel.h @@ -22,9 +22,8 @@ namespace gui class Panel { public: - Panel(PanelType type, std::string name, PanelDockZone dock_zone, bool isOpen = false); + Panel(std::string name, PanelDockZone dock_zone, bool isOpen = false); virtual ~Panel(); - PanelType GetType() const; const char* GetName() const; virtual void Update(float dt); @@ -36,11 +35,9 @@ namespace gui PanelDockZone GetDockZone() const; protected: - PanelType mType; std::string mPanelName; bool mIsOpen; PanelDockZone mDockZone; - // Editor* mpEditor; int mX; int mY; diff --git a/src/internal_libs/gui/panel_defs.h b/src/internal_libs/gui/panel_defs.h index afca703..da8c200 100644 --- a/src/internal_libs/gui/panel_defs.h +++ b/src/internal_libs/gui/panel_defs.h @@ -11,30 +11,6 @@ namespace lunarium { namespace gui { - enum PanelType - { - // core - PT_CORE_CONSOLE, - - // editor - PT_MAIN, - PT_ABOUT, - PT_WORLD_TREE, - PT_WORLD_VIEW, - PT_ASSET_BROWSER, - PT_PROPERTIES_VIEW, - PT_EDITOR_CONSOLE, - - // Map Editor - PT_MAP_CANVAS, - PT_TILE_SET_VIEW, - PT_TILE_PROPERTIES, - PT_MAP_PROPERTIES, - PT_MAP_PREVIEW, - - PT_UNKNOWN, - }; - enum PanelDockZone { DDZ_LEFT, diff --git a/src/run_modes/editor/editor.cpp b/src/run_modes/editor/editor.cpp index 25f8bcf..e74309c 100644 --- a/src/run_modes/editor/editor.cpp +++ b/src/run_modes/editor/editor.cpp @@ -60,10 +60,10 @@ namespace editor return res; } - mPanelManager.AddPanel(new AssetBrowser("")).LogIfFailed(LogCat); - mPanelManager.AddPanel(new WorldTree()).LogIfFailed(LogCat); - mPanelManager.AddPanel(new WorldView()).LogIfFailed(LogCat); - mPanelManager.AddPanel(new PropertiesView()).LogIfFailed(LogCat); + mPanelManager.AddPanel(new AssetBrowser(""), mPanels.AssetBrowser).LogIfFailed(LogCat); + mPanelManager.AddPanel(new WorldTree(), mPanels.WorldTree).LogIfFailed(LogCat); + mPanelManager.AddPanel(new WorldView(), mPanels.WorldView).LogIfFailed(LogCat); + mPanelManager.AddPanel(new PropertiesView(), mPanels.PropertiesView).LogIfFailed(LogCat); return OpRes::OK(); } @@ -150,7 +150,7 @@ namespace editor std::filesystem::path Editor::GetAssetBrowserLocation() { - return mProject.GetAssetDirectory() / ((AssetBrowser*)mPanelManager.GetPanel(gui::PanelType::PT_ASSET_BROWSER))->GetSelectedDirectory(); + return mProject.GetAssetDirectory() / ((AssetBrowser*)mPanelManager.GetPanel(mPanels.AssetBrowser))->GetSelectedDirectory(); } Project* Editor::GetProject() @@ -207,7 +207,7 @@ namespace editor { Logger::Log(LogCat, LogLevel::ERROR, "Could not create a new project: %s", result.Description); } - ((AssetBrowser*)mPanelManager.GetPanel(PanelType::PT_ASSET_BROWSER))->SetAssetDirectory(*mpPath / std::filesystem::path("contents/assets")); + ((AssetBrowser*)mPanelManager.GetPanel(mPanels.AssetBrowser))->SetAssetDirectory(*mpPath / std::filesystem::path("contents/assets")); mDoNewProject = false; } else if (mFileBrowser.GetResult() == FileBrowser::Result::CANCEL) @@ -231,7 +231,7 @@ namespace editor mDoOpenProject = false; return; } - ((AssetBrowser*)mPanelManager.GetPanel(PanelType::PT_ASSET_BROWSER))->SetAssetDirectory(mpPath->parent_path() / std::filesystem::path("contents/assets")); + ((AssetBrowser*)mPanelManager.GetPanel(mPanels.AssetBrowser))->SetAssetDirectory(mpPath->parent_path() / std::filesystem::path("contents/assets")); mDoOpenProject = false; } else if (mFileBrowser.GetResult() == FileBrowser::Result::CANCEL) @@ -389,10 +389,10 @@ namespace editor } ImGui::Separator(); - HandleOpenPanel("Asset Browser", gui::PanelType::PT_ASSET_BROWSER); - HandleOpenPanel("World Tree", gui::PanelType::PT_WORLD_TREE); - HandleOpenPanel("World View", gui::PanelType::PT_WORLD_VIEW); - HandleOpenPanel("Properties", gui::PanelType::PT_PROPERTIES_VIEW); + HandleOpenPanel("Asset Browser", mPanels.AssetBrowser); + HandleOpenPanel("World Tree", mPanels.WorldTree); + HandleOpenPanel("World View", mPanels.WorldView); + HandleOpenPanel("Properties", mPanels.PropertiesView); ImGui::EndMenu(); } @@ -427,11 +427,11 @@ namespace editor } - void Editor::HandleOpenPanel(const char* name, gui::PanelType type) + void Editor::HandleOpenPanel(const char* name, uint32_t id) { if (ImGui::MenuItem(name)) { - mPanelManager.OpenPanel(type); + mPanelManager.OpenPanel(id); } } diff --git a/src/run_modes/editor/editor.h b/src/run_modes/editor/editor.h index af640e2..b95caf5 100644 --- a/src/run_modes/editor/editor.h +++ b/src/run_modes/editor/editor.h @@ -70,6 +70,16 @@ namespace lunarium { namespace editor FileBrowser mFileBrowser; const std::filesystem::path* mpPath; + // Panels + struct + { + uint32_t AssetBrowser; + uint32_t WorldTree; + uint32_t WorldView; + uint32_t PropertiesView; + } mPanels; + + // Non-Docking panels AboutPanel mAboutPanel; @@ -89,7 +99,7 @@ namespace lunarium { namespace editor void DestroyTools(); void HandleMenuEvents(); - void HandleOpenPanel(const char* name, gui::PanelType type); + void HandleOpenPanel(const char* name, uint32_t id); }; diff --git a/src/run_modes/editor/panel_manager.cpp b/src/run_modes/editor/panel_manager.cpp index 6e7f1db..960eab6 100644 --- a/src/run_modes/editor/panel_manager.cpp +++ b/src/run_modes/editor/panel_manager.cpp @@ -52,60 +52,52 @@ namespace lunarium { namespace editor } - OpRes PanelManager::AddPanel(gui::Panel* panel) + OpRes PanelManager::AddPanel(gui::Panel* panel, uint32_t& id) { - if (mPanels.find(panel->GetType()) != mPanels.end()) + if (mPanelsByName.find(panel->GetName()) != mPanelsByName.end()) { return OpRes::Fail("Cannot add panel - panel already exists. Panel Name: %s", panel->GetName()); } - mPanels[panel->GetType()] = panel; + mPanelsByName[panel->GetName()] = panel; + mPanels.push_back(panel); + id = mPanels.size() - 1; return OpRes::OK(); } - void PanelManager::OpenPanel(PanelType type) + void PanelManager::OpenPanel(uint32_t id) { - Panel* p = GetPanel(type); - if (!p || p->IsOpen()) - { + if (mPanels.size() >= id || id < 0) return; - } - p->SetOpen(true); + mPanels[id]->SetOpen(true); } - void PanelManager::ClosePanel(PanelType type) + void PanelManager::ClosePanel(uint32_t id) { - Panel* p = GetPanel(type); - if (!p || !p->IsOpen()) - { + if (mPanels.size() >= id || id < 0) return; - } - p->SetOpen(false); + mPanels[id]->SetOpen(false); } - bool PanelManager::IsOpen(PanelType type) + bool PanelManager::IsOpen(uint32_t id) { - Panel* p = GetPanel(type); - if (!p) - { + if (mPanels.size() >= id || id < 0) return false; - } - return p->IsOpen(); + return mPanels[id]->IsOpen(); } - Panel* PanelManager::GetPanel(PanelType type) + Panel* PanelManager::GetPanel(uint32_t id) { - auto iter = mPanels.find(type); - if (iter != mPanels.end()) + if (id >= 0 && id < mPanels.size()) { - return iter->second; + return mPanels[id]; } - Logger::Log(mpEditor->GetLogCat(), LogLevel::WARNING, "Requested panel not found: %d", type); + Logger::Log(mpEditor->GetLogCat(), LogLevel::WARNING, "Requested panel not found: %d", id); return nullptr; } @@ -134,55 +126,21 @@ namespace lunarium { namespace editor { for (auto iter = mPanels.begin(); iter != mPanels.end(); iter++) { - if (iter->second->IsOpen()) + if ((*iter)->IsOpen()) { - iter->second->Update(delta); + (*iter)->Update(delta); } } } - - // void PanelManager::OnRender(lunarium::IGraphics* g) - // { - // // mpMainPanel->DoFrame(); - - // //ImGuiViewport* Viewport = ImGui::GetMainViewport(); - // ImGuiViewport* Viewport = ImGui::GetWindowViewport(); - // ImGui::SetNextWindowPos( Viewport->WorkPos ); - // ImGui::SetNextWindowSize( Viewport->WorkSize ); - // ImGui::SetNextWindowViewport( Viewport->ID ); - // ImGuiWindowFlags WindowFlags = 0; - // WindowFlags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDocking; - // WindowFlags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus; - - // ImGui::PushStyleVar( ImGuiStyleVar_WindowRounding, 0.0f ); - // ImGui::PushStyleVar( ImGuiStyleVar_WindowBorderSize, 0.0f ); - // ImGui::PushStyleVar( ImGuiStyleVar_WindowPadding, ImVec2( 0.0f, 0.0f ) ); - - // ImGui::Begin(mName.c_str(), nullptr, WindowFlags); - // ImGui::PopStyleVar(3); - - // MakeDockSpaces(); - - // ImGui::End(); - - // for (auto iter = mPanels.begin(); iter != mPanels.end(); iter++) - // { - // if (iter->second->IsOpen()) - // { - // ImGui::SetNextWindowClass(&mWindowClass); - // iter->second->DoFrame(); - // } - // } - // } void PanelManager::RenderPanels() { for (auto iter = mPanels.begin(); iter != mPanels.end(); iter++) { - if (iter->second->IsOpen()) + if ((*iter)->IsOpen()) { ImGui::SetNextWindowClass(&mWindowClass); - iter->second->DoFrame(); + (*iter)->DoFrame(); } } } @@ -194,7 +152,7 @@ namespace lunarium { namespace editor { for (auto iter = mPanels.begin(); iter != mPanels.end(); iter++) { - delete iter->second; + delete (*iter); } mPanels.clear(); @@ -232,7 +190,7 @@ namespace lunarium { namespace editor // Dock Panels for (auto iter = mPanels.begin(); iter != mPanels.end(); iter++) { - PanelDockZone dz = iter->second->GetDockZone(); + PanelDockZone dz = (*iter)->GetDockZone(); if (dz != PanelDockZone::DDZ_NONE) { // If the panel expects the bottom node to be split but it isn't @@ -251,7 +209,7 @@ namespace lunarium { namespace editor dz = PanelDockZone::DDZ_BOT_LEFT; } - ImGui::DockBuilderDockWindow(iter->second->GetName(), mDockZoneIDs[dz]); + ImGui::DockBuilderDockWindow((*iter)->GetName(), mDockZoneIDs[dz]); } } } diff --git a/src/run_modes/editor/panel_manager.h b/src/run_modes/editor/panel_manager.h index 2493394..10ff1a5 100644 --- a/src/run_modes/editor/panel_manager.h +++ b/src/run_modes/editor/panel_manager.h @@ -13,6 +13,7 @@ #include #include #include +#include struct ImGuiWindowClass; @@ -30,11 +31,11 @@ namespace editor void Shutdown(); // Panel interface - OpRes AddPanel(gui::Panel* panel); - void OpenPanel(gui::PanelType type); - void ClosePanel(gui::PanelType type); - bool IsOpen(gui::PanelType type); - gui::Panel* GetPanel(gui::PanelType type); + [[nodiscard]] OpRes AddPanel(gui::Panel* panel, uint32_t& id); + void OpenPanel(uint32_t id); + void ClosePanel(uint32_t id); + bool IsOpen(uint32_t id); + gui::Panel* GetPanel(uint32_t id); const ImGuiWindowClass* GetWindowClass() const; // Docking @@ -49,9 +50,10 @@ namespace editor private: Editor* mpEditor; std::string mName; - bool mSplitBottom; // If ture the bottom dock node will also be split into left/right + bool mSplitBottom; // If true the bottom dock node will also be split into left/right bool mResetDockSpace; - std::map mPanels; + std::vector mPanels; + std::map mPanelsByName; unsigned int mDockSpaceID; ImGuiWindowClass mWindowClass; std::map mDockZoneIDs; diff --git a/src/run_modes/editor/panels/about.cpp b/src/run_modes/editor/panels/about.cpp index cc5c9d7..bb8548e 100644 --- a/src/run_modes/editor/panels/about.cpp +++ b/src/run_modes/editor/panels/about.cpp @@ -16,7 +16,7 @@ namespace lunarium namespace editor { AboutPanel::AboutPanel() - : Panel(gui::PanelType::PT_ABOUT, "About", gui::PanelDockZone::DDZ_NONE) + : Panel("About", gui::PanelDockZone::DDZ_NONE) { } diff --git a/src/run_modes/editor/panels/assetBrowser.cpp b/src/run_modes/editor/panels/assetBrowser.cpp index 55fd653..9cc9cdd 100644 --- a/src/run_modes/editor/panels/assetBrowser.cpp +++ b/src/run_modes/editor/panels/assetBrowser.cpp @@ -15,7 +15,7 @@ namespace lunarium namespace editor { AssetBrowser::AssetBrowser(std::filesystem::path dir) - : Panel(gui::PanelType::PT_ASSET_BROWSER, "Asset Browser", gui::PanelDockZone::DDZ_BOTTOM, true), + : Panel("Asset Browser", gui::PanelDockZone::DDZ_BOTTOM, true), mAssetDirectory(dir), mTreeRoot(nullptr), mSelectedNode(nullptr) { mTreeRoot = ReloadAssets(mAssetDirectory); diff --git a/src/run_modes/editor/panels/propertiesView.cpp b/src/run_modes/editor/panels/propertiesView.cpp index 3f3a63b..572112f 100644 --- a/src/run_modes/editor/panels/propertiesView.cpp +++ b/src/run_modes/editor/panels/propertiesView.cpp @@ -14,7 +14,7 @@ namespace lunarium { namespace editor { PropertiesView::PropertiesView() - : Panel(gui::PanelType::PT_PROPERTIES_VIEW, "Properties", gui::PanelDockZone::DDZ_RIGHT, true) + : Panel("Properties", gui::PanelDockZone::DDZ_RIGHT, true) { } diff --git a/src/run_modes/editor/panels/worldTree.cpp b/src/run_modes/editor/panels/worldTree.cpp index f2e73d0..4ead478 100644 --- a/src/run_modes/editor/panels/worldTree.cpp +++ b/src/run_modes/editor/panels/worldTree.cpp @@ -7,7 +7,7 @@ ******************************************************************************/ #include "worldTree.h" -#include +#include #include #include @@ -16,7 +16,7 @@ namespace lunarium namespace editor { WorldTree::WorldTree() - : Panel(gui::PanelType::PT_WORLD_TREE, "World Tree", gui::PanelDockZone::DDZ_LEFT, true), mpWorld(nullptr) + : Panel("World Tree", gui::PanelDockZone::DDZ_LEFT, true), mpWorld(nullptr) { } diff --git a/src/run_modes/editor/panels/worldView.cpp b/src/run_modes/editor/panels/worldView.cpp index 858f5ed..59e9587 100644 --- a/src/run_modes/editor/panels/worldView.cpp +++ b/src/run_modes/editor/panels/worldView.cpp @@ -8,7 +8,7 @@ #include "worldView.h" #include -#include +#include #include #include #include "../panel_manager.h" @@ -18,7 +18,7 @@ namespace lunarium namespace editor { WorldView::WorldView() - : Panel(gui::PanelType::PT_WORLD_VIEW, "World View", gui::PanelDockZone::DDZ_CENTER ,true), mpWorld(nullptr) + : Panel("World View", gui::PanelDockZone::DDZ_CENTER ,true), mpWorld(nullptr) { } diff --git a/src/run_modes/editor/tools/map_editor/map_editor.cpp b/src/run_modes/editor/tools/map_editor/map_editor.cpp index 1fb7310..4df34e4 100644 --- a/src/run_modes/editor/tools/map_editor/map_editor.cpp +++ b/src/run_modes/editor/tools/map_editor/map_editor.cpp @@ -47,8 +47,8 @@ namespace lunarium { namespace editor return OpRes::Fail("Could not initialize the panel manager!"); } - mPanelManager.AddPanel(new MapCanvas(this)).LogIfFailed(mpEditor->GetLogCat()); - mPanelManager.AddPanel(new TileSetView(this)).LogIfFailed(mpEditor->GetLogCat()); + mPanelManager.AddPanel(new MapCanvas(this), mPanels.MapCanvas).LogIfFailed(mpEditor->GetLogCat()); + mPanelManager.AddPanel(new TileSetView(this), mPanels.TileSetView).LogIfFailed(mpEditor->GetLogCat()); Open(); @@ -156,17 +156,17 @@ namespace lunarium { namespace editor mpMap->ClearMap(); // Add all tilesets that match the Map's tile size - ((TileSetView*)mPanelManager.GetPanel(gui::PanelType::PT_TILE_SET_VIEW))->ClearTileSets(); + ((TileSetView*)mPanelManager.GetPanel(mPanels.TileSetView))->ClearTileSets(); for (auto iter = mTileSets.begin(); iter != mTileSets.end(); iter++) { if (iter->second->GetTileSize() == mpMap->GetTileSize()) { mpMap->AddTileSet(iter->second->GetTileSetID(), iter->second); - ((TileSetView*)mPanelManager.GetPanel(gui::PanelType::PT_TILE_SET_VIEW))->AddTileSet(iter->second); + ((TileSetView*)mPanelManager.GetPanel(mPanels.TileSetView))->AddTileSet(iter->second); } } - ((MapCanvas*)mPanelManager.GetPanel(gui::PanelType::PT_MAP_CANVAS))->SetTileMap(mpMap); + ((MapCanvas*)mPanelManager.GetPanel(mPanels.MapCanvas))->SetTileMap(mpMap); } OpRes MapEditor::LoadMap(std::string map) @@ -282,7 +282,7 @@ namespace lunarium { namespace editor if (mpMap && mpMap->GetTileSize() == ts->GetTileSize()) { mpMap->AddTileSet(ts->GetTileSetID(), ts); - ((TileSetView*)mPanelManager.GetPanel(gui::PanelType::PT_TILE_SET_VIEW))->AddTileSet(ts); + ((TileSetView*)mPanelManager.GetPanel(mPanels.TileSetView))->AddTileSet(ts); } mImportTileSet = false; @@ -300,6 +300,6 @@ namespace lunarium { namespace editor void MapEditor::ChangeSelectedTile(TileRef tile) { - ((MapCanvas*)mPanelManager.GetPanel(gui::PanelType::PT_MAP_CANVAS))->SetSelectedTile(tile); + ((MapCanvas*)mPanelManager.GetPanel(mPanels.MapCanvas))->SetSelectedTile(tile); } }} diff --git a/src/run_modes/editor/tools/map_editor/map_editor.h b/src/run_modes/editor/tools/map_editor/map_editor.h index 43feaea..ae43ffe 100644 --- a/src/run_modes/editor/tools/map_editor/map_editor.h +++ b/src/run_modes/editor/tools/map_editor/map_editor.h @@ -60,6 +60,11 @@ namespace editor Editor* mpEditor; PanelManager mPanelManager; + struct + { + uint32_t MapCanvas; + uint32_t TileSetView; + } mPanels; FileBrowser mFileBrowser; diff --git a/src/run_modes/editor/tools/map_editor/panels/map_canvas.cpp b/src/run_modes/editor/tools/map_editor/panels/map_canvas.cpp index 0861b4f..49e608d 100644 --- a/src/run_modes/editor/tools/map_editor/panels/map_canvas.cpp +++ b/src/run_modes/editor/tools/map_editor/panels/map_canvas.cpp @@ -21,7 +21,7 @@ namespace lunarium { namespace editor { MapCanvas::MapCanvas(MapEditor* editor) - : Panel(gui::PanelType::PT_MAP_CANVAS, "Map Canvas", gui::PanelDockZone::DDZ_CENTER, true), + : Panel("Map Canvas", gui::PanelDockZone::DDZ_CENTER, true), mpMapEditor(editor), mpCanvasImage(nullptr), mMap(nullptr), mSelectedTile({-1, -1}), mFrameBuffer(-1), mMapSizeChanged(false), mZoomFactor(1.0f), mScrollDragged(false) { diff --git a/src/run_modes/editor/tools/map_editor/panels/tile_set_view.cpp b/src/run_modes/editor/tools/map_editor/panels/tile_set_view.cpp index 8087dea..aa2d88b 100644 --- a/src/run_modes/editor/tools/map_editor/panels/tile_set_view.cpp +++ b/src/run_modes/editor/tools/map_editor/panels/tile_set_view.cpp @@ -20,7 +20,7 @@ namespace lunarium { namespace editor { TileSetView::TileSetView(MapEditor* editor) - : Panel(gui::PanelType::PT_TILE_SET_VIEW, "Tile Set View", gui::PanelDockZone::DDZ_RIGHT, true), + : Panel("Tile Set View", gui::PanelDockZone::DDZ_RIGHT, true), mpEditor(editor), mpSelectedTileSet(nullptr), mpViewImage(nullptr), mFrameBuffer(-1), mViewOffset({0, 0}), mViewZoom(1.0f), mMouseDown(false) { diff --git a/src/run_modes/game/CMakeLists.txt b/src/run_modes/player/CMakeLists.txt similarity index 100% rename from src/run_modes/game/CMakeLists.txt rename to src/run_modes/player/CMakeLists.txt diff --git a/src/run_modes/game/object/object.h b/src/run_modes/player/object/object.h similarity index 100% rename from src/run_modes/game/object/object.h rename to src/run_modes/player/object/object.h diff --git a/src/run_modes/game/world/world.cpp b/src/run_modes/player/world/world.cpp similarity index 100% rename from src/run_modes/game/world/world.cpp rename to src/run_modes/player/world/world.cpp diff --git a/src/run_modes/game/world/world.h b/src/run_modes/player/world/world.h similarity index 100% rename from src/run_modes/game/world/world.h rename to src/run_modes/player/world/world.h