Skip to content

Commit

Permalink
option whether to draw !keys in the center or menu for csgo
Browse files Browse the repository at this point in the history
  • Loading branch information
rtldg committed Jan 11, 2022
1 parent e1e4047 commit f474a94
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions addons/sourcemod/scripting/include/shavit/hud.inc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#define HUD2_VELOCITYDIFFERENCE (1 << 13)
#define HUD2_USPSILENCER (1 << 14) // spawns usps with a silencer on
#define HUD2_GLOCKBURST (1 << 15) // spawns glocks with burst
#define HUD2_CENTERKEYS (1 << 16) // CSGO option to toggle whether !keys is shown as center-text or in that panel thing.

#define HUD_DEFAULT (HUD_MASTER|HUD_CENTER|HUD_ZONEHUD|HUD_OBSERVE|HUD_TOPLEFT|HUD_SYNC|HUD_TIMELEFT|HUD_2DVEL|HUD_SPECTATORS)
#define HUD_DEFAULT2 (HUD2_PERFS)
Expand Down
24 changes: 20 additions & 4 deletions addons/sourcemod/scripting/shavit-hud.sp
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,13 @@ Action ShowHUDMenu(int client, int item)
menu.AddItem(sInfo, sHudItem);
}

if (gEV_Type == Engine_CSGO)
{
FormatEx(sInfo, 16, "@%d", HUD2_CENTERKEYS);
FormatEx(sHudItem, 64, "%T", "HudCenterKeys", client);
menu.AddItem(sInfo, sHudItem);
}

menu.ExitButton = true;
menu.DisplayAt(client, item, MENU_TIME_FOREVER);

Expand Down Expand Up @@ -1077,7 +1084,13 @@ void TriggerHUDUpdate(int client, bool keysonly = false) // keysonly because CS:
UpdateTopLeftHUD(client, true);
}

UpdateCenterKeys(client);
bool draw_keys = HUD1Enabled(gI_HUDSettings[client], HUD_KEYOVERLAY);
bool center_keys = HUD2Enabled(gI_HUD2Settings[client], HUD2_CENTERKEYS);

if (draw_keys && center_keys)
{
UpdateCenterKeys(client);
}

if(IsSource2013(gEV_Type))
{
Expand All @@ -1086,16 +1099,19 @@ void TriggerHUDUpdate(int client, bool keysonly = false) // keysonly because CS:
UpdateKeyHint(client);
}
}
else if ((gI_HUDSettings[client] & HUD_SPECTATORS) > 0
else if (((gI_HUDSettings[client] & HUD_SPECTATORS) > 0 || (draw_keys && !center_keys))
&& (!gB_Zones || !Shavit_IsClientCreatingZone(client))
&& (GetClientMenu(client, null) == MenuSource_None || GetClientMenu(client, null) == MenuSource_RawPanel)
)
{
bool bShouldDraw = false;
Panel pHUD = new Panel();

//UpdateKeyOverlay(client, pHUD, bShouldDraw);
//pHUD.DrawItem("", ITEMDRAW_RAWLINE);
if (!center_keys)
{
UpdateKeyOverlay(client, pHUD, bShouldDraw);
pHUD.DrawItem("", ITEMDRAW_RAWLINE);
}

UpdateSpectatorList(client, pHUD, bShouldDraw);

Expand Down
4 changes: 4 additions & 0 deletions addons/sourcemod/translations/shavit-hud.phrases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@
"#format" "{1:d}"
"en" "(Speed Limit: {1})"
}
"HudCenterKeys"
{
"en" "!keys in the center"
}
// ---------- Menus ---------- //
"HUDMenuTitle"
{
Expand Down

0 comments on commit f474a94

Please sign in to comment.