From b2713fd3191f8588b87d025408974d0d8293b385 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 21 Oct 2018 01:56:49 +1000 Subject: [PATCH] Add an option to sort weapons by priority in the weapons panel --- _hud_descriptions.cfg | 1 + hud_luma.cfg | 1 + hud_luminos.cfg | 1 + hud_luminos_minimal.cfg | 1 + hud_luminos_minimal_xhair.cfg | 1 + hud_luminos_old.cfg | 1 + hud_nexuiz.cfg | 1 + qcsrc/client/autocvars.qh | 1 + qcsrc/client/defs.qh | 1 + qcsrc/client/hud/hud_config.qc | 1 + qcsrc/client/hud/panel/weapons.qc | 8 ++++++-- 11 files changed, 16 insertions(+), 2 deletions(-) diff --git a/_hud_descriptions.cfg b/_hud_descriptions.cfg index 30e5a8bee..6e393e6a5 100644 --- a/_hud_descriptions.cfg +++ b/_hud_descriptions.cfg @@ -63,6 +63,7 @@ seta hud_panel_weapons_label_scale "" "scale of the weapon text label" seta hud_panel_weapons_accuracy "" "show accuracy color as the weapon icon background; colors can be configured with accuracy_color* cvars" seta hud_panel_weapons_ammo "" "show ammo as a status bar" seta hud_panel_weapons_onlyowned "" "show only owned weapons, set it to 2 to show only the held weapon" +seta hud_panel_weapons_orderbyimpulse "" "List weapons in their impulse order instead of priority" seta hud_panel_weapons_noncurrent_alpha "" "alpha of noncurrent weapons" seta hud_panel_weapons_noncurrent_scale "" "scale of noncurrent weapons, relative to the current weapon" seta hud_panel_weapons_selection_radius "" "number of weapons that get partially highlighted on each side of the currently selected weapon" diff --git a/hud_luma.cfg b/hud_luma.cfg index 9dcfe0629..c4ef1b0c2 100644 --- a/hud_luma.cfg +++ b/hud_luma.cfg @@ -64,6 +64,7 @@ seta hud_panel_weapons_timeout_fadefgmin "0.4" seta hud_panel_weapons_timeout_speed_in "0.25" seta hud_panel_weapons_timeout_speed_out "0.75" seta hud_panel_weapons_onlyowned "1" +seta hud_panel_weapons_orderbyimpulse "1" seta hud_panel_weapons_noncurrent_alpha "0.8" seta hud_panel_weapons_noncurrent_scale "0.9" seta hud_panel_weapons_selection_radius "0" diff --git a/hud_luminos.cfg b/hud_luminos.cfg index 3f4fe39fa..15b9066da 100644 --- a/hud_luminos.cfg +++ b/hud_luminos.cfg @@ -64,6 +64,7 @@ seta hud_panel_weapons_timeout_fadefgmin "0.4" seta hud_panel_weapons_timeout_speed_in "0.25" seta hud_panel_weapons_timeout_speed_out "0.75" seta hud_panel_weapons_onlyowned "1" +seta hud_panel_weapons_orderbyimpulse "1" seta hud_panel_weapons_noncurrent_alpha "1" seta hud_panel_weapons_noncurrent_scale "1" seta hud_panel_weapons_selection_radius "0" diff --git a/hud_luminos_minimal.cfg b/hud_luminos_minimal.cfg index 609ab766d..eb61ca79e 100644 --- a/hud_luminos_minimal.cfg +++ b/hud_luminos_minimal.cfg @@ -64,6 +64,7 @@ seta hud_panel_weapons_timeout_fadefgmin "0" seta hud_panel_weapons_timeout_speed_in "0.25" seta hud_panel_weapons_timeout_speed_out "0.75" seta hud_panel_weapons_onlyowned "1" +seta hud_panel_weapons_orderbyimpulse "1" seta hud_panel_weapons_noncurrent_alpha "1" seta hud_panel_weapons_noncurrent_scale "1" seta hud_panel_weapons_selection_radius "0" diff --git a/hud_luminos_minimal_xhair.cfg b/hud_luminos_minimal_xhair.cfg index b7a7d20ab..bd4dc3f3f 100644 --- a/hud_luminos_minimal_xhair.cfg +++ b/hud_luminos_minimal_xhair.cfg @@ -64,6 +64,7 @@ seta hud_panel_weapons_timeout_fadefgmin "0" seta hud_panel_weapons_timeout_speed_in "0.25" seta hud_panel_weapons_timeout_speed_out "0.75" seta hud_panel_weapons_onlyowned "1" +seta hud_panel_weapons_orderbyimpulse "1" seta hud_panel_weapons_noncurrent_alpha "1" seta hud_panel_weapons_noncurrent_scale "1" seta hud_panel_weapons_selection_radius "0" diff --git a/hud_luminos_old.cfg b/hud_luminos_old.cfg index ce8186811..82b70e222 100644 --- a/hud_luminos_old.cfg +++ b/hud_luminos_old.cfg @@ -64,6 +64,7 @@ seta hud_panel_weapons_timeout_fadefgmin "0" seta hud_panel_weapons_timeout_speed_in "0.25" seta hud_panel_weapons_timeout_speed_out "0.75" seta hud_panel_weapons_onlyowned "1" +seta hud_panel_weapons_orderbyimpulse "1" seta hud_panel_weapons_noncurrent_alpha "1" seta hud_panel_weapons_noncurrent_scale "1" seta hud_panel_weapons_selection_radius "0" diff --git a/hud_nexuiz.cfg b/hud_nexuiz.cfg index 4159b01c7..b3733967e 100644 --- a/hud_nexuiz.cfg +++ b/hud_nexuiz.cfg @@ -64,6 +64,7 @@ seta hud_panel_weapons_timeout_fadefgmin "0" seta hud_panel_weapons_timeout_speed_in "0.25" seta hud_panel_weapons_timeout_speed_out "0.75" seta hud_panel_weapons_onlyowned "0" +seta hud_panel_weapons_orderbyimpulse "1" seta hud_panel_weapons_noncurrent_alpha "1" seta hud_panel_weapons_noncurrent_scale "1" seta hud_panel_weapons_selection_radius "0" diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index db756608d..dd6ba66af 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -351,6 +351,7 @@ float autocvar_hud_panel_weapons_selection_radius = 0; float autocvar_hud_panel_weapons_selection_speed = 10; float autocvar_hud_panel_weapons_timeout; int autocvar_hud_panel_weapons_timeout_effect; +bool autocvar_hud_panel_weapons_orderbyimpulse = true; float autocvar_hud_panel_weapons_timeout_fadebgmin; float autocvar_hud_panel_weapons_timeout_fadefgmin; float autocvar_hud_panel_weapons_timeout_speed_in = 0.25; diff --git a/qcsrc/client/defs.qh b/qcsrc/client/defs.qh index 5204e8f36..788c1bac3 100644 --- a/qcsrc/client/defs.qh +++ b/qcsrc/client/defs.qh @@ -114,6 +114,7 @@ float bgmtime; string weaponorder_byimpulse; string weaponorder_bypriority; +bool weapons_orderbyimpulse; // update priority list when toggling this float vortex_charge_movingavg; diff --git a/qcsrc/client/hud/hud_config.qc b/qcsrc/client/hud/hud_config.qc index 3043e6e68..a6c22c74e 100644 --- a/qcsrc/client/hud/hud_config.qc +++ b/qcsrc/client/hud/hud_config.qc @@ -97,6 +97,7 @@ void HUD_Panel_ExportCfg(string cfgname) HUD_Write_Cvar("hud_panel_weapons_timeout_speed_in"); HUD_Write_Cvar("hud_panel_weapons_timeout_speed_out"); HUD_Write_Cvar("hud_panel_weapons_onlyowned"); + HUD_Write_Cvar("hud_panel_weapons_orderbyimpulse"); HUD_Write_Cvar("hud_panel_weapons_noncurrent_alpha"); HUD_Write_Cvar("hud_panel_weapons_noncurrent_scale"); HUD_Write_Cvar("hud_panel_weapons_selection_radius"); diff --git a/qcsrc/client/hud/panel/weapons.qc b/qcsrc/client/hud/panel/weapons.qc index 8bf11cf1a..aae33881b 100644 --- a/qcsrc/client/hud/panel/weapons.qc +++ b/qcsrc/client/hud/panel/weapons.qc @@ -91,11 +91,15 @@ void HUD_Weapons() HUD_Panel_LoadCvars(); // figure out weapon order (how the weapons are sorted) // TODO make this configurable - if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0]) + if(weaponorder_bypriority != autocvar_cl_weaponpriority || autocvar_hud_panel_weapons_orderbyimpulse != weapons_orderbyimpulse || !weaponorder[0]) { int weapon_cnt; + weapons_orderbyimpulse = autocvar_hud_panel_weapons_orderbyimpulse; strcpy(weaponorder_bypriority, autocvar_cl_weaponpriority); - strcpy(weaponorder_byimpulse, W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority)))); + string weporder = W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority)); + if(autocvar_hud_panel_weapons_orderbyimpulse) + weporder = W_FixWeaponOrder_BuildImpulseList(weporder); + strcpy(weaponorder_byimpulse, weporder); weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " "); weapon_cnt = 0; -- 2.39.2