3 #include <common/mapinfo.qh>
4 #include <common/ent_cs.qh>
5 #include <server/mutators/mutator/gamemode_ctf.qh> // TODO: remove
7 // Mod icons panel (#10)
9 bool mod_active; // is there any active mod icon?
11 void DrawCAItem(vector myPos, vector mySize, float aspect_ratio, int layout, int i)
13 TC(int, layout); TC(int, i);
16 vector color = '0 0 0';
20 stat = STAT(REDALIVE);
21 pic = "player_red.tga";
25 stat = STAT(BLUEALIVE);
26 pic = "player_blue.tga";
30 stat = STAT(YELLOWALIVE);
31 pic = "player_yellow.tga";
36 stat = STAT(PINKALIVE);
37 pic = "player_pink.tga";
42 if(mySize.x/mySize.y > aspect_ratio)
44 i = aspect_ratio * mySize.y;
45 myPos.x = myPos.x + (mySize.x - i) / 2;
50 i = 1/aspect_ratio * mySize.x;
51 myPos.y = myPos.y + (mySize.y - i) / 2;
57 drawpic_aspect_skin(myPos, pic, eX * 0.7 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
58 drawstring_aspect(myPos + eX * 0.7 * mySize.x, ftos(stat), eX * 0.3 * mySize.x + eY * mySize.y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
61 drawstring_aspect(myPos, ftos(stat), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
64 // Clan Arena and Freeze Tag HUD modicons
65 void HUD_Mod_CA(vector myPos, vector mySize)
67 mod_active = 1; // required in each mod function that always shows something
70 if(gametype == MAPINFO_TYPE_CA)
71 layout = autocvar_hud_panel_modicons_ca_layout;
72 else //if(gametype == MAPINFO_TYPE_FREEZETAG)
73 layout = autocvar_hud_panel_modicons_freezetag_layout;
76 aspect_ratio = (layout) ? 2 : 1;
77 rows = HUD_GetRowCount(team_count, mySize, aspect_ratio);
78 columns = ceil(team_count/rows);
81 float row = 0, column = 0;
83 itemSize = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
84 for(i=0; i<team_count; ++i)
86 pos = myPos + eX * column * itemSize.x + eY * row * itemSize.y;
88 DrawCAItem(pos, itemSize, aspect_ratio, layout, i);
99 // CTF HUD modicon section
100 int redflag_prevframe, blueflag_prevframe, yellowflag_prevframe, pinkflag_prevframe, neutralflag_prevframe; // status during previous frame
101 int redflag_prevstatus, blueflag_prevstatus, yellowflag_prevstatus, pinkflag_prevstatus, neutralflag_prevstatus; // last remembered status
102 float redflag_statuschange_time, blueflag_statuschange_time, yellowflag_statuschange_time, pinkflag_statuschange_time, neutralflag_statuschange_time; // time when the status changed
104 void HUD_Mod_CTF_Reset()
106 redflag_prevstatus = blueflag_prevstatus = yellowflag_prevstatus = pinkflag_prevstatus = neutralflag_prevstatus = 0;
107 redflag_prevframe = blueflag_prevframe = yellowflag_prevframe = pinkflag_prevframe = neutralflag_prevframe = 0;
108 redflag_statuschange_time = blueflag_statuschange_time = yellowflag_statuschange_time = pinkflag_statuschange_time = neutralflag_statuschange_time = 0;
111 void HUD_Mod_CTF(vector pos, vector mySize)
113 vector redflag_pos, blueflag_pos, yellowflag_pos, pinkflag_pos, neutralflag_pos;
115 float f; // every function should have that
117 int redflag, blueflag, yellowflag, pinkflag, neutralflag; // current status
118 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
119 bool ctf_oneflag; // one-flag CTF mode enabled/disabled
120 int stat_items = STAT(CTF_FLAGSTATUS);
121 float fs, fs2, fs3, size1, size2;
124 redflag = (stat_items/CTF_RED_FLAG_TAKEN) & 3;
125 blueflag = (stat_items/CTF_BLUE_FLAG_TAKEN) & 3;
126 yellowflag = (stat_items/CTF_YELLOW_FLAG_TAKEN) & 3;
127 pinkflag = (stat_items/CTF_PINK_FLAG_TAKEN) & 3;
128 neutralflag = (stat_items/CTF_NEUTRAL_FLAG_TAKEN) & 3;
130 ctf_oneflag = (stat_items & CTF_FLAG_NEUTRAL);
132 mod_active = (redflag || blueflag || yellowflag || pinkflag || neutralflag);
134 if (autocvar__hud_configure) {
141 ctf_oneflag = neutralflag = 0; // disable neutral flag in hud editor?
144 // when status CHANGES, set old status into prevstatus and current status into status
145 #define X(team) MACRO_BEGIN { \
146 if (team##flag != team##flag_prevframe) { \
147 team##flag_statuschange_time = time; \
148 team##flag_prevstatus = team##flag_prevframe; \
149 team##flag_prevframe = team##flag; \
151 team##flag_statuschange_elapsedtime = time - team##flag_statuschange_time; \
160 const float BLINK_FACTOR = 0.15;
161 const float BLINK_BASE = 0.85;
163 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
165 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
167 const float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
169 #define X(team, cond) \
170 string team##_icon = string_null, team##_icon_prevstatus = string_null; \
171 int team##_alpha, team##_alpha_prevstatus; \
172 team##_alpha = team##_alpha_prevstatus = 1; \
174 switch (team##flag) { \
175 case 1: team##_icon = "flag_" #team "_taken"; break; \
176 case 2: team##_icon = "flag_" #team "_lost"; break; \
177 case 3: team##_icon = "flag_" #team "_carrying"; team##_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break; \
179 if ((stat_items & CTF_SHIELDED) && (cond)) { \
180 team##_icon = "flag_" #team "_shielded"; \
182 team##_icon = string_null; \
186 switch (team##flag_prevstatus) { \
187 case 1: team##_icon_prevstatus = "flag_" #team "_taken"; break; \
188 case 2: team##_icon_prevstatus = "flag_" #team "_lost"; break; \
189 case 3: team##_icon_prevstatus = "flag_" #team "_carrying"; team##_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break; \
191 if (team##flag == 3) { \
192 team##_icon_prevstatus = "flag_" #team "_carrying"; /* make it more visible */\
193 } else if((stat_items & CTF_SHIELDED) && (cond)) { \
194 team##_icon_prevstatus = "flag_" #team "_shielded"; \
196 team##_icon_prevstatus = string_null; \
201 X(red, myteam != NUM_TEAM_1);
202 X(blue, myteam != NUM_TEAM_2);
203 X(yellow, myteam != NUM_TEAM_3);
204 X(pink, myteam != NUM_TEAM_4);
209 // hacky, but these aren't needed
210 red_icon = red_icon_prevstatus = blue_icon = blue_icon_prevstatus = yellow_icon = yellow_icon_prevstatus = pink_icon = pink_icon_prevstatus = string_null;
212 } else switch (team_count) {
214 case 2: fs = 0.5; fs2 = 0.5; fs3 = 0.5; break;
215 case 3: fs = 1; fs2 = 0.35; fs3 = 0.35; break;
216 case 4: fs = 0.75; fs2 = 0.25; fs3 = 0.5; break;
219 if (mySize_x > mySize_y) {
235 blueflag_pos = pos + eX * fs2 * size1;
236 yellowflag_pos = pos - eX * fs2 * size1;
237 pinkflag_pos = pos + eX * fs3 * size1;
241 redflag_pos = pos + eX * fs2 * size1;
243 yellowflag_pos = pos - eX * fs2 * size1;
244 pinkflag_pos = pos + eX * fs3 * size1;
248 redflag_pos = pos + eX * fs3 * size1;
249 blueflag_pos = pos - eX * fs2 * size1;
250 yellowflag_pos = pos;
251 pinkflag_pos = pos + eX * fs2 * size1;
255 redflag_pos = pos - eX * fs2 * size1;
256 blueflag_pos = pos + eX * fs3 * size1;
257 yellowflag_pos = pos + eX * fs2 * size1;
262 neutralflag_pos = pos;
263 flag_size = e1 * fs * size1 + e2 * size2;
265 #define X(team) MACRO_BEGIN { \
266 f = bound(0, team##flag_statuschange_elapsedtime * 2, 1); \
267 if (team##_icon_prevstatus && f < 1) \
268 drawpic_aspect_skin_expanding(team##flag_pos, team##_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * team##_alpha_prevstatus, DRAWFLAG_NORMAL, f); \
270 drawpic_aspect_skin(team##flag_pos, team##_icon, flag_size, '1 1 1', panel_fg_alpha * team##_alpha * f, DRAWFLAG_NORMAL); \
280 // Keyhunt HUD modicon section
283 void HUD_Mod_KH(vector pos, vector mySize)
285 mod_active = 1; // keyhunt should never hide the mod icons panel
287 // Read current state
289 int state = STAT(KH_KEYS);
291 int all_keys, team1_keys, team2_keys, team3_keys, team4_keys, dropped_keys, carrying_keys;
292 all_keys = team1_keys = team2_keys = team3_keys = team4_keys = dropped_keys = carrying_keys = 0;
294 for(i = 0; i < 4; ++i)
296 key_state = (bitshift(state, i * -5) & 31) - 1;
309 case NUM_TEAM_1: ++team1_keys; break;
310 case NUM_TEAM_2: ++team2_keys; break;
311 case NUM_TEAM_3: ++team3_keys; break;
312 case NUM_TEAM_4: ++team4_keys; break;
313 case 29: ++dropped_keys; break;
319 // Calculate slot measurements
323 if(all_keys == 4 && mySize.x * 0.5 < mySize.y && mySize.y * 0.5 < mySize.x)
325 // Quadratic arrangement
326 slot_size = eX * mySize.x * 0.5 + eY * mySize.y * 0.5;
328 KH_SLOTS[1] = pos + eX * slot_size.x;
329 KH_SLOTS[2] = pos + eY * slot_size.y;
330 KH_SLOTS[3] = pos + eX * slot_size.x + eY * slot_size.y;
334 if(mySize.x > mySize.y)
336 // Horizontal arrangement
337 slot_size = eX * mySize.x / all_keys + eY * mySize.y;
338 for(i = 0; i < all_keys; ++i)
339 KH_SLOTS[i] = pos + eX * slot_size.x * i;
343 // Vertical arrangement
344 slot_size = eX * mySize.x + eY * mySize.y / all_keys;
345 for(i = 0; i < all_keys; ++i)
346 KH_SLOTS[i] = pos + eY * slot_size.y * i;
350 // Make icons blink in case of RUN HERE
352 float blink = 0.6 + sin(2*M_PI*time) / 2.5; // Oscillate between 0.2 and 1
359 case NUM_TEAM_1: if(team1_keys == all_keys) alpha = blink; break;
360 case NUM_TEAM_2: if(team2_keys == all_keys) alpha = blink; break;
361 case NUM_TEAM_3: if(team3_keys == all_keys) alpha = blink; break;
362 case NUM_TEAM_4: if(team4_keys == all_keys) alpha = blink; break;
370 if(myteam == NUM_TEAM_1 && carrying_keys)
372 drawpic_aspect_skin(KH_SLOTS[i++], "kh_red_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
376 drawpic_aspect_skin(KH_SLOTS[i++], "kh_red_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
379 if(myteam == NUM_TEAM_2 && carrying_keys)
381 drawpic_aspect_skin(KH_SLOTS[i++], "kh_blue_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
385 drawpic_aspect_skin(KH_SLOTS[i++], "kh_blue_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
388 if(myteam == NUM_TEAM_3 && carrying_keys)
390 drawpic_aspect_skin(KH_SLOTS[i++], "kh_yellow_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
394 drawpic_aspect_skin(KH_SLOTS[i++], "kh_yellow_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
397 if(myteam == NUM_TEAM_4 && carrying_keys)
399 drawpic_aspect_skin(KH_SLOTS[i++], "kh_pink_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
403 drawpic_aspect_skin(KH_SLOTS[i++], "kh_pink_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
405 while(dropped_keys--)
406 drawpic_aspect_skin(KH_SLOTS[i++], "kh_dropped", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
409 // Keepaway HUD mod icon
410 int kaball_prevstatus; // last remembered status
411 float kaball_statuschange_time; // time when the status changed
413 // we don't need to reset for keepaway since it immediately
414 // autocorrects prevstatus as to if the player has the ball or not
416 void HUD_Mod_Keepaway(vector pos, vector mySize)
418 mod_active = 1; // keepaway should always show the mod HUD
420 float BLINK_FACTOR = 0.15;
421 float BLINK_BASE = 0.85;
422 float BLINK_FREQ = 5;
423 float kaball_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
425 int stat_items = STAT(ITEMS);
426 int kaball = (stat_items/IT_KEY1) & 1;
428 if(kaball != kaball_prevstatus)
430 kaball_statuschange_time = time;
431 kaball_prevstatus = kaball;
434 vector kaball_pos, kaball_size;
436 if(mySize.x > mySize.y) {
437 kaball_pos = pos + eX * 0.25 * mySize.x;
438 kaball_size = eX * 0.5 * mySize.x + eY * mySize.y;
440 kaball_pos = pos + eY * 0.25 * mySize.y;
441 kaball_size = eY * 0.5 * mySize.y + eX * mySize.x;
444 float kaball_statuschange_elapsedtime = time - kaball_statuschange_time;
445 float f = bound(0, kaball_statuschange_elapsedtime*2, 1);
447 if(kaball_prevstatus && f < 1)
448 drawpic_aspect_skin_expanding(kaball_pos, "keepawayball_carrying", kaball_size, '1 1 1', panel_fg_alpha * kaball_alpha, DRAWFLAG_NORMAL, f);
451 drawpic_aspect_skin(pos, "keepawayball_carrying", eX * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL);
455 // Nexball HUD mod icon
456 void HUD_Mod_NexBall(vector pos, vector mySize)
458 float nb_pb_starttime, dt, p;
461 stat_items = STAT(ITEMS);
462 nb_pb_starttime = STAT(NB_METERSTART);
464 if (stat_items & IT_KEY1)
469 //Manage the progress bar if any
470 if (nb_pb_starttime > 0)
472 dt = (time - nb_pb_starttime) % nb_pb_period;
473 // one period of positive triangle
474 p = 2 * dt / nb_pb_period;
478 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);
481 if (stat_items & IT_KEY1)
482 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
485 // Race/CTS HUD mod icons
486 float crecordtime_prev; // last remembered crecordtime
487 float crecordtime_change_time; // time when crecordtime last changed
488 float srecordtime_prev; // last remembered srecordtime
489 float srecordtime_change_time; // time when srecordtime last changed
491 float race_status_time;
492 int race_status_prev;
493 string race_status_name_prev;
494 void HUD_Mod_Race(vector pos, vector mySize)
496 mod_active = 1; // race should never hide the mod icons panel
498 me = playerslots[player_localnum];
500 float f; // yet another function has this
501 score = me.(scores[ps_primary]);
503 if(!(scores_flags[ps_primary] & SFL_TIME) || teamplay) // race/cts record display on HUD
504 return; // no records in the actual race
506 // clientside personal record
508 if(gametype == MAPINFO_TYPE_CTS)
512 float t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
514 if(score && (score < t || !t)) {
515 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
516 if(autocvar_cl_autodemo_delete_keeprecords)
518 f = autocvar_cl_autodemo_delete;
520 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
524 if(t != crecordtime_prev) {
525 crecordtime_prev = t;
526 crecordtime_change_time = time;
529 vector textPos, medalPos;
531 if(mySize.x > mySize.y) {
533 squareSize = min(mySize.y, mySize.x/2);
534 textPos = pos + eX * 0.5 * max(0, mySize.x/2 - squareSize) + eY * 0.5 * (mySize.y - squareSize);
535 medalPos = pos + eX * 0.5 * max(0, mySize.x/2 - squareSize) + eX * 0.5 * mySize.x + eY * 0.5 * (mySize.y - squareSize);
538 squareSize = min(mySize.x, mySize.y/2);
539 textPos = pos + eY * 0.5 * max(0, mySize.y/2 - squareSize) + eX * 0.5 * (mySize.x - squareSize);
540 medalPos = pos + eY * 0.5 * max(0, mySize.y/2 - squareSize) + eY * 0.5 * mySize.y + eX * 0.5 * (mySize.x - squareSize);
543 f = time - crecordtime_change_time;
546 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
547 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);
549 drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
550 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);
551 drawstring_aspect_expanding(pos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
552 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);
556 t = race_server_record;
557 if(t != srecordtime_prev) {
558 srecordtime_prev = t;
559 srecordtime_change_time = time;
561 f = time - srecordtime_change_time;
564 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
565 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);
567 drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
568 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);
569 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);
570 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);
573 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
574 race_status_time = time + 5;
575 race_status_prev = race_status;
576 if (race_status_name_prev)
577 strunzone(race_status_name_prev);
578 race_status_name_prev = strzone(race_status_name);
583 a = bound(0, race_status_time - time, 1);
586 s = textShortenToWidth(race_status_name, squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
590 rank = race_CheckName(race_status_name);
594 rankname = count_ordinal(rank);
597 namepos = medalPos + '0 0.8 0' * squareSize;
599 rankpos = medalPos + '0 0.15 0' * squareSize;
602 drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
603 else if(race_status == 1) {
604 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);
605 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
606 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
607 } else if(race_status == 2) {
608 if(race_status_name == entcs_GetName(player_localnum) || !race_myrank || race_myrank < rank)
609 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);
611 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);
612 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
613 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
614 } else if(race_status == 3) {
615 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);
616 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
617 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
620 if (race_status_time - time <= 0) {
621 race_status_prev = -1;
624 strunzone(race_status_name);
625 race_status_name = string_null;
626 if(race_status_name_prev)
627 strunzone(race_status_name_prev);
628 race_status_name_prev = string_null;
632 void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, int layout, int i)
634 TC(int, layout); TC(int, i);
637 vector color = '0 0 0';
641 stat = STAT(DOM_PPS_RED);
642 pic = "dom_icon_red";
646 stat = STAT(DOM_PPS_BLUE);
647 pic = "dom_icon_blue";
651 stat = STAT(DOM_PPS_YELLOW);
652 pic = "dom_icon_yellow";
657 stat = STAT(DOM_PPS_PINK);
658 pic = "dom_icon_pink";
662 float pps_ratio = stat / STAT(DOM_TOTAL_PPS);
664 if(mySize.x/mySize.y > aspect_ratio)
666 i = aspect_ratio * mySize.y;
667 myPos.x = myPos.x + (mySize.x - i) / 2;
672 i = 1/aspect_ratio * mySize.x;
673 myPos.y = myPos.y + (mySize.y - i) / 2;
677 if (layout) // show text too
680 color *= 0.5 + pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max
681 if (layout == 2) // average pps
682 drawstring_aspect(myPos + eX * mySize.y, ftos_decimals(stat, 2), eX * (2/3) * mySize.x + eY * mySize.y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
683 else // percentage of average pps
684 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);
688 drawpic_aspect_skin(myPos, pic, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
691 drawsetcliparea(myPos.x, myPos.y + mySize.y * (1 - pps_ratio), mySize.y, mySize.y * pps_ratio);
692 drawpic_aspect_skin(myPos, strcat(pic, "-highlighted"), '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
697 void HUD_Mod_Dom(vector myPos, vector mySize)
699 mod_active = 1; // required in each mod function that always shows something
701 int layout = autocvar_hud_panel_modicons_dom_layout;
704 aspect_ratio = (layout) ? 3 : 1;
705 rows = HUD_GetRowCount(team_count, mySize, aspect_ratio);
706 columns = ceil(team_count/rows);
709 float row = 0, column = 0;
710 vector pos, itemSize;
711 itemSize = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
712 for(i=0; i<team_count; ++i)
714 pos = myPos + eX * column * itemSize.x + eY * row * itemSize.y;
716 DrawDomItem(pos, itemSize, aspect_ratio, layout, i);
727 void HUD_ModIcons_SetFunc()
731 case MAPINFO_TYPE_KEYHUNT: HUD_ModIcons_GameType = HUD_Mod_KH; break;
732 case MAPINFO_TYPE_CTF: HUD_ModIcons_GameType = HUD_Mod_CTF; break;
733 case MAPINFO_TYPE_NEXBALL: HUD_ModIcons_GameType = HUD_Mod_NexBall; break;
734 case MAPINFO_TYPE_CTS:
735 case MAPINFO_TYPE_RACE: HUD_ModIcons_GameType = HUD_Mod_Race; break;
736 case MAPINFO_TYPE_CA:
737 case MAPINFO_TYPE_FREEZETAG: HUD_ModIcons_GameType = HUD_Mod_CA; break;
738 case MAPINFO_TYPE_DOMINATION: HUD_ModIcons_GameType = HUD_Mod_Dom; break;
739 case MAPINFO_TYPE_KEEPAWAY: HUD_ModIcons_GameType = HUD_Mod_Keepaway; break;
743 int mod_prev; // previous state of mod_active to check for a change
745 float mod_change; // "time" when mod_active changed
749 if(!autocvar__hud_configure)
751 if(!autocvar_hud_panel_modicons) return;
752 if(!HUD_ModIcons_GameType) return;
755 HUD_Panel_UpdateCvars();
757 draw_beginBoldFont();
759 if(mod_active != mod_prev) {
761 mod_prev = mod_active;
764 if(mod_active || autocvar__hud_configure)
765 mod_alpha = bound(0, (time - mod_change) * 2, 1);
767 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
770 HUD_Panel_DrawBg(mod_alpha);
774 panel_pos += '1 1 0' * panel_bg_padding;
775 panel_size -= '2 2 0' * panel_bg_padding;
778 if(autocvar__hud_configure)
779 HUD_Mod_CTF(panel_pos, panel_size);
781 HUD_ModIcons_GameType(panel_pos, panel_size);