Add CVar listeners for Debug menu

This commit is contained in:
Phillip Stephens 2021-05-30 18:23:20 -07:00
parent 6fb78f1add
commit 45097955a7
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
2 changed files with 22 additions and 2 deletions

View File

@ -1090,6 +1090,24 @@ void ImGuiConsole::ShowAppMainMenuBar(bool canInspect) {
} }
void ImGuiConsole::PreUpdate() { void ImGuiConsole::PreUpdate() {
if (!m_isInitialized) {
m_isInitialized = true;
m_cvarCommons.m_debugOverlayShowFrameCounter->addListener(
[this](hecl::CVar* c) { m_frameCounter = c->toBoolean(); });
m_cvarCommons.m_debugOverlayShowFramerate->addListener([this](hecl::CVar* c) { m_frameRate = c->toBoolean(); });
m_cvarCommons.m_debugOverlayShowInGameTime->addListener([this](hecl::CVar* c) { m_inGameTime = c->toBoolean(); });
m_cvarCommons.m_debugOverlayShowRoomTimer->addListener([this](hecl::CVar* c) { m_roomTimer = c->toBoolean(); });
m_cvarCommons.m_debugOverlayPlayerInfo->addListener([this](hecl::CVar* c) { m_playerInfo = c->toBoolean(); });
m_cvarCommons.m_debugOverlayWorldInfo->addListener([this](hecl::CVar* c) { m_worldInfo = c->toBoolean(); });
m_cvarCommons.m_debugOverlayAreaInfo->addListener([this](hecl::CVar* c) { m_areaInfo = c->toBoolean(); });
m_cvarCommons.m_debugOverlayLayerInfo->addListener([this](hecl::CVar* c) { m_layerInfo = c->toBoolean(); });
m_cvarCommons.m_debugOverlayShowRandomStats->addListener([this](hecl::CVar* c) { m_randomStats = c->toBoolean(); });
m_cvarCommons.m_debugOverlayShowResourceStats->addListener(
[this](hecl::CVar* c) { m_resourceStats = c->toBoolean(); });
m_cvarCommons.m_debugOverlayShowInput->addListener([this](hecl::CVar* c) { m_showInput = c->toBoolean(); });
m_cvarMgr.findCVar("developer")->addListener([this](hecl::CVar* c) { m_developer = c->toBoolean(); });
m_cvarMgr.findCVar("cheats")->addListener([this](hecl::CVar* c) { m_cheats = c->toBoolean(); });
}
// We ned to make sure we have a valid CRandom16 at all times, so lets do that here // We ned to make sure we have a valid CRandom16 at all times, so lets do that here
if (g_StateManager != nullptr && g_StateManager->GetActiveRandom() == nullptr) { if (g_StateManager != nullptr && g_StateManager->GetActiveRandom() == nullptr) {
g_StateManager->SetActiveRandomToDefault(); g_StateManager->SetActiveRandomToDefault();

View File

@ -60,6 +60,7 @@ private:
bool m_inspectActiveOnly = false; bool m_inspectActiveOnly = false;
bool m_inspectCurrentAreaOnly = false; bool m_inspectCurrentAreaOnly = false;
std::array<char, 40> m_inspectFilterText{}; std::array<char, 40> m_inspectFilterText{};
std::array<char, 40> m_layersFilterText{}; std::array<char, 40> m_layersFilterText{};
std::array<char, 40> m_cvarFiltersText{}; std::array<char, 40> m_cvarFiltersText{};
@ -76,8 +77,9 @@ private:
bool m_randomStats = m_cvarCommons.m_debugOverlayShowRandomStats->toBoolean(); bool m_randomStats = m_cvarCommons.m_debugOverlayShowRandomStats->toBoolean();
bool m_resourceStats = m_cvarCommons.m_debugOverlayShowResourceStats->toBoolean(); bool m_resourceStats = m_cvarCommons.m_debugOverlayShowResourceStats->toBoolean();
bool m_showInput = m_cvarCommons.m_debugOverlayShowInput->toBoolean(); bool m_showInput = m_cvarCommons.m_debugOverlayShowInput->toBoolean();
const bool m_developer = m_cvarMgr.findCVar("developer")->toBoolean(); bool m_developer = m_cvarMgr.findCVar("developer")->toBoolean();
const bool m_cheats = m_cvarMgr.findCVar("cheats")->toBoolean(); bool m_cheats = m_cvarMgr.findCVar("cheats")->toBoolean();
bool m_isInitialized = false;
int m_debugOverlayCorner = 2; // bottom-left int m_debugOverlayCorner = 2; // bottom-left
const void* m_currentRoom = nullptr; const void* m_currentRoom = nullptr;