]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge remote branch 'origin/master' into terencehill/essential_weapons_panel
authorSamual <samual@xonotic.org>
Sun, 3 Jul 2011 07:53:38 +0000 (03:53 -0400)
committerSamual <samual@xonotic.org>
Sun, 3 Jul 2011 07:53:38 +0000 (03:53 -0400)
defaultXonotic.cfg
qcsrc/client/autocvars.qh
qcsrc/client/hud.qc

index a616d1769264196d8b0a81b5a554d1c7efa13986..2376bf472ab02009dff4407739d0f65df99ca239 100644 (file)
@@ -1431,6 +1431,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 ae87f9a429258e197af0c2c4063a3c71f3f5ae11..a6d7be9a89697ea712e3a9b85625997955611fcb 100644 (file)
@@ -283,6 +283,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 6b11719567d055e4234fd81ddb8344f3ba4316e8..7a0c1a0f897f6c8c17c5ce8f0af5275cd60ce0a9 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(hud != HUD_NORMAL) return;
        if(!autocvar__hud_configure)
@@ -644,6 +644,70 @@ void HUD_Weapons(void)
 
        HUD_Panel_UpdateCvars(weapons);
 
+       // TODO make this configurable
+       if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
+       {
+               float weapon_cnt;
+               if(weaponorder_bypriority)
+                       strunzone(weaponorder_bypriority);
+               if(weaponorder_byimpulse)
+                       strunzone(weaponorder_byimpulse);
+
+               weaponorder_bypriority = strzone(autocvar_cl_weaponpriority);
+               weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
+               weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
+
+               weapon_cnt = 0;
+               for(i = WEP_FIRST; i <= WEP_LAST; ++i)
+               {
+                       self = get_weaponinfo(i);
+                       if(self.impulse >= 0)
+                       {
+                               weaponorder[weapon_cnt] = self;
+                               ++weapon_cnt;
+                       }
+               }
+               for(i = weapon_cnt; i < WEP_MAXCOUNT; ++i)
+                       weaponorder[i] = NULL;
+               heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
+
+               weaponorder_cmp_str = string_null;
+       }
+
+       float when, fadetime;
+       when = autocvar_hud_panel_weapons_complainbubble_time;
+       fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
+       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;
+               }
+               if(autocvar_hud_panel_weapons_complainbubble && time - complain_weapon_time < when + fadetime)// && complain_weapon >= 0
+                       ++weapon_count;
+               if (weapon_count == 0)
+                       return;
+               // 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,37 +771,6 @@ void HUD_Weapons(void)
                }
        }
 
-       float i, weapid, wpnalpha, weapon_cnt;
-
-       // TODO make this configurable
-       if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
-       {
-               if(weaponorder_bypriority)
-                       strunzone(weaponorder_bypriority);
-               if(weaponorder_byimpulse)
-                       strunzone(weaponorder_byimpulse);
-
-               weaponorder_bypriority = strzone(autocvar_cl_weaponpriority);
-               weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
-               weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
-
-               weapon_cnt = 0;
-               for(i = WEP_FIRST; i <= WEP_LAST; ++i)
-               {
-                       self = get_weaponinfo(i);
-                       if(self.impulse >= 0)
-                       {
-                               weaponorder[weapon_cnt] = self;
-                               ++weapon_cnt;
-                       }
-               }
-               for(i = weapon_cnt; i < WEP_MAXCOUNT; ++i)
-                       weaponorder[i] = NULL;
-               heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
-
-               weaponorder_cmp_str = string_null;
-       }
-
        HUD_Panel_DrawBg(1);
        if(panel_bg_padding)
        {
@@ -745,6 +778,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,16 +791,12 @@ 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;
-       float when;
-       when = autocvar_hud_panel_weapons_complainbubble_time;
-       float fadetime;
-       fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
 
        vector color;
        vector wpnpos;
@@ -805,13 +836,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) || (self.weapon == complain_weapon && time - complain_weapon_time < when + fadetime && autocvar_hud_panel_weapons_complainbubble)))
+               if (!autocvar__hud_configure)
+                       continue;
                wpnpos = panel_pos + eX * column * wpnsize_x + eY * row * wpnsize_y;
 
                weapid = self.impulse;