From 2dec198afc10773837a0c0234ddf3e71d4bf5515 Mon Sep 17 00:00:00 2001 From: UncraftedName Date: Sun, 15 Sep 2024 21:59:16 -0700 Subject: [PATCH] Add miscellaneous HUD features to the imgui hud tab --- spt/features/ent_props.cpp | 7 ++++++- spt/features/saveloads.cpp | 8 +++++++- spt/features/shadow.cpp | 6 +++++- spt/features/tas.cpp | 6 +++++- spt/features/tracing.cpp | 6 +++++- spt/features/visualizations/oob_ents.cpp | 5 ++++- 6 files changed, 32 insertions(+), 6 deletions(-) diff --git a/spt/features/ent_props.cpp b/spt/features/ent_props.cpp index 490f6066f..0a90a3a66 100644 --- a/spt/features/ent_props.cpp +++ b/spt/features/ent_props.cpp @@ -10,6 +10,8 @@ #include "string_utils.hpp" #include "spt\utils\portal_utils.hpp" #include "SPTLib\patterns.hpp" +#include "visualizations/imgui/imgui_interface.hpp" + #include #include @@ -445,7 +447,7 @@ void EntProps::LoadFeature() #if defined(SPT_HUD_ENABLED) && defined(SPT_PORTAL_UTILS) if (utils::DoesGameLookLikePortal()) { - AddHudCallback( + bool hudEnabled = AddHudCallback( "portal_bubble", [this](std::string) { @@ -453,6 +455,9 @@ void EntProps::LoadFeature() spt_hud_feat.DrawTopHudElement(L"portal bubble: %d", in_bubble); }, y_spt_hud_portal_bubble); + + if (hudEnabled) + SptImGui::RegisterHudCvarCheckbox(y_spt_hud_portal_bubble); } #endif diff --git a/spt/features/saveloads.cpp b/spt/features/saveloads.cpp index 80bb563d8..7ad06bf5c 100644 --- a/spt/features/saveloads.cpp +++ b/spt/features/saveloads.cpp @@ -4,6 +4,9 @@ #include "signals.hpp" #include "convar.hpp" #include "..\features\afterticks.hpp" +#include "spt\features\hud.hpp" +#include "visualizations/imgui/imgui_interface.hpp" + #include static std::vector _saveloadTypes = {"segment", "execute", "render"}; @@ -134,7 +137,7 @@ void SaveloadsFeature::LoadFeature() InitCommand(y_spt_saveloads_stop); #ifdef SPT_HUD_ENABLED - AddHudCallback( + bool hudEnabled = AddHudCallback( "saveloads_showcurindex", [this](std::string) { @@ -147,6 +150,9 @@ void SaveloadsFeature::LoadFeature() spt_hud_feat.DrawTopHudElement(L"SAVELOADS: Not executing"); }, y_spt_hud_saveloads_showcurindex); + + if (hudEnabled) + SptImGui::RegisterHudCvarCheckbox(y_spt_hud_saveloads_showcurindex); #endif SetSignonStateSignal.Connect(this, &SaveloadsFeature::OnSetSignonState); diff --git a/spt/features/shadow.cpp b/spt/features/shadow.cpp index 19a21be7b..8b0ae61be 100644 --- a/spt/features/shadow.cpp +++ b/spt/features/shadow.cpp @@ -6,6 +6,7 @@ #include "ent_utils.hpp" #include "ent_props.hpp" #include "playerio.hpp" +#include "visualizations/imgui/imgui_interface.hpp" ConVar y_spt_hud_shadow_info("y_spt_hud_shadow_info", "0", @@ -73,7 +74,7 @@ void ShadowPosition::LoadFeature() if (ORIG_GetShadowPosition) { #ifdef SPT_HUD_ENABLED - AddHudCallback( + bool hudEnabled = AddHudCallback( "shadow_info", [this](std::string) { @@ -83,6 +84,9 @@ void ShadowPosition::LoadFeature() spt_hud_feat.DrawTopHudElement(L"shadow ang (pyr): %.3f %.3f %.3f", ang.x, ang.y, ang.z); }, y_spt_hud_shadow_info); + + if (hudEnabled) + SptImGui::RegisterHudCvarCheckbox(y_spt_hud_shadow_info); #endif } diff --git a/spt/features/tas.cpp b/spt/features/tas.cpp index f616c2e74..146a37fad 100644 --- a/spt/features/tas.cpp +++ b/spt/features/tas.cpp @@ -12,6 +12,7 @@ #include "interfaces.hpp" #include "tracing.hpp" #include "signals.hpp" +#include "visualizations/imgui/imgui_interface.hpp" ConVar tas_strafe("tas_strafe", "0", FCVAR_TAS_RESET); ConVar tas_strafe_type( @@ -309,7 +310,7 @@ void TASFeature::LoadFeature() AfterFramesSignal.Connect(&scripts::g_TASReader, &scripts::SourceTASReader::OnAfterFrames); #ifdef SPT_HUD_ENABLED - AddHudCallback( + bool hudEnabled = AddHudCallback( "script_progress", [this](std::string) { @@ -318,6 +319,9 @@ void TASFeature::LoadFeature() scripts::g_TASReader.GetCurrentScriptLength()); }, y_spt_hud_script_progress); + + if (hudEnabled) + SptImGui::RegisterHudCvarCheckbox(y_spt_hud_script_progress); #endif } diff --git a/spt/features/tracing.cpp b/spt/features/tracing.cpp index f925d5b1b..669b44c43 100644 --- a/spt/features/tracing.cpp +++ b/spt/features/tracing.cpp @@ -12,6 +12,7 @@ #include "..\strafe\strafestuff.hpp" #include "portal_utils.hpp" #include "ent_props.hpp" +#include "visualizations/imgui/imgui_interface.hpp" #include "model_types.h" @@ -543,7 +544,7 @@ void Tracing::LoadFeature() #ifdef SPT_HUD_ENABLED if (interfaces::engineTraceClient) { - AddHudCallback( + bool hudEnabled = AddHudCallback( "oob", [](std::string) { @@ -554,6 +555,9 @@ void Tracing::LoadFeature() spt_hud_feat.DrawTopHudElement(L"oob: %d", oob); }, y_spt_hud_oob); + + if (hudEnabled) + SptImGui::RegisterHudCvarCheckbox(y_spt_hud_oob); } #endif } diff --git a/spt/features/visualizations/oob_ents.cpp b/spt/features/visualizations/oob_ents.cpp index 567d357d1..6b87de9e3 100644 --- a/spt/features/visualizations/oob_ents.cpp +++ b/spt/features/visualizations/oob_ents.cpp @@ -11,6 +11,7 @@ #include "spt\features\ent_props.hpp" #include "spt\features\hud.hpp" #include "renderer\mesh_renderer.hpp" +#include "imgui\imgui_interface.hpp" class HudOobEntsFeature : public FeatureWrapper { @@ -70,8 +71,10 @@ void HudOobEntsFeature::LoadFeature() if (!TickSignal.Works) return; TickSignal.Connect(this, &HudOobEntsFeature::OnTickSignal); - AddHudCallback( + bool hudEnabled = AddHudCallback( "hud oob ents", [this](std::string) { PrintEntsHud(); }, spt_hud_oob_ents); + if (hudEnabled) + SptImGui::RegisterHudCvarCheckbox(spt_hud_oob_ents); InitCommand(spt_print_oob_ents); #ifdef SPT_MESH_RENDERING_ENABLED if (spt_meshRenderer.signal.Works)