Skip to content

Commit

Permalink
Rename spt_hud feature name
Browse files Browse the repository at this point in the history
  • Loading branch information
evanlin96069 authored and lipsanen committed May 27, 2023
1 parent 45fa98e commit 32234ee
Show file tree
Hide file tree
Showing 15 changed files with 145 additions and 138 deletions.
6 changes: 3 additions & 3 deletions spt/feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ void Feature::InitConcommandBase(ConCommandBase& convar)
bool Feature::AddHudCallback(const char* key, std::function<void(std::string)> func, ConVar& convar)
{
#ifdef SPT_HUD_ENABLED
bool result = spt_hud.AddHudCallback(key,
HudCallback(
func, [&convar]() { return convar.GetBool(); }, false));
bool result = spt_hud_feat.AddHudCallback(key,
HudCallback(
func, [&convar]() { return convar.GetBool(); }, false));

if (result)
{
Expand Down
13 changes: 7 additions & 6 deletions spt/features/boog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ void BoogFeature::BoogTick()

bool BoogFeature::ShouldDrawBoog()
{
bool rval = ticksLeftToDrawBoog > 0 && y_spt_hud_edgebug.GetBool() && interfaces::surface && spt_hud.renderView;
bool rval =
ticksLeftToDrawBoog > 0 && y_spt_hud_edgebug.GetBool() && interfaces::surface && spt_hud_feat.renderView;

if (rval)
{
Expand All @@ -78,7 +79,7 @@ bool BoogFeature::ShouldDrawBoog()
void BoogFeature::DrawBoog()
{
auto surface = interfaces::surface;
auto renderView = spt_hud.renderView;
auto renderView = spt_hud_feat.renderView;

if (boogFont == 0)
{
Expand Down Expand Up @@ -117,7 +118,7 @@ void BoogFeature::DrawBoog()

bool BoogFeature::ShouldLoadFeature()
{
return spt_hud.ShouldLoadFeature() && spt_playerio.ShouldLoadFeature();
return spt_hud_feat.ShouldLoadFeature() && spt_playerio.ShouldLoadFeature();
}

void BoogFeature::InitHooks() {}
Expand Down Expand Up @@ -146,9 +147,9 @@ void BoogFeature::LoadFeature()

if (boogHooked)
{
bool result = spt_hud.AddHudDefaultGroup(HudCallback(std::bind(&BoogFeature::DrawBoog, this),
std::bind(&BoogFeature::ShouldDrawBoog, this),
false));
bool result = spt_hud_feat.AddHudDefaultGroup(HudCallback(std::bind(&BoogFeature::DrawBoog, this),
std::bind(&BoogFeature::ShouldDrawBoog, this),
false));
if (result)
{
InitConcommandBase(y_spt_hud_edgebug);
Expand Down
55 changes: 28 additions & 27 deletions spt/features/ent_props.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,38 +450,39 @@ void EntProps::LoadFeature()
[this](std::string)
{
int in_bubble = GetEnvironmentPortal() != NULL;
spt_hud.DrawTopHudElement(L"portal bubble: %d", in_bubble);
spt_hud_feat.DrawTopHudElement(L"portal bubble: %d", in_bubble);
},
y_spt_hud_portal_bubble);
}
#endif

bool result = spt_hud.AddHudCallback("ent_info",
HudCallback(
[](std::string args)
{
std::string info;
if (args == "")
info = y_spt_hud_ent_info.GetString();
else
info = args;
if (!whiteSpacesOnly(info))
{
int entries = utils::FillInfoArray(info,
INFO_ARRAY,
MAX_ENTRIES,
INFO_BUFFER_SIZE,
PROP_SEPARATOR,
ENT_SEPARATOR);
for (int i = 0; i < entries; ++i)
{
spt_hud.DrawTopHudElement(
INFO_ARRAY + i * INFO_BUFFER_SIZE);
}
}
},
[]() { return true; },
false));
bool result = spt_hud_feat.AddHudCallback("ent_info",
HudCallback(
[](std::string args)
{
std::string info;
if (args == "")
info = y_spt_hud_ent_info.GetString();
else
info = args;
if (!whiteSpacesOnly(info))
{
int entries =
utils::FillInfoArray(info,
INFO_ARRAY,
MAX_ENTRIES,
INFO_BUFFER_SIZE,
PROP_SEPARATOR,
ENT_SEPARATOR);
for (int i = 0; i < entries; ++i)
{
spt_hud_feat.DrawTopHudElement(
INFO_ARRAY + i * INFO_BUFFER_SIZE);
}
}
},
[]() { return true; },
false));

if (result)
{
Expand Down
10 changes: 5 additions & 5 deletions spt/features/hops_hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ static HopsHud spt_hops_hud;

bool HopsHud::ShouldLoadFeature()
{
return spt_hud.ShouldLoadFeature();
return spt_hud_feat.ShouldLoadFeature();
}

bool HopsHud::ShouldDraw()
Expand Down Expand Up @@ -472,7 +472,7 @@ void HopsHud::PrintStrafeCol(std::function<void(const ljstats::SegmentStats&, wc
}

// Leave space left for last line
if (y + fontTall * 2 > spt_hud.renderView->height)
if (y + fontTall * 2 > spt_hud_feat.renderView->height)
{
break;
}
Expand All @@ -488,7 +488,7 @@ void HopsHud::InitHooks() {}

void HopsHud::LoadFeature()
{
bool result = spt_hud.AddHudDefaultGroup(
bool result = spt_hud_feat.AddHudDefaultGroup(
HudCallback(std::bind(&HopsHud::DrawHopHud, this), std::bind(&HopsHud::ShouldDraw, this), false));

if (result && OngroundSignal.Works && JumpSignal.Works)
Expand Down Expand Up @@ -528,7 +528,7 @@ void HopsHud::DrawHopHud()
swprintf_s(buffer, BUFFER_SIZE, fmt, value); \
DrawBuffer();

if (hopsFont == 0 && !spt_hud.GetFont(FONT_Trebuchet24, hopsFont))
if (hopsFont == 0 && !spt_hud_feat.GetFont(FONT_Trebuchet24, hopsFont))
{
return;
}
Expand All @@ -538,7 +538,7 @@ void HopsHud::DrawHopHud()
const Color white(255, 255, 255, 255);

auto surface = interfaces::surface;
auto renderView = spt_hud.renderView;
auto renderView = spt_hud_feat.renderView;

surface->DrawSetTextFont(hopsFont);
surface->DrawSetTextColor(white);
Expand Down
62 changes: 31 additions & 31 deletions spt/features/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

extern ConVar _y_spt_overlay;

HUDFeature spt_hud;
HUDFeature spt_hud_feat;

ConVar y_spt_hud("y_spt_hud", "1", 0, "When set to 1, displays SPT HUD.");
ConVar y_spt_hud_left("y_spt_hud_left", "0", FCVAR_CHEAT, "When set to 1, displays SPT HUD on the left.");
Expand Down Expand Up @@ -70,7 +70,7 @@ static int HudGroupCompletionFunc(AUTOCOMPLETION_FUNCTION_PARAMS)

std::istringstream iss(base);
std::vector<std::string> args{std::istream_iterator<std::string>{iss}, std::istream_iterator<std::string>{}};

int argc = args.size();
switch (argc)
{
Expand All @@ -79,7 +79,7 @@ static int HudGroupCompletionFunc(AUTOCOMPLETION_FUNCTION_PARAMS)
case 1:
{
std::vector<std::string> suggestions;
for (const auto& group : spt_hud.hudUserGroups)
for (const auto& group : spt_hud_feat.hudUserGroups)
{
suggestions.push_back(group.first);
}
Expand All @@ -88,7 +88,7 @@ static int HudGroupCompletionFunc(AUTOCOMPLETION_FUNCTION_PARAMS)
}
case 2:
{
if (args[1] == "all" || spt_hud.hudUserGroups.contains(args[1]))
if (args[1] == "all" || spt_hud_feat.hudUserGroups.contains(args[1]))
return AutoCompleteList::AutoCompleteSuggest(base,
incomplete,
{
Expand All @@ -112,10 +112,10 @@ static int HudGroupCompletionFunc(AUTOCOMPLETION_FUNCTION_PARAMS)
case 3:
case 4:
{
if (args[2] == "add" || (argc == 4 && args [2] == "edit"))
if (args[2] == "add" || (argc == 4 && args[2] == "edit"))
{
std::vector<std::string> suggestions;
for (const auto& group : spt_hud.hudCallbacks)
for (const auto& group : spt_hud_feat.hudCallbacks)
{
suggestions.push_back(group.first);
}
Expand Down Expand Up @@ -143,7 +143,7 @@ CON_COMMAND_F_COMPLETION(spt_hud_group,
{
if (args.ArgC() < 2)
{
for (const auto& group : spt_hud.hudUserGroups)
for (const auto& group : spt_hud_feat.hudUserGroups)
{
Msg("%s\n", group.first.c_str());
}
Expand All @@ -152,7 +152,7 @@ CON_COMMAND_F_COMPLETION(spt_hud_group,

auto commandAction = [args](std::string name) -> bool
{
HudUserGroup& group = spt_hud.hudUserGroups[name];
HudUserGroup& group = spt_hud_feat.hudUserGroups[name];

int argc = args.ArgC();
if (argc == 2)
Expand All @@ -174,7 +174,7 @@ CON_COMMAND_F_COMPLETION(spt_hud_group,
}

std::string element = args.Arg(3);
if (!spt_hud.hudCallbacks.contains(element))
if (!spt_hud_feat.hudCallbacks.contains(element))
{
Msg("%s is not a HUD element.\n", element.c_str());
return false;
Expand Down Expand Up @@ -210,7 +210,7 @@ CON_COMMAND_F_COMPLETION(spt_hud_group,
return false;
}
std::string element = args.Arg(4);
if (!spt_hud.hudCallbacks.contains(element))
if (!spt_hud_feat.hudCallbacks.contains(element))
{
Msg("%s is not a HUD element.\n", element.c_str());
return false;
Expand Down Expand Up @@ -265,7 +265,7 @@ CON_COMMAND_F_COMPLETION(spt_hud_group,
if (argc == 3)
{
std::string fontName = "Invalid";
for (const auto& kv : spt_hud.fonts)
for (const auto& kv : spt_hud_feat.fonts)
{
if (kv.second == group.font)
{
Expand All @@ -277,7 +277,7 @@ CON_COMMAND_F_COMPLETION(spt_hud_group,
}
else if (argc == 4)
{
if (!spt_hud.GetFont(args.Arg(3), group.font))
if (!spt_hud_feat.GetFont(args.Arg(3), group.font))
{
Msg("Invalid font name.\n");
return false;
Expand Down Expand Up @@ -319,13 +319,13 @@ CON_COMMAND_F_COMPLETION(spt_hud_group,
std::string name = args.Arg(1);
if (name == "all")
{
for (auto& kv : spt_hud.hudUserGroups)
for (auto& kv : spt_hud_feat.hudUserGroups)
{
if (!commandAction(kv.first))
return;
}
}
else if (spt_hud.hudUserGroups.contains(name))
else if (spt_hud_feat.hudUserGroups.contains(name))
{
commandAction(name);
}
Expand All @@ -348,13 +348,13 @@ CON_COMMAND(spt_hud_group_add, "Add a HUD group. Usage: spt_hud_group_add <group
{
Msg("\"all\" cannot be a group name!\n");
}
else if (spt_hud.hudUserGroups.contains(name))
else if (spt_hud_feat.hudUserGroups.contains(name))
{
Msg("Group %s already exist!\n", name.c_str());
}
else
{
spt_hud.hudUserGroups[name] = HudUserGroup();
spt_hud_feat.hudUserGroups[name] = HudUserGroup();
}
}

Expand All @@ -364,7 +364,7 @@ CON_COMMAND(spt_hud_group_remove, "Remove HUD group(s). Usage: spt_hud_group_rem
static int HudGroupRemoveCompletionFunc(AUTOCOMPLETION_FUNCTION_PARAMS)
{
std::vector<std::string> suggestions;
for (const auto& group : spt_hud.hudUserGroups)
for (const auto& group : spt_hud_feat.hudUserGroups)
{
suggestions.push_back(group.first);
}
Expand All @@ -389,11 +389,11 @@ CON_COMMAND_F_COMPLETION(spt_hud_group_remove,
std::string name = args.Arg(1);
if (name == "all")
{
spt_hud.hudUserGroups.clear();
spt_hud_feat.hudUserGroups.clear();
}
else if (spt_hud.hudUserGroups.contains(name))
else if (spt_hud_feat.hudUserGroups.contains(name))
{
spt_hud.hudUserGroups.erase(name);
spt_hud_feat.hudUserGroups.erase(name);
}
else
{
Expand Down Expand Up @@ -647,7 +647,7 @@ void HUDFeature::LoadFeature()

cl_showpos = g_pCVar->FindVar("cl_showpos");
cl_showfps = g_pCVar->FindVar("cl_showfps");
bool result = spt_hud.AddHudDefaultGroup(HudCallback(
bool result = spt_hud_feat.AddHudDefaultGroup(HudCallback(
std::bind(&HUDFeature::DrawDefaultHUD, this), []() { return y_spt_hud.GetBool(); }, false));
if (result)
{
Expand Down Expand Up @@ -793,7 +793,7 @@ void HUDFeature::DrawHUD(bool overlay)

IMPL_HOOK_THISCALL(HUDFeature, void, CEngineVGui__Paint, void*, PaintMode_t mode)
{
if (spt_hud.loadingSuccessful && mode & PAINT_INGAMEPANELS)
if (spt_hud_feat.loadingSuccessful && mode & PAINT_INGAMEPANELS)
{
#ifdef SPT_OVERLAY_ENABLED
/*
Expand All @@ -805,20 +805,20 @@ IMPL_HOOK_THISCALL(HUDFeature, void, CEngineVGui__Paint, void*, PaintMode_t mode
* both views.
*/
Assert(spt_overlay.mainView);
spt_hud.renderView = spt_overlay.mainView;
spt_hud.DrawHUD(false);
spt_hud_feat.renderView = spt_overlay.mainView;
spt_hud_feat.DrawHUD(false);
if (_y_spt_overlay.GetBool())
{
Assert(spt_overlay.overlayView);
spt_hud.renderView = spt_overlay.overlayView;
spt_hud.DrawHUD(true);
spt_hud_feat.renderView = spt_overlay.overlayView;
spt_hud_feat.DrawHUD(true);
}
#else
Assert(spt_hud.renderView);
spt_hud.DrawHUD(false);
Assert(spt_hud_feat.renderView);
spt_hud_feat.DrawHUD(false);
#endif
}
spt_hud.ORIG_CEngineVGui__Paint(thisptr, mode);
spt_hud_feat.ORIG_CEngineVGui__Paint(thisptr, mode);
}

HudCallback::HudCallback() : drawInOverlay(false) {}
Expand All @@ -830,7 +830,7 @@ HudCallback::HudCallback(std::function<void(std::string)> drawable, std::functio

HudUserGroup::HudUserGroup() : x(0), y(0), shouldDraw(true), textcolor(255, 255, 255, 255), background(0, 0, 0, 0)
{
if (!spt_hud.GetFont(FONT_DefaultFixedOutline, font))
if (!spt_hud_feat.GetFont(FONT_DefaultFixedOutline, font))
{
font = 0;
}
Expand All @@ -843,7 +843,7 @@ std::string HudUserGroup::ToString() const
ss << "pos: (" << x << ", " << y << ")\n";

std::string fontName = "Invalid";
for (const auto& kv : spt_hud.fonts)
for (const auto& kv : spt_hud_feat.fonts)
{
if (kv.second == font)
{
Expand Down
2 changes: 1 addition & 1 deletion spt/features/hud.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,4 @@ class HUDFeature : public FeatureWrapper<HUDFeature>
Color StringToColor(const std::string& color);
std::string ColorToString(Color color);

extern HUDFeature spt_hud;
extern HUDFeature spt_hud_feat;
Loading

0 comments on commit 32234ee

Please sign in to comment.