Console behavior split into it's own base class (so that the Core and Editor can have different looking console panels).
parent
6e2f676f11
commit
fed77546dc
@ -0,0 +1,72 @@
|
||||
/******************************************************************************
|
||||
* File - core_console.cpp
|
||||
* Author - Joey Pollack
|
||||
* Date - 2022/02/10 (y/m/d)
|
||||
* Mod Date - 2022/02/10 (y/m/d)
|
||||
* Description - console for the game mode
|
||||
******************************************************************************/
|
||||
|
||||
#include "core_console.h"
|
||||
#include <gui/dearimgui/imgui.h>
|
||||
#include <gui/dearimgui/imgui_internal.h> // To use the DockWindowXXX methods
|
||||
|
||||
namespace lunarium
|
||||
{
|
||||
CoreConsole::CoreConsole()
|
||||
: Console(gui::PanelType::PT_CORE_CONSOLE, "Core Console"), mDockIsInit(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool CoreConsole::DoFrame()
|
||||
{
|
||||
InitDock();
|
||||
|
||||
if (!mIsOpen)
|
||||
return false;
|
||||
|
||||
|
||||
ImGuiViewport* pView = ImGui::GetMainViewport();
|
||||
|
||||
float myHeight = pView->WorkSize.y / 3.0f;
|
||||
float y = pView->WorkPos.y + (myHeight * 2);
|
||||
|
||||
float alpha = IsFocused() ? 0.75f : 0.5f;
|
||||
ImGui::SetNextWindowPos(ImVec2(pView->WorkPos.x, y), ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize(ImVec2(pView->WorkSize.x, myHeight), ImGuiCond_Always);
|
||||
ImGui::SetNextWindowBgAlpha(alpha);
|
||||
if (!ImGui::Begin(GetName(), &mIsOpen, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar
|
||||
| ImGuiWindowFlags_NoCollapse))
|
||||
{
|
||||
ImGui::End();
|
||||
return mIsOpen;
|
||||
}
|
||||
|
||||
Console::DoFrame();
|
||||
|
||||
ImGui::End();
|
||||
|
||||
return mIsOpen;
|
||||
}
|
||||
|
||||
void CoreConsole::InitDock()
|
||||
{
|
||||
ImGuiViewport* Viewport = ImGui::GetMainViewport();
|
||||
// ImGuiID mainID = ImGui::DockSpace(ImGui::GetID("Core Dockspace"));
|
||||
ImGuiID mainID = ImGui::DockSpaceOverViewport(Viewport, ImGuiDockNodeFlags_PassthruCentralNode);
|
||||
if (!ImGui::DockBuilderGetNode(mainID) || !mDockIsInit)
|
||||
{
|
||||
mDockIsInit = true;
|
||||
ImGui::DockBuilderRemoveNode(mainID);
|
||||
ImGui::DockBuilderAddNode(mainID, ImGuiDockNodeFlags_DockSpace);
|
||||
ImGui::DockBuilderSetNodeSize(mainID, Viewport->Size);
|
||||
//ImGui::DockBuilderSetNodePos(mDockSpaces.Main, Viewport->WorkPos);
|
||||
|
||||
ImGuiID bottom = ImGui::DockBuilderSplitNode(mainID, ImGuiDir_Down, 0.35f, nullptr, nullptr);
|
||||
ImGui::DockBuilderFinish(mainID);
|
||||
|
||||
// Dock Panels
|
||||
//ImGui::DockBuilderDockWindow(GetName(), bottom);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
/******************************************************************************
|
||||
* File - core_console.h
|
||||
* Author - Joey Pollack
|
||||
* Date - 2022/02/10 (y/m/d)
|
||||
* Mod Date - 2022/02/10 (y/m/d)
|
||||
* Description - console for the game mode
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef CORE_CONSOLE_H_
|
||||
#define CORE_CONSOLE_H_
|
||||
|
||||
#include <gui/console.h>
|
||||
|
||||
namespace lunarium
|
||||
{
|
||||
class CoreConsole : public gui::Console
|
||||
{
|
||||
public:
|
||||
CoreConsole();
|
||||
bool DoFrame() override;
|
||||
|
||||
private:
|
||||
void InitDock();
|
||||
bool mDockIsInit;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // CORE_CONSOLE_H_
|
||||
Loading…
Reference in New Issue