2021-08-06 18:12:07 -07:00
|
|
|
#pragma once
|
2021-12-25 22:36:38 +01:00
|
|
|
#ifndef DEDICATED
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Initialization
|
|
|
|
void DrawConsole(bool* bDraw);
|
2021-08-06 18:12:07 -07:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Globals
|
2021-12-25 22:36:38 +01:00
|
|
|
inline ImVector<char*> Items;
|
2021-08-06 18:12:07 -07:00
|
|
|
|
2021-12-25 22:36:38 +01:00
|
|
|
class CConsole
|
2021-08-06 18:12:07 -07:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
2021-12-25 22:36:38 +01:00
|
|
|
char m_szInputBuf[256] = { 0 };
|
|
|
|
ImVector<const char*> m_ivCommands;
|
|
|
|
ImVector<char*> m_ivHistory;
|
|
|
|
int m_nHistoryPos = -1;
|
|
|
|
ImGuiTextFilter m_itFilter;
|
|
|
|
bool m_bAutoScroll = true;
|
|
|
|
bool m_bScrollToBottom = false;
|
|
|
|
bool m_bThemeSet = false;
|
2021-08-06 18:12:07 -07:00
|
|
|
|
|
|
|
public:
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2021-12-25 22:36:38 +01:00
|
|
|
CConsole();
|
|
|
|
~CConsole();
|
2021-08-06 18:12:07 -07:00
|
|
|
|
2021-12-25 22:36:38 +01:00
|
|
|
void Draw(const char* title, bool* bDraw);
|
2021-08-06 18:12:07 -07:00
|
|
|
void ProcessCommand(const char* command_line);
|
|
|
|
int TextEditCallback(ImGuiInputTextCallbackData* data);
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// History
|
|
|
|
static int TextEditCallbackStub(ImGuiInputTextCallbackData* data)
|
|
|
|
{
|
2021-12-25 22:36:38 +01:00
|
|
|
CConsole* console = (CConsole*)data->UserData;
|
2021-08-06 18:12:07 -07:00
|
|
|
return console->TextEditCallback(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// Utility
|
|
|
|
void ClearLog()
|
|
|
|
{
|
2021-12-25 22:36:38 +01:00
|
|
|
for (int i = 0; i < Items.Size; i++) { free(Items[i]); }
|
2021-08-06 18:12:07 -07:00
|
|
|
Items.clear();
|
|
|
|
}
|
|
|
|
void AddLog(const char* fmt, ...) IM_FMTARGS(2)
|
|
|
|
{
|
|
|
|
char buf[1024];
|
|
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
|
|
vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args);
|
|
|
|
buf[IM_ARRAYSIZE(buf) - 1] = 0;
|
|
|
|
va_end(args);
|
|
|
|
Items.push_back(Strdup(buf));
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
// Style
|
|
|
|
void SetStyleVar()
|
|
|
|
{
|
|
|
|
ImGuiStyle& style = ImGui::GetStyle();
|
|
|
|
ImVec4* colors = style.Colors;
|
|
|
|
|
|
|
|
colors[ImGuiCol_Text] = ImVec4(0.81f, 0.81f, 0.81f, 1.00f);
|
|
|
|
colors[ImGuiCol_TextDisabled] = ImVec4(0.56f, 0.56f, 0.56f, 1.00f);
|
|
|
|
colors[ImGuiCol_WindowBg] = ImVec4(0.27f, 0.27f, 0.27f, 1.00f);
|
|
|
|
colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f);
|
|
|
|
colors[ImGuiCol_PopupBg] = ImVec4(0.27f, 0.27f, 0.27f, 1.00f);
|
|
|
|
colors[ImGuiCol_Border] = ImVec4(0.41f, 0.41f, 0.41f, 1.00f);
|
|
|
|
colors[ImGuiCol_BorderShadow] = ImVec4(0.04f, 0.04f, 0.04f, 0.64f);
|
|
|
|
colors[ImGuiCol_FrameBg] = ImVec4(0.13f, 0.13f, 0.13f, 1.00f);
|
|
|
|
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.19f, 0.19f, 0.19f, 1.00f);
|
|
|
|
colors[ImGuiCol_FrameBgActive] = ImVec4(0.24f, 0.24f, 0.24f, 1.00f);
|
|
|
|
colors[ImGuiCol_TitleBg] = ImVec4(0.22f, 0.22f, 0.22f, 1.00f);
|
|
|
|
colors[ImGuiCol_TitleBgActive] = ImVec4(0.27f, 0.27f, 0.27f, 1.00f);
|
|
|
|
colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f);
|
|
|
|
colors[ImGuiCol_MenuBarBg] = ImVec4(0.22f, 0.22f, 0.22f, 1.00f);
|
|
|
|
colors[ImGuiCol_ScrollbarBg] = ImVec4(0.10f, 0.10f, 0.10f, 1.00f);
|
|
|
|
colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.41f, 0.41f, 0.41f, 1.00f);
|
|
|
|
colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.53f, 0.53f, 0.53f, 1.00f);
|
|
|
|
colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.63f, 0.63f, 0.63f, 1.00f);
|
|
|
|
colors[ImGuiCol_CheckMark] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f);
|
|
|
|
colors[ImGuiCol_SliderGrab] = ImVec4(0.41f, 0.41f, 0.41f, 1.00f);
|
|
|
|
colors[ImGuiCol_SliderGrabActive] = ImVec4(0.53f, 0.53f, 0.53f, 1.00f);
|
|
|
|
colors[ImGuiCol_Button] = ImVec4(0.35f, 0.35f, 0.35f, 1.00f);
|
|
|
|
colors[ImGuiCol_ButtonHovered] = ImVec4(0.45f, 0.45f, 0.45f, 1.00f);
|
|
|
|
colors[ImGuiCol_ButtonActive] = ImVec4(0.52f, 0.52f, 0.52f, 1.00f);
|
|
|
|
colors[ImGuiCol_Header] = ImVec4(0.35f, 0.35f, 0.35f, 1.00f);
|
|
|
|
colors[ImGuiCol_HeaderHovered] = ImVec4(0.45f, 0.45f, 0.45f, 1.00f);
|
|
|
|
colors[ImGuiCol_HeaderActive] = ImVec4(0.53f, 0.53f, 0.53f, 1.00f);
|
|
|
|
colors[ImGuiCol_Separator] = ImVec4(0.53f, 0.53f, 0.57f, 1.00f);
|
|
|
|
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.53f, 0.53f, 0.53f, 1.00f);
|
|
|
|
colors[ImGuiCol_SeparatorActive] = ImVec4(0.63f, 0.63f, 0.63f, 1.00f);
|
|
|
|
colors[ImGuiCol_ResizeGrip] = ImVec4(0.41f, 0.41f, 0.41f, 1.00f);
|
|
|
|
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.52f, 0.52f, 0.52f, 1.00f);
|
|
|
|
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.63f, 0.63f, 0.63f, 1.00f);
|
|
|
|
colors[ImGuiCol_Tab] = ImVec4(0.18f, 0.18f, 0.18f, 1.00f);
|
|
|
|
colors[ImGuiCol_TabHovered] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f);
|
|
|
|
colors[ImGuiCol_TabActive] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f);
|
|
|
|
|
|
|
|
style.WindowBorderSize = 0.0f;
|
|
|
|
style.FrameBorderSize = 1.0f;
|
|
|
|
style.ChildBorderSize = 1.0f;
|
|
|
|
style.PopupBorderSize = 1.0f;
|
|
|
|
style.TabBorderSize = 1.0f;
|
|
|
|
|
|
|
|
style.WindowRounding = 2.5f;
|
|
|
|
style.FrameRounding = 0.0f;
|
|
|
|
style.ChildRounding = 0.0f;
|
|
|
|
style.PopupRounding = 0.0f;
|
|
|
|
style.TabRounding = 1.0f;
|
|
|
|
style.ScrollbarRounding = 1.0f;
|
|
|
|
|
|
|
|
style.ItemSpacing = ImVec2(4, 4);
|
|
|
|
style.WindowPadding = ImVec2(5, 5);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-12-25 22:36:38 +01:00
|
|
|
extern CConsole* g_GameConsole;
|
|
|
|
#endif // !DEDICATED
|