]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into terencehill/essential_weapons_panel
authorterencehill <piuntn@gmail.com>
Thu, 19 May 2011 17:11:38 +0000 (19:11 +0200)
committerterencehill <piuntn@gmail.com>
Thu, 19 May 2011 17:11:38 +0000 (19:11 +0200)
defaultXonotic.cfg
qcsrc/client/autocvars.qh
qcsrc/client/hud.qc

index 1db88b208faf9dd15925c4584a12ac6980257292..015050522be352a498afcb963fa36a78b941c60f 100644 (file)
@@ -1427,6 +1427,7 @@ seta hud_panel_weapons_ammo_full_nails 200 "show 100% of the status bar at this
 seta hud_panel_weapons_ammo_full_cells 80 "show 100% of the status bar at this ammo count"
 seta hud_panel_weapons_ammo_full_rockets 80 "show 100% of the status bar at this ammo count"
 seta hud_panel_weapons_ammo_full_fuel 100 "show 100% of the status bar at this ammo count"
+seta hud_panel_weapons_onlyowned 0 "show only owned weapons"
 
 seta hud_panel_ammo_maxammo "40" "when you have this much ammo, the ammo status bar is full"
 
index b2a1602686530db5db228200b390fb5fc1379fff..fd1357c3999601e1d8b5b5fcefe17a315025f9f2 100644 (file)
@@ -273,6 +273,7 @@ float autocvar_hud_panel_weapons_complainbubble_padding;
 float autocvar_hud_panel_weapons_complainbubble_time;
 var float autocvar_hud_panel_weapons_fade = 1;
 float autocvar_hud_panel_weapons_label;
+float autocvar_hud_panel_weapons_onlyowned;
 float autocvar_hud_panel_weapons_timeout;
 float autocvar_hud_panel_weapons_timeout_effect;
 float autocvar_hud_progressbar_alpha;
index 91256b9c5d566bb9d1d900368ceb53688992766e..a3926d012fd404978301d855f2628ada64100d07 100644 (file)
@@ -612,7 +612,7 @@ float GetAmmoTypeForWep(float i)
 
 void HUD_Weapons(void)
 {
-       float f, screen_ar;
+       float i, f, screen_ar;
        float center_x, center_y;
 
        if(!autocvar__hud_configure)
@@ -644,6 +644,33 @@ void HUD_Weapons(void)
 
        HUD_Panel_UpdateCvars(weapons);
 
+       float weapons_st = getstati(STAT_WEAPONS);
+       float weapon_count;
+       if (!autocvar__hud_configure && autocvar_hud_panel_weapons_onlyowned)
+       {
+               vector old_panel_size;
+               for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
+               {
+                       if(weapons_st & weaponorder[i].weapons)
+                               ++weapon_count;
+               }
+               // reduce size of the panel
+               if (panel_size_y > panel_size_x)
+               {
+                       old_panel_size_y = panel_size_y;
+                       panel_size_y *= weapon_count / WEP_COUNT;
+                       panel_pos_y += (old_panel_size_y - panel_size_y) / 2;
+               }
+               else
+               {
+                       old_panel_size_x = panel_size_x;
+                       panel_size_x *= weapon_count / WEP_COUNT;
+                       panel_pos_x += (old_panel_size_x - panel_size_x) / 2;
+               }
+       }
+       else
+               weapon_count = WEP_COUNT;
+
        if (timeout && time >= weapontime + timeout && !autocvar__hud_configure)
        {
                f = (time - (weapontime + timeout)) / timeout_effect_length;
@@ -707,11 +734,10 @@ void HUD_Weapons(void)
                }
        }
 
-       float i, weapid, wpnalpha, weapon_cnt;
-
        // TODO make this configurable
        if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
        {
+               float weapon_cnt;
                if(weaponorder_bypriority)
                        strunzone(weaponorder_bypriority);
                if(weaponorder_byimpulse)
@@ -745,6 +771,8 @@ void HUD_Weapons(void)
                panel_size -= '2 2 0' * panel_bg_padding;
        }
 
+       float weapid, wpnalpha;
+
        if(autocvar_hud_panel_weapons_fade)
        {
                wpnalpha = 3.2 - 2 * (time - weapontime);
@@ -756,9 +784,9 @@ void HUD_Weapons(void)
        float rows, columns;
        float aspect = autocvar_hud_panel_weapons_aspect;
        rows = panel_size_y/panel_size_x;
-       rows = bound(1, floor((sqrt(4 * aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
+       rows = bound(1, floor((sqrt(4 * aspect * rows * weapon_count + rows * rows) + rows + 0.5) / 2), weapon_count);
 
-       columns = ceil(WEP_COUNT/rows);
+       columns = ceil(weapon_count/rows);
        float row, column;
 
        float a, type, fullammo;
@@ -805,13 +833,15 @@ void HUD_Weapons(void)
                                acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i))));
        }
 
-       float weapons_st = getstati(STAT_WEAPONS);
-
        for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
        {
                self = weaponorder[i];
                if (!self || self.impulse < 0)
                        continue;
+               if (autocvar_hud_panel_weapons_onlyowned)
+               if (!(weapons_st & self.weapons))
+               if (!autocvar__hud_configure)
+                       continue;
                wpnpos = panel_pos + eX * column * wpnsize_x + eY * row * wpnsize_y;
 
                weapid = self.impulse;