]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Weapons panel: allow to show only the held weapon (hud_panel_weapons_onlyowned 2)
authorterencehill <piuntn@gmail.com>
Mon, 18 Jun 2018 17:18:03 +0000 (19:18 +0200)
committerterencehill <piuntn@gmail.com>
Mon, 18 Jun 2018 17:18:03 +0000 (19:18 +0200)
_hud_descriptions.cfg
qcsrc/client/autocvars.qh
qcsrc/client/hud/panel/weapons.qc

index 9a1654f83abd1a177f392a12fd6d785ce883a706..30e5a8bee9a8756fe9fafe883306260e1e4025aa 100644 (file)
@@ -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"
index b6b33c3b1766670b0f8350b37236fa37bbb23da1..8eb3ca1dcb1a623111fc2a7a095d31ff946ebdc0 100644 (file)
@@ -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;
index 4506f69a0c591b603d41ca4fa5f6a497581c071f..f94979133c588c634d576f8e8b1b1fb545fa9337 100644 (file)
@@ -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
                {