From 97cfd32677a2aff42e3c5d9b9e23d30fbc00ab8a Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Fri, 3 Feb 2023 16:23:19 +0100 Subject: [PATCH] Add a cvar to swap health and armor position on alternative HUD When enabled, this makes the layout identical to the standard HUD (similar to how most other games lay out health and armor on a HUD). --- src/g_statusbar/shared_hud.cpp | 2 +- wadsrc/static/menudef.txt | 1 + wadsrc/static/zscript/ui/statusbar/alt_hud.zs | 8 ++++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/g_statusbar/shared_hud.cpp b/src/g_statusbar/shared_hud.cpp index a6a6ea410..f53e93a74 100644 --- a/src/g_statusbar/shared_hud.cpp +++ b/src/g_statusbar/shared_hud.cpp @@ -74,6 +74,7 @@ CVAR (Int , hud_showlag, 0, CVAR_ARCHIVE); // Show input latency (maketic - g CVAR (Int, hud_ammo_order, 0, CVAR_ARCHIVE); // ammo image and text order CVAR (Int, hud_ammo_red, 25, CVAR_ARCHIVE) // ammo percent less than which status is red CVAR (Int, hud_ammo_yellow, 50, CVAR_ARCHIVE) // ammo percent less is yellow more green +CVAR (Bool, hud_swaphealtharmor, false, CVAR_ARCHIVE); // swap health and armor position on HUD CVAR (Int, hud_health_red, 25, CVAR_ARCHIVE) // health amount less than which status is red CVAR (Int, hud_health_yellow, 50, CVAR_ARCHIVE) // health amount less than which status is yellow CVAR (Int, hud_health_green, 100, CVAR_ARCHIVE) // health amount above is blue, below is green @@ -193,4 +194,3 @@ void DBaseStatusBar::DrawAltHUD() VMCall(func, params, countof(params), nullptr, 0); } } - diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index d92e1280e..517ef29d0 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -1155,6 +1155,7 @@ OptionMenu "AltHUDOptions" protected Option "$ALTHUDMNU_AMMOORDER", "hud_ammo_order", "AltHUDAmmoOrder" Slider "$ALTHUDMNU_AMMORED", "hud_ammo_red", 0, 100, 1, 0 Slider "$ALTHUDMNU_AMMOYELLOW", "hud_ammo_yellow", 0, 100, 1, 0 + Option "$ALTHUDMNU_SWAPHEALTHARMOR", "hud_swaphealtharmor", "OnOff" Slider "$ALTHUDMNU_HEALTHRED", "hud_health_red", 0, 100, 1, 0 Slider "$ALTHUDMNU_HEALTHYELLOW", "hud_health_yellow", 0, 100, 1, 0 Slider "$ALTHUDMNU_HEALTHGREEN", "hud_health_green", 0, 100, 1, 0 diff --git a/wadsrc/static/zscript/ui/statusbar/alt_hud.zs b/wadsrc/static/zscript/ui/statusbar/alt_hud.zs index 69939da27..203d55ec4 100644 --- a/wadsrc/static/zscript/ui/statusbar/alt_hud.zs +++ b/wadsrc/static/zscript/ui/statusbar/alt_hud.zs @@ -926,8 +926,12 @@ class AltHud ui DrawStatus(CPlayer, 5, hudheight-75); DrawFrags(CPlayer, 5, hudheight-70); } - DrawHealth(CPlayer, 5, hudheight-45); - DrawArmor(BasicArmor(CPlayer.mo.FindInventory('BasicArmor')), HexenArmor(CPlayer.mo.FindInventory('HexenArmor')), 5, hudheight-20); + + int armory = hud_swaphealtharmor ? hudheight-45 : hudheight-20; + int healthy = hud_swaphealtharmor ? hudheight-20 : hudheight-45; + DrawHealth(CPlayer, 5, healthy); + DrawArmor(BasicArmor(CPlayer.mo.FindInventory('BasicArmor')), HexenArmor(CPlayer.mo.FindInventory('HexenArmor')), 5, armory); + int y = DrawKeys(CPlayer, hudwidth-4, hudheight-10); y = DrawAmmo(CPlayer, hudwidth-5, y); if (hud_showweapons) DrawWeapons(CPlayer, hudwidth - 5, y);