Skip to content

Commit

Permalink
Add miscellaneous HUD features to the imgui hud tab
Browse files Browse the repository at this point in the history
  • Loading branch information
UncraftedName committed Sep 17, 2024
1 parent 22e6753 commit 2dec198
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 6 deletions.
7 changes: 6 additions & 1 deletion spt/features/ent_props.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <string>
#include <unordered_map>

Expand Down Expand Up @@ -445,14 +447,17 @@ void EntProps::LoadFeature()
#if defined(SPT_HUD_ENABLED) && defined(SPT_PORTAL_UTILS)
if (utils::DoesGameLookLikePortal())
{
AddHudCallback(
bool hudEnabled = AddHudCallback(
"portal_bubble",
[this](std::string)
{
int in_bubble = GetEnvironmentPortal() != NULL;
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

Expand Down
8 changes: 7 additions & 1 deletion spt/features/saveloads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <format>

static std::vector<const char*> _saveloadTypes = {"segment", "execute", "render"};
Expand Down Expand Up @@ -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)
{
Expand All @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion spt/features/shadow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -73,7 +74,7 @@ void ShadowPosition::LoadFeature()
if (ORIG_GetShadowPosition)
{
#ifdef SPT_HUD_ENABLED
AddHudCallback(
bool hudEnabled = AddHudCallback(
"shadow_info",
[this](std::string)
{
Expand All @@ -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
}

Expand Down
6 changes: 5 additions & 1 deletion spt/features/tas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
{
Expand All @@ -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
}

Expand Down
6 changes: 5 additions & 1 deletion spt/features/tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -543,7 +544,7 @@ void Tracing::LoadFeature()
#ifdef SPT_HUD_ENABLED
if (interfaces::engineTraceClient)
{
AddHudCallback(
bool hudEnabled = AddHudCallback(
"oob",
[](std::string)
{
Expand All @@ -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
}
5 changes: 4 additions & 1 deletion spt/features/visualizations/oob_ents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<HudOobEntsFeature>
{
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 2dec198

Please sign in to comment.