]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
fix some obvious bugs
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index 87ab320803ae8e038aedec4e5a6da5d43847a6f8..3d3fe93cc41ce8ba33a5116c9cde740b1af9c9e3 100644 (file)
@@ -501,8 +501,14 @@ void HUD_Weapons(void)
        float weapon_count;
        if (autocvar_hud_panel_weapons_onlyowned)
        {
-               if(autocvar__hud_configure && menu_enabled != 2)
-                       HUD_Panel_DrawBg(1); // also draw the bg of the entire panel
+               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)
@@ -666,14 +672,13 @@ void HUD_Weapons(void)
                        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;
 
                // draw background behind currently selected weapon
-               if(self.weapon == activeweapon)
+               if(self.weapon == switchweapon)
                        drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
 
                // draw the weapon accuracy
@@ -819,7 +824,7 @@ string GetAmmoPicture(float i)
        }
 }
 
-void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
+void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected, float infinite_ammo)
 {
        float a;
        if(autocvar__hud_configure)
@@ -831,7 +836,9 @@ void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_s
                a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
 
        vector color;
-       if(a < 10)
+       if(infinite_ammo)
+               color = '0 0.5 0.75';
+       else if(a < 10)
                color = '0.7 0 0';
        else
                color = '1 1 1';
@@ -862,12 +869,12 @@ void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_s
 
     if(autocvar_hud_panel_ammo_text)
     {
-        if(a > 0)
+        if(a > 0 || infinite_ammo)
             drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
         else // "ghost" ammo count
             drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
     }
-       if(a > 0)
+       if(a > 0 || infinite_ammo)
                drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
        else // "ghost" ammo icon
                drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
@@ -929,20 +936,23 @@ void HUD_Ammo(void)
                ammo_size_y = newSize;
        }
 
-       float i, stat_items, currently_selected;
+       float i, stat_items, currently_selected, infinite_ammo;
+       infinite_ammo = FALSE;
        if (autocvar_hud_panel_ammo_onlycurrent)
        {
                if(autocvar__hud_configure)
                {
-                       DrawAmmoItem(pos, ammo_size, 2, true); //show rockets
+                       DrawAmmoItem(pos, ammo_size, 2, true, FALSE); //show rockets
                        return;
                }
                stat_items = getstati(STAT_ITEMS);
+               if (stat_items & IT_UNLIMITED_WEAPON_AMMO)
+                       infinite_ammo = TRUE;
                for (i = 0; i < AMMO_COUNT; ++i) {
                        currently_selected = stat_items & GetAmmoItemCode(i);
                        if (currently_selected)
                        {
-                               DrawAmmoItem(pos, ammo_size, i, true);
+                               DrawAmmoItem(pos, ammo_size, i, true, infinite_ammo);
                                return;
                        }
                }
@@ -950,9 +960,11 @@ void HUD_Ammo(void)
        }
 
        stat_items = getstati(STAT_ITEMS);
+       if (stat_items & IT_UNLIMITED_WEAPON_AMMO)
+               infinite_ammo = TRUE;
        for (i = 0; i < AMMO_COUNT; ++i) {
                currently_selected = stat_items & GetAmmoItemCode(i);
-               DrawAmmoItem(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, i, currently_selected);
+               DrawAmmoItem(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, i, currently_selected, infinite_ammo);
                ++row;
                if(row >= rows)
                {
@@ -1865,7 +1877,7 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s
        }
 }
 
-void HUD_Centerprint(string s1, string s2, float type, float msg)
+void HUD_KillCenterprint(string s1, string s2, float type, float msg)
 {
        float gentle;
        gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
@@ -2459,19 +2471,20 @@ void HUD_Score_Rankings(vector pos, vector mySize, entity me, float team_count)
        entity tm, pl;
 #define SCOREPANEL_MAX_ENTRIES 6
 #define SCOREPANEL_ASPECTRATIO 2
-       const float entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize_y/mySize_x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
-       const vector fontsize = '1 1 0' * (mySize_y/entries);
+       float entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize_y/mySize_x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
+       vector fontsize = '1 1 0' * (mySize_y/entries);
 
        vector rgb, score_color;
        rgb = '1 1 1';
        score_color = '1 1 1';
 
-       const float name_size = mySize_x*0.75;
-       const float spacing_size = mySize_x*0.04;
+       float name_size = mySize_x*0.75;
+       float spacing_size = mySize_x*0.04;
        const float highlight_alpha = 0.2;
        float i, me_printed, first_pl;
        string s;
-       i, first_pl = 0;
+       i = 0;
+       first_pl = 0;
        if (autocvar__hud_configure)
        {
                float players_per_team;
@@ -4564,7 +4577,7 @@ void HUD_CenterPrint (void)
        {
                if (j == CENTERPRINT_MAX_MSGS)
                        j = 0;
-               if (centerprint_expire_time[j] < time)
+               if (centerprint_expire_time[j] <= time)
                {
                        if (centerprint_countdown_num[j] && centerprint_time[j] > 0)
                        {
@@ -4605,11 +4618,12 @@ void HUD_CenterPrint (void)
                                                pos_y -= fontsize_y;
                                        else
                                                pos_y -= fontsize_y * CENTERPRINT_SPACING/2;
-                                       if (pos_y < panel_pos_y) // check if the next line can be shown
-                                       {
-                                               drawfontscale = '1 1 0';
-                                               return;
-                                       }
+                                       // NOTE: uncommented so as to not reject messages whenever they are "too large" -- This just continues drawing it anyway.
+                                       //if (pos_y < panel_pos_y) // check if the next line can be shown
+                                       //{
+                                       //      drawfontscale = '1 1 0';
+                                       //      return;
+                                       //}
                                }
                        }
                        current_msg_pos_y = pos_y; // save starting pos (first line) of the current message
@@ -4631,11 +4645,12 @@ void HUD_CenterPrint (void)
                                }
                                else
                                        pos_y += fontsize_y * CENTERPRINT_SPACING/2;
-                               if (!autocvar_hud_panel_centerprint_flip && pos_y > panel_pos_y + panel_size_y - fontsize_y) // check if the next line can be shown
-                               {
-                                       drawfontscale = '1 1 0';
-                                       return;
-                               }
+                               // NOTE: uncommented so as to not reject messages whenever they are "too large" -- This just continues drawing it anyway.
+                               //if (!autocvar_hud_panel_centerprint_flip && pos_y > panel_pos_y + panel_size_y - fontsize_y) // check if the next line can be shown
+                               //{
+                               //      drawfontscale = '1 1 0';
+                               //      return;
+                               //}
                        }
                }
                msg_size = pos_y - msg_size;