Skip to content

Commit ae735e9

Browse files
authored
Merge pull request #287 from rtxa/add-options-for-custom-hud
Add custom VGUI2 HUD settings to Advanced Options
2 parents 7c5c854 + d4618ac commit ae735e9

File tree

7 files changed

+140
-11
lines changed

7 files changed

+140
-11
lines changed

gamedir/ui/resource/language/bugfixedhl_english.utf8.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,12 @@
8181
"BHL_AdvOptions_HUD_Color2_Title" "HUD HP/AP/Ammo (Medium) color"
8282

8383
"BHL_AdvOptions_HUD_Color3" "HP/AP/Ammo (Low)"
84-
"BHL_AdvOptions_HUD_Color3_Title" "HUD HP/AP/Ammo (Medium) color"
84+
"BHL_AdvOptions_HUD_Color3_Title" "HUD HP/AP/Ammo (Low) color"
85+
86+
"BHL_AdvOptions_HUD_Color4" "HP/AP/Ammo (Very low)"
87+
"BHL_AdvOptions_HUD_Color4_Title" "HUD HP/AP/Ammo (Very low) color"
88+
89+
"BHL_AdvOptions_HUD_ColorOverride" "Color HUD numbers by amount (HP/AP/Ammo)"
8590

8691
"BHL_AdvOptions_HUD_Render" "Enhanced sprite rendering *"
8792
"BHL_AdvOptions_HUD_Dim" "Dim HUD when inactive"
@@ -96,6 +101,7 @@
96101
"BHL_AdvOptions_HUD_JumpSpeedCross" "Jump speed under crosshair"
97102

98103
"BHL_AdvOptions_HUD_Deathnotice" "VGUI2 Deathnotice *"
104+
"BHL_AdvOptions_HUD_CustomHud" "VGUI2 Custom HUD (HP/AP/Ammo) *"
99105

100106
"BHL_AdvOptions_HUD_RenderMsg" "* Requires hardware rendering mode"
101107

gamedir/ui/resource/options/HudSubOptions.res

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"fieldName" "OpacityLabel"
2424
"xpos" "38"
2525
"ypos" "15"
26-
"wide" "180"
26+
"wide" "150"
2727
"tall" "24"
2828
"autoResize" "0"
2929
"pinCorner" "0"
@@ -48,7 +48,7 @@
4848
{
4949
"ControlName" "CCvarTextEntry"
5050
"fieldName" "OpacityValue"
51-
"xpos" "292"
51+
"xpos" "212"
5252
"ypos" "30"
5353
"wide" "48"
5454
"tall" "24"
@@ -72,7 +72,7 @@
7272
"fieldName" "OpacitySlider"
7373
"xpos" "38"
7474
"ypos" "32"
75-
"wide" "252"
75+
"wide" "172"
7676
"tall" "24"
7777
"autoResize" "0"
7878
"pinCorner" "0"
@@ -363,12 +363,40 @@
363363
"useproportionalinsets" "0"
364364
"Default" "0"
365365
}
366+
"CustomHudCheckbox"
367+
{
368+
"ControlName" "CCvarCheckButton"
369+
"fieldName" "CustomHudCheckBox"
370+
"xpos" "230"
371+
"ypos" "184"
372+
"wide" "240"
373+
"tall" "24"
374+
"autoResize" "0"
375+
"pinCorner" "0"
376+
"RoundedCorners" "15"
377+
"pin_corner_to_sibling" "0"
378+
"pin_to_sibling_corner" "0"
379+
"visible" "1"
380+
"enabled" "1"
381+
"tabPosition" "0"
382+
"labelText" "#BHL_AdvOptions_HUD_CustomHud"
383+
"textAlignment" "west"
384+
"dulltext" "0"
385+
"brighttext" "0"
386+
"wrap" "0"
387+
"centerwrap" "0"
388+
"textinsetx" "6"
389+
"textinsety" "0"
390+
"autowidetocontents" "0"
391+
"useproportionalinsets" "0"
392+
"Default" "0"
393+
}
366394
"DeathnoticeCheckbox"
367395
{
368396
"ControlName" "CCvarCheckButton"
369397
"fieldName" "DeathnoticeCheckbox"
370398
"xpos" "230"
371-
"ypos" "184"
399+
"ypos" "160"
372400
"wide" "192"
373401
"tall" "24"
374402
"autoResize" "0"
@@ -396,7 +424,7 @@
396424
"ControlName" "CCVarComboBox"
397425
"fieldName" "TimerBox"
398426
"xpos" "274"
399-
"ypos" "92"
427+
"ypos" "45"
400428
"wide" "192"
401429
"tall" "24"
402430
"autoResize" "0"
@@ -418,7 +446,7 @@
418446
"ControlName" "CCVarComboBox"
419447
"fieldName" "ScaleBox"
420448
"xpos" "274"
421-
"ypos" "145"
449+
"ypos" "100"
422450
"wide" "192"
423451
"tall" "24"
424452
"autoResize" "0"
@@ -440,7 +468,7 @@
440468
"ControlName" "Label"
441469
"fieldName" "TimerLabel"
442470
"xpos" "276"
443-
"ypos" "64"
471+
"ypos" "15"
444472
"wide" "214"
445473
"tall" "24"
446474
"autoResize" "0"
@@ -494,7 +522,7 @@
494522
"ControlName" "Label"
495523
"fieldName" "Label2"
496524
"xpos" "276"
497-
"ypos" "117"
525+
"ypos" "72"
498526
"wide" "214"
499527
"tall" "24"
500528
"autoResize" "0"

gamedir/ui/resource/options/HudSubOptionsColors.res

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,78 @@
193193
"enabled" "1"
194194
"tabPosition" "0"
195195
}
196+
"Color4Label"
197+
{
198+
"ControlName" "Label"
199+
"fieldName" "Color4Label"
200+
"xpos" "12"
201+
"ypos" "128"
202+
"wide" "150"
203+
"tall" "24"
204+
"autoResize" "0"
205+
"pinCorner" "0"
206+
"RoundedCorners" "15"
207+
"pin_corner_to_sibling" "0"
208+
"pin_to_sibling_corner" "0"
209+
"visible" "1"
210+
"enabled" "1"
211+
"tabPosition" "0"
212+
"labelText" "#BHL_AdvOptions_HUD_Color4"
213+
"textAlignment" "west"
214+
"dulltext" "0"
215+
"brighttext" "0"
216+
"wrap" "0"
217+
"centerwrap" "0"
218+
"textinsetx" "0"
219+
"textinsety" "0"
220+
"autowidetocontents" "0"
221+
"useproportionalinsets" "0"
222+
}
223+
"Color4Value"
224+
{
225+
"ControlName" "CCvarColor"
226+
"fieldName" "Color4Value"
227+
"xpos" "170"
228+
"ypos" "128"
229+
"wide" "128"
230+
"tall" "24"
231+
"autoResize" "0"
232+
"pinCorner" "0"
233+
"RoundedCorners" "15"
234+
"pin_corner_to_sibling" "0"
235+
"pin_to_sibling_corner" "0"
236+
"visible" "1"
237+
"enabled" "1"
238+
"tabPosition" "0"
239+
}
240+
"ColorOverrideCheckbox"
241+
{
242+
"ControlName" "CCvarCheckButton"
243+
"fieldName" "ColorOverrideCheckbox"
244+
"xpos" "5"
245+
"ypos" "160"
246+
"wide" "300"
247+
"tall" "24"
248+
"autoResize" "0"
249+
"pinCorner" "0"
250+
"RoundedCorners" "15"
251+
"pin_corner_to_sibling" "0"
252+
"pin_to_sibling_corner" "0"
253+
"visible" "1"
254+
"enabled" "1"
255+
"tabPosition" "0"
256+
"labelText" "#BHL_AdvOptions_HUD_ColorOverride"
257+
"textAlignment" "west"
258+
"dulltext" "0"
259+
"brighttext" "0"
260+
"wrap" "0"
261+
"centerwrap" "0"
262+
"textinsetx" "6"
263+
"textinsety" "0"
264+
"autowidetocontents" "0"
265+
"useproportionalinsets" "0"
266+
"Default" "0"
267+
}
196268
"BuildModeDialog"
197269
{
198270
"ControlName" "BuildModeDialog"

src/game/client/gameui/options/options_hud.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ CHudSubOptions::CHudSubOptions(vgui2::Panel *parent)
3737
m_pJumpSpeedCrossCheckbox = new CCvarCheckButton(this, "JumpSpeedCrossCheckbox", "#BHL_AdvOptions_HUD_JumpSpeedCross", "hud_jumpspeed_below_cross");
3838

3939
m_pDeathnoticeVGui = new CCvarCheckButton(this, "DeathnoticeCheckbox", "#BHL_AdvOptions_HUD_Deathnotice", "hud_deathnotice_vgui");
40+
m_pCustomHudVGui = new CCvarCheckButton(this, "CustomHudCheckbox", "#BHL_AdvOptions_HUD_CustomHud", "hud_custom");
4041

4142
m_pTimerBox = new CCVarComboBox(this, "TimerBox", "hud_timer");
4243
m_pTimerBox->AddItem("#BHL_AdvOptions_Hud_Timer0", "0");
@@ -67,6 +68,7 @@ CHudSubOptions::CHudSubOptions(vgui2::Panel *parent)
6768
{
6869
m_pRenderCheckbox->SetEnabled(false);
6970
m_pDeathnoticeVGui->SetEnabled(false);
71+
m_pCustomHudVGui->SetEnabled(false);
7072
}
7173
}
7274

@@ -93,6 +95,11 @@ void CHudSubOptions::OnResetData()
9395
else
9496
m_pDeathnoticeVGui->SetSelected(false);
9597

98+
if (m_pCustomHudVGui->IsEnabled())
99+
m_pCustomHudVGui->ResetData();
100+
else
101+
m_pCustomHudVGui->SetSelected(false);
102+
96103
m_pTimerBox->ResetData();
97104
m_pScaleBox->ResetData();
98105
}
@@ -116,6 +123,9 @@ void CHudSubOptions::OnApplyChanges()
116123
if (m_pDeathnoticeVGui->IsEnabled())
117124
m_pDeathnoticeVGui->ApplyChanges();
118125

126+
if (m_pCustomHudVGui->IsEnabled())
127+
m_pCustomHudVGui->ApplyChanges();
128+
119129
m_pTimerBox->ApplyChanges();
120130
m_pScaleBox->ApplyChanges();
121131
}

src/game/client/gameui/options/options_hud.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class CHudSubOptions : public vgui2::PropertyPage
4141
CCvarCheckButton *m_pJumpSpeedCrossCheckbox = nullptr;
4242

4343
CCvarCheckButton *m_pDeathnoticeVGui = nullptr;
44+
CCvarCheckButton *m_pCustomHudVGui = nullptr;
4445

4546
CCVarComboBox *m_pTimerBox = nullptr;
4647
CCVarComboBox *m_pScaleBox = nullptr;

src/game/client/gameui/options/options_hud_colors.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <vgui_controls/Label.h>
22
#include "client_vgui.h"
33
#include "cvar_color.h"
4+
#include "cvar_check_button.h"
45
#include "options_hud_colors.h"
56

67
CHudSubOptionsColors::CHudSubOptionsColors(vgui2::Panel *parent)
@@ -20,6 +21,11 @@ CHudSubOptionsColors::CHudSubOptionsColors(vgui2::Panel *parent)
2021
m_pColorLabel[3] = new vgui2::Label(this, "Color3Label", "#BHL_AdvOptions_HUD_Color3");
2122
m_pColorValue[3] = new CCvarColor(this, "Color3Value", "hud_color3", "#BHL_AdvOptions_HUD_Color3_Title");
2223

24+
m_pColorLabel[4] = new vgui2::Label(this, "Color4Label", "#BHL_AdvOptions_HUD_Color4");
25+
m_pColorValue[4] = new CCvarColor(this, "Color4Value", "hud_color4", "#BHL_AdvOptions_HUD_Color4_Title");
26+
27+
m_pColorOverride = new CCvarCheckButton(this, "ColorOverrideCheckbox", "#BHL_AdvOptions_HUD_ColorOverride", "hud_color_override", true);
28+
2329
LoadControlSettings(VGUI2_ROOT_DIR "resource/options/HudSubOptionsColors.res");
2430
}
2531

@@ -29,6 +35,8 @@ void CHudSubOptionsColors::OnResetData()
2935
m_pColorValue[1]->ResetData();
3036
m_pColorValue[2]->ResetData();
3137
m_pColorValue[3]->ResetData();
38+
m_pColorValue[4]->ResetData();
39+
m_pColorOverride->ResetData();
3240
}
3341

3442
void CHudSubOptionsColors::OnApplyChanges()
@@ -37,4 +45,6 @@ void CHudSubOptionsColors::OnApplyChanges()
3745
m_pColorValue[1]->ApplyChanges();
3846
m_pColorValue[2]->ApplyChanges();
3947
m_pColorValue[3]->ApplyChanges();
48+
m_pColorValue[4]->ApplyChanges();
49+
m_pColorOverride->ApplyChanges();
4050
}

src/game/client/gameui/options/options_hud_colors.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <vgui_controls/PropertyPage.h>
44

55
class CCvarColor;
6+
class CCvarCheckButton;
67

78
class CHudSubOptionsColors : public vgui2::PropertyPage
89
{
@@ -15,8 +16,9 @@ class CHudSubOptionsColors : public vgui2::PropertyPage
1516
virtual void OnApplyChanges();
1617

1718
private:
18-
vgui2::Label *m_pColorLabel[4];
19-
CCvarColor *m_pColorValue[4];
19+
vgui2::Label *m_pColorLabel[5];
20+
CCvarColor *m_pColorValue[5];
21+
CCvarCheckButton *m_pColorOverride = nullptr;
2022
};
2123

2224
#endif

0 commit comments

Comments
 (0)