Adds a setting to allow LUA console and Debug Log windows to to be unstuck from the window (probably useful for Editor run mode).

Gui_Panel_Refactor
Joeyrp 4 years ago
parent 4486eb8890
commit ba5a7f6064

@ -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;
}
}

@ -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<std::string> mMsgHistory;
friend GuiListener;
GuiListener mListener;

@ -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;
}
}

@ -27,6 +27,8 @@ namespace lunarium
void SetShow(bool show);
bool IsShown() const;
bool IsStuckToWindow() const;
void SetStickToWindow(bool stick);
const std::vector<std::string>* 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<std::string> mCommandHistory;
bool mbNewCommand;

Loading…
Cancel
Save