Skip to content

Commit 828e244

Browse files
committed
feat: sar_hud_shorthand
concise smaller hud for middle crosshair thing
1 parent 10f8731 commit 828e244

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

docs/cvars.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@
272272
|sar_hud_session|0|Draws current session tick.|
273273
|sar_hud_set_text|cmd|sar_hud_set_text \<id> \<text>... - sets and shows the nth text value in the HUD|
274274
|sar_hud_set_text_color|cmd|sar_hud_set_text_color \<id> [color] - sets the color of the nth text value in the HUD. Reset by not giving color.|
275+
|sar_hud_shorthand|0|Whether to hide the text part of HUD elements.|
275276
|sar_hud_show_text|cmd|sar_hud_show_text \<id\|all> - shows the nth text value in the HUD|
276277
|sar_hud_spacing|1|Spacing between elements of HUD.|
277278
|sar_hud_steps|0|Draws total step count.|

src/Features/Hud/Hud.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Variable sar_hud_font_color("sar_hud_font_color", "255 255 255 255", "RGBA font
2929

3030
Variable sar_hud_precision("sar_hud_precision", "2", 0, "Precision of HUD numbers.\n");
3131
Variable sar_hud_velocity_precision("sar_hud_velocity_precision", "2", 0, "Precision of velocity HUD numbers.\n");
32+
Variable sar_hud_shorthand("sar_hud_shorthand", "0", "Whether to hide the text part of HUD elements.\n", FCVAR_DONTRECORD);
3233

3334
Variable sar_hud_rainbow("sar_hud_rainbow", "-1", -1, 1, "Enables the rainbow HUD mode. -1 = default, 0 = disable, 1 = enable.\n", FCVAR_DONTRECORD);
3435
static bool g_rainbow = false;
@@ -174,6 +175,12 @@ void HudContext::DrawElement(const char *fmt, ...) {
174175
vsnprintf(data, sizeof(data), fmt, argptr);
175176
va_end(argptr);
176177

178+
// cut off to the first ": " if shorthand is on
179+
if (sar_hud_shorthand.GetBool()) {
180+
char *colon = strstr(data, ": ");
181+
if (colon) strcpy(data, colon + 2);
182+
}
183+
177184
surface->DrawTxt(font, this->xPadding, this->yPadding + this->elements * (this->fontSize + this->spacing), this->textColor, data);
178185

179186
++this->elements;

src/Features/Hud/Hud.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ extern Variable sar_hud_y;
169169
extern Variable sar_hud_font_index;
170170
extern Variable sar_hud_font_color;
171171
extern Variable sar_hud_precision;
172+
extern Variable sar_hud_shorthand;
172173
extern QAngle g_bluePortalAngles[2];
173174
extern QAngle g_orangePortalAngles[2];
174175

0 commit comments

Comments
 (0)