Skip to content

Commit

Permalink
Add spt_hud & spt_hud_left cvars to imgui text hud tab
Browse files Browse the repository at this point in the history
  • Loading branch information
UncraftedName committed Sep 17, 2024
1 parent 2dec198 commit 9b7bfd0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
6 changes: 6 additions & 0 deletions spt/features/hud.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ class HUDFeature : public FeatureWrapper<HUDFeature>
virtual bool ShouldLoadFeature() override;
bool GetFont(const std::string& fontName, vgui::HFont& fontOut);

// call from LoadFeature or later
bool LoadingSuccessful() const
{
return loadingSuccessful;
}

protected:
virtual void InitHooks() override;
virtual void PreHook() override;
Expand Down
18 changes: 17 additions & 1 deletion spt/features/visualizations/imgui/imgui_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "interfaces.hpp"
#include "spt/spt-serverplugin.hpp"
#include "spt/utils/spt_vprof.hpp"
#include "spt/features/hud.hpp"

#include "thirdparty/imgui/imgui_internal.h"
#include "thirdparty/imgui/imgui_impl_dx9.h"
Expand Down Expand Up @@ -414,6 +415,16 @@ class SptImGuiFeature : public FeatureWrapper<SptImGuiFeature>
{
if (!open)
return;

// Maybe this callback should be in the HUD feature file? Something to think about..

extern ConVar y_spt_hud;
extern ConVar y_spt_hud_left;

ImGui::BeginDisabled(!SptImGui::CvarCheckbox(y_spt_hud, "enable text HUD"));
SptImGui::CvarCheckbox(y_spt_hud_left, "left HUD");
ImGui::Separator();

int i = 0;
for (auto& cvarInfo : hudCvars)
{
Expand Down Expand Up @@ -445,6 +456,8 @@ class SptImGuiFeature : public FeatureWrapper<SptImGuiFeature>
ImGui::PopID();
i++;
}

ImGui::EndDisabled();
}

static void ReloadFontSize()
Expand Down Expand Up @@ -626,7 +639,10 @@ class SptImGuiFeature : public FeatureWrapper<SptImGuiFeature>
SptImGui::RegisterSectionCallback(SptImGuiGroup::Dev_ImGui, DevSectionCallback);
SptImGui::RegisterTabCallback(SptImGuiGroup::Settings, SettingsTabCallback);
SetupSettingsTabIniHandler();
SptImGui::RegisterTabCallback(SptImGuiGroup::Hud, HudTabCallback);
#ifdef SPT_HUD_ENABLED
if (spt_hud_feat.LoadingSuccessful())
SptImGui::RegisterTabCallback(SptImGuiGroup::Hud, HudTabCallback);
#endif
};

virtual void UnloadFeature()
Expand Down

0 comments on commit 9b7bfd0

Please sign in to comment.