Skip to content

Commit

Permalink
Client: ScorePanel: Add RCD efficiency type
Browse files Browse the repository at this point in the history
  • Loading branch information
tmp64 committed Sep 29, 2024
1 parent d35250b commit 5c05c5b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 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.
6 changes: 3 additions & 3 deletions src/game/client/gameui/options/options_scoreboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ CScoreboardSubOptions::CScoreboardSubOptions(vgui2::Panel *parent)

m_pShowEff = new CCvarCheckButton(this, "ShowEff", "#BHL_AdvOptions_Scores_ShowEff", "hud_scoreboard_showeff");
m_pEffTypeLabel = new vgui2::Label(this, "EffTypeLabel", "#BHL_AdvOptions_Scores_EffType");
m_pEffTypeBox = new vgui2::ComboBox(this, "EffTypeBox", 2, false);
m_pEffTypeBox = new vgui2::ComboBox(this, "EffTypeBox", 3, false);
m_EffTypeItems[0] = m_pEffTypeBox->AddItem("#BHL_AdvOptions_Scores_EffType0", new KeyValues("Type0", "value", 0));
m_EffTypeItems[1] = m_pEffTypeBox->AddItem("#BHL_AdvOptions_Scores_EffType1", new KeyValues("Type1", "value", 1));
m_EffTypeItems[1] = m_pEffTypeBox->AddItem("#BHL_AdvOptions_Scores_EffType2", new KeyValues("Type2", "value", 2));

m_pMouseLabel = new vgui2::Label(this, "MouseLabel", "#BHL_AdvOptions_Scores_Mouse");
m_pMouseBox = new vgui2::ComboBox(this, "MouseBox", 3, false);
Expand Down Expand Up @@ -48,7 +49,7 @@ void CScoreboardSubOptions::OnResetData()
m_pShowInHud->ResetData();

int type = gEngfuncs.pfnGetCvarFloat("hud_scoreboard_efftype");
type = clamp(type, 0, 1);
type = clamp(type, 0, 2);
m_pEffTypeBox->ActivateItem(m_EffTypeItems[type]);

type = gEngfuncs.pfnGetCvarFloat("hud_scoreboard_mousebtn");
Expand Down Expand Up @@ -77,7 +78,6 @@ void CScoreboardSubOptions::ApplyEffType()
KeyValues *userdata = m_pEffTypeBox->GetActiveItemUserData();
Assert(userdata);
int val = userdata->GetInt("value", 0);
Assert(val >= 0 && val <= 1);

char buf[128];
snprintf(buf, sizeof(buf), "hud_scoreboard_efftype %d", val);
Expand Down
9 changes: 8 additions & 1 deletion src/game/client/vgui/score_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ Color CScorePanel::GetPlayerBgColor(CPlayerInfo *pi)

float CScorePanel::CalculateEfficiency(int kills, int deaths)
{
int type = clamp(hud_scoreboard_efftype.GetInt(), 0, 1);
int type = clamp(hud_scoreboard_efftype.GetInt(), 0, 2);

switch (type)
{
Expand All @@ -866,6 +866,13 @@ float CScorePanel::CalculateEfficiency(int kills, int deaths)
deaths = 0;
return (float)kills / (deaths + 1);
}
case 2:
{
// K / (K + D)
if (kills + deaths == 0)
return 1.0f;
return (float)kills / (kills + deaths);
}
}

return 0;
Expand Down

0 comments on commit 5c05c5b

Please sign in to comment.