2 // Mod icons panel (#10)
4 bool mod_active; // is there any active mod icon?
6 void DrawCAItem(vector myPos, vector mySize, float aspect_ratio, int layout, int i)
10 vector color = '0 0 0';
14 stat = STAT(REDALIVE);
15 pic = "player_red.tga";
19 stat = STAT(BLUEALIVE);
20 pic = "player_blue.tga";
24 stat = STAT(YELLOWALIVE);
25 pic = "player_yellow.tga";
30 stat = STAT(PINKALIVE);
31 pic = "player_pink.tga";
36 if(mySize.x/mySize.y > aspect_ratio)
38 i = aspect_ratio * mySize.y;
39 myPos.x = myPos.x + (mySize.x - i) / 2;
44 i = 1/aspect_ratio * mySize.x;
45 myPos.y = myPos.y + (mySize.y - i) / 2;
51 drawpic_aspect_skin(myPos, pic, eX * 0.7 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
52 drawstring_aspect(myPos + eX * 0.7 * mySize.x, ftos(stat), eX * 0.3 * mySize.x + eY * mySize.y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
55 drawstring_aspect(myPos, ftos(stat), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
58 // Clan Arena and Freeze Tag HUD modicons
59 void HUD_Mod_CA(vector myPos, vector mySize)
61 mod_active = 1; // required in each mod function that always shows something
64 if(gametype == MAPINFO_TYPE_CA)
65 layout = autocvar_hud_panel_modicons_ca_layout;
66 else //if(gametype == MAPINFO_TYPE_FREEZETAG)
67 layout = autocvar_hud_panel_modicons_freezetag_layout;
70 aspect_ratio = (layout) ? 2 : 1;
71 rows = HUD_GetRowCount(team_count, mySize, aspect_ratio);
72 columns = ceil(team_count/rows);
75 float row = 0, column = 0;
77 itemSize = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
78 for(i=0; i<team_count; ++i)
80 pos = myPos + eX * column * itemSize.x + eY * row * itemSize.y;
82 DrawCAItem(pos, itemSize, aspect_ratio, layout, i);
93 // CTF HUD modicon section
94 int redflag_prevframe, blueflag_prevframe, yellowflag_prevframe, pinkflag_prevframe, neutralflag_prevframe; // status during previous frame
95 int redflag_prevstatus, blueflag_prevstatus, yellowflag_prevstatus, pinkflag_prevstatus, neutralflag_prevstatus; // last remembered status
96 float redflag_statuschange_time, blueflag_statuschange_time, yellowflag_statuschange_time, pinkflag_statuschange_time, neutralflag_statuschange_time; // time when the status changed
98 void HUD_Mod_CTF_Reset()
100 redflag_prevstatus = blueflag_prevstatus = yellowflag_prevstatus = pinkflag_prevstatus = neutralflag_prevstatus = 0;
101 redflag_prevframe = blueflag_prevframe = yellowflag_prevframe = pinkflag_prevframe = neutralflag_prevframe = 0;
102 redflag_statuschange_time = blueflag_statuschange_time = yellowflag_statuschange_time = pinkflag_statuschange_time = neutralflag_statuschange_time = 0;
105 void HUD_Mod_CTF(vector pos, vector mySize)
107 vector redflag_pos, blueflag_pos, yellowflag_pos, pinkflag_pos, neutralflag_pos;
109 float f; // every function should have that
111 int redflag, blueflag, yellowflag, pinkflag, neutralflag; // current status
112 float redflag_statuschange_elapsedtime = 0, blueflag_statuschange_elapsedtime = 0, yellowflag_statuschange_elapsedtime = 0, pinkflag_statuschange_elapsedtime = 0, neutralflag_statuschange_elapsedtime = 0; // time since the status changed
113 bool ctf_oneflag; // one-flag CTF mode enabled/disabled
114 int stat_items = STAT(CTF_FLAGSTATUS);
115 float fs, fs2, fs3, size1, size2;
118 redflag = (stat_items/CTF_RED_FLAG_TAKEN) & 3;
119 blueflag = (stat_items/CTF_BLUE_FLAG_TAKEN) & 3;
120 yellowflag = (stat_items/CTF_YELLOW_FLAG_TAKEN) & 3;
121 pinkflag = (stat_items/CTF_PINK_FLAG_TAKEN) & 3;
122 neutralflag = (stat_items/CTF_NEUTRAL_FLAG_TAKEN) & 3;
124 ctf_oneflag = (stat_items & CTF_FLAG_NEUTRAL);
126 mod_active = (redflag || blueflag || yellowflag || pinkflag || neutralflag);
128 if (autocvar__hud_configure) {
135 ctf_oneflag = neutralflag = 0; // disable neutral flag in hud editor?
138 // when status CHANGES, set old status into prevstatus and current status into status
139 #define X(team) MACRO_BEGIN { \
140 if (team##flag != team##flag_prevframe) { \
141 team##flag_statuschange_time = time; \
142 team##flag_prevstatus = team##flag_prevframe; \
143 team##flag_prevframe = team##flag; \
145 team##flag_statuschange_elapsedtime = time - team##flag_statuschange_time; \
154 const float BLINK_FACTOR = 0.15;
155 const float BLINK_BASE = 0.85;
157 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
159 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
161 const float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
163 #define X(team, cond) \
164 string team##_icon = string_null, team##_icon_prevstatus = string_null; \
165 int team##_alpha, team##_alpha_prevstatus; \
166 team##_alpha = team##_alpha_prevstatus = 1; \
168 switch (team##flag) { \
169 case 1: team##_icon = "flag_" #team "_taken"; break; \
170 case 2: team##_icon = "flag_" #team "_lost"; break; \
171 case 3: team##_icon = "flag_" #team "_carrying"; team##_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break; \
173 if ((stat_items & CTF_SHIELDED) && (cond)) { \
174 team##_icon = "flag_" #team "_shielded"; \
176 team##_icon = string_null; \
180 switch (team##flag_prevstatus) { \
181 case 1: team##_icon_prevstatus = "flag_" #team "_taken"; break; \
182 case 2: team##_icon_prevstatus = "flag_" #team "_lost"; break; \
183 case 3: team##_icon_prevstatus = "flag_" #team "_carrying"; team##_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break; \
185 if (team##flag == 3) { \
186 team##_icon_prevstatus = "flag_" #team "_carrying"; /* make it more visible */\
187 } else if((stat_items & CTF_SHIELDED) && (cond)) { \
188 team##_icon_prevstatus = "flag_" #team "_shielded"; \
190 team##_icon_prevstatus = string_null; \
195 X(red, myteam != NUM_TEAM_1);
196 X(blue, myteam != NUM_TEAM_2);
197 X(yellow, myteam != NUM_TEAM_3);
198 X(pink, myteam != NUM_TEAM_4);
203 // hacky, but these aren't needed
204 red_icon = red_icon_prevstatus = blue_icon = blue_icon_prevstatus = yellow_icon = yellow_icon_prevstatus = pink_icon = pink_icon_prevstatus = string_null;
206 } else switch (team_count) {
208 case 2: fs = 0.5; fs2 = 0.5; fs3 = 0.5; break;
209 case 3: fs = 1; fs2 = 0.35; fs3 = 0.35; break;
210 case 4: fs = 0.75; fs2 = 0.25; fs3 = 0.5; break;
213 if (mySize_x > mySize_y) {
229 blueflag_pos = pos + eX * fs2 * size1;
230 yellowflag_pos = pos - eX * fs2 * size1;
231 pinkflag_pos = pos + eX * fs3 * size1;
235 redflag_pos = pos + eX * fs2 * size1;
237 yellowflag_pos = pos - eX * fs2 * size1;
238 pinkflag_pos = pos + eX * fs3 * size1;
242 redflag_pos = pos + eX * fs3 * size1;
243 blueflag_pos = pos - eX * fs2 * size1;
244 yellowflag_pos = pos;
245 pinkflag_pos = pos + eX * fs2 * size1;
249 redflag_pos = pos - eX * fs2 * size1;
250 blueflag_pos = pos + eX * fs3 * size1;
251 yellowflag_pos = pos + eX * fs2 * size1;
256 neutralflag_pos = pos;
257 flag_size = e1 * fs * size1 + e2 * size2;
259 #define X(team) MACRO_BEGIN { \
260 f = bound(0, team##flag_statuschange_elapsedtime * 2, 1); \
261 if (team##_icon_prevstatus && f < 1) \
262 drawpic_aspect_skin_expanding(team##flag_pos, team##_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * team##_alpha_prevstatus, DRAWFLAG_NORMAL, f); \
264 drawpic_aspect_skin(team##flag_pos, team##_icon, flag_size, '1 1 1', panel_fg_alpha * team##_alpha * f, DRAWFLAG_NORMAL); \
274 // Keyhunt HUD modicon section
277 void HUD_Mod_KH(vector pos, vector mySize)
279 mod_active = 1; // keyhunt should never hide the mod icons panel
281 // Read current state
283 int state = STAT(KH_KEYS);
285 int all_keys, team1_keys, team2_keys, team3_keys, team4_keys, dropped_keys, carrying_keys;
286 all_keys = team1_keys = team2_keys = team3_keys = team4_keys = dropped_keys = carrying_keys = 0;
288 for(i = 0; i < 4; ++i)
290 key_state = (bitshift(state, i * -5) & 31) - 1;
303 case NUM_TEAM_1: ++team1_keys; break;
304 case NUM_TEAM_2: ++team2_keys; break;
305 case NUM_TEAM_3: ++team3_keys; break;
306 case NUM_TEAM_4: ++team4_keys; break;
307 case 29: ++dropped_keys; break;
313 // Calculate slot measurements
317 if(all_keys == 4 && mySize.x * 0.5 < mySize.y && mySize.y * 0.5 < mySize.x)
319 // Quadratic arrangement
320 slot_size = eX * mySize.x * 0.5 + eY * mySize.y * 0.5;
322 KH_SLOTS[1] = pos + eX * slot_size.x;
323 KH_SLOTS[2] = pos + eY * slot_size.y;
324 KH_SLOTS[3] = pos + eX * slot_size.x + eY * slot_size.y;
328 if(mySize.x > mySize.y)
330 // Horizontal arrangement
331 slot_size = eX * mySize.x / all_keys + eY * mySize.y;
332 for(i = 0; i < all_keys; ++i)
333 KH_SLOTS[i] = pos + eX * slot_size.x * i;
337 // Vertical arrangement
338 slot_size = eX * mySize.x + eY * mySize.y / all_keys;
339 for(i = 0; i < all_keys; ++i)
340 KH_SLOTS[i] = pos + eY * slot_size.y * i;
344 // Make icons blink in case of RUN HERE
346 float blink = 0.6 + sin(2*M_PI*time) / 2.5; // Oscillate between 0.2 and 1
353 case NUM_TEAM_1: if(team1_keys == all_keys) alpha = blink; break;
354 case NUM_TEAM_2: if(team2_keys == all_keys) alpha = blink; break;
355 case NUM_TEAM_3: if(team3_keys == all_keys) alpha = blink; break;
356 case NUM_TEAM_4: if(team4_keys == all_keys) alpha = blink; break;
364 if(myteam == NUM_TEAM_1 && carrying_keys)
366 drawpic_aspect_skin(KH_SLOTS[i++], "kh_red_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
370 drawpic_aspect_skin(KH_SLOTS[i++], "kh_red_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
373 if(myteam == NUM_TEAM_2 && carrying_keys)
375 drawpic_aspect_skin(KH_SLOTS[i++], "kh_blue_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
379 drawpic_aspect_skin(KH_SLOTS[i++], "kh_blue_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
382 if(myteam == NUM_TEAM_3 && carrying_keys)
384 drawpic_aspect_skin(KH_SLOTS[i++], "kh_yellow_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
388 drawpic_aspect_skin(KH_SLOTS[i++], "kh_yellow_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
391 if(myteam == NUM_TEAM_4 && carrying_keys)
393 drawpic_aspect_skin(KH_SLOTS[i++], "kh_pink_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
397 drawpic_aspect_skin(KH_SLOTS[i++], "kh_pink_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
399 while(dropped_keys--)
400 drawpic_aspect_skin(KH_SLOTS[i++], "kh_dropped", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
403 // Keepaway HUD mod icon
404 int kaball_prevstatus; // last remembered status
405 float kaball_statuschange_time; // time when the status changed
407 // we don't need to reset for keepaway since it immediately
408 // autocorrects prevstatus as to if the player has the ball or not
410 void HUD_Mod_Keepaway(vector pos, vector mySize)
412 mod_active = 1; // keepaway should always show the mod HUD
414 float BLINK_FACTOR = 0.15;
415 float BLINK_BASE = 0.85;
416 float BLINK_FREQ = 5;
417 float kaball_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
419 int stat_items = STAT(ITEMS);
420 int kaball = (stat_items/IT_KEY1) & 1;
422 if(kaball != kaball_prevstatus)
424 kaball_statuschange_time = time;
425 kaball_prevstatus = kaball;
428 vector kaball_pos, kaball_size;
430 if(mySize.x > mySize.y) {
431 kaball_pos = pos + eX * 0.25 * mySize.x;
432 kaball_size = eX * 0.5 * mySize.x + eY * mySize.y;
434 kaball_pos = pos + eY * 0.25 * mySize.y;
435 kaball_size = eY * 0.5 * mySize.y + eX * mySize.x;
438 float kaball_statuschange_elapsedtime = time - kaball_statuschange_time;
439 float f = bound(0, kaball_statuschange_elapsedtime*2, 1);
441 if(kaball_prevstatus && f < 1)
442 drawpic_aspect_skin_expanding(kaball_pos, "keepawayball_carrying", kaball_size, '1 1 1', panel_fg_alpha * kaball_alpha, DRAWFLAG_NORMAL, f);
445 drawpic_aspect_skin(pos, "keepawayball_carrying", eX * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL);
449 // Nexball HUD mod icon
450 void HUD_Mod_NexBall(vector pos, vector mySize)
452 float nb_pb_starttime, dt, p;
455 stat_items = STAT(ITEMS);
456 nb_pb_starttime = STAT(NB_METERSTART);
458 if (stat_items & IT_KEY1)
463 //Manage the progress bar if any
464 if (nb_pb_starttime > 0)
466 dt = (time - nb_pb_starttime) % nb_pb_period;
467 // one period of positive triangle
468 p = 2 * dt / nb_pb_period;
472 HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, (mySize.x <= mySize.y), 0, autocvar_hud_progressbar_nexball_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
475 if (stat_items & IT_KEY1)
476 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
479 // Race/CTS HUD mod icons
480 float crecordtime_prev; // last remembered crecordtime
481 float crecordtime_change_time; // time when crecordtime last changed
482 float srecordtime_prev; // last remembered srecordtime
483 float srecordtime_change_time; // time when srecordtime last changed
485 float race_status_time;
486 int race_status_prev;
487 string race_status_name_prev;
488 void HUD_Mod_Race(vector pos, vector mySize)
490 mod_active = 1; // race should never hide the mod icons panel
492 me = playerslots[player_localnum];
494 float f; // yet another function has this
495 score = me.(scores[ps_primary]);
497 if(!(scores_flags[ps_primary] & SFL_TIME) || teamplay) // race/cts record display on HUD
498 return; // no records in the actual race
500 // clientside personal record
502 if(gametype == MAPINFO_TYPE_CTS)
506 float t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
508 if(score && (score < t || !t)) {
509 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
510 if(autocvar_cl_autodemo_delete_keeprecords)
512 f = autocvar_cl_autodemo_delete;
514 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
518 if(t != crecordtime_prev) {
519 crecordtime_prev = t;
520 crecordtime_change_time = time;
523 vector textPos, medalPos;
525 if(mySize.x > mySize.y) {
527 squareSize = min(mySize.y, mySize.x/2);
528 textPos = pos + eX * 0.5 * max(0, mySize.x/2 - squareSize) + eY * 0.5 * (mySize.y - squareSize);
529 medalPos = pos + eX * 0.5 * max(0, mySize.x/2 - squareSize) + eX * 0.5 * mySize.x + eY * 0.5 * (mySize.y - squareSize);
532 squareSize = min(mySize.x, mySize.y/2);
533 textPos = pos + eY * 0.5 * max(0, mySize.y/2 - squareSize) + eX * 0.5 * (mySize.x - squareSize);
534 medalPos = pos + eY * 0.5 * max(0, mySize.y/2 - squareSize) + eY * 0.5 * mySize.y + eX * 0.5 * (mySize.x - squareSize);
537 f = time - crecordtime_change_time;
540 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
541 drawstring_aspect(textPos + eY * 0.25 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
543 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
544 drawstring_aspect(textPos + eY * 0.25 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
545 drawstring_aspect_expanding(pos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
546 drawstring_aspect_expanding(pos + eY * 0.25 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
550 t = race_server_record;
551 if(t != srecordtime_prev) {
552 srecordtime_prev = t;
553 srecordtime_change_time = time;
555 f = time - srecordtime_change_time;
558 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
559 drawstring_aspect(textPos + eY * 0.75 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
561 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
562 drawstring_aspect(textPos + eY * 0.75 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
563 drawstring_aspect_expanding(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
564 drawstring_aspect_expanding(textPos + eY * 0.75 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
567 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
568 race_status_time = time + 5;
569 race_status_prev = race_status;
570 if (race_status_name_prev)
571 strunzone(race_status_name_prev);
572 race_status_name_prev = strzone(race_status_name);
577 a = bound(0, race_status_time - time, 1);
580 s = textShortenToWidth(race_status_name, squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
584 rank = race_CheckName(race_status_name);
588 rankname = count_ordinal(rank);
591 namepos = medalPos + '0 0.8 0' * squareSize;
593 rankpos = medalPos + '0 0.15 0' * squareSize;
596 drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
597 else if(race_status == 1) {
598 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);
599 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
600 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
601 } else if(race_status == 2) {
602 if(race_status_name == entcs_GetName(player_localnum) || !race_myrank || race_myrank < rank)
603 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);
605 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);
606 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
607 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
608 } else if(race_status == 3) {
609 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);
610 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
611 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
614 if (race_status_time - time <= 0) {
615 race_status_prev = -1;
618 strunzone(race_status_name);
619 race_status_name = string_null;
620 if(race_status_name_prev)
621 strunzone(race_status_name_prev);
622 race_status_name_prev = string_null;
626 void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, int layout, int i)
630 vector color = '0 0 0';
634 stat = STAT(DOM_PPS_RED);
635 pic = "dom_icon_red";
639 stat = STAT(DOM_PPS_BLUE);
640 pic = "dom_icon_blue";
644 stat = STAT(DOM_PPS_YELLOW);
645 pic = "dom_icon_yellow";
650 stat = STAT(DOM_PPS_PINK);
651 pic = "dom_icon_pink";
655 float pps_ratio = stat / STAT(DOM_TOTAL_PPS);
657 if(mySize.x/mySize.y > aspect_ratio)
659 i = aspect_ratio * mySize.y;
660 myPos.x = myPos.x + (mySize.x - i) / 2;
665 i = 1/aspect_ratio * mySize.x;
666 myPos.y = myPos.y + (mySize.y - i) / 2;
670 if (layout) // show text too
673 color *= 0.5 + pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max
674 if (layout == 2) // average pps
675 drawstring_aspect(myPos + eX * mySize.y, ftos_decimals(stat, 2), eX * (2/3) * mySize.x + eY * mySize.y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
676 else // percentage of average pps
677 drawstring_aspect(myPos + eX * mySize.y, strcat( ftos(floor(pps_ratio*100 + 0.5)), "%" ), eX * (2/3) * mySize.x + eY * mySize.y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
681 drawpic_aspect_skin(myPos, pic, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
684 drawsetcliparea(myPos.x, myPos.y + mySize.y * (1 - pps_ratio), mySize.y, mySize.y * pps_ratio);
685 drawpic_aspect_skin(myPos, strcat(pic, "-highlighted"), '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
690 void HUD_Mod_Dom(vector myPos, vector mySize)
692 mod_active = 1; // required in each mod function that always shows something
694 int layout = autocvar_hud_panel_modicons_dom_layout;
697 aspect_ratio = (layout) ? 3 : 1;
698 rows = HUD_GetRowCount(team_count, mySize, aspect_ratio);
699 columns = ceil(team_count/rows);
702 float row = 0, column = 0;
703 vector pos, itemSize;
704 itemSize = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
705 for(i=0; i<team_count; ++i)
707 pos = myPos + eX * column * itemSize.x + eY * row * itemSize.y;
709 DrawDomItem(pos, itemSize, aspect_ratio, layout, i);
720 void HUD_ModIcons_SetFunc()
724 case MAPINFO_TYPE_KEYHUNT: HUD_ModIcons_GameType = HUD_Mod_KH; break;
725 case MAPINFO_TYPE_CTF: HUD_ModIcons_GameType = HUD_Mod_CTF; break;
726 case MAPINFO_TYPE_NEXBALL: HUD_ModIcons_GameType = HUD_Mod_NexBall; break;
727 case MAPINFO_TYPE_CTS:
728 case MAPINFO_TYPE_RACE: HUD_ModIcons_GameType = HUD_Mod_Race; break;
729 case MAPINFO_TYPE_CA:
730 case MAPINFO_TYPE_FREEZETAG: HUD_ModIcons_GameType = HUD_Mod_CA; break;
731 case MAPINFO_TYPE_DOMINATION: HUD_ModIcons_GameType = HUD_Mod_Dom; break;
732 case MAPINFO_TYPE_KEEPAWAY: HUD_ModIcons_GameType = HUD_Mod_Keepaway; break;
736 int mod_prev; // previous state of mod_active to check for a change
738 float mod_change; // "time" when mod_active changed
742 if(!autocvar__hud_configure)
744 if(!autocvar_hud_panel_modicons) return;
745 if(!HUD_ModIcons_GameType) return;
748 HUD_Panel_UpdateCvars();
750 draw_beginBoldFont();
752 if(mod_active != mod_prev) {
754 mod_prev = mod_active;
757 if(mod_active || autocvar__hud_configure)
758 mod_alpha = bound(0, (time - mod_change) * 2, 1);
760 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
763 HUD_Panel_DrawBg(mod_alpha);
767 panel_pos += '1 1 0' * panel_bg_padding;
768 panel_size -= '2 2 0' * panel_bg_padding;
771 if(autocvar__hud_configure)
772 HUD_Mod_CTF(panel_pos, panel_size);
774 HUD_ModIcons_GameType(panel_pos, panel_size);