2021-12-25 22:36:38 +01:00
|
|
|
/******************************************************************************
|
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
File : IConsole.cpp
|
|
|
|
Date : 18:07:2021
|
|
|
|
Author : Kawe Mazidjatari
|
2022-01-12 02:53:07 +01:00
|
|
|
Purpose: Implements the in-game console front-end
|
2021-12-25 22:36:38 +01:00
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
History:
|
|
|
|
- 15:06:2021 | 14:56 : Created by Kawe Mazidjatari
|
|
|
|
- 07:08:2021 | 15:22 : Multithread 'CommandExecute' operations to prevent deadlock in render thread
|
|
|
|
- 07:08:2021 | 15:25 : Fix a race condition that occured when detaching the 'CommandExecute' thread
|
|
|
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
2022-01-12 02:53:07 +01:00
|
|
|
#include "core/stdafx.h"
|
|
|
|
#include "core/init.h"
|
|
|
|
#include "tier0/cvar.h"
|
2022-01-18 11:23:14 +01:00
|
|
|
#include "tier0/commandline.h"
|
2022-01-12 02:53:07 +01:00
|
|
|
#include "windows/id3dx.h"
|
|
|
|
#include "windows/console.h"
|
|
|
|
#include "gameui/IConsole.h"
|
|
|
|
#include "client/IVEngineClient.h"
|
|
|
|
|
2021-12-25 22:36:38 +01:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
CConsole::CConsole()
|
|
|
|
{
|
|
|
|
ClearLog();
|
|
|
|
memset(m_szInputBuf, 0, sizeof(m_szInputBuf));
|
|
|
|
|
|
|
|
m_nHistoryPos = -1;
|
|
|
|
m_bAutoScroll = true;
|
|
|
|
m_bScrollToBottom = false;
|
2022-01-14 20:45:36 +01:00
|
|
|
m_bInitialized = false;
|
2021-12-25 22:36:38 +01:00
|
|
|
|
2022-01-17 23:20:03 +01:00
|
|
|
m_vsvCommands.push_back("CLEAR");
|
|
|
|
m_vsvCommands.push_back("HELP");
|
|
|
|
m_vsvCommands.push_back("HISTORY");
|
2022-01-28 12:56:51 +01:00
|
|
|
|
|
|
|
snprintf(m_szSummary, 256, "%llu history items", m_vsvHistory.size());
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
CConsole::~CConsole()
|
|
|
|
{
|
|
|
|
ClearLog();
|
2022-01-17 23:20:03 +01:00
|
|
|
m_vsvHistory.clear();
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2022-01-17 23:20:03 +01:00
|
|
|
// Purpose: game console main render loop
|
2021-12-25 22:36:38 +01:00
|
|
|
//-----------------------------------------------------------------------------
|
2022-01-14 20:45:36 +01:00
|
|
|
void CConsole::Draw(const char* pszTitle, bool* bDraw)
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
2022-01-12 02:53:07 +01:00
|
|
|
if (!m_bInitialized)
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
|
|
|
SetStyleVar();
|
2022-01-12 02:53:07 +01:00
|
|
|
m_bInitialized = true;
|
2022-01-17 23:20:03 +01:00
|
|
|
m_pszConsoleTitle = pszTitle;
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
2022-01-19 19:00:40 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
//ImGui::ShowStyleEditor();
|
|
|
|
//ImGui::ShowDemoWindow();
|
|
|
|
}
|
2021-12-25 22:36:38 +01:00
|
|
|
|
2022-01-28 12:56:51 +01:00
|
|
|
/**************************
|
|
|
|
* BASE PANEL SETUP *
|
|
|
|
**************************/
|
|
|
|
{
|
2022-02-06 16:33:11 +01:00
|
|
|
static int nVars{};
|
2022-01-17 23:20:03 +01:00
|
|
|
if (!*bDraw)
|
|
|
|
{
|
|
|
|
m_bActivate = false;
|
|
|
|
return;
|
|
|
|
}
|
2022-01-28 12:56:51 +01:00
|
|
|
if (m_bDefaultTheme)
|
|
|
|
{
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2{ 8.f, 10.f });
|
2022-02-06 16:33:11 +01:00
|
|
|
nVars = 1;
|
2022-01-28 12:56:51 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2{ 4.f, 6.f });
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 1.0f);
|
2022-02-06 16:33:11 +01:00
|
|
|
nVars = 2;
|
2022-01-28 12:56:51 +01:00
|
|
|
}
|
2022-01-19 19:00:40 +01:00
|
|
|
|
2022-01-17 23:20:03 +01:00
|
|
|
ImGui::SetNextWindowSize(ImVec2(1000, 600), ImGuiCond_FirstUseEver);
|
|
|
|
ImGui::SetWindowPos(ImVec2(-1000, 50), ImGuiCond_FirstUseEver);
|
|
|
|
|
|
|
|
BasePanel(bDraw);
|
2022-01-19 19:00:40 +01:00
|
|
|
|
2022-02-06 16:33:11 +01:00
|
|
|
ImGui::PopStyleVar(nVars);
|
2022-01-17 23:20:03 +01:00
|
|
|
}
|
|
|
|
|
2022-01-28 12:56:51 +01:00
|
|
|
/**************************
|
|
|
|
* SUGGESTION PANEL SETUP *
|
|
|
|
**************************/
|
|
|
|
{
|
2022-02-06 16:33:11 +01:00
|
|
|
static int nVars{};
|
2022-01-17 23:20:03 +01:00
|
|
|
if (CanAutoComplete())
|
|
|
|
{
|
2022-01-28 12:56:51 +01:00
|
|
|
if (m_bDefaultTheme)
|
|
|
|
{
|
|
|
|
static ImGuiStyle& style = ImGui::GetStyle();
|
|
|
|
m_vecSuggestWindowPos.y = m_vecSuggestWindowPos.y + style.WindowPadding.y + 1.5f;
|
2022-02-06 16:33:11 +01:00
|
|
|
nVars = 2;
|
2022-01-28 12:56:51 +01:00
|
|
|
}
|
|
|
|
|
2022-01-19 19:00:40 +01:00
|
|
|
ImGui::SetNextWindowPos(m_vecSuggestWindowPos);
|
|
|
|
ImGui::SetNextWindowSize(m_vecSuggestWindowSize);
|
|
|
|
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 1.0f);
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(500, 37));
|
|
|
|
|
2022-01-17 23:20:03 +01:00
|
|
|
SuggestPanel();
|
2022-01-19 19:00:40 +01:00
|
|
|
|
2022-02-06 16:33:11 +01:00
|
|
|
ImGui::PopStyleVar(nVars);
|
2022-01-17 23:20:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-25 22:36:38 +01:00
|
|
|
|
2022-01-17 23:20:03 +01:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose: runs tasks for the console while not being drawn
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void CConsole::Think(void)
|
|
|
|
{
|
2022-01-22 15:51:09 +01:00
|
|
|
if (m_ivConLog.Size > con_max_size_logvector->GetInt())
|
|
|
|
{
|
|
|
|
while (m_ivConLog.Size > con_max_size_logvector->GetInt() / 4 * 3)
|
|
|
|
{
|
|
|
|
m_ivConLog.erase(m_ivConLog.begin());
|
|
|
|
m_nScrollBack++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while ((int)m_vsvHistory.size() > 512)
|
|
|
|
{
|
|
|
|
m_vsvHistory.erase(m_vsvHistory.begin());
|
|
|
|
}
|
2022-01-17 23:20:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose: draws the console's main surface
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void CConsole::BasePanel(bool* bDraw)
|
|
|
|
{
|
|
|
|
if (!ImGui::Begin(m_pszConsoleTitle, bDraw))
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
2022-01-17 23:20:03 +01:00
|
|
|
ImGui::End();
|
|
|
|
return;
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Reserve enough left-over height and width for 1 separator + 1 input text
|
|
|
|
const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
|
2022-01-17 23:20:03 +01:00
|
|
|
const float footer_width_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetWindowWidth();
|
2021-12-25 22:36:38 +01:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
ImGui::Separator();
|
|
|
|
if (ImGui::BeginPopup("Options"))
|
|
|
|
{
|
2022-01-17 23:20:03 +01:00
|
|
|
OptionsPanel();
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
|
|
|
if (ImGui::Button("Options"))
|
|
|
|
{
|
|
|
|
ImGui::OpenPopup("Options");
|
|
|
|
}
|
2022-01-12 02:53:07 +01:00
|
|
|
|
2021-12-25 22:36:38 +01:00
|
|
|
ImGui::SameLine();
|
2022-01-28 12:56:51 +01:00
|
|
|
m_itFilter.Draw("Filter | ", footer_width_to_reserve - 500);
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
ImGui::Text(m_szSummary);
|
|
|
|
|
2021-12-25 22:36:38 +01:00
|
|
|
ImGui::Separator();
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
ImGui::BeginChild("ScrollingRegion", ImVec2(0, -footer_height_to_reserve), true, ImGuiWindowFlags_AlwaysVerticalScrollbar);
|
2022-01-12 02:53:07 +01:00
|
|
|
|
|
|
|
if (m_bCopyToClipBoard) { ImGui::LogToClipboard(); }
|
|
|
|
ColorLog();
|
|
|
|
if (m_bCopyToClipBoard)
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
|
|
|
ImGui::LogToClipboard();
|
2022-01-12 02:53:07 +01:00
|
|
|
ImGui::LogFinish();
|
2021-12-25 22:36:38 +01:00
|
|
|
|
2022-01-12 02:53:07 +01:00
|
|
|
m_bCopyToClipBoard = false;
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
|
|
|
|
2022-01-22 15:51:09 +01:00
|
|
|
if (m_nScrollBack > 0)
|
|
|
|
{
|
|
|
|
ImGui::SetScrollY(ImGui::GetScrollY() - m_nScrollBack * ImGui::GetTextLineHeightWithSpacing() - m_nScrollBack - 90);
|
|
|
|
m_nScrollBack = 0;
|
|
|
|
}
|
|
|
|
|
2022-01-12 02:53:07 +01:00
|
|
|
if (m_bScrollToBottom || (m_bAutoScroll && ImGui::GetScrollY() >= ImGui::GetScrollMaxY()))
|
|
|
|
{
|
|
|
|
ImGui::SetScrollHereY(1.0f);
|
|
|
|
m_bScrollToBottom = false;
|
|
|
|
}
|
2021-12-25 22:36:38 +01:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
ImGui::EndChild();
|
|
|
|
ImGui::Separator();
|
|
|
|
|
|
|
|
ImGui::PushItemWidth(footer_width_to_reserve - 80);
|
|
|
|
if (ImGui::IsWindowAppearing()) { ImGui::SetKeyboardFocusHere(); }
|
2022-01-14 20:45:36 +01:00
|
|
|
|
2021-12-25 22:36:38 +01:00
|
|
|
if (ImGui::InputText("##input", m_szInputBuf, IM_ARRAYSIZE(m_szInputBuf), input_text_flags, &TextEditCallbackStub, (void*)this))
|
|
|
|
{
|
2022-01-17 23:20:03 +01:00
|
|
|
if (m_nSuggestPos != -1)
|
|
|
|
{
|
|
|
|
// Remove the default value from ConVar before assigning it to the input buffer.
|
|
|
|
std::string svConVar = m_vsvSuggest[m_nSuggestPos].substr(0, m_vsvSuggest[m_nSuggestPos].find(' ')) + " ";
|
|
|
|
memmove(m_szInputBuf, svConVar.c_str(), svConVar.size() + 1);
|
2021-12-25 22:36:38 +01:00
|
|
|
|
2022-01-17 23:20:03 +01:00
|
|
|
m_bSuggestActive = false;
|
|
|
|
m_nSuggestPos = -1;
|
|
|
|
m_bReclaimFocus = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-18 00:39:59 +01:00
|
|
|
if (m_szInputBuf[0])
|
|
|
|
{
|
|
|
|
ProcessCommand(m_szInputBuf);
|
|
|
|
memset(m_szInputBuf, '\0', 1);
|
|
|
|
}
|
2022-01-17 23:20:03 +01:00
|
|
|
|
|
|
|
m_bSuggestActive = false;
|
|
|
|
m_nSuggestPos = -1;
|
|
|
|
m_bReclaimFocus = true;
|
|
|
|
}
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Auto-focus on window apparition.
|
|
|
|
ImGui::SetItemDefaultFocus();
|
|
|
|
|
2022-01-17 23:20:03 +01:00
|
|
|
// Auto-focus previous widget.
|
2022-01-12 02:53:07 +01:00
|
|
|
if (m_bReclaimFocus)
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
2022-01-17 23:20:03 +01:00
|
|
|
ImGui::SetKeyboardFocusHere(-1);
|
2022-01-12 02:53:07 +01:00
|
|
|
m_bReclaimFocus = false;
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
|
|
|
|
2022-01-17 23:20:03 +01:00
|
|
|
m_vecSuggestWindowPos = ImGui::GetItemRectMin();
|
|
|
|
m_vecSuggestWindowPos.y += ImGui::GetItemRectSize().y;
|
2022-01-22 15:51:09 +01:00
|
|
|
m_vecSuggestWindowSize = ImVec2(500, std::clamp((int)m_vsvSuggest.size() * (int)ImGui::GetTextLineHeight(), 37, 122));
|
2022-01-17 23:20:03 +01:00
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
if (ImGui::Button("Submit"))
|
|
|
|
{
|
2022-01-18 00:39:59 +01:00
|
|
|
if (m_szInputBuf[0])
|
|
|
|
{
|
|
|
|
ProcessCommand(m_szInputBuf);
|
|
|
|
memset(m_szInputBuf, '\0', 1);
|
|
|
|
}
|
2022-01-17 23:20:03 +01:00
|
|
|
m_bReclaimFocus = true;
|
2022-01-19 23:12:43 +01:00
|
|
|
m_nSuggestPos = -1;
|
|
|
|
m_bSuggestActive = false;
|
2022-01-17 23:20:03 +01:00
|
|
|
}
|
2021-12-25 22:36:38 +01:00
|
|
|
ImGui::End();
|
|
|
|
}
|
|
|
|
|
2022-01-12 02:53:07 +01:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose: draws the options panel
|
|
|
|
//-----------------------------------------------------------------------------
|
2022-01-17 23:20:03 +01:00
|
|
|
void CConsole::OptionsPanel(void)
|
2022-01-12 02:53:07 +01:00
|
|
|
{
|
|
|
|
ImGui::Checkbox("Auto-Scroll", &m_bAutoScroll);
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
ImGui::PushItemWidth(100);
|
|
|
|
|
|
|
|
ImGui::PopItemWidth();
|
|
|
|
|
|
|
|
if (ImGui::SmallButton("Clear"))
|
|
|
|
{
|
|
|
|
ClearLog();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
m_bCopyToClipBoard = ImGui::SmallButton("Copy");
|
|
|
|
|
|
|
|
ImGui::Text("Console Hotkey:");
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
if (ImGui::Hotkey("##OpenIConsoleBind0", &g_pImGuiConfig->IConsole_Config.m_nBind0, ImVec2(80, 80)))
|
|
|
|
{
|
|
|
|
g_pImGuiConfig->Save();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::Text("Browser Hotkey:");
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
if (ImGui::Hotkey("##OpenIBrowserBind0", &g_pImGuiConfig->IBrowser_Config.m_nBind0, ImVec2(80, 80)))
|
|
|
|
{
|
|
|
|
g_pImGuiConfig->Save();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndPopup();
|
|
|
|
}
|
|
|
|
|
2022-01-16 00:59:20 +01:00
|
|
|
//-----------------------------------------------------------------------------
|
2022-01-17 23:20:03 +01:00
|
|
|
// Purpose: draws the suggestion panel with results based on user input
|
2022-01-16 00:59:20 +01:00
|
|
|
//-----------------------------------------------------------------------------
|
2022-01-17 23:20:03 +01:00
|
|
|
void CConsole::SuggestPanel(void)
|
2022-01-16 00:59:20 +01:00
|
|
|
{
|
2022-01-17 23:20:03 +01:00
|
|
|
ImGui::Begin("##suggest", nullptr, popup_window_flags);
|
|
|
|
ImGui::PushAllowKeyboardFocus(false);
|
|
|
|
|
|
|
|
for (int i = 0; i < m_vsvSuggest.size(); i++)
|
2022-01-16 00:59:20 +01:00
|
|
|
{
|
2022-01-17 23:20:03 +01:00
|
|
|
bool bIsIndexActive = m_nSuggestPos == i;
|
|
|
|
|
|
|
|
ImGui::PushID(i);
|
|
|
|
if (ImGui::Selectable(m_vsvSuggest[i].c_str(), bIsIndexActive))
|
2022-01-16 00:59:20 +01:00
|
|
|
{
|
2022-01-17 23:20:03 +01:00
|
|
|
ImGui::Separator();
|
|
|
|
|
|
|
|
// Remove the default value from ConVar before assigning it to the input buffer.
|
|
|
|
std::string svConVar = m_vsvSuggest[i].substr(0, m_vsvSuggest[i].find(' ')) + " ";
|
|
|
|
memmove(m_szInputBuf, svConVar.c_str(), svConVar.size() + 1);
|
|
|
|
|
|
|
|
m_bSuggestActive = false;
|
|
|
|
m_nSuggestPos = -1;
|
|
|
|
m_bReclaimFocus = true;
|
2022-01-16 00:59:20 +01:00
|
|
|
}
|
2022-01-17 23:20:03 +01:00
|
|
|
ImGui::PopID();
|
|
|
|
|
|
|
|
if (bIsIndexActive)
|
2022-01-16 00:59:20 +01:00
|
|
|
{
|
2022-01-18 11:23:14 +01:00
|
|
|
// Make sure we bring the currently 'active' item into view.
|
2022-01-17 23:20:03 +01:00
|
|
|
if (m_bSuggestMoved)
|
|
|
|
{
|
2022-01-18 11:23:14 +01:00
|
|
|
ImGuiWindow* pWindow = ImGui::GetCurrentWindow();
|
|
|
|
ImRect imRect = ImGui::GetCurrentContext()->LastItemData.Rect;
|
|
|
|
|
|
|
|
ImGui::ScrollToBringRectIntoView(pWindow, imRect);
|
2022-01-17 23:20:03 +01:00
|
|
|
m_bSuggestMoved = false;
|
|
|
|
}
|
2022-01-16 00:59:20 +01:00
|
|
|
}
|
2022-01-20 00:24:41 +01:00
|
|
|
|
|
|
|
if (m_bSuggestUpdate)
|
|
|
|
{
|
|
|
|
ImGui::SetScrollHereY(0.f);
|
|
|
|
m_bSuggestUpdate = false;
|
|
|
|
}
|
2022-01-16 00:59:20 +01:00
|
|
|
}
|
2022-01-17 23:20:03 +01:00
|
|
|
|
|
|
|
ImGui::PopAllowKeyboardFocus();
|
|
|
|
ImGui::End();
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2022-02-13 15:16:09 +01:00
|
|
|
// Purpose: checks if the console can autocomplete based on input
|
2022-01-17 23:20:03 +01:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
bool CConsole::CanAutoComplete(void)
|
|
|
|
{
|
|
|
|
// Show ConVar/ConCommand suggestions when at least 2 characters have been entered.
|
|
|
|
if (strlen(m_szInputBuf) > 1)
|
|
|
|
{
|
|
|
|
// Update suggestions if input buffer changed.
|
|
|
|
if (strcmp(m_szInputBuf, m_szInputBufOld) != 0)
|
|
|
|
{
|
|
|
|
memmove(m_szInputBufOld, m_szInputBuf, strlen(m_szInputBuf) + 1);
|
|
|
|
FindFromPartial();
|
|
|
|
}
|
|
|
|
if ((int)m_vsvSuggest.size() <= 0)
|
|
|
|
{
|
|
|
|
m_nSuggestPos = -1;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_nSuggestPos = -1;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Don't suggest if user tries to assign value to ConVar or execute ConCommand.
|
|
|
|
if (strstr(m_szInputBuf, " ") || strstr(m_szInputBuf, ";"))
|
|
|
|
{
|
|
|
|
m_bSuggestActive = false;
|
|
|
|
m_nSuggestPos = -1;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
m_bSuggestActive = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose: find ConVars/ConCommands from user input and add to vector
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void CConsole::FindFromPartial(void)
|
|
|
|
{
|
2022-01-18 11:23:14 +01:00
|
|
|
m_nSuggestPos = -1;
|
2022-01-20 00:24:41 +01:00
|
|
|
m_bSuggestUpdate = true;
|
2022-01-17 23:20:03 +01:00
|
|
|
m_vsvSuggest.clear();
|
2022-01-18 11:23:14 +01:00
|
|
|
|
2022-01-17 23:20:03 +01:00
|
|
|
for (int i = 0; i < g_vsvAllConVars.size(); i++)
|
|
|
|
{
|
|
|
|
if (m_vsvSuggest.size() < con_suggestion_limit->GetInt())
|
|
|
|
{
|
|
|
|
if (g_vsvAllConVars[i].find(m_szInputBuf) != std::string::npos)
|
|
|
|
{
|
2022-01-20 14:18:19 +01:00
|
|
|
if (std::find(m_vsvSuggest.begin(), m_vsvSuggest.end(), g_vsvAllConVars[i]) == m_vsvSuggest.end())
|
2022-01-17 23:20:03 +01:00
|
|
|
{
|
|
|
|
std::string svValue;
|
|
|
|
ConVar* pConVar = g_pCVar->FindVar(g_vsvAllConVars[i].c_str());
|
|
|
|
if (pConVar != nullptr)
|
|
|
|
{
|
2022-01-18 02:21:40 +01:00
|
|
|
svValue = "= \""; // Assign default value to string if its a ConVar.
|
|
|
|
svValue.append(g_pCVar->FindVar(g_vsvAllConVars[i].c_str())->GetString());
|
|
|
|
svValue.append("\"");
|
2022-01-19 19:00:40 +01:00
|
|
|
|
|
|
|
if (con_suggestion_helptext->GetBool())
|
|
|
|
{
|
|
|
|
std::string svHelpText = g_pCVar->FindVar(g_vsvAllConVars[i].c_str())->GetHelpText();
|
|
|
|
|
|
|
|
if (!svHelpText.empty())
|
|
|
|
{
|
|
|
|
svValue.append(" [" + svHelpText + "]");
|
|
|
|
}
|
|
|
|
}
|
2022-01-17 23:20:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
m_vsvSuggest.push_back(g_vsvAllConVars[i] + " " + svValue + "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else { break; }
|
|
|
|
}
|
2022-01-16 00:59:20 +01:00
|
|
|
}
|
|
|
|
|
2021-12-25 22:36:38 +01:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose: executes submitted commands in a separate thread
|
|
|
|
//-----------------------------------------------------------------------------
|
2022-01-14 20:45:36 +01:00
|
|
|
void CConsole::ProcessCommand(const char* pszCommand)
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
2022-01-14 20:45:36 +01:00
|
|
|
AddLog("# %s\n", pszCommand);
|
2021-12-25 22:36:38 +01:00
|
|
|
|
2022-01-14 20:45:36 +01:00
|
|
|
std::thread t(IVEngineClient_CommandExecute, this, pszCommand);
|
2021-12-25 22:36:38 +01:00
|
|
|
t.detach(); // Detach from render thread.
|
|
|
|
|
|
|
|
// This is to avoid a race condition.
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
|
|
|
|
|
|
|
m_nHistoryPos = -1;
|
2022-01-17 23:20:03 +01:00
|
|
|
for (int i = (int)m_vsvHistory.size() - 1; i >= 0; i--)
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
2022-01-17 23:20:03 +01:00
|
|
|
if (Stricmp(m_vsvHistory[i].c_str(), pszCommand) == 0)
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
2022-01-17 23:20:03 +01:00
|
|
|
m_vsvHistory.erase(m_vsvHistory.begin() + i);
|
2021-12-25 22:36:38 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-17 23:20:03 +01:00
|
|
|
m_vsvHistory.push_back(Strdup(pszCommand));
|
2022-01-14 20:45:36 +01:00
|
|
|
if (Stricmp(pszCommand, "CLEAR") == 0)
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
|
|
|
ClearLog();
|
|
|
|
}
|
2022-01-14 20:45:36 +01:00
|
|
|
else if (Stricmp(pszCommand, "HELP") == 0)
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
2022-01-12 02:53:07 +01:00
|
|
|
AddLog("Commands:");
|
2022-01-17 23:20:03 +01:00
|
|
|
for (int i = 0; i < (int)m_vsvCommands.size(); i++)
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
2022-01-17 23:20:03 +01:00
|
|
|
AddLog("- %s", m_vsvCommands[i].c_str());
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
AddLog("Log types:");
|
2022-01-12 02:53:07 +01:00
|
|
|
AddLog("Script(S): = Server DLL (Script VM)");
|
|
|
|
AddLog("Script(C): = Client DLL (Script VM)");
|
|
|
|
AddLog("Script(U): = UI DLL (Script VM)");
|
|
|
|
|
|
|
|
AddLog("Native(S): = Server DLL (Code)");
|
|
|
|
AddLog("Native(C): = Client DLL (Code)");
|
|
|
|
AddLog("Native(U): = UI DLL (Code)");
|
|
|
|
|
|
|
|
AddLog("Native(E): = Engine DLL (Code)");
|
|
|
|
AddLog("Native(F): = FileSys DLL (Code)");
|
|
|
|
AddLog("Native(R): = RTech DLL (Code)");
|
|
|
|
AddLog("Native(M): = MatSys DLL (Code)");
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
2022-01-14 20:45:36 +01:00
|
|
|
else if (Stricmp(pszCommand, "HISTORY") == 0)
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
2022-01-17 23:20:03 +01:00
|
|
|
int nFirst = (int)m_vsvHistory.size() - 10;
|
|
|
|
for (int i = nFirst > 0 ? nFirst : 0; i < (int)m_vsvHistory.size(); i++)
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
2022-01-18 02:10:54 +01:00
|
|
|
AddLog("%3d: %s\n", i, m_vsvHistory[i].c_str());
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_bScrollToBottom = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2022-01-17 23:20:03 +01:00
|
|
|
// Purpose: console input box callback
|
2021-12-25 22:36:38 +01:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
int CConsole::TextEditCallback(ImGuiInputTextCallbackData* data)
|
|
|
|
{
|
|
|
|
switch (data->EventFlag)
|
|
|
|
{
|
|
|
|
case ImGuiInputTextFlags_CallbackCompletion:
|
|
|
|
{
|
|
|
|
// Locate beginning of current word.
|
2022-01-14 20:45:36 +01:00
|
|
|
const char* pszWordEnd = data->Buf + data->CursorPos;
|
|
|
|
const char* pszWordStart = pszWordEnd;
|
|
|
|
while (pszWordStart > data->Buf)
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
2022-01-14 20:45:36 +01:00
|
|
|
const char c = pszWordStart[-1];
|
2021-12-25 22:36:38 +01:00
|
|
|
if (c == ' ' || c == '\t' || c == ',' || c == ';')
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2022-01-14 20:45:36 +01:00
|
|
|
pszWordStart--;
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ImGuiInputTextFlags_CallbackHistory:
|
|
|
|
{
|
2022-01-17 23:20:03 +01:00
|
|
|
if (m_bSuggestActive)
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
2022-01-17 23:20:03 +01:00
|
|
|
if (data->EventKey == ImGuiKey_UpArrow && m_nSuggestPos > - 1)
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
2022-01-17 23:20:03 +01:00
|
|
|
m_nSuggestPos--;
|
|
|
|
m_bSuggestMoved = true;
|
|
|
|
}
|
|
|
|
else if (data->EventKey == ImGuiKey_DownArrow)
|
|
|
|
{
|
|
|
|
if (m_nSuggestPos < (int)m_vsvSuggest.size() - 1)
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
2022-01-17 23:20:03 +01:00
|
|
|
m_nSuggestPos++;
|
|
|
|
m_bSuggestMoved = true;
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-01-17 23:20:03 +01:00
|
|
|
else // Allow user to navigate through the history if suggest isn't drawn.
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
2022-01-17 23:20:03 +01:00
|
|
|
const int nPrevHistoryPos = m_nHistoryPos;
|
|
|
|
if (data->EventKey == ImGuiKey_UpArrow)
|
|
|
|
{
|
|
|
|
if (m_nHistoryPos == -1)
|
|
|
|
{
|
|
|
|
m_nHistoryPos = (int)m_vsvHistory.size() - 1;
|
|
|
|
}
|
|
|
|
else if (m_nHistoryPos > 0)
|
|
|
|
{
|
|
|
|
m_nHistoryPos--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (data->EventKey == ImGuiKey_DownArrow)
|
|
|
|
{
|
|
|
|
if (m_nHistoryPos != -1)
|
|
|
|
{
|
|
|
|
if (++m_nHistoryPos >= (int)m_vsvHistory.size())
|
|
|
|
{
|
|
|
|
m_nHistoryPos = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (nPrevHistoryPos != m_nHistoryPos)
|
|
|
|
{
|
|
|
|
std::string svHistory = (m_nHistoryPos >= 0) ? m_vsvHistory[m_nHistoryPos] : "";
|
|
|
|
|
|
|
|
if (!svHistory.empty())
|
|
|
|
{
|
|
|
|
if (!strstr(m_vsvHistory[m_nHistoryPos].c_str(), " "))
|
|
|
|
{
|
|
|
|
// Append whitespace to previous entered command if absent or no parameters where passed.
|
|
|
|
svHistory.append(" ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
data->DeleteChars(0, data->BufTextLen);
|
|
|
|
data->InsertChars(0, svHistory.c_str());
|
|
|
|
}
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
2022-01-17 23:20:03 +01:00
|
|
|
break;
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
2022-01-28 12:56:51 +01:00
|
|
|
case ImGuiInputTextFlags_CallbackAlways:
|
|
|
|
{
|
|
|
|
char szValue[256]{};
|
|
|
|
sprintf_s(szValue, 256, "%s", m_szInputBuf);
|
|
|
|
|
|
|
|
// Remove space or semicolon before we call 'g_pCVar->FindVar(..)'.
|
|
|
|
for (int i = 0; i < strlen(szValue); i++)
|
|
|
|
{
|
|
|
|
if (szValue[i] == ' ' || szValue[i] == ';')
|
|
|
|
{
|
|
|
|
szValue[i] = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ConVar* pConVar = g_pCVar->FindVar(szValue);
|
|
|
|
if (pConVar != nullptr)
|
|
|
|
{
|
|
|
|
// Display the current and default value of ConVar if found.
|
|
|
|
snprintf(m_szSummary, 256, "(\"%s\", default \"%s\")", pConVar->GetString(), pConVar->GetDefault());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Display amount of history items if ConVar cannot be found.
|
|
|
|
snprintf(m_szSummary, 256, "%llu history items", m_vsvHistory.size());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-01-12 02:53:07 +01:00
|
|
|
//-----------------------------------------------------------------------------
|
2022-01-17 23:20:03 +01:00
|
|
|
// Purpose: console input box callback stub
|
2022-01-12 02:53:07 +01:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
int CConsole::TextEditCallbackStub(ImGuiInputTextCallbackData* data)
|
|
|
|
{
|
2022-01-14 20:45:36 +01:00
|
|
|
CConsole* pConsole = (CConsole*)data->UserData;
|
|
|
|
return pConsole->TextEditCallback(data);
|
2022-01-12 02:53:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose: adds logs to the vector
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void CConsole::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);
|
|
|
|
m_ivConLog.push_back(Strdup(buf));
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose: clears the entire vector
|
|
|
|
//-----------------------------------------------------------------------------
|
2022-01-17 23:20:03 +01:00
|
|
|
void CConsole::ClearLog(void)
|
2022-01-12 02:53:07 +01:00
|
|
|
{
|
|
|
|
for (int i = 0; i < m_ivConLog.Size; i++) { free(m_ivConLog[i]); }
|
|
|
|
m_ivConLog.clear();
|
|
|
|
}
|
2021-12-25 22:36:38 +01:00
|
|
|
|
2022-01-12 02:53:07 +01:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose: colors important logs
|
|
|
|
//-----------------------------------------------------------------------------
|
2022-01-17 23:20:03 +01:00
|
|
|
void CConsole::ColorLog(void)
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
2022-01-12 02:53:07 +01:00
|
|
|
for (int i = 0; i < m_ivConLog.Size; i++)
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
2022-01-14 20:45:36 +01:00
|
|
|
const char* pszConLog = m_ivConLog[i];
|
|
|
|
if (!m_itFilter.PassFilter(pszConLog))
|
2022-01-12 02:53:07 +01:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
2022-01-14 20:45:36 +01:00
|
|
|
ImVec4 imColor;
|
2022-01-12 02:53:07 +01:00
|
|
|
|
|
|
|
// General
|
2022-01-18 00:39:59 +01:00
|
|
|
if (strstr(pszConLog, "")) { imColor = ImVec4(0.81f, 0.81f, 0.81f, 1.00f); true; }
|
2022-01-14 20:45:36 +01:00
|
|
|
if (strstr(pszConLog, "[INFO]")) { imColor = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); true; }
|
|
|
|
if (strstr(pszConLog, "[ERROR]")) { imColor = ImVec4(1.00f, 0.00f, 0.00f, 1.00f); true; }
|
|
|
|
if (strstr(pszConLog, "[DEBUG]")) { imColor = ImVec4(0.00f, 0.30f, 1.00f, 1.00f); true; }
|
|
|
|
if (strstr(pszConLog, "[WARNING]")) { imColor = ImVec4(1.00f, 1.00f, 0.00f, 0.80f); true; }
|
|
|
|
if (strncmp(pszConLog, "# ", 2) == 0) { imColor = ImVec4(1.00f, 0.80f, 0.60f, 1.00f); true; }
|
2022-01-12 02:53:07 +01:00
|
|
|
|
|
|
|
// Script virtual machines per game dll
|
2022-01-14 20:45:36 +01:00
|
|
|
if (strstr(pszConLog, "Script(S):")) { imColor = ImVec4(0.59f, 0.58f, 0.73f, 1.00f); true; }
|
|
|
|
if (strstr(pszConLog, "Script(C):")) { imColor = ImVec4(0.59f, 0.58f, 0.63f, 1.00f); true; }
|
|
|
|
if (strstr(pszConLog, "Script(U):")) { imColor = ImVec4(0.59f, 0.48f, 0.53f, 1.00f); true; }
|
|
|
|
if (strstr(pszConLog, "Script(X):")) { imColor = ImVec4(0.59f, 0.58f, 0.63f, 1.00f); true; }
|
2022-01-12 02:53:07 +01:00
|
|
|
|
|
|
|
// Native per game dll
|
2022-01-22 15:51:09 +01:00
|
|
|
if (strstr(pszConLog, "Native(S):")) { imColor = ImVec4(0.23f, 0.47f, 0.85f, 1.00f); true; }
|
|
|
|
if (strstr(pszConLog, "Native(C):")) { imColor = ImVec4(0.46f, 0.46f, 0.46f, 1.00f); true; }
|
|
|
|
if (strstr(pszConLog, "Native(U):")) { imColor = ImVec4(0.59f, 0.35f, 0.46f, 1.00f); true; }
|
2022-01-12 02:53:07 +01:00
|
|
|
|
|
|
|
// Native per sys dll
|
2022-01-14 20:45:36 +01:00
|
|
|
if (strstr(pszConLog, "Native(E):")) { imColor = ImVec4(0.70f, 0.70f, 0.70f, 1.00f); true; }
|
|
|
|
if (strstr(pszConLog, "Native(F):")) { imColor = ImVec4(0.32f, 0.64f, 0.72f, 1.00f); true; }
|
|
|
|
if (strstr(pszConLog, "Native(R):")) { imColor = ImVec4(0.36f, 0.70f, 0.35f, 1.00f); true; }
|
|
|
|
if (strstr(pszConLog, "Native(M):")) { imColor = ImVec4(0.75f, 0.41f, 0.67f, 1.00f); true; }
|
2022-01-12 02:53:07 +01:00
|
|
|
|
|
|
|
// Callbacks
|
|
|
|
//if (strstr(item, "CodeCallback_")) { color = ImVec4(0.00f, 0.30f, 1.00f, 1.00f); has_color = true; }
|
|
|
|
|
|
|
|
// Squirrel VM script errors
|
2022-01-14 20:45:36 +01:00
|
|
|
if (strstr(pszConLog, ".gnut")) { imColor = ImVec4(1.00f, 1.00f, 1.00f, 0.60f); true; }
|
|
|
|
if (strstr(pszConLog, ".nut")) { imColor = ImVec4(1.00f, 1.00f, 1.00f, 0.60f); true; }
|
|
|
|
if (strstr(pszConLog, "[CLIENT]")) { imColor = ImVec4(1.00f, 0.00f, 0.00f, 1.00f); true; }
|
|
|
|
if (strstr(pszConLog, "[SERVER]")) { imColor = ImVec4(1.00f, 0.00f, 0.00f, 1.00f); true; }
|
|
|
|
if (strstr(pszConLog, "[UI]")) { imColor = ImVec4(1.00f, 0.00f, 0.00f, 1.00f); true; }
|
|
|
|
if (strstr(pszConLog, "SCRIPT ERROR")) { imColor = ImVec4(1.00f, 0.00f, 0.00f, 1.00f); true; }
|
|
|
|
if (strstr(pszConLog, "SCRIPT COMPILE")) { imColor = ImVec4(1.00f, 0.00f, 0.00f, 1.00f); true; }
|
|
|
|
if (strstr(pszConLog, ".gnut #")) { imColor = ImVec4(1.00f, 0.00f, 0.00f, 1.00f); true; }
|
|
|
|
if (strstr(pszConLog, ".nut #")) { imColor = ImVec4(1.00f, 0.00f, 0.00f, 1.00f); true; }
|
|
|
|
if (strstr(pszConLog, "): -> ")) { imColor = ImVec4(1.00f, 0.00f, 0.00f, 1.00f); true; }
|
2022-01-22 15:51:09 +01:00
|
|
|
if (strstr(pszConLog, "):Warning:")) { imColor = ImVec4(1.00f, 1.00f, 0.00f, 1.00f); true; }
|
2022-01-12 02:53:07 +01:00
|
|
|
|
|
|
|
// Squirrel VM script debug
|
2022-01-14 20:45:36 +01:00
|
|
|
if (strstr(pszConLog, "CALLSTACK")) { imColor = ImVec4(1.00f, 1.00f, 0.00f, 0.80f); true; }
|
|
|
|
if (strstr(pszConLog, "LOCALS")) { imColor = ImVec4(1.00f, 1.00f, 0.00f, 0.80f); true; }
|
|
|
|
if (strstr(pszConLog, "*FUNCTION")) { imColor = ImVec4(1.00f, 1.00f, 0.00f, 0.80f); true; }
|
|
|
|
if (strstr(pszConLog, "DIAGPRINTS")) { imColor = ImVec4(1.00f, 1.00f, 0.00f, 0.80f); true; }
|
|
|
|
if (strstr(pszConLog, " File : ")) { imColor = ImVec4(0.00f, 0.30f, 1.00f, 1.00f); true; }
|
|
|
|
if (strstr(pszConLog, "<><>GRX<><>")) { imColor = ImVec4(0.00f, 0.30f, 1.00f, 1.00f); true; }
|
2022-01-12 02:53:07 +01:00
|
|
|
|
|
|
|
// Filters
|
|
|
|
//if (strstr(item, ") -> ")) { color = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); has_color = true; }
|
|
|
|
|
2022-01-14 20:45:36 +01:00
|
|
|
ImGui::PushStyleColor(ImGuiCol_Text, imColor);
|
|
|
|
ImGui::TextWrapped(pszConLog);
|
|
|
|
ImGui::PopStyleColor();
|
2022-01-12 02:53:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose: sets the console front-end style
|
|
|
|
//-----------------------------------------------------------------------------
|
2022-01-17 23:20:03 +01:00
|
|
|
void CConsole::SetStyleVar(void)
|
2022-01-12 02:53:07 +01:00
|
|
|
{
|
2022-01-18 11:23:14 +01:00
|
|
|
ImGuiStyle& style = ImGui::GetStyle();
|
|
|
|
ImVec4* colors = style.Colors;
|
|
|
|
|
|
|
|
if (!g_pCmdLine->CheckParm("-imgui_default_theme"))
|
|
|
|
{
|
|
|
|
|
|
|
|
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);
|
2022-01-28 12:56:51 +01:00
|
|
|
|
|
|
|
style.WindowBorderSize = 0.0f;
|
|
|
|
style.FrameBorderSize = 1.0f;
|
|
|
|
style.ChildBorderSize = 1.0f;
|
|
|
|
style.PopupBorderSize = 1.0f;
|
|
|
|
style.TabBorderSize = 1.0f;
|
|
|
|
|
|
|
|
style.WindowRounding = 4.0f;
|
|
|
|
style.FrameRounding = 1.0f;
|
|
|
|
style.ChildRounding = 1.0f;
|
|
|
|
style.PopupRounding = 3.0f;
|
|
|
|
style.TabRounding = 1.0f;
|
|
|
|
style.ScrollbarRounding = 1.0f;
|
2022-01-18 11:23:14 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-28 12:56:51 +01:00
|
|
|
colors[ImGuiCol_WindowBg] = ImVec4(0.11f, 0.13f, 0.17f, 1.00f);
|
|
|
|
colors[ImGuiCol_ChildBg] = ImVec4(0.02f, 0.04f, 0.06f, 1.00f);
|
|
|
|
colors[ImGuiCol_PopupBg] = ImVec4(0.11f, 0.13f, 0.17f, 1.00f);
|
|
|
|
colors[ImGuiCol_Border] = ImVec4(0.41f, 0.41f, 0.41f, 0.50f);
|
|
|
|
colors[ImGuiCol_BorderShadow] = ImVec4(0.04f, 0.04f, 0.04f, 0.00f);
|
|
|
|
colors[ImGuiCol_FrameBg] = ImVec4(0.02f, 0.04f, 0.06f, 1.00f);
|
|
|
|
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.04f, 0.06f, 0.10f, 1.00f);
|
|
|
|
colors[ImGuiCol_FrameBgActive] = ImVec4(0.04f, 0.07f, 0.12f, 1.00f);
|
|
|
|
colors[ImGuiCol_TitleBg] = ImVec4(0.26f, 0.51f, 0.78f, 1.00f);
|
|
|
|
colors[ImGuiCol_TitleBgActive] = ImVec4(0.26f, 0.51f, 0.78f, 1.00f);
|
|
|
|
colors[ImGuiCol_MenuBarBg] = ImVec4(0.11f, 0.13f, 0.17f, 1.00f);
|
|
|
|
colors[ImGuiCol_ScrollbarBg] = ImVec4(0.14f, 0.19f, 0.24f, 1.00f);
|
|
|
|
colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.23f, 0.36f, 0.51f, 1.00f);
|
|
|
|
colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.30f, 0.46f, 0.65f, 1.00f);
|
|
|
|
colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.31f, 0.49f, 0.69f, 1.00f);
|
|
|
|
colors[ImGuiCol_SliderGrab] = ImVec4(0.31f, 0.43f, 0.43f, 1.00f);
|
|
|
|
colors[ImGuiCol_SliderGrabActive] = ImVec4(0.41f, 0.56f, 0.57f, 1.00f);
|
|
|
|
colors[ImGuiCol_Button] = ImVec4(0.31f, 0.43f, 0.43f, 1.00f);
|
|
|
|
colors[ImGuiCol_ButtonHovered] = ImVec4(0.38f, 0.52f, 0.53f, 1.00f);
|
|
|
|
colors[ImGuiCol_ButtonActive] = ImVec4(0.41f, 0.56f, 0.57f, 1.00f);
|
|
|
|
colors[ImGuiCol_Header] = ImVec4(0.31f, 0.43f, 0.43f, 1.00f);
|
|
|
|
colors[ImGuiCol_HeaderHovered] = ImVec4(0.38f, 0.53f, 0.53f, 1.00f);
|
|
|
|
colors[ImGuiCol_HeaderActive] = ImVec4(0.41f, 0.56f, 0.57f, 1.00f);
|
|
|
|
colors[ImGuiCol_Separator] = ImVec4(0.53f, 0.53f, 0.57f, 0.00f);
|
|
|
|
colors[ImGuiCol_ResizeGrip] = ImVec4(0.41f, 0.41f, 0.41f, 0.50f);
|
|
|
|
colors[ImGuiCol_Tab] = ImVec4(0.31f, 0.43f, 0.43f, 1.00f);
|
|
|
|
colors[ImGuiCol_TabHovered] = ImVec4(0.38f, 0.53f, 0.53f, 1.00f);
|
|
|
|
colors[ImGuiCol_TabActive] = ImVec4(0.41f, 0.56f, 0.57f, 1.00f);
|
|
|
|
colors[ImGuiCol_TableHeaderBg] = ImVec4(0.14f, 0.19f, 0.24f, 1.00f);
|
|
|
|
colors[ImGuiCol_TableBorderStrong] = ImVec4(0.20f, 0.26f, 0.33f, 1.00f);
|
|
|
|
colors[ImGuiCol_TableBorderLight] = ImVec4(0.22f, 0.29f, 0.37f, 1.00f);
|
|
|
|
|
|
|
|
style.WindowBorderSize = 1.0f;
|
|
|
|
style.FrameBorderSize = 0.0f;
|
|
|
|
style.ChildBorderSize = 0.0f;
|
|
|
|
style.PopupBorderSize = 1.0f;
|
|
|
|
style.TabBorderSize = 1.0f;
|
|
|
|
|
|
|
|
style.WindowRounding = 4.0f;
|
|
|
|
style.FrameRounding = 1.0f;
|
|
|
|
style.ChildRounding = 1.0f;
|
|
|
|
style.PopupRounding = 3.0f;
|
|
|
|
style.TabRounding = 1.0f;
|
|
|
|
style.ScrollbarRounding = 3.0f;
|
|
|
|
|
|
|
|
m_bDefaultTheme = true;
|
2022-01-18 11:23:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
style.ItemSpacing = ImVec2(4, 4);
|
2022-01-22 15:51:09 +01:00
|
|
|
style.FramePadding = ImVec2(4, 4);
|
2022-01-18 11:23:14 +01:00
|
|
|
style.WindowPadding = ImVec2(5, 5);
|
2022-01-19 19:00:40 +01:00
|
|
|
style.WindowMinSize = ImVec2(518, 518);
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
|
|
|
|
2022-01-12 02:53:07 +01:00
|
|
|
CConsole* g_pIConsole = new CConsole();
|