]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
display secrets in the scoreboard
authorPrzemysław Grzywacz <nexather@gmail.com>
Sun, 23 Oct 2011 09:12:00 +0000 (11:12 +0200)
committerPrzemysław Grzywacz <nexather@gmail.com>
Sun, 23 Oct 2011 09:12:00 +0000 (11:12 +0200)
qcsrc/client/scoreboard.qc
qcsrc/common/constants.qh
qcsrc/server/cl_client.qc
qcsrc/server/g_world.qc
qcsrc/server/secret.qc
qcsrc/server/secret.qh

index be457e480876119eaf22a614cfe8138c8ca374f1..1e24e8272d0881084893da67cc65f95521a5a783 100644 (file)
@@ -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;
+       drawstring(pos, key, hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
+       pos_x = xmax - stringwidth(value, FALSE, hud_fontsize) - hud_fontsize_x;
+       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;
@@ -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;
index 9c40578739b3ae00744a63dc3fd0e14bd827a250..857a8c50ebba50e8dfff7cb010c95dd6596935e5 100644 (file)
@@ -355,6 +355,9 @@ const float STAT_VEHICLESTAT_RELOAD1 = 64;
 const float STAT_VEHICLESTAT_AMMO2   = 65;
 const float STAT_VEHICLESTAT_RELOAD2 = 66;
 
+const float STAT_SECRETS_TOTAL = 70;
+const float STAT_SECRETS_FOUND = 71;
+
 // mod stats (1xx)
 const float STAT_REDALIVE = 100;
 const float STAT_BLUEALIVE = 101;
index 4a2de06131ffe3ad6bba6c06ba9269b570bbd411..e39f5f86f9dfbf97b028ee830751b7d7baf06a95 100644 (file)
@@ -3012,7 +3012,10 @@ void PlayerPreThink (void)
 
                if(g_nexball)
                        nexball_setstatus();
-
+               
+               // secret status
+               secrets_setstatus();
+               
                self.dmg_team = max(0, self.dmg_team - autocvar_g_teamdamage_resetspeed * frametime);
 
                //self.angles_y=self.v_angle_y + 90;   // temp
index 93157819efe8f6685c7594ba38e0f35942d0fe2a..1d895db6dbe1472e692d30f100a9dccff527b536 100644 (file)
@@ -851,7 +851,11 @@ void spawnfunc_worldspawn (void)
        addstat(STAT_MOVEVARS_MAXSPEED, AS_FLOAT, stat_sv_maxspeed);
        addstat(STAT_MOVEVARS_AIRACCEL_QW, AS_FLOAT, stat_sv_airaccel_qw);
        addstat(STAT_MOVEVARS_AIRSTRAFEACCEL_QW, AS_FLOAT, stat_sv_airstrafeaccel_qw);
-
+       
+       // secrets
+       addstat(STAT_SECRETS_TOTAL, AS_FLOAT, stat_secrets_total);
+       addstat(STAT_SECRETS_FOUND, AS_FLOAT, stat_secrets_found);
+       
        next_pingtime = time + 5;
 
        detect_maptype();
index 96470623b45a05d1bdbc0105a829d3d9960ad294..ca4a49cf4035b760c9da07aadca904fe2c602696 100644 (file)
@@ -1,6 +1,13 @@
-/*
-A secret has been found!
-*/
+
+
+void secrets_setstatus() {
+       self.stat_secrets_total = secrets_total;
+       self.stat_secrets_found = secrets_found;
+}
+
+/**
+ * A secret has been found (maybe :P)
+ */
 void trigger_secret_touch() {
        // only a player can trigger this
        if (other.classname != "player")
index 2eadc42f47e5c8ce521c0a2ac1018fb5c01b2319..dd94b192195634c277aa16615de1da490a5b0ef6 100644 (file)
@@ -8,3 +8,12 @@ float secrets_total;
  */
 float secrets_found;
 
+
+.float stat_secrets_total;
+.float stat_secrets_found;
+
+/**
+ * update secrets status.
+ */
+void secrets_setstatus();
+