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 || (stat_items & CTF_SHIELDED));
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 && team_count >= 3);
204 X(pink, myteam != NUM_TEAM_4 && team_count >= 4);
205 X(neutral, ctf_oneflag);
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 && 0) /* TODO Replace 0 with stalemate condition */ \
268 drawpic_aspect_skin(team##flag_pos, "flag_stalemate", flag_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); \
269 if (team##_icon_prevstatus && f < 1) \
270 drawpic_aspect_skin_expanding(team##flag_pos, team##_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * team##_alpha_prevstatus, DRAWFLAG_NORMAL, f); \
272 drawpic_aspect_skin(team##flag_pos, team##_icon, flag_size, '1 1 1', panel_fg_alpha * team##_alpha * f, DRAWFLAG_NORMAL); \
282 // Keyhunt HUD modicon section
285 void HUD_Mod_KH(vector pos, vector mySize)
287 mod_active = 1; // keyhunt should never hide the mod icons panel
289 // Read current state
291 int state = STAT(KH_KEYS);
293 int all_keys, team1_keys, team2_keys, team3_keys, team4_keys, dropped_keys, carrying_keys;
294 all_keys = team1_keys = team2_keys = team3_keys = team4_keys = dropped_keys = carrying_keys = 0;
296 for(i = 0; i < 4; ++i)
298 key_state = (bitshift(state, i * -5) & 31) - 1;
311 case NUM_TEAM_1: ++team1_keys; break;
312 case NUM_TEAM_2: ++team2_keys; break;
313 case NUM_TEAM_3: ++team3_keys; break;
314 case NUM_TEAM_4: ++team4_keys; break;
315 case 29: ++dropped_keys; break;
321 // Calculate slot measurements
325 if(all_keys == 4 && mySize.x * 0.5 < mySize.y && mySize.y * 0.5 < mySize.x)
327 // Quadratic arrangement
328 slot_size = eX * mySize.x * 0.5 + eY * mySize.y * 0.5;
330 KH_SLOTS[1] = pos + eX * slot_size.x;
331 KH_SLOTS[2] = pos + eY * slot_size.y;
332 KH_SLOTS[3] = pos + eX * slot_size.x + eY * slot_size.y;
336 if(mySize.x > mySize.y)
338 // Horizontal arrangement
339 slot_size = eX * mySize.x / all_keys + eY * mySize.y;
340 for(i = 0; i < all_keys; ++i)
341 KH_SLOTS[i] = pos + eX * slot_size.x * i;
345 // Vertical arrangement
346 slot_size = eX * mySize.x + eY * mySize.y / all_keys;
347 for(i = 0; i < all_keys; ++i)
348 KH_SLOTS[i] = pos + eY * slot_size.y * i;
352 // Make icons blink in case of RUN HERE
354 float blink = 0.6 + sin(2*M_PI*time) / 2.5; // Oscillate between 0.2 and 1
361 case NUM_TEAM_1: if(team1_keys == all_keys) alpha = blink; break;
362 case NUM_TEAM_2: if(team2_keys == all_keys) alpha = blink; break;
363 case NUM_TEAM_3: if(team3_keys == all_keys) alpha = blink; break;
364 case NUM_TEAM_4: if(team4_keys == all_keys) alpha = blink; break;
372 if(myteam == NUM_TEAM_1 && carrying_keys)
374 drawpic_aspect_skin(KH_SLOTS[i++], "kh_red_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
378 drawpic_aspect_skin(KH_SLOTS[i++], "kh_red_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
381 if(myteam == NUM_TEAM_2 && carrying_keys)
383 drawpic_aspect_skin(KH_SLOTS[i++], "kh_blue_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
387 drawpic_aspect_skin(KH_SLOTS[i++], "kh_blue_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
390 if(myteam == NUM_TEAM_3 && carrying_keys)
392 drawpic_aspect_skin(KH_SLOTS[i++], "kh_yellow_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
396 drawpic_aspect_skin(KH_SLOTS[i++], "kh_yellow_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
399 if(myteam == NUM_TEAM_4 && carrying_keys)
401 drawpic_aspect_skin(KH_SLOTS[i++], "kh_pink_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
405 drawpic_aspect_skin(KH_SLOTS[i++], "kh_pink_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
407 while(dropped_keys--)
408 drawpic_aspect_skin(KH_SLOTS[i++], "kh_dropped", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
411 // Keepaway HUD mod icon
412 int kaball_prevstatus; // last remembered status
413 float kaball_statuschange_time; // time when the status changed
415 // we don't need to reset for keepaway since it immediately
416 // autocorrects prevstatus as to if the player has the ball or not
418 void HUD_Mod_Keepaway(vector pos, vector mySize)
420 mod_active = 1; // keepaway should always show the mod HUD
422 float BLINK_FACTOR = 0.15;
423 float BLINK_BASE = 0.85;
424 float BLINK_FREQ = 5;
425 float kaball_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
427 int stat_items = STAT(ITEMS);
428 int kaball = (stat_items/IT_KEY1) & 1;
430 if(kaball != kaball_prevstatus)
432 kaball_statuschange_time = time;
433 kaball_prevstatus = kaball;
436 vector kaball_pos, kaball_size;
438 if(mySize.x > mySize.y) {
439 kaball_pos = pos + eX * 0.25 * mySize.x;
440 kaball_size = eX * 0.5 * mySize.x + eY * mySize.y;
442 kaball_pos = pos + eY * 0.25 * mySize.y;
443 kaball_size = eY * 0.5 * mySize.y + eX * mySize.x;
446 float kaball_statuschange_elapsedtime = time - kaball_statuschange_time;
447 float f = bound(0, kaball_statuschange_elapsedtime*2, 1);
449 if(kaball_prevstatus && f < 1)
450 drawpic_aspect_skin_expanding(kaball_pos, "keepawayball_carrying", kaball_size, '1 1 1', panel_fg_alpha * kaball_alpha, DRAWFLAG_NORMAL, f);
453 drawpic_aspect_skin(pos, "keepawayball_carrying", eX * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL);
457 // Nexball HUD mod icon
458 void HUD_Mod_NexBall(vector pos, vector mySize)
460 float nb_pb_starttime, dt, p;
463 stat_items = STAT(ITEMS);
464 nb_pb_starttime = STAT(NB_METERSTART);
466 if (stat_items & IT_KEY1)
471 //Manage the progress bar if any
472 if (nb_pb_starttime > 0)
474 dt = (time - nb_pb_starttime) % nb_pb_period;
475 // one period of positive triangle
476 p = 2 * dt / nb_pb_period;
480 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);
483 if (stat_items & IT_KEY1)
484 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
487 // Race/CTS HUD mod icons
488 float crecordtime_prev; // last remembered crecordtime
489 float crecordtime_change_time; // time when crecordtime last changed
490 float srecordtime_prev; // last remembered srecordtime
491 float srecordtime_change_time; // time when srecordtime last changed
493 float race_status_time;
494 int race_status_prev;
495 string race_status_name_prev;
497 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
498 int race_CheckName(string net_name)
501 for (i=RANKINGS_CNT-1;i>=0;--i)
502 if(grecordholder[i] == net_name)
507 void race_showTime(string text, vector pos, vector timeText_ofs, float theTime, vector textSize, float f)
509 drawstring_aspect(pos, text, textSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
510 drawstring_aspect(pos + timeText_ofs, TIME_ENCODED_TOSTRING(theTime), textSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
512 drawstring_aspect_expanding(pos, text, textSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
513 drawstring_aspect_expanding(pos + timeText_ofs, TIME_ENCODED_TOSTRING(theTime), textSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
517 void HUD_Mod_Race(vector pos, vector mySize)
519 mod_active = 1; // race should never hide the mod icons panel
521 me = playerslots[player_localnum];
523 score = me.(scores[ps_primary]);
525 if(!(scores_flags[ps_primary] & SFL_TIME) || teamplay) // race/cts record display on HUD
526 return; // no records in the actual race
528 // clientside personal record
530 if(gametype == MAPINFO_TYPE_CTS)
534 float t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
536 if(score && (score < t || !t)) {
537 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
538 if(autocvar_cl_autodemo_delete_keeprecords)
540 float f = autocvar_cl_autodemo_delete;
542 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
546 if(t != crecordtime_prev) {
547 crecordtime_prev = t;
548 crecordtime_change_time = time;
551 vector textPos, medalPos;
553 if(mySize.x > mySize.y) {
555 squareSize = min(mySize.y, mySize.x/2);
556 textPos = pos + eX * 0.5 * max(0, mySize.x/2 - squareSize) + eY * 0.5 * (mySize.y - squareSize);
557 medalPos = pos + eX * 0.5 * max(0, mySize.x/2 - squareSize) + eX * 0.5 * mySize.x + eY * 0.5 * (mySize.y - squareSize);
560 squareSize = min(mySize.x, mySize.y/2);
561 textPos = pos + eY * 0.5 * max(0, mySize.y/2 - squareSize) + eX * 0.5 * (mySize.x - squareSize);
562 medalPos = pos + eY * 0.5 * max(0, mySize.y/2 - squareSize) + eY * 0.5 * mySize.y + eX * 0.5 * (mySize.x - squareSize);
564 vector textSize = eX * squareSize + eY * 0.25 * squareSize;
566 race_showTime(_("Personal best"), textPos, eY * 0.25 * squareSize, t, textSize, time - crecordtime_change_time);
569 t = race_server_record;
570 if(t != srecordtime_prev) {
571 srecordtime_prev = t;
572 srecordtime_change_time = time;
575 textPos += eY * 0.5 * squareSize;
576 race_showTime(_("Server best"), textPos, eY * 0.25 * squareSize, t, textSize, time - srecordtime_change_time);
578 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
579 race_status_time = time + 5;
580 race_status_prev = race_status;
581 if (race_status_name_prev)
582 strunzone(race_status_name_prev);
583 race_status_name_prev = strzone(race_status_name);
588 a = bound(0, race_status_time - time, 1);
591 s = textShortenToWidth(race_status_name, squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
595 rank = race_CheckName(race_status_name);
599 rankname = count_ordinal(rank);
602 namepos = medalPos + '0 0.8 0' * squareSize;
604 rankpos = medalPos + '0 0.15 0' * squareSize;
607 drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
608 else if(race_status == 1) {
609 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);
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);
612 } else if(race_status == 2) {
613 if(race_status_name == entcs_GetName(player_localnum) || !race_myrank || race_myrank < rank)
614 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);
616 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);
617 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
618 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
619 } else if(race_status == 3) {
620 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);
621 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
622 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
625 if (race_status_time - time <= 0) {
626 race_status_prev = -1;
629 strunzone(race_status_name);
630 race_status_name = string_null;
631 if(race_status_name_prev)
632 strunzone(race_status_name_prev);
633 race_status_name_prev = string_null;
637 void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, int layout, int i)
639 TC(int, layout); TC(int, i);
642 vector color = '0 0 0';
646 stat = STAT(DOM_PPS_RED);
647 pic = "dom_icon_red";
651 stat = STAT(DOM_PPS_BLUE);
652 pic = "dom_icon_blue";
656 stat = STAT(DOM_PPS_YELLOW);
657 pic = "dom_icon_yellow";
662 stat = STAT(DOM_PPS_PINK);
663 pic = "dom_icon_pink";
667 float pps_ratio = stat / STAT(DOM_TOTAL_PPS);
669 if(mySize.x/mySize.y > aspect_ratio)
671 i = aspect_ratio * mySize.y;
672 myPos.x = myPos.x + (mySize.x - i) / 2;
677 i = 1/aspect_ratio * mySize.x;
678 myPos.y = myPos.y + (mySize.y - i) / 2;
682 if (layout) // show text too
685 color *= 0.5 + pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max
686 if (layout == 2) // average pps
687 drawstring_aspect(myPos + eX * mySize.y, ftos_decimals(stat, 2), eX * (2/3) * mySize.x + eY * mySize.y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
688 else // percentage of average pps
689 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);
693 drawpic_aspect_skin(myPos, pic, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
696 drawsetcliparea(myPos.x, myPos.y + mySize.y * (1 - pps_ratio), mySize.y, mySize.y * pps_ratio);
697 drawpic_aspect_skin(myPos, strcat(pic, "-highlighted"), '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
702 void HUD_Mod_Dom(vector myPos, vector mySize)
704 mod_active = 1; // required in each mod function that always shows something
706 int layout = autocvar_hud_panel_modicons_dom_layout;
709 aspect_ratio = (layout) ? 3 : 1;
710 rows = HUD_GetRowCount(team_count, mySize, aspect_ratio);
711 columns = ceil(team_count/rows);
714 float row = 0, column = 0;
715 vector pos, itemSize;
716 itemSize = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
717 for(i=0; i<team_count; ++i)
719 pos = myPos + eX * column * itemSize.x + eY * row * itemSize.y;
721 DrawDomItem(pos, itemSize, aspect_ratio, layout, i);
732 void HUD_ModIcons_SetFunc()
736 case MAPINFO_TYPE_KEYHUNT: HUD_ModIcons_GameType = HUD_Mod_KH; break;
737 case MAPINFO_TYPE_CTF: HUD_ModIcons_GameType = HUD_Mod_CTF; break;
738 case MAPINFO_TYPE_NEXBALL: HUD_ModIcons_GameType = HUD_Mod_NexBall; break;
739 case MAPINFO_TYPE_CTS:
740 case MAPINFO_TYPE_RACE: HUD_ModIcons_GameType = HUD_Mod_Race; break;
741 case MAPINFO_TYPE_CA:
742 case MAPINFO_TYPE_FREEZETAG: HUD_ModIcons_GameType = HUD_Mod_CA; break;
743 case MAPINFO_TYPE_DOMINATION: HUD_ModIcons_GameType = HUD_Mod_Dom; break;
744 case MAPINFO_TYPE_KEEPAWAY: HUD_ModIcons_GameType = HUD_Mod_Keepaway; break;
748 int mod_prev; // previous state of mod_active to check for a change
750 float mod_change; // "time" when mod_active changed
754 if(!autocvar__hud_configure)
756 if(!autocvar_hud_panel_modicons) return;
757 if(!HUD_ModIcons_GameType) return;
760 HUD_Panel_UpdateCvars();
762 draw_beginBoldFont();
764 if(mod_active != mod_prev) {
766 mod_prev = mod_active;
769 if(mod_active || autocvar__hud_configure)
770 mod_alpha = bound(0, (time - mod_change) * 2, 1);
772 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
774 if (autocvar_hud_panel_modicons_dynamichud)
779 HUD_Panel_DrawBg(mod_alpha);
783 panel_pos += '1 1 0' * panel_bg_padding;
784 panel_size -= '2 2 0' * panel_bg_padding;
787 if(autocvar__hud_configure)
788 HUD_Mod_CTF(panel_pos, panel_size);
790 HUD_ModIcons_GameType(panel_pos, panel_size);