diff --git a/src/graphics/gui/logGui.cpp b/src/graphics/gui/logGui.cpp index 6bbdc58..4dcbe48 100644 --- a/src/graphics/gui/logGui.cpp +++ b/src/graphics/gui/logGui.cpp @@ -45,7 +45,7 @@ namespace lunarium //////////////////////////////////////////////////////////// LogGui* LogGui::mpInstance = nullptr; LogGui::LogGui() - : mbShow(false), mListener(this), mbOglDebug(false), mbInfoVerbose(false) + : mbShow(false), mbStickToWindow(true), mListener(this), mbOglDebug(false), mbInfoVerbose(false) { } @@ -83,17 +83,30 @@ namespace lunarium Core::MainWindow().GetPosition(&x, &y); int width, height; Core::MainWindow().GetFramebufferSize(&width, &height); - int logHeight = height / 2.0f; - - ImGui::SetNextWindowPos(ImVec2(x, y + logHeight), ImGuiCond_Always); - ImGui::SetNextWindowSize(ImVec2((width / 3.0f) * 2.0f, logHeight), ImGuiCond_Always); - if (!ImGui::Begin("Debug Log", &mbShow, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove - | ImGuiWindowFlags_NoSavedSettings)) + + if (mbStickToWindow) { - ImGui::End(); - return; + ImGui::SetNextWindowPos(ImVec2(x, y + logHeight), ImGuiCond_Always); + ImGui::SetNextWindowSize(ImVec2((width / 3.0f) * 2.0f, logHeight), ImGuiCond_Always); + if (!ImGui::Begin("Debug Log", &mbShow, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove + | ImGuiWindowFlags_NoSavedSettings)) + { + ImGui::End(); + return; + } } + else + { + ImGui::SetNextWindowPos(ImVec2(x, y + logHeight), ImGuiCond_FirstUseEver); + ImGui::SetNextWindowSize(ImVec2((width / 3.0f) * 2.0f, logHeight), ImGuiCond_FirstUseEver); + if (!ImGui::Begin("Debug Log", &mbShow)) + { + ImGui::End(); + return; + } + } + ImGui::BeginChild("Message Types", ImVec2(0.0f, 20.0f)); ImGui::Checkbox("OGL_DEBUG", &mbOglDebug); ImGui::SameLine(); @@ -152,4 +165,14 @@ namespace lunarium { return mbShow; } + + bool LogGui::IsStuckToWindow() const + { + return mbStickToWindow; + } + + void LogGui::SetStickToWindow(bool stick) + { + mbStickToWindow = stick; + } } \ No newline at end of file diff --git a/src/graphics/gui/logGui.h b/src/graphics/gui/logGui.h index 6aa5abd..81b175e 100644 --- a/src/graphics/gui/logGui.h +++ b/src/graphics/gui/logGui.h @@ -39,10 +39,13 @@ namespace lunarium void SetShow(bool show); bool IsShown() const; + bool IsStuckToWindow() const; + void SetStickToWindow(bool stick); private: static LogGui* mpInstance; bool mbShow; + bool mbStickToWindow; std::vector mMsgHistory; friend GuiListener; GuiListener mListener; diff --git a/src/graphics/gui/luaConsole.cpp b/src/graphics/gui/luaConsole.cpp index 60d67a5..eb41028 100644 --- a/src/graphics/gui/luaConsole.cpp +++ b/src/graphics/gui/luaConsole.cpp @@ -19,7 +19,7 @@ namespace lunarium { LuaConsole* LuaConsole::mpInstance = nullptr; LuaConsole::LuaConsole() - : mbShow(false), mbNewCommand(false) + : mbShow(false), mbStickToWindow(true), mbNewCommand(false) { memset(mBuffer, 0, LUA_CON_BUFFER_SIZE); } @@ -56,15 +56,29 @@ namespace lunarium int width, height; Core::MainWindow().GetFramebufferSize(&width, &height); - ImGui::SetNextWindowPos(ImVec2(x, y), ImGuiCond_Always); - ImGui::SetNextWindowSize(ImVec2(width / 3.0f, height / 3.0f), ImGuiCond_Always); - if (!ImGui::Begin("LUA Console", &mbShow, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove - | ImGuiWindowFlags_NoSavedSettings)) + if (mbStickToWindow) { - ImGui::End(); - return; + ImGui::SetNextWindowPos(ImVec2(x, y), ImGuiCond_Always); + ImGui::SetNextWindowSize(ImVec2(width / 3.0f, height / 3.0f), ImGuiCond_Always); + if (!ImGui::Begin("LUA Console", &mbShow, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove + | ImGuiWindowFlags_NoSavedSettings)) + { + ImGui::End(); + return; + } + } + else + { + ImGui::SetNextWindowPos(ImVec2(x, y), ImGuiCond_FirstUseEver); + ImGui::SetNextWindowSize(ImVec2(width / 3.0f, height / 3.0f), ImGuiCond_FirstUseEver); + if (!ImGui::Begin("LUA Console", &mbShow)) + { + ImGui::End(); + return; + } } + ImGui::BeginChild("history", ImVec2(0, 0), false, ImGuiWindowFlags_HorizontalScrollbar); for (int i = 0; i < mCommandHistory.size(); i++) { @@ -122,4 +136,14 @@ namespace lunarium return false; } + + bool LuaConsole::IsStuckToWindow() const + { + return mbStickToWindow; + } + + void LuaConsole::SetStickToWindow(bool stick) + { + mbStickToWindow = stick; + } } \ No newline at end of file diff --git a/src/graphics/gui/luaConsole.h b/src/graphics/gui/luaConsole.h index b2ee532..da3a5fd 100644 --- a/src/graphics/gui/luaConsole.h +++ b/src/graphics/gui/luaConsole.h @@ -27,6 +27,8 @@ namespace lunarium void SetShow(bool show); bool IsShown() const; + bool IsStuckToWindow() const; + void SetStickToWindow(bool stick); const std::vector* GetCommandHistory() const; std::string GetLastCommand(); @@ -36,6 +38,7 @@ namespace lunarium private: static LuaConsole* mpInstance; bool mbShow; + bool mbStickToWindow; char mBuffer[LUA_CON_BUFFER_SIZE]; std::vector mCommandHistory; bool mbNewCommand;