]> 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>
Mon, 12 Sep 2011 06:37:32 +0000 (02:37 -0400)
committerSamual <samual@xonotic.org>
Mon, 12 Sep 2011 06:37:32 +0000 (02:37 -0400)
defaultXonotic.cfg
qcsrc/client/autocvars.qh
qcsrc/client/hud.qc
qcsrc/menu/xonotic/dialog_hudpanel_weapons.c

index f5bbb5653f0e2eb8c23d0c01b7f6d5f510f029d5..24f3921df4de50cc19ed7a5a88dfc9320883b8dd 100644 (file)
@@ -1446,6 +1446,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 1 "show only owned weapons"
 
 seta hud_panel_ammo_maxammo "40" "when you have this much ammo, the ammo status bar is full"
 
index bf425fc477921897eefd7cb7bfeaabb02d7feed8..8f3372a6c821726040637f3abdc07d8e351a21f3 100644 (file)
@@ -303,6 +303,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 9c28bea1f343339d866c6d11191c8b4024324af4..043b5ea98a957b60fd2b32ae7a343b81773102ed 100644 (file)
@@ -250,11 +250,7 @@ HUD panels
 // draw the background/borders
 #define HUD_Panel_DrawBg(alpha)\
 if(panel_bg != "0")\
-       draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel_bg, panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha * alpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER));\
-if(highlightedPanel == hud_configure_active_panel && autocvar__hud_configure)\
-{\
-       HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);\
-} ENDS_WITH_CURLY_BRACE
+       draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel_bg, panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha * alpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER))
 
 //basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu
 void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, float vertical, float baralign, vector theColor, float theAlpha, float drawflag)
@@ -435,7 +431,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)
@@ -468,6 +464,79 @@ void HUD_Weapons(void)
        HUD_Panel_UpdateCvars(weapons);
        HUD_Panel_ApplyFadeAlpha();
 
+       // 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_panel_weapons_onlyowned)
+       {
+               if(autocvar__hud_configure)
+               {
+                       if (weapons_st == 0)
+                               for(i = 0; i <= WEP_LAST-WEP_FIRST; i += floor((WEP_LAST-WEP_FIRST)/5))
+                                       weapons_st |= power2of(i);
+                       if(menu_enabled != 2)
+                               HUD_Panel_DrawBg(1); // also draw the bg of the entire panel
+               }
+
+               vector old_panel_size;
+               for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
+               {
+                       if(weapons_st & weaponorder[i].weapons)
+                               ++weapon_count;
+               }
+               if(!autocvar__hud_configure && (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;
@@ -531,37 +600,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)
        {
@@ -569,6 +607,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);
@@ -580,21 +620,17 @@ 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;
        vector wpnsize;
-       
+
        vector ammo_color;
        float ammo_alpha;
        wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
@@ -629,13 +665,14 @@ 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)))
+                       continue;
                wpnpos = panel_pos + eX * column * wpnsize_x + eY * row * wpnsize_y;
 
                weapid = self.impulse;
@@ -4844,10 +4881,18 @@ void HUD_Main (void)
        if(autocvar__con_chat_maximized)
                HUD_Chat(); // HUD_DrawPanel(HUD_PANEL_CHAT);
 
-       if(autocvar__hud_configure && tab_panel != -1)
+       if(autocvar__hud_configure)
        {
-               HUD_Panel_UpdatePosSizeForId(tab_panel)
-               drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL);
+               if(tab_panel != -1)
+               {
+                       HUD_Panel_UpdatePosSizeForId(tab_panel)
+                       drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL);
+               }
+               if(highlightedPanel != -1)
+               {
+                       HUD_Panel_UpdatePosSizeForId(highlightedPanel);
+                       HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha));
+               }
        }
 
        hud_configure_prev = autocvar__hud_configure;
index d0daa678422237378b21adc71800766c0627e481..b31622f67390e02f1d1465b02c5b55652fab1907 100644 (file)
@@ -4,7 +4,7 @@ CLASS(XonoticHUDWeaponsDialog) EXTENDS(XonoticRootDialog)
        ATTRIB(XonoticHUDWeaponsDialog, title, string, _("Weapons Panel"))
        ATTRIB(XonoticHUDWeaponsDialog, color, vector, SKINCOLOR_DIALOG_TEAMSELECT)
        ATTRIB(XonoticHUDWeaponsDialog, intendedWidth, float, 0.4)
-       ATTRIB(XonoticHUDWeaponsDialog, rows, float, 17)
+       ATTRIB(XonoticHUDWeaponsDialog, rows, float, 18)
        ATTRIB(XonoticHUDWeaponsDialog, columns, float, 4)
        ATTRIB(XonoticHUDWeaponsDialog, name, string, "HUDweapons")
 ENDCLASS(XonoticHUDWeaponsDialog)
@@ -40,6 +40,9 @@ void XonoticHUDWeaponsDialog_fill(entity me)
                        setDependentStringNotEqual(e, strzone(strcat("hud_panel_", panelname, "_timeout")), "0");
        me.TR(me);
                me.TD(me, 1, 4, e = makeXonoticTextLabel(0, _("Weapon icons:")));
+       me.TR(me);
+               me.TDempty(me, 0.2);
+               me.TD(me, 1, 3.8, e = makeXonoticCheckBox(0, "hud_panel_weapons_onlyowned", _("Show only owned weapons")));
        me.TR(me);
                me.TDempty(me, 0.2);
                me.TD(me, 1, 1.4, e = makeXonoticTextLabel(0, _("Show weapon ID as:")));