]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/scoreboard.qc
fix accelerometer with csqcmodels
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / scoreboard.qc
index d4556374ac288e36b6f6c15213f83e80bb798dc2..05c8df88cfc68f767c1eb268bab64044dc9ef4fa 100644 (file)
@@ -234,7 +234,7 @@ void HUD_UpdateTeamPos(entity Team)
        }
 }
 
-void Cmd_HUD_Help(float argc)
+void Cmd_HUD_Help()
 {
        print(_("You can modify the scoreboard using the ^2scoreboard_columns_set command.\n"));
        print(_("^3|---------------------------------------------------------------|\n"));
@@ -244,7 +244,7 @@ void Cmd_HUD_Help(float argc)
        print(_("The following field names are recognized (case insensitive):\n"));
        print(_("You can use a ^3|^7 to start the right-aligned fields.\n\n"));
 
-       print(_("^3name^7 or ^3nick^7         Name of a player\n"));
+       print(_("^3name^7 or ^3nick^7             Name of a player\n"));
        print(_("^3ping^7                     Ping time\n"));
        print(_("^3pl^7                       Packet loss\n"));
        print(_("^3kills^7                    Number of kills\n"));
@@ -308,17 +308,17 @@ void Cmd_HUD_SetFields(float argc)
        float missing;
 
        // TODO: re enable with gametype dependant cvars?
-       if(argc < 2) // no arguments provided
+       if(argc < 3) // no arguments provided
                argc = tokenizebyseparator(strcat("x ", autocvar_scoreboard_columns), " ");
 
-       if(argc < 2)
+       if(argc < 3)
                argc = tokenizebyseparator(strcat("x ", HUD_DefaultColumnLayout()), " ");
 
-       if(argc == 2)
+       if(argc == 3)
        {
-               if(argv(1) == "default")
+               if(argv(2) == "default")
                        argc = tokenizebyseparator(strcat("x ", HUD_DefaultColumnLayout()), " ");
-               else if(argv(1) == "all")
+               else if(argv(2) == "all")
                {
                        string s;
                        s = "ping pl color name |";
@@ -509,7 +509,7 @@ string HUD_GetField(entity pl, float field)
                case SP_PING:
                        if not(pl.gotscores)
                                return "\xEE\x82\x8D\xEE\x82\x8D\xEE\x82\x8D"; // >>> sign
-                       //str = getplayerkey(pl.sv_entnum, "ping");
+                       //str = getplayerkeyvalue(pl.sv_entnum, "ping");
                        f = pl.ping;
                        if(f == 0)
                                return _("N/A");
@@ -538,7 +538,7 @@ string HUD_GetField(entity pl, float field)
                        }
                        else if(!teamplay)
                        {
-                               f = stof(getplayerkey(pl.sv_entnum, "colors"));
+                               f = stof(getplayerkeyvalue(pl.sv_entnum, "colors"));
                                {
                                        hud_field_icon0 = "gfx/scoreboard/playercolor_base";
                                        hud_field_icon1 = "gfx/scoreboard/playercolor_shirt";
@@ -597,7 +597,7 @@ string HUD_FixScoreboardColumnWidth(float i, string str)
 
        if(hud_field_icon0 != "")
        {
-               sz = drawgetimagesize(hud_field_icon0);
+               sz = draw_getimagesize(hud_field_icon0);
                f = sz_x / sz_y;
                if(hud_fixscoreboardcolumnwidth_iconlen < f)
                        hud_fixscoreboardcolumnwidth_iconlen = f;
@@ -605,7 +605,7 @@ string HUD_FixScoreboardColumnWidth(float i, string str)
 
        if(hud_field_icon1 != "")
        {
-               sz = drawgetimagesize(hud_field_icon1);
+               sz = draw_getimagesize(hud_field_icon1);
                f = sz_x / sz_y;
                if(hud_fixscoreboardcolumnwidth_iconlen < f)
                        hud_fixscoreboardcolumnwidth_iconlen = f;
@@ -613,7 +613,7 @@ string HUD_FixScoreboardColumnWidth(float i, string str)
 
        if(hud_field_icon2 != "")
        {
-               sz = drawgetimagesize(hud_field_icon2);
+               sz = draw_getimagesize(hud_field_icon2);
                f = sz_x / sz_y;
                if(hud_fixscoreboardcolumnwidth_iconlen < f)
                        hud_fixscoreboardcolumnwidth_iconlen = f;
@@ -894,7 +894,7 @@ vector HUD_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_siz
                {
                        if(pl.team != tm.team)
                                continue;
-                       HUD_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1), i);
+                       HUD_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localnum), i);
                        pos_y += 1.25 * hud_fontsize_y;
                        ++i;
                }
@@ -903,7 +903,7 @@ vector HUD_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_siz
                {
                        if(pl.team == COLOR_SPECTATOR)
                                continue;
-                       HUD_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1), i);
+                       HUD_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localnum), i);
                        pos_y += 1.25 * hud_fontsize_y;
                        ++i;
                }
@@ -924,7 +924,7 @@ float HUD_WouldDrawScoreboard() {
                return 1;
        else if (intermission == 2)
                return 0;
-       else if (spectatee_status != -1 && getstati(STAT_HEALTH) <= 0 && autocvar_cl_deathscoreboard && gametype != GAME_CTS)
+       else if (spectatee_status != -1 && getstati(STAT_HEALTH) <= 0 && autocvar_cl_deathscoreboard && gametype != MAPINFO_TYPE_CTS)
                return 1;
        else if (scoreboard_showscores_force)
                return 1;
@@ -1053,6 +1053,59 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
        return pos;
 }
 
+vector HUD_DrawKeyValue(vector pos, string key, string value) {
+       float px = pos_x;
+       pos_x += hud_fontsize_x * 0.25;
+       drawstring(pos, key, hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
+       pos_x = xmax - stringwidth(value, FALSE, hud_fontsize) - hud_fontsize_x * 0.25;
+       drawstring(pos, value, hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
+       pos_x = px;
+       pos_y+= hud_fontsize_y;
+       
+       return pos;
+}
+
+vector HUD_DrawMapStats(vector pos, vector rgb, vector bg_size) {
+       float stat_secrets_found, stat_secrets_total;
+       float rows;
+       string val;
+
+       // get secrets stats
+       stat_secrets_found = getstatf(STAT_SECRETS_FOUND);
+       stat_secrets_total = getstatf(STAT_SECRETS_TOTAL);
+
+       // get number of rows
+       rows = (stat_secrets_total ? 1 : 0);
+
+       // if no rows, return
+       if not(rows)
+               return pos;
+
+       //  draw table header
+       drawstring(pos, _("Map stats:"), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
+       pos_y += 1.25 * hud_fontsize_y + autocvar_scoreboard_border_thickness;
+       
+       // draw table   
+       vector tmp;
+       tmp_x = sbwidth;
+       tmp_y = hud_fontsize_y * rows;
+
+       if (teamplay)
+               drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb * autocvar_scoreboard_color_bg_team, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
+       else
+               drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
+       drawborderlines(autocvar_scoreboard_border_thickness, pos, tmp, '0 0 0', scoreboard_alpha_bg * 0.75, DRAWFLAG_NORMAL);
+
+       // draw secrets
+       val = sprintf("%d/%d", stat_secrets_found, stat_secrets_total);
+       pos = HUD_DrawKeyValue(pos, _("Secrets found:"), val);
+       
+       // update position
+       pos_y += 1.25 * hud_fontsize_y;
+       return pos;
+}
+
+
 vector HUD_DrawScoreboardRankings(vector pos, entity pl,  vector rgb, vector bg_size)
 {
        float i;
@@ -1094,7 +1147,7 @@ vector HUD_DrawScoreboardRankings(vector pos, entity pl,  vector rgb, vector bg_
                        continue;
                n = grecordholder[i];
                p = race_PlaceName(i+1);
-               if(grecordholder[i] == GetPlayerName(player_localentnum - 1))
+               if(grecordholder[i] == GetPlayerName(player_localnum))
                        drawfill(pos, '1 0 0' * sbwidth + '0 1.25 0' * hud_fontsize_y, hl_rgb, scoreboard_highlight_alpha_self, DRAWFLAG_NORMAL);
                else if(!mod(i, 2) && scoreboard_highlight)
                        drawfill(pos, '1 0 0' * sbwidth + '0 1.25 0' * hud_fontsize_y, hl_rgb, scoreboard_highlight_alpha, DRAWFLAG_NORMAL);
@@ -1151,11 +1204,11 @@ void HUD_DrawScoreboard()
        entity pl, tm;
        string str;
 
-       xmin = autocvar_scoreboard_offset_left * vid_conwidth;
-       ymin = autocvar_con_notify * autocvar_con_notifysize;
+       xmin = (autocvar_scoreboard_offset_left * vid_conwidth);
+       ymin = max((autocvar_con_notify * autocvar_con_notifysize), (autocvar_scoreboard_offset_vertical * vid_conwidth));
 
-       xmax = (1 - autocvar_scoreboard_offset_right) * vid_conwidth;
-       ymax = vid_conheight - ymin;
+       xmax = ((1 - autocvar_scoreboard_offset_right) * vid_conwidth);
+       ymax = (vid_conheight - ymin);
 
        sbwidth = xmax - xmin;
 
@@ -1172,7 +1225,7 @@ void HUD_DrawScoreboard()
        pos_y += sb_heading_fontsize_y + hud_fontsize_y * 0.25;
 
        // Draw the scoreboard
-       vector bg_size = drawgetimagesize("gfx/scoreboard/scoreboard_bg") * autocvar_scoreboard_bg_scale;
+       vector bg_size = draw_getimagesize("gfx/scoreboard/scoreboard_bg") * autocvar_scoreboard_bg_scale;
 
        if(teamplay)
        {
@@ -1210,7 +1263,7 @@ void HUD_DrawScoreboard()
                }
        }
 
-       if(gametype == GAME_CTS || gametype == GAME_RACE) {
+       if(gametype == MAPINFO_TYPE_CTS || gametype == MAPINFO_TYPE_RACE) {
                if(race_speedaward) {
                        drawcolorcodedstring(pos, sprintf(_("Speed award: %d ^7(%s^7)"), race_speedaward, race_speedaward_holder), hud_fontsize, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
                        pos_y += 1.25 * hud_fontsize_y;
@@ -1228,6 +1281,12 @@ void HUD_DrawScoreboard()
                        pos = HUD_DrawScoreboardAccuracyStats(pos, rgb, bg_size);
        }
 
+               
+       if(teamplay)
+               pos = HUD_DrawMapStats(pos, GetTeamRGB(myteam), bg_size);
+       else
+               pos = HUD_DrawMapStats(pos, rgb, bg_size);
+
        // List spectators
        float specs;
        specs = 0;
@@ -1237,7 +1296,7 @@ void HUD_DrawScoreboard()
                if(pl.team != COLOR_SPECTATOR)
                        continue;
                pos_y += 1.25 * hud_fontsize_y;
-               HUD_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1), specs);
+               HUD_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localnum), specs);
                ++specs;
        }
 
@@ -1253,7 +1312,7 @@ void HUD_DrawScoreboard()
        tl = getstatf(STAT_TIMELIMIT);
        fl = getstatf(STAT_FRAGLIMIT);
        ll = getstatf(STAT_LEADLIMIT);
-       if(gametype == GAME_LMS)
+       if(gametype == MAPINFO_TYPE_LMS)
        {
                if(tl > 0)
                        str = strcat(str, sprintf(_(" for up to ^1%1.0f minutes^7"), tl));