From: terencehill Date: Mon, 18 Jun 2018 17:18:03 +0000 (+0200) Subject: Weapons panel: allow to show only the held weapon (hud_panel_weapons_onlyowned 2) X-Git-Tag: xonotic-v0.8.5~2010^2~2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=700f5d7a71980b894c79e0b5d7defe6aa0b45d96;p=xonotic%2Fxonotic-data.pk3dir.git Weapons panel: allow to show only the held weapon (hud_panel_weapons_onlyowned 2) --- diff --git a/_hud_descriptions.cfg b/_hud_descriptions.cfg index 9a1654f83..30e5a8bee 100644 --- a/_hud_descriptions.cfg +++ b/_hud_descriptions.cfg @@ -62,7 +62,7 @@ seta hud_panel_weapons_label "" "1 = show number of weapon, 2 = show bound key o 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" +seta hud_panel_weapons_onlyowned "" "show only owned weapons, set it to 2 to show only the held weapon" 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/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index b6b33c3b1..8eb3ca1dc 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -344,7 +344,7 @@ float autocvar_hud_panel_weapons_complainbubble_padding; float autocvar_hud_panel_weapons_complainbubble_time; int autocvar_hud_panel_weapons_label; float autocvar_hud_panel_weapons_label_scale = 0.5; -bool autocvar_hud_panel_weapons_onlyowned; +int autocvar_hud_panel_weapons_onlyowned; float autocvar_hud_panel_weapons_noncurrent_alpha = 1; float autocvar_hud_panel_weapons_noncurrent_scale = 1; float autocvar_hud_panel_weapons_selection_radius = 0; diff --git a/qcsrc/client/hud/panel/weapons.qc b/qcsrc/client/hud/panel/weapons.qc index 4506f69a0..f94979133 100644 --- a/qcsrc/client/hud/panel/weapons.qc +++ b/qcsrc/client/hud/panel/weapons.qc @@ -110,6 +110,13 @@ void HUD_Weapons() if(!autocvar_hud_panel_weapons_complainbubble || autocvar__hud_configure || time - complain_weapon_time >= when + fadetime) complain_weapon = 0; + entity wepent = viewmodels[0]; // TODO: unhardcode + + if (wepent.switchweapon == WEP_Null) + panel_switchweapon = NULL; + else if (!panel_switchweapon) + panel_switchweapon = wepent.switchweapon; + if(autocvar__hud_configure) { if(!weapons_stat) @@ -159,10 +166,18 @@ void HUD_Weapons() // do we own this weapon? weapon_count = 0; - for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i) - if((weapons_stat & WepSet_FromWeapon(weaponorder[i])) || (weaponorder[i].m_id == complain_weapon)) - ++weapon_count; - + if (autocvar_hud_panel_weapons_onlyowned >= 2) // only current + { + for (i = 0; i <= WEP_LAST-WEP_FIRST; ++i) + if (weaponorder[i] == panel_switchweapon || weaponorder[i].m_id == complain_weapon) + ++weapon_count; + } + else + { + for (i = 0; i <= WEP_LAST-WEP_FIRST; ++i) + if ((weapons_stat & WepSet_FromWeapon(weaponorder[i])) || weaponorder[i].m_id == complain_weapon) + ++weapon_count; + } // might as well commit suicide now, no reason to live ;) if (weapon_count == 0) @@ -373,13 +388,6 @@ void HUD_Weapons() switch_speed = frametime * autocvar_hud_panel_weapons_selection_speed; vector radius_size = weapon_size * (autocvar_hud_panel_weapons_selection_radius + 1); - entity wepent = viewmodels[0]; // TODO: unhardcode - - if(wepent.switchweapon == WEP_Null) - panel_switchweapon = NULL; - else if(!panel_switchweapon) - panel_switchweapon = wepent.switchweapon; - // draw background behind currently selected weapon // do it earlier to make sure bg is drawn behind every weapon icons while it's moving if(panel_switchweapon) @@ -395,10 +403,18 @@ void HUD_Weapons() if(!it || weapon_id < 0) { continue; } // skip this weapon if we don't own it (and onlyowned is enabled)-- or if weapons_complainbubble is showing for this weapon - if(autocvar_hud_panel_weapons_onlyowned) + if (autocvar_hud_panel_weapons_onlyowned) { - if (!((weapons_stat & WepSet_FromWeapon(it)) || (it.m_id == complain_weapon))) - continue; + if (autocvar_hud_panel_weapons_onlyowned >= 2) // only current + { + if (!(it == panel_switchweapon || it.m_id == complain_weapon)) + continue; + } + else + { + if (!((weapons_stat & WepSet_FromWeapon(it)) || (it.m_id == complain_weapon))) + continue; + } } else {