]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
Merge branch 'master' into terencehill/infinite_ammo
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index 062a6db30ecc2e47d960e9fedb0cb50276f5fddb..0707d717dcc11e89dcf6e6bf9bfb59a4a2e2c710 100644 (file)
@@ -963,7 +963,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)
@@ -975,7 +975,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';
@@ -1006,12 +1008,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);
@@ -1071,20 +1073,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;
                        }
                }
@@ -1092,9 +1097,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)
                {
@@ -1850,7 +1857,7 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s
                                print (sprintf(_("%s^7 is a ^1BERSERKER!\n"), s1));
                } else if(type == KILL_SPREE_25) {
                        if(gentle)
-                               print (sprintf(_("%s^7 made ^1TWENTY FIFE SCORES IN A ROW!\n"), s1));
+                               print (sprintf(_("%s^7 made ^1TWENTY FIVE SCORES IN A ROW!\n"), s1));
                        else
                                print (sprintf(_("%s^7 inflicts ^1CARNAGE!\n"), s1));
                } else if(type == KILL_SPREE_30) {
@@ -2586,9 +2593,7 @@ void HUD_Score_Rankings(vector pos, vector mySize, entity me, float team_count)
 #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 float height = mySize_y/entries;
-       const vector fontsize = '0.9 0.9 0' * height;
-       pos_y += height * (1 - 0.9) / 2;
+       const vector fontsize = '1 1 0' * (mySize_y/entries);
 
        vector rgb, score_color;
        rgb = '1 1 1';
@@ -2602,20 +2607,19 @@ void HUD_Score_Rankings(vector pos, vector mySize, entity me, float team_count)
        i, first_pl = 0;
        if (autocvar__hud_configure)
        {
+               float players_per_team;
                if (team_count)
                {
                        // show team scores in the first line
                        float score_size = mySize_x / team_count;
-                       for(tm = teams.sort_next; tm; tm = tm.sort_next) {
-                               if(tm.team == COLOR_SPECTATOR)
-                                       continue;
-                               if (tm.team == myteam)
-                                       HUD_Panel_DrawHighlight(pos - eY * (height * (1 - 0.9) / 2) + eX * score_size * i, eX * score_size + eY * height, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-                               drawstring_aspect(pos + eX * score_size * i, ftos(123), eX * score_size + eY * fontsize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
-                               ++i;
+                       players_per_team = max(2, ceil((entries - 1) / team_count));
+                       for(i=0; i<team_count; ++i) {
+                               if (i == floor((entries - 2) / players_per_team) || (entries == 1 && i == 0))
+                                       HUD_Panel_DrawHighlight(pos + eX * score_size * i, eX * score_size + eY * fontsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                               drawstring_aspect(pos + eX * score_size * i, ftos(175 - 23*i), eX * score_size + eY * fontsize_y, GetTeamRGB(ColorByTeam(i)) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
                        }
                        first_pl = 1;
-                       pos_y += height;
+                       pos_y += fontsize_y;
                }
                score = 10 + SCOREPANEL_MAX_ENTRIES * 3;
                for (i=first_pl; i<entries; ++i)
@@ -2626,7 +2630,7 @@ void HUD_Score_Rankings(vector pos, vector mySize, entity me, float team_count)
                        if (i == entries-1 && autocvar_hud_panel_score_rankings == 1)
                        {
                                rgb = '1 1 0';
-                               drawfill(pos - eY * (height * (1 - 0.9) / 2), eX * mySize_x + eY * height, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                               drawfill(pos, eX * mySize_x + eY * fontsize_y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                                s = GetPlayerName(pl.sv_entnum);
                                score = 7;
                        }
@@ -2637,11 +2641,11 @@ void HUD_Score_Rankings(vector pos, vector mySize, entity me, float team_count)
                        }
 
                        if (team_count)
-                               score_color = GetTeamRGB(ColorByTeam(mod(i + 2, team_count))) * 0.8;
+                               score_color = GetTeamRGB(ColorByTeam(floor((i - first_pl) / players_per_team))) * 0.8;
                        s = textShortenToWidth(s, name_size, fontsize, stringwidth_colors);
                        drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
                        drawstring(pos + eX * (name_size + spacing_size), ftos(score), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
-                       pos_y += height;
+                       pos_y += fontsize_y;
                }
                return;
        }
@@ -2656,17 +2660,20 @@ void HUD_Score_Rankings(vector pos, vector mySize, entity me, float team_count)
                        if(tm.team == COLOR_SPECTATOR)
                                continue;
                        if (tm.team == myteam)
-                               drawfill(pos - eY * (height * (1 - 0.9) / 2) + eX * score_size * i, eX * score_size + eY * height, '1 1 1', highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                               drawfill(pos + eX * score_size * i, eX * score_size + eY * fontsize_y, '1 1 1', highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                        drawstring_aspect(pos + eX * score_size * i, ftos(tm.(teamscores[ts_primary])), eX * score_size + eY * fontsize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
                        ++i;
                }
                first_pl = 1;
-               pos_y += height;
+               pos_y += fontsize_y;
+               tm = teams.sort_next;
        }
        i = first_pl;
-       for (pl = players.sort_next; pl && i<entries; pl = pl.sort_next, ++i)
+
+       do
+       for (pl = players.sort_next; pl && i<entries; pl = pl.sort_next)
        {
-               if (pl.team == COLOR_SPECTATOR)
+               if ((team_count && pl.team != tm.team) || pl.team == COLOR_SPECTATOR)
                        continue;
 
                if (i == entries-1 && !me_printed && pl != me)
@@ -2688,15 +2695,17 @@ void HUD_Score_Rankings(vector pos, vector mySize, entity me, float team_count)
                        if (i == first_pl)
                                rgb = '0 1 0'; //first: green
                        me_printed = 1;
-                       drawfill(pos - eY * (height * (1 - 0.9) / 2), eX * mySize_x + eY * height, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                       drawfill(pos, eX * mySize_x + eY * fontsize_y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                }
                if (team_count)
                        score_color = GetTeamRGB(pl.team) * 0.8;
                s = textShortenToWidth(GetPlayerName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
                drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
                drawstring(pos + eX * (name_size + spacing_size), ftos(pl.(scores[ps_primary])), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
-               pos_y += height;
+               pos_y += fontsize_y;
+               ++i;
        }
+       while (i<entries && team_count && (tm = tm.sort_next) && (tm.team != COLOR_SPECTATOR || (tm = tm.sort_next)));
 }
 
 void HUD_Score(void)