]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
Small cleanup
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index 9406d3c85b726abdf026a832cd08f26fb093aa39..c70003153727db151802168d2336775ed3380e97 100644 (file)
@@ -89,11 +89,12 @@ void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector the
 
 vector HUD_Get_Num_Color (float x, float maxvalue)
 {
+       float blinkingamt;
        vector color;
-       if(x > maxvalue) {
-               color_x = 0;
+       if(x >= maxvalue) {
+               color_x = sin(2*M_PI*time);
                color_y = 1;
-               color_z = 0;
+               color_z = sin(2*M_PI*time);
        }
        else if(x > maxvalue * 0.75) {
                color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
@@ -120,6 +121,14 @@ vector HUD_Get_Num_Color (float x, float maxvalue)
                color_y = 0;
                color_z = 0;
        }
+
+       blinkingamt = (1 - x/maxvalue/0.25);
+       if(blinkingamt > 0)
+       {
+               color_x = color_x - color_x * blinkingamt * sin(2*M_PI*time);
+               color_y = color_y - color_y * blinkingamt * sin(2*M_PI*time);
+               color_z = color_z - color_z * blinkingamt * sin(2*M_PI*time);
+       }
        return color;
 }
 
@@ -395,9 +404,9 @@ string MakeRaceString(float cp, float mytime, float histime, float lapdelta, str
        if(histime < 0)
                return strcat(col, cpname);
        else if(hisname == "")
-               return strcat(col, sprintf(_("%s (%s)")), cpname, timestr);
+               return strcat(col, sprintf(_("%s (%s)"), cpname, timestr));
        else
-               return strcat(col, sprintf(_("%s (%s %s)")), cpname, timestr, strcat(hisname, col, lapstr));
+               return strcat(col, sprintf(_("%s (%s %s)"), cpname, timestr, strcat(hisname, col, lapstr)));
 }
 
 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
@@ -699,16 +708,9 @@ void HUD_Weapons(void)
        }
 
        float i, weapid, wpnalpha, weapon_cnt;
-       weapon_cnt = 0;
-       for(i = WEP_FIRST; i <= WEP_LAST; ++i)
-       {
-               self = get_weaponinfo(i);
-               if(self.impulse >= 0)
-                       ++weapon_cnt;
-       }
 
        // TODO make this configurable
-       if(weaponorder_bypriority != autocvar_cl_weaponpriority)
+       if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
        {
                if(weaponorder_bypriority)
                        strunzone(weaponorder_bypriority);
@@ -729,6 +731,8 @@ void HUD_Weapons(void)
                                ++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;
@@ -803,11 +807,13 @@ void HUD_Weapons(void)
 
        float weapons_st = getstati(STAT_WEAPONS);
 
-       for(i = 0; i < weapon_cnt; ++i)
+       for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
        {
+               self = weaponorder[i];
+               if (!self || self.impulse < 0)
+                       continue;
                wpnpos = panel_pos + eX * column * wpnsize_x + eY * row * wpnsize_y;
 
-               self = weaponorder[i];
                weapid = self.impulse;
 
                // draw background behind currently selected weapon
@@ -837,7 +843,7 @@ void HUD_Weapons(void)
                }
 
                // draw the weapon icon
-               if((weapid >= 0) && (weapons_st & self.weapons))
+               if(weapons_st & self.weapons)
                {
                        drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
 
@@ -902,7 +908,7 @@ void HUD_Weapons(void)
 
                        string s;
                        if(complain_weapon_type == 0) {
-                               s = "Out of ammo";
+                               s = _("Out of ammo");
                                color = stov(autocvar_hud_panel_weapons_complainbubble_color_outofammo);
                        }
                        else if(complain_weapon_type == 1) {
@@ -996,7 +1002,7 @@ void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_s
                drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
 
     if(a > 0 && autocvar_hud_panel_ammo_progressbar)
-        HUD_Panel_DrawProgressBar(myPos + eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize_x, mySize - eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize_x, autocvar_hud_panel_ammo_progressbar_name, 0, 0, a/autocvar_hud_panel_ammo_maxammo, color, autocvar_hud_progressbar_alpha * panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
+        HUD_Panel_DrawProgressBar(myPos + eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize_x, mySize - eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize_x, autocvar_hud_panel_ammo_progressbar_name, a/autocvar_hud_panel_ammo_maxammo, 0, 0, color, autocvar_hud_progressbar_alpha * panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
 
     if(autocvar_hud_panel_ammo_text)
     {
@@ -1294,10 +1300,19 @@ void HUD_Powerups(void)
 
 // Health/armor (#3)
 //
-float health_time, prev_health;
-float armor_time, prev_armor;
-var float saved_health = -2;
-var float saved_armor = -2;
+
+// prev_* vars contain the health/armor at the previous FRAME
+// set to -1 when player is dead or was not playing
+float prev_health, prev_armor;
+float health_damagetime, armor_damagetime;
+float health_beforedamage, armor_beforedamage;
+// old_p_* vars keep track of previous values when smoothing value changes of the progressbar
+float old_p_health, old_p_armor;
+float old_p_healthtime, old_p_armortime;
+// prev_p_* vars contain the health/armor progressbar value at the previous FRAME
+// set to -1 to forcedly stop effects when we switch spectated player (e.g. from playerX: 70h to playerY: 50h)
+float prev_p_health, prev_p_armor;
+
 void HUD_HealthArmor(void)
 {
        float armor, health, fuel;
@@ -1309,36 +1324,36 @@ void HUD_HealthArmor(void)
                health = getstati(STAT_HEALTH);
                if(health <= 0)
                {
-                       health_time = -1;
+                       prev_health = -1;
                        return;
                }
-               if (autocvar_hud_panel_healtharmor_progressbar_gfx)
-               {
-                       if ( (prev_spectatee_status == -1 && spectatee_status > 0) //before observing, now spectating
-                         || (prev_spectatee_status > 0 && spectatee_status > 0 && prev_spectatee_status != spectatee_status) //changed spectated player
-                       )
-                       {
-                               //no effect
-                               saved_health = 0;
-                               saved_armor = 0;
-                               health_time = 0;
-                               armor_time = 0;
-                       }
-                       else if(prev_spectatee_status == -1 || (prev_spectatee_status > 0 && !spectatee_status)) //before spectating/observing, now playing
-                               health_time = -1;
+               armor = getstati(STAT_ARMOR);
 
-                       if (health_time == -1)
-                       {
-                               //start the load effect
-                               saved_health = -2;
-                               saved_armor = -2;
-                               health_time = time;
-                               armor_time = time;
-                               prev_health = 0;
-                               prev_armor = 0;
-                       }
+               // code to check for spectatee_status changes is in Ent_ClientData()
+               // prev_p_health and prev_health can be set to -1 there
+
+               if (prev_p_health == -1)
+               {
+                       // no effect
+                       health_beforedamage = 0;
+                       armor_beforedamage = 0;
+                       health_damagetime = 0;
+                       armor_damagetime = 0;
+                       prev_health = health;
+                       prev_armor = armor;
+                       old_p_health = health;
+                       old_p_armor = armor;
+                       prev_p_health = health;
+                       prev_p_armor = armor;
+               }
+               else if (prev_health == -1)
+               {
+                       //start the load effect
+                       health_damagetime = 0;
+                       armor_damagetime = 0;
+                       prev_health = 0;
+                       prev_armor = 0;
                }
-               armor = getstati(STAT_ARMOR);
                fuel = getstati(STAT_FUEL);
        }
        else
@@ -1461,34 +1476,39 @@ void HUD_HealthArmor(void)
                                pain_health_alpha = 1;
                                if (autocvar_hud_panel_healtharmor_progressbar_gfx)
                                {
-                                       if (saved_health == -1)
+                                       if (autocvar_hud_panel_healtharmor_progressbar_gfx_smooth > 0)
                                        {
-                                               if (prev_health == 0 || prev_health - health >= 3)
+                                               if (fabs(prev_health - health) >= autocvar_hud_panel_healtharmor_progressbar_gfx_smooth)
+                                               {
+                                                       if (time - old_p_healthtime < 1)
+                                                               old_p_health = prev_p_health;
+                                                       else
+                                                               old_p_health = prev_health;
+                                                       old_p_healthtime = time;
+                                               }
+                                               if (time - old_p_healthtime < 1)
                                                {
-                                                       health_time = time;
-                                                       saved_health = prev_health;
+                                                       p_health += (old_p_health - health) * (1 - (time - old_p_healthtime));
+                                                       prev_p_health = p_health;
                                                }
                                        }
-                                       if (saved_health != -1)
+                                       if (autocvar_hud_panel_healtharmor_progressbar_gfx_damage > 0)
                                        {
-                                               float d = time - health_time;
-                                               if (d < 1)
+                                               if (prev_health - health >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage)
                                                {
-                                                       if (saved_health == -2)
-                                                               p_health *= sqrt(d);
-                                                       else
-                                                       {
-                                                               HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, saved_health/maxhealth, is_vertical, health_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * (1 - d * d), DRAWFLAG_NORMAL);
-                                                               if (prev_health - health >= 1) //refresh the effect if repeatedly damaged
-                                                                       health_time = time;
-                                                       }
+                                                       if (time - health_damagetime >= 1)
+                                                               health_beforedamage = prev_health;
+                                                       health_damagetime = time;
+                                               }
+                                               if (time - health_damagetime < 1)
+                                               {
+                                                       float health_damagealpha = 1 - (time - health_damagetime)*(time - health_damagetime);
+                                                       HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, health_beforedamage/maxhealth, is_vertical, health_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * health_damagealpha, DRAWFLAG_NORMAL);
                                                }
-                                               else
-                                                       saved_health = -1; //damage effect ended
                                        }
                                        prev_health = health;
 
-                                       if (health <= 40 && saved_health != -2)
+                                       if (health <= autocvar_hud_panel_healtharmor_progressbar_gfx_lowhealth)
                                        {
                                                float BLINK_FACTOR = 0.15;
                                                float BLINK_BASE = 0.85;
@@ -1511,30 +1531,35 @@ void HUD_HealthArmor(void)
                                p_armor = armor;
                                if (autocvar_hud_panel_healtharmor_progressbar_gfx)
                                {
-                                       if (saved_armor == -1)
+                                       if (autocvar_hud_panel_healtharmor_progressbar_gfx_smooth > 0)
                                        {
-                                               if (prev_armor == 0 || prev_armor - armor >= 3)
+                                               if (fabs(prev_armor - armor) >= autocvar_hud_panel_healtharmor_progressbar_gfx_smooth)
                                                {
-                                                       armor_time = time;
-                                                       saved_armor = prev_armor;
+                                                       if (time - old_p_armortime < 1)
+                                                               old_p_armor = prev_p_armor;
+                                                       else
+                                                               old_p_armor = prev_armor;
+                                                       old_p_armortime = time;
+                                               }
+                                               if (time - old_p_armortime < 1)
+                                               {
+                                                       p_armor += (old_p_armor - armor) * (1 - (time - old_p_armortime));
+                                                       prev_p_armor = p_armor;
                                                }
                                        }
-                                       if (saved_armor != -1)
+                                       if (autocvar_hud_panel_healtharmor_progressbar_gfx_damage > 0)
                                        {
-                                               float d = time - armor_time;
-                                               if (d < 1)
+                                               if (prev_armor - armor >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage)
                                                {
-                                                       if (saved_armor == -2)
-                                                               p_armor *= sqrt(d);
-                                                       else
-                                                       {
-                                                               HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, saved_armor/maxarmor, is_vertical, armor_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * (1 - d * d), DRAWFLAG_NORMAL);
-                                                               if (prev_armor - armor >= 1) //refresh the effect if repeatedly damaged
-                                                                       armor_time = time;
-                                                       }
+                                                       if (time - armor_damagetime >= 1)
+                                                               armor_beforedamage = prev_armor;
+                                                       armor_damagetime = time;
+                                               }
+                                               if (time - armor_damagetime < 1)
+                                               {
+                                                       float armor_damagealpha = 1 - (time - armor_damagetime)*(time - armor_damagetime);
+                                                       HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, armor_beforedamage/maxarmor, is_vertical, armor_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * armor_damagealpha, DRAWFLAG_NORMAL);
                                                }
-                                               else
-                                                       saved_armor = -1; //damage effect ended
                                        }
                                        prev_armor = armor;
                                }
@@ -1687,7 +1712,7 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s
                        }
                }
                else if(type == KILL_FIRST_BLOOD)
-                       print(sprintf("^1%s^1 drew first blood\n", s1));
+                       print(sprintf(_("^1%s^1 drew first blood\n"), s1));
                else if (type == DEATH_TELEFRAG) {
                        HUD_KillNotify_Push(s1, s2, 1, DEATH_TELEFRAG);
                        if(gentle)
@@ -1847,7 +1872,7 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s
                } else if (type == DEATH_SLIME) {
                        HUD_KillNotify_Push(s1, "", 0, DEATH_SLIME);
                        if(alsoprint)
-                               print (sprintf("^1%s^1 was slimed\n", s1));
+                               print (sprintf(_("^1%s^1 was slimed\n"), s1));
                } else if (type == DEATH_LAVA) {
                        HUD_KillNotify_Push(s1, "", 0, DEATH_LAVA);
                        if(alsoprint)
@@ -1938,7 +1963,7 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s
                        print(sprintf(_("%s^7 returned the %s\n"), s1, s2));
                } else if(type == INFO_CAPTUREFLAG) {
                        HUD_KillNotify_Push(s1, s2, 0, INFO_CAPTUREFLAG);
-                       print(sprintf(_("%1^7 captured the %s%s\n"), s1, s2, s3));
+                       print(sprintf(_("%s^7 captured the %s%s\n"), s1, s2, s3));
                }
        } else if(msg == MSG_RACE) {
                if(type == RACE_SERVER_RECORD) {
@@ -2082,7 +2107,8 @@ void HUD_Notify (void)
        height = mySize_y/entries;
        
        vector fontsize;
-       fontsize = '0.5 0.5 0' * height;
+       float fontheight = height * autocvar_hud_panel_notify_fontsize;
+       fontsize = '0.5 0.5 0' * fontheight;
 
        float a;
        float when;
@@ -2256,7 +2282,7 @@ void HUD_Notify (void)
                        }
                        
                        attacker = textShortenToWidth(killnotify_attackers[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
-                       pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
+                       pos_attacker = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
                        weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
 
                        if(s != "")
@@ -2342,8 +2368,8 @@ void HUD_Notify (void)
                        victim = textShortenToWidth(killnotify_victims[j], 0.48 * mySize_x - height, fontsize, stringwidth_colors);
 :hud_config_notifyprint
                        width_attacker = stringwidth(attacker, TRUE, fontsize);
-                       pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * (0.5 * fontsize_y + i * height);
-                       pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * (0.5 * fontsize_y + i * height);
+                       pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
+                       pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight)));
                        weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
 
                        if(s != "")
@@ -2553,6 +2579,126 @@ void HUD_Radar(void)
 // Score (#7)
 //
 void HUD_UpdatePlayerTeams();
+void HUD_Score_Rankings(vector pos, vector mySize, entity me, float team_count)
+{
+       float score;
+       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 float height = mySize_y/entries;
+       const vector fontsize = '0.9 0.9 0' * height;
+       pos_y += height * (1 - 0.9) / 2;
+
+       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;
+       const float highlight_alpha = 0.2;
+       float i, me_printed, first_pl;
+       string s;
+       i, first_pl = 0;
+       if (autocvar__hud_configure)
+       {
+               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;
+                       }
+                       first_pl = 1;
+                       pos_y += height;
+               }
+               score = 10 + SCOREPANEL_MAX_ENTRIES * 3;
+               for (i=first_pl; i<entries; ++i)
+               {
+                       //simulate my score is lower than all displayed players,
+                       //so that I don't appear at all showing pure rankings.
+                       //This is to better show the difference between the 2 ranking views
+                       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);
+                               s = GetPlayerName(pl.sv_entnum);
+                               score = 7;
+                       }
+                       else
+                       {
+                               s = sprintf(_("Player %d"), i + 1 - first_pl);
+                               score -= 3;
+                       }
+
+                       if (team_count)
+                               score_color = GetTeamRGB(ColorByTeam(mod(i + 2, team_count))) * 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;
+               }
+               return;
+       }
+
+       if (!scoreboard_fade_alpha) // the scoreboard too calls HUD_UpdatePlayerTeams
+               HUD_UpdatePlayerTeams();
+       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)
+                               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);
+                       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;
+       }
+       i = first_pl;
+       for (pl = players.sort_next; pl && i<entries; pl = pl.sort_next, ++i)
+       {
+               if (pl.team == COLOR_SPECTATOR)
+                       continue;
+
+               if (i == entries-1 && !me_printed && pl != me)
+               if (autocvar_hud_panel_score_rankings == 1 && spectatee_status != -1)
+               {
+                       for (pl = me.sort_next; pl; pl = pl.sort_next)
+                               if (pl.team != COLOR_SPECTATOR)
+                                       break;
+
+                       if (pl)
+                               rgb = '1 1 0'; //not last but not among the leading players: yellow
+                       else
+                               rgb = '1 0 0'; //last: red
+                       pl = me;
+               }
+
+               if (pl == me)
+               {
+                       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);
+               }
+               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;
+       }
+}
+
 void HUD_Score(void)
 {
        if(!autocvar__hud_configure)
@@ -2617,83 +2763,7 @@ void HUD_Score(void)
        } else if (!teamplay) { // non-teamgames
                if ((spectatee_status == -1 && !autocvar__hud_configure) || autocvar_hud_panel_score_rankings)
                {
-#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;
-
-                       vector rgb;
-                       rgb = '1 1 1';
-
-                       const float name_size = mySize_x*0.75;
-                       const float highlight_alpha = 0.2;
-                       float i, me_printed;
-                       string s;
-                       if (autocvar__hud_configure)
-                       {
-                               score = 10 + SCOREPANEL_MAX_ENTRIES * 3;
-                               for (i=0; i<entries; ++i)
-                               {
-                                       //simulate my score is lower than all displayed players,
-                                       //so that I don't appear at all showing pure rankings.
-                                       //This is to better show the difference between the 2 ranking views
-                                       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);
-                                               s = GetPlayerName(pl.sv_entnum);
-                                               score = 7;
-                                       }
-                                       else
-                                       {
-                                               s = strcat("Player", ftos(i+1));
-                                               score -= 3;
-                                       }
-
-                                       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 * mySize_x*0.79, ftos(score), fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-                                       pos_y += height;
-                               }
-                               return;
-                       }
-
-                       if (!scoreboard_fade_alpha) // the scoreboard too calls HUD_UpdatePlayerTeams
-                               HUD_UpdatePlayerTeams();
-
-                       for (pl = players.sort_next, i=0; pl && i<entries; pl = pl.sort_next, ++i)
-                       {
-                               if (pl.team == COLOR_SPECTATOR)
-                                       continue;
-
-                               if (i == entries-1 && !me_printed && pl != me)
-                               if (autocvar_hud_panel_score_rankings == 1 && spectatee_status != -1)
-                               {
-                                       for (pl = me.sort_next; pl; pl = pl.sort_next)
-                                               if (pl.team != COLOR_SPECTATOR)
-                                                       break;
-
-                                       if (pl)
-                                               rgb = '1 1 0'; //not last but not among the leading players: yellow
-                                       else
-                                               rgb = '1 0 0'; //last: red
-                                       pl = me;
-                               }
-
-                               if (pl == me)
-                               {
-                                       if (i == 0)
-                                               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);
-                               }
-                               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 * mySize_x*0.79, ftos(pl.(scores[ps_primary])), fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-                               pos_y += height;
-                       }
+                       HUD_Score_Rankings(pos, mySize, me, 0);
                        return;
                }
                // me vector := [team/connected frags id]
@@ -2732,20 +2802,17 @@ void HUD_Score(void)
                drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize_x + eY * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
                drawstring_aspect(pos + eX * 0.75 * mySize_x, distribution_str, eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
        } else { // teamgames
-               float max_fragcount;
-               max_fragcount = -99;
-
                float scores_count, row, column, rows, columns;
                vector offset;
                vector score_pos, score_size; //for scores other than myteam
-               if (spectatee_status == -1)
+               if (spectatee_status == -1 || autocvar_hud_panel_score_rankings)
                {
-                       if (autocvar__hud_configure)
-                               scores_count = 4;
-                       else for(tm = teams.sort_next; tm; tm = tm.sort_next) {
-                               if(tm.team == COLOR_SPECTATOR)
-                                       continue;
+                       for(tm = teams.sort_next; tm, tm.team != COLOR_SPECTATOR; tm = tm.sort_next)
                                ++scores_count;
+                       if (autocvar_hud_panel_score_rankings)
+                       {
+                               HUD_Score_Rankings(pos, mySize, me, scores_count);
+                               return;
                        }
                        rows = mySize_y/mySize_x;
                        rows = bound(1, floor((sqrt(4 * (3/1) * rows * scores_count + rows * rows) + rows + 0.5) / 2), scores_count);
@@ -2773,6 +2840,9 @@ void HUD_Score(void)
                }
                else
                        score_size = eX * mySize_x*(1/4) + eY * mySize_y*(1/3);
+
+               float max_fragcount;
+               max_fragcount = -99;
                for(tm = teams.sort_next; tm; tm = tm.sort_next) {
                        if(tm.team == COLOR_SPECTATOR)
                                continue;
@@ -2975,10 +3045,10 @@ void HUD_VoteWindow(void)
                {
                        vote_yescount = 0;
                        vote_nocount = 0;
-                       print("^1You have to answer before entering hud configure mode\n");
+                       print(_("^1You must answer before entering hud configure mode\n"));
                        cvar_set("_hud_configure", "0");
                }
-               vote_called_vote = strzone(_("^2Name ^7instead of \"^1Unregistered player\" ^7in stats"));
+               vote_called_vote = strzone(_("^2Name ^7instead of \"^1Unregistered player^7\" in stats"));
                uid2name_dialog = 1;
        }
 
@@ -3069,9 +3139,9 @@ void HUD_VoteWindow(void)
        drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL);
 
        // print the yes/no counts
-    s = sprintf(_("Yes (%s): %d"), getcommandkey("vyes", "vyes"), ftos(vote_yescount));
+    s = sprintf(_("Yes (%s): %d"), getcommandkey("vyes", "vyes"), vote_yescount);
        drawstring_aspect(pos + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '0 1 0', a, DRAWFLAG_NORMAL);
-    s = sprintf(_("No (%s): %d"), getcommandkey("vno", "vno"), ftos(vote_nocount));
+    s = sprintf(_("No (%s): %d"), getcommandkey("vno", "vno"), vote_nocount);
        drawstring_aspect(pos + eX * 0.5 * mySize_x + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '1 0 0', a, DRAWFLAG_NORMAL);
 
        // draw the progress bar backgrounds
@@ -4156,7 +4226,7 @@ void HUD_InfoMessages(void)
                }
                else if(warmup_stage && !intermission && !spectatee_status)
                {
-                       s = strcat("^2Press ^3%s^2 to end warmup", getcommandkey("ready", "ready"));
+                       s = sprintf(_("^2Press ^3%s^2 to end warmup"), getcommandkey("ready", "ready"));
                        drawInfoMessage(s)
                }
 
@@ -4182,7 +4252,7 @@ void HUD_InfoMessages(void)
                                        if (tm)
                                        if (tm.team != COLOR_SPECTATOR)
                                        if (tm.team_size == ts_max)
-                                               s = strcat(s, sprintf(" Press ^3%s%s to adjust", getcommandkey("team menu", "menu_showteamselect"), blinkcolor));
+                                               s = strcat(s, sprintf(_(" Press ^3%s%s to adjust"), getcommandkey("team menu", "menu_showteamselect"), blinkcolor));
                                        drawInfoMessage(s)
                                }
                        }
@@ -4205,7 +4275,6 @@ void HUD_InfoMessages(void)
 //
 vector acc_prevspeed;
 float acc_prevtime, acc_avg, top_speed, top_speed_time;
-
 void HUD_Physics(void)
 {
        if(!autocvar__hud_configure)
@@ -4421,7 +4490,7 @@ void HUD_Physics(void)
                        HUD_Panel_GetProgressBarColor(acceleration_neg);
                else
                        HUD_Panel_GetProgressBarColor(acceleration);
-               HUD_Panel_DrawProgressBar(panel_pos + acceleration_offset, panel_size, "progressbar", acceleration/autocvar_hud_panel_physics_acceleration_max, 0, acceleration_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+               HUD_Panel_DrawProgressBar(panel_pos + acceleration_offset, panel_size, "accelbar", acceleration/autocvar_hud_panel_physics_acceleration_max, 0, acceleration_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
        }
        if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 3)
                drawstring_aspect(panel_pos + acceleration_offset, strcat(ftos_decimals(acceleration, 2), "g"), panel_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
@@ -4589,7 +4658,7 @@ void HUD_Main (void)
                        }
                }
                if (warning)
-                       print("Automatically fixed wrong/missing panel numbers in _hud_panelorder\n");
+                       print(_("Automatically fixed wrong/missing panel numbers in _hud_panelorder\n"));
 
                cvar_set("_hud_panelorder", s);
                if(hud_panelorder_prev)