Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
cl_race.qh File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void HUD_Mod_Race (vector myPos, vector mySize, bool should_draw)

Variables

bool autocvar_cl_autodemo_delete_keeprecords

Function Documentation

◆ HUD_Mod_Race()

void HUD_Mod_Race ( vector myPos,
vector mySize,
bool should_draw )

Definition at line 59 of file cl_race.qc.

60{
61 if (!should_draw)
62 return;
63
65 float score = me.(scores(ps_primary));
66
67 if(!(scores_flags(ps_primary) & SFL_TIME) || teamplay) // race/cts record display on HUD
68 {
69 mod_active = 0; // hide it in this case!
70 return; // no records in the actual race
71 }
72
73 mod_active = 1;
74
75 // clientside personal record
76 string rr;
77 if(ISGAMETYPE(CTS))
78 rr = CTS_RECORD;
79 else
80 rr = RACE_RECORD;
81 float t = stof(db_get(ClientProgsDB, strcat(mi_shortname, rr, "time")));
82
83 if (score && (score < t || !t) && !isdemo())
84 race_UpdateDB(rr, score, t);
85
86 if(t != crecordtime_prev) {
89 }
90
91 vector textPos, medalPos;
92 float squareSize;
93 if(mySize.x > mySize.y) {
94 // text on left side
95 squareSize = min(mySize.y, mySize.x/2);
96 vector ofs = vec2(0.5 * max(0, mySize.x/2 - squareSize), 0.5 * (mySize.y - squareSize));
97 textPos = pos + ofs;
98 ofs.x += 0.5 * mySize.x;
99 medalPos = pos + ofs;
100 } else {
101 // text on top
102 squareSize = min(mySize.x, mySize.y/2);
103 vector ofs = vec2(0.5 * (mySize.x - squareSize), 0.5 * max(0, mySize.y/2 - squareSize));
104 textPos = pos + ofs;
105 ofs.y += 0.5 * mySize.y;
106 medalPos = pos + ofs;
107 }
108 vector textSize = vec2(squareSize, 0.25 * squareSize);
109
110 race_showTime(_("Personal best"), textPos, eY * 0.25 * squareSize, t, textSize, time - crecordtime_change_time);
111
112 // server record
114 if(t != srecordtime_prev) {
117 }
118
119 textPos += eY * 0.5 * squareSize;
120 race_showTime(_("Server best"), textPos, eY * 0.25 * squareSize, t, textSize, time - srecordtime_change_time);
121
126 }
127
128 // race "awards"
129 float a = bound(0, race_status_time - time, 1);
130 string s = textShortenToWidth(ColorTranslateRGB(race_status_name), squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
131
132 float rank = 0;
133 if(race_status > 0)
135 string rankname = count_ordinal(rank);
136 vector namepos = medalPos + '0 0.8 0' * squareSize;
137 vector rankpos = medalPos + '0 0.15 0' * squareSize;
138
139 if(race_status == 0)
140 drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
141 else if(race_status == 1) {
142 drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newtime", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
143 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
144 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
145 } else if(race_status == 2) {
146 if(strdecolorize(race_status_name) == strdecolorize(entcs_GetName(player_localnum)) || !race_myrank || race_myrank < rank)
147 drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newrankgreen", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
148 else
149 drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newrankyellow", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
150 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
151 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
152 } else if(race_status == 3) {
153 drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newrecordserver", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
154 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
155 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
156 }
157
158 if (race_status_time - time <= 0) {
159 race_status_prev = -1;
160 race_status = -1;
163 }
164}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
int race_CheckName(string net_name)
Definition cl_race.qc:18
float srecordtime_change_time
Definition cl_race.qc:10
float crecordtime_prev
Definition cl_race.qc:7
float srecordtime_prev
Definition cl_race.qc:9
float race_status_time
Definition cl_race.qc:12
void race_UpdateDB(string rr, float new_score, float old_score)
Definition cl_race.qc:42
void race_showTime(string text, vector pos, vector timeText_ofs, float theTime, vector textSize, float f)
Definition cl_race.qc:32
float crecordtime_change_time
Definition cl_race.qc:8
string race_status_name_prev
Definition cl_race.qc:14
int race_status_prev
Definition cl_race.qc:13
void drawstring_aspect(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag)
Definition draw.qc:109
void drawcolorcodedstring_aspect(vector pos, string text, vector sz, float theAlpha, float drawflag)
Definition draw.qc:115
#define drawpic_aspect_skin(pos, pic, sz, color, theAlpha, drawflag)
Definition draw.qh:78
entity playerslots[255]
Definition main.qh:84
int ClientProgsDB
Definition main.qh:204
#define ISGAMETYPE(NAME)
Definition main.qh:46
const int SFL_TIME
Display as mm:ss.s, value is stored as 10ths of a second (AND 0 is the worst possible value!...
Definition scores.qh:122
#define scores_flags(this)
Definition scores.qh:147
string textShortenToWidth(string theText, float maxWidth, vector theFontSize, textLengthUpToWidth_widthFunction_t tw)
Definition util.qc:1171
string mi_shortname
Definition util.qh:126
#define CTS_RECORD
Definition util.qh:98
#define RACE_RECORD
Definition util.qh:97
ERASEABLE string count_ordinal(int interval)
Definition counting.qh:66
const float DRAWFLAG_NORMAL
float player_localnum
float time
string entcs_GetName(int i)
Definition ent_cs.qh:151
float panel_fg_alpha
Definition hud.qh:169
PlayerScoreField ps_primary
Definition hud.qh:117
ERASEABLE string db_get(int db, string key)
Definition map.qh:91
float isdemo()
float stof(string val,...)
float bound(float min, float value, float max)
float min(float f,...)
float max(float f,...)
bool mod_active
Definition modicons.qh:7
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
float race_myrank
Definition racetimer.qh:49
float race_server_record
Definition racetimer.qh:29
string race_status_name
Definition racetimer.qh:48
float race_status
Definition racetimer.qh:47
vector
Definition self.qh:92
ERASEABLE string ColorTranslateRGB(string s)
Definition string.qh:196
#define strfree(this)
Definition string.qh:59
#define strcpy(this, s)
Definition string.qh:52
float stringwidth_colors(string s, vector theSize)
Definition string.qh:30
bool teamplay
Definition teams.qh:59
const vector eY
Definition vector.qh:45
#define vec2(...)
Definition vector.qh:90

References bound(), ClientProgsDB, ColorTranslateRGB(), count_ordinal(), crecordtime_change_time, crecordtime_prev, CTS_RECORD, db_get(), drawcolorcodedstring_aspect(), DRAWFLAG_NORMAL, drawpic_aspect_skin, drawstring_aspect(), entcs_GetName(), entity(), eY, isdemo(), ISGAMETYPE, max(), mi_shortname, min(), mod_active, panel_fg_alpha, player_localnum, playerslots, ps_primary, race_CheckName(), race_myrank, RACE_RECORD, race_server_record, race_showTime(), race_status, race_status_name, race_status_name_prev, race_status_prev, race_status_time, race_UpdateDB(), scores_flags, SFL_TIME, srecordtime_change_time, srecordtime_prev, stof(), strcat(), strcpy, strfree, stringwidth_colors(), teamplay, textShortenToWidth(), time, vec2, and vector.

Referenced by Race::void(), and RaceCTS::void().

Variable Documentation

◆ autocvar_cl_autodemo_delete_keeprecords

bool autocvar_cl_autodemo_delete_keeprecords

Definition at line 3 of file cl_race.qh.

Referenced by race_UpdateDB().