diff --git a/src/core/core.cpp b/src/core/core.cpp index 67ff5c1..d977b54 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -56,13 +56,19 @@ namespace lunarium Logger::Log(LogCategory::CORE, LogLevel::INFO, "Lunarium is shutting down!"); + int x, y; + mpInstance->MainWindow().GetPosition(&x, &y); + mpInstance->mState.Display.WindowStartPosition.X = x; + mpInstance->mState.Display.WindowStartPosition.Y = y; + + mpInstance->mpWindow->GetFramebufferSize(&mpInstance->mState.Display.WindowedSize.Width, &mpInstance->mState.Display.WindowedSize.Height); mpInstance->mpWindow->GetPosition(&mpInstance->mState.Display.WindowStartPosition.X, &mpInstance->mState.Display.WindowStartPosition.Y); - mpInstance->mState.SaveToFile("lunarium_state.xml"); + mpInstance->mState.SaveToFile(); // Run Mode shuts down first mpInstance->mpRunMode->Shutdown(); diff --git a/src/core/state.cpp b/src/core/state.cpp index 0b22bf3..9d6e7b1 100644 --- a/src/core/state.cpp +++ b/src/core/state.cpp @@ -50,6 +50,8 @@ namespace lunarium s.Interface.MainFont = ""; s.Mode = RunMode::MODE_TEST; + s.LoadedFile = "default_state.xml"; + return s; } @@ -148,11 +150,22 @@ namespace lunarium state.Interface.MainFont = interface.attribute("MainFont").value(); } - + state.LoadedFile = filename; return OpRes::OK(); } + + OpRes State::SaveToFile() + { + if (LoadedFile == "") + { + LoadedFile = "UNNAMED_STATE.xml"; + } + Logger::Log(LogCategory::CORE, LogLevel::INFO, "Saving state file: %s", LoadedFile.c_str()); + return SaveToFile(LoadedFile); + } + OpRes State::SaveToFile(std::string filename) { pugi::xml_document doc; diff --git a/src/core/state.h b/src/core/state.h index 6cb8ec8..7fd5cc5 100644 --- a/src/core/state.h +++ b/src/core/state.h @@ -69,6 +69,10 @@ namespace lunarium static State CreateDefault(); static OpRes CreateFromFile(std::string filename, State& state); OpRes SaveToFile(std::string filename); + OpRes SaveToFile(); + + private: + std::string LoadedFile; }; } diff --git a/src/run_modes/editor/editor.cpp b/src/run_modes/editor/editor.cpp index 90542d9..cef19e9 100644 --- a/src/run_modes/editor/editor.cpp +++ b/src/run_modes/editor/editor.cpp @@ -59,6 +59,7 @@ namespace editor void Editor::OnTick(double delta) { + // Panels for (auto iter = mPanels.begin(); iter != mPanels.end(); iter++) { if (iter->second->IsOpen()) @@ -67,6 +68,12 @@ namespace editor } } + // Tools + if (mpMapEditor) + { + mpMapEditor->OnTick(delta); + } + HandleMenuEvents(); } @@ -82,6 +89,10 @@ namespace editor } } + if (mpMapEditor) + { + mpMapEditor->OnRender(g); + } if (mpFileBrowser) { diff --git a/src/run_modes/editor/panels/mainPanel.cpp b/src/run_modes/editor/panels/mainPanel.cpp index fe01342..1f39492 100644 --- a/src/run_modes/editor/panels/mainPanel.cpp +++ b/src/run_modes/editor/panels/mainPanel.cpp @@ -77,7 +77,7 @@ namespace editor // STATUS BAR const ImGuiViewport* viewport = ImGui::GetMainViewport(); ImGui::SetNextWindowViewport(viewport->ID); - ImGui::SetNextWindowSize(ImVec2(mWidth, ImGui::GetFrameHeight() - 12.0f), ImGuiCond_Always); + ImGui::SetNextWindowSize(ImVec2(mWidth, ImGui::GetFrameHeight() - 15.0f), ImGuiCond_Always); ImGui::SetNextWindowPos(ImVec2(mX, mY + (mHeight - ImGui::GetFrameHeight() - 8.0f)), ImGuiCond_Always); ImGui::Begin("status bar", &mIsOpen, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize diff --git a/src/run_modes/editor/panels/worldView.cpp b/src/run_modes/editor/panels/worldView.cpp index d7fd801..847b605 100644 --- a/src/run_modes/editor/panels/worldView.cpp +++ b/src/run_modes/editor/panels/worldView.cpp @@ -25,6 +25,7 @@ namespace editor if (!mIsOpen) return false; + //ImGui::SetNextWindowPosition() if (!ImGui::Begin("World View", &mIsOpen, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar)) { ImGui::End(); 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 d668574..3f0a00c 100644 --- a/src/run_modes/editor/tools/map_editor/map_editor.cpp +++ b/src/run_modes/editor/tools/map_editor/map_editor.cpp @@ -48,7 +48,7 @@ namespace lunarium { namespace editor } } - bool MapEditor::OnRender(IGraphics* g) + bool MapEditor::OnRender(lunarium::IGraphics* g) { if (!mIsOpen) { 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 2b0c020..6a21a03 100644 --- a/src/run_modes/editor/tools/map_editor/map_editor.h +++ b/src/run_modes/editor/tools/map_editor/map_editor.h @@ -13,10 +13,12 @@ #include #include -namespace lunarium { namespace editor +namespace lunarium { + class IGraphics; + +namespace editor { class Editor; - class IGraphics; class Panel; class MapEditor { @@ -26,7 +28,7 @@ namespace lunarium { namespace editor OpRes Initialize(Editor* editor); void Shutdown(); void OnTick(double delta); - bool OnRender(IGraphics* g); + bool OnRender(lunarium::IGraphics* g); void Open(); void Close(); diff --git a/src/run_modes/tester/tester.cpp b/src/run_modes/tester/tester.cpp index f8ec240..f87d1f8 100644 --- a/src/run_modes/tester/tester.cpp +++ b/src/run_modes/tester/tester.cpp @@ -35,8 +35,8 @@ namespace lunarium Logger::Log(mLogCat, LogLevel::INFO, "EDITOR DETECTED!"); #endif - mpScene = new SimpleRenderScene(mLogCat); - // mpScene = new PhysicsScene(mLogCat); + // mpScene = new SimpleRenderScene(mLogCat); + mpScene = new PhysicsScene(mLogCat); mpScene->OnLoad(); 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/ - +