From 7ad2ad7aa373c24088dc8fd93d343043b8c72965 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Przemys=C5=82aw=20Grzywacz?= Date: Sun, 23 Oct 2011 11:12:00 +0200 Subject: [PATCH] display secrets in the scoreboard --- qcsrc/client/scoreboard.qc | 59 ++++++++++++++++++++++++++++++++++++++ qcsrc/common/constants.qh | 3 ++ qcsrc/server/cl_client.qc | 5 +++- qcsrc/server/g_world.qc | 6 +++- qcsrc/server/secret.qc | 13 +++++++-- qcsrc/server/secret.qh | 9 ++++++ 6 files changed, 90 insertions(+), 5 deletions(-) diff --git a/qcsrc/client/scoreboard.qc b/qcsrc/client/scoreboard.qc index be457e480..1e24e8272 100644 --- a/qcsrc/client/scoreboard.qc +++ b/qcsrc/client/scoreboard.qc @@ -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; diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index 9c4057873..857a8c50e 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -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; diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 4a2de0613..e39f5f86f 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -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 diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 93157819e..1d895db6d 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -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(); diff --git a/qcsrc/server/secret.qc b/qcsrc/server/secret.qc index 96470623b..ca4a49cf4 100644 --- a/qcsrc/server/secret.qc +++ b/qcsrc/server/secret.qc @@ -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") diff --git a/qcsrc/server/secret.qh b/qcsrc/server/secret.qh index 2eadc42f4..dd94b1921 100644 --- a/qcsrc/server/secret.qh +++ b/qcsrc/server/secret.qh @@ -8,3 +8,12 @@ float secrets_total; */ float secrets_found; + +.float stat_secrets_total; +.float stat_secrets_found; + +/** + * update secrets status. + */ +void secrets_setstatus(); + -- 2.39.2