]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud/panel/weapons.qc
Merge branch 'Mario/cs_clientcvars' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud / panel / weapons.qc
index fe2aefc60d1c3fe5f123c49386a235ccb3cc2b8b..a7c0ade00b473de2f7e49cd3604464f657e1fe59 100644 (file)
@@ -1,5 +1,12 @@
 #include "weapons.qh"
-// Weapon icons (#0)
+
+#include <client/autocvars.qh>
+#include <client/defs.qh>
+#include <client/miscfunctions.qh>
+#include <client/view.qh>
+#include <common/wepent.qh>
+
+// Weapons (#0)
 
 entity weaponorder[Weapons_MAX];
 void weaponorder_swap(int i, int j, entity pass)
@@ -23,7 +30,7 @@ int weaponorder_cmp(int i, int j, entity pass)
        int nHidden = 0; \
        FOREACH(Weapons, it != WEP_Null, { \
                if (weapons_stat & WepSet_FromWeapon(it)) continue; \
-               if (it.spawnflags & WEP_FLAG_MUTATORBLOCKED) nHidden += 1; \
+               if (it.spawnflags & WEP_FLAG_HIDDEN || it.spawnflags & WEP_FLAG_MUTATORBLOCKED) nHidden += 1; \
        }); \
        vector table_size = HUD_GetTableSize_BestItemAR((Weapons_COUNT - 1) - nHidden, panel_size, aspect); \
        columns = table_size.x; \
@@ -81,7 +88,7 @@ void HUD_Weapons()
        }
 
        // update generic hud functions
-       HUD_Panel_UpdateCvars();
+       HUD_Panel_LoadCvars();
 
        // figure out weapon order (how the weapons are sorted) // TODO make this configurable
        if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
@@ -152,7 +159,7 @@ void HUD_Weapons()
                if(autocvar__hud_configure)
                {
                        if(hud_configure_menu_open != 2)
-                               HUD_Panel_DrawBg(1); // also draw the bg of the entire panel
+                               HUD_Panel_DrawBg(); // also draw the bg of the entire panel
                }
 
                // do we own this weapon?
@@ -314,7 +321,7 @@ void HUD_Weapons()
                HUD_Scale_Enable();
        else
                HUD_Scale_Disable();
-       HUD_Panel_DrawBg(1);
+       HUD_Panel_DrawBg();
 
        if(center.x == -1)
                return; // panel has gone off screen
@@ -371,10 +378,12 @@ void HUD_Weapons()
                switch_speed = frametime * autocvar_hud_panel_weapons_selection_speed;
        vector radius_size = weapon_size * (autocvar_hud_panel_weapons_selection_radius + 1);
 
-       if(switchweapon == WEP_Null)
+       entity wepent = viewmodels[0]; // TODO: unhardcode
+
+       if(wepent.switchweapon == WEP_Null)
                panel_switchweapon = NULL;
        else if(!panel_switchweapon)
-               panel_switchweapon = 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
@@ -403,7 +412,7 @@ void HUD_Weapons()
                }
 
                // figure out the drawing position of weapon
-               weapon_pos = (panel_pos + eX * column * weapon_size.x + eY * row * weapon_size.y);
+               weapon_pos = panel_pos + vec2(column * weapon_size.x, row * weapon_size.y);
 
                // update position of the currently selected weapon
                if(it == panel_switchweapon)