]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
hud_panel_weapons_onlyowned to display only owned weapons; panel gets dynamically...
authorterencehill <piuntn@gmail.com>
Thu, 12 May 2011 20:29:18 +0000 (22:29 +0200)
committerterencehill <piuntn@gmail.com>
Thu, 12 May 2011 20:29:18 +0000 (22:29 +0200)
defaultXonotic.cfg
qcsrc/client/autocvars.qh
qcsrc/client/hud.qc

index ee2570b9dd8aace0f0156fa2dc27dadbb1ad27ca..5ba1df638919ff4cd46d56d7dc434279a21aee73 100644 (file)
@@ -1424,6 +1424,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 2fe09ea1ea77ec130472162c69e58e41223616f8..f7d18d993efe5dae4fca783aef4919ffa2a99240 100644 (file)
@@ -271,6 +271,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..7924c2983edf99f8a4db35bde3178290f6ea85fe 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,7 +734,7 @@ void HUD_Weapons(void)
                }
        }
 
-       float i, weapid, wpnalpha, weapon_cnt;
+       float weapid, wpnalpha, weapon_cnt;
 
        // TODO make this configurable
        if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
@@ -756,9 +783,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 +832,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;