Skip to content

Commit

Permalink
Client: Options: Add HUD Scale
Browse files Browse the repository at this point in the history
  • Loading branch information
tmp64 committed Nov 25, 2023
1 parent e0b2929 commit ddede7e
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 51 deletions.
Binary file modified gamedir/ui/resource/language/bugfixedhl_english.txt
Binary file not shown.
Binary file modified gamedir/ui/resource/language/bugfixedhl_russian.txt
Binary file not shown.
99 changes: 74 additions & 25 deletions gamedir/ui/resource/options/HudSubOptions.res
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@
{
"ControlName" "CCvarCheckButton"
"fieldName" "SpeedCrossCheckbox"
"xpos" "194"
"xpos" "230"
"ypos" "208"
"wide" "230"
"tall" "24"
Expand Down Expand Up @@ -339,7 +339,7 @@
{
"ControlName" "CCvarCheckButton"
"fieldName" "JumpSpeedCrossCheckbox"
"xpos" "194"
"xpos" "230"
"ypos" "232"
"wide" "230"
"tall" "24"
Expand Down Expand Up @@ -367,9 +367,9 @@
{
"ControlName" "CCvarCheckButton"
"fieldName" "DeathnoticeCheckbox"
"xpos" "264"
"ypos" "136"
"wide" "238"
"xpos" "230"
"ypos" "184"
"wide" "192"
"tall" "24"
"autoResize" "0"
"pinCorner" "0"
Expand All @@ -391,6 +391,50 @@
"useproportionalinsets" "0"
"Default" "0"
}
"TimerBox"
{
"ControlName" "CCVarComboBox"
"fieldName" "TimerBox"
"xpos" "274"
"ypos" "92"
"wide" "192"
"tall" "24"
"autoResize" "0"
"pinCorner" "0"
"RoundedCorners" "15"
"pin_corner_to_sibling" "0"
"pin_to_sibling_corner" "0"
"visible" "1"
"enabled" "1"
"tabPosition" "0"
"textHidden" "0"
"editable" "0"
"maxchars" "-1"
"NumericInputOnly" "0"
"unicode" "0"
}
"ScaleBox"
{
"ControlName" "CCVarComboBox"
"fieldName" "ScaleBox"
"xpos" "274"
"ypos" "145"
"wide" "192"
"tall" "24"
"autoResize" "0"
"pinCorner" "0"
"RoundedCorners" "15"
"pin_corner_to_sibling" "0"
"pin_to_sibling_corner" "0"
"visible" "1"
"enabled" "1"
"tabPosition" "0"
"textHidden" "0"
"editable" "0"
"maxchars" "-1"
"NumericInputOnly" "0"
"unicode" "0"
}
"TimerLabel"
{
"ControlName" "Label"
Expand Down Expand Up @@ -418,13 +462,13 @@
"autowidetocontents" "0"
"useproportionalinsets" "0"
}
"TimerBox"
"Label1"
{
"ControlName" "ComboBox"
"fieldName" "TimerBox"
"xpos" "274"
"ypos" "92"
"wide" "192"
"ControlName" "Label"
"fieldName" "Label1"
"xpos" "28"
"ypos" "256"
"wide" "280"
"tall" "24"
"autoResize" "0"
"pinCorner" "0"
Expand All @@ -434,19 +478,24 @@
"visible" "1"
"enabled" "1"
"tabPosition" "0"
"textHidden" "0"
"editable" "0"
"maxchars" "-1"
"NumericInputOnly" "0"
"unicode" "0"
"labelText" "#BHL_AdvOptions_HUD_RenderMsg"
"textAlignment" "west"
"dulltext" "1"
"brighttext" "0"
"wrap" "0"
"centerwrap" "0"
"textinsetx" "0"
"textinsety" "0"
"autowidetocontents" "0"
"useproportionalinsets" "0"
}
"Label1"
"Label2"
{
"ControlName" "Label"
"fieldName" "Label1"
"xpos" "28"
"ypos" "256"
"wide" "280"
"fieldName" "Label2"
"xpos" "276"
"ypos" "117"
"wide" "214"
"tall" "24"
"autoResize" "0"
"pinCorner" "0"
Expand All @@ -456,9 +505,9 @@
"visible" "1"
"enabled" "1"
"tabPosition" "0"
"labelText" "#BHL_AdvOptions_HUD_RenderMsg"
"labelText" "#BHL_AdvOptions_Hud_Scale"
"textAlignment" "west"
"dulltext" "1"
"dulltext" "0"
"brighttext" "0"
"wrap" "0"
"centerwrap" "0"
Expand All @@ -471,8 +520,8 @@
{
"ControlName" "BuildModeDialog"
"fieldName" "BuildModeDialog"
"xpos" "1146"
"ypos" "308"
"xpos" "1076"
"ypos" "226"
"wide" "300"
"tall" "420"
"autoResize" "0"
Expand Down
33 changes: 9 additions & 24 deletions src/game/client/gameui/options/options_hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,19 @@ CHudSubOptions::CHudSubOptions(vgui2::Panel *parent)

m_pDeathnoticeVGui = new CCvarCheckButton(this, "DeathnoticeCheckbox", "#BHL_AdvOptions_HUD_Deathnotice", "hud_deathnotice_vgui");

m_pTimerLabel = new vgui2::Label(this, "TimerLabel", "#BHL_AdvOptions_Hud_Timer");
m_pTimerBox = new CCVarComboBox(this, "TimerBox", "hud_timer");
m_pTimerBox->AddItem("#BHL_AdvOptions_Hud_Timer0", "0");
m_pTimerBox->AddItem("#BHL_AdvOptions_Hud_Timer1", "1");
m_pTimerBox->AddItem("#BHL_AdvOptions_Hud_Timer2", "2");
m_pTimerBox->AddItem("#BHL_AdvOptions_Hud_Timer3", "3");

m_pScaleBox = new CCVarComboBox(this, "ScaleBox", "hud_scale");
m_pScaleBox->AddItem("#BHL_AdvOptions_Hud_ScaleAuto", "0");
m_pScaleBox->AddItem("50%", "1");
m_pScaleBox->AddItem("100%", "2");
m_pScaleBox->AddItem("200%", "3");
m_pScaleBox->AddItem("400%", "5");

LoadControlSettings(VGUI2_ROOT_DIR "resource/options/HudSubOptions.res");
m_pOpacityLabel->MoveToFront(); // Obscured by the slider

Expand All @@ -56,29 +62,6 @@ CHudSubOptions::CHudSubOptions(vgui2::Panel *parent)
}
}

void CHudSubOptions::PerformLayout()
{
BaseClass::PerformLayout();

int x, speedY, jumpY;
int wide, tall;

// Resize hud_speedometer
m_pSpeedCheckbox->GetPos(x, speedY);
m_pSpeedCheckbox->GetContentSize(wide, tall);
m_pSpeedCheckbox->SetWide(wide);
int xpos = x + wide;

// Resize hud_jumpspeed
m_pJumpSpeedCheckbox->GetPos(x, jumpY);
m_pJumpSpeedCheckbox->GetContentSize(wide, tall);
m_pJumpSpeedCheckbox->SetWide(wide);
xpos = max(xpos, x + wide);

m_pSpeedCrossCheckbox->SetPos(xpos + 4, speedY);
m_pJumpSpeedCrossCheckbox->SetPos(xpos + 4, jumpY);
}

void CHudSubOptions::OnResetData()
{
if (m_pRenderCheckbox->IsEnabled())
Expand All @@ -103,6 +86,7 @@ void CHudSubOptions::OnResetData()
m_pDeathnoticeVGui->SetSelected(false);

m_pTimerBox->ResetData();
m_pScaleBox->ResetData();
}

void CHudSubOptions::OnApplyChanges()
Expand All @@ -125,6 +109,7 @@ void CHudSubOptions::OnApplyChanges()
m_pDeathnoticeVGui->ApplyChanges();

m_pTimerBox->ApplyChanges();
m_pScaleBox->ApplyChanges();
}

void CHudSubOptions::OnSliderMoved(KeyValues *kv)
Expand Down
3 changes: 1 addition & 2 deletions src/game/client/gameui/options/options_hud.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class CHudSubOptions : public vgui2::PropertyPage
public:
CHudSubOptions(vgui2::Panel *parent);

void PerformLayout() override;
void OnResetData() override;
void OnApplyChanges() override;

Expand All @@ -43,8 +42,8 @@ class CHudSubOptions : public vgui2::PropertyPage

CCvarCheckButton *m_pDeathnoticeVGui = nullptr;

vgui2::Label *m_pTimerLabel = nullptr;
CCVarComboBox *m_pTimerBox = nullptr;
CCVarComboBox *m_pScaleBox = nullptr;

MESSAGE_FUNC_PARAMS(OnSliderMoved, "SliderMoved", kv);
MESSAGE_FUNC_PARAMS(OnCvarTextChanged, "CvarTextChanged", kv);
Expand Down

0 comments on commit ddede7e

Please sign in to comment.