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 bool ctf_stalemate; // currently in stalemate
121 int stat_items = STAT(CTF_FLAGSTATUS);
122 float fs, fs2, fs3, size1, size2;
125 redflag = (stat_items/CTF_RED_FLAG_TAKEN) & 3;
126 blueflag = (stat_items/CTF_BLUE_FLAG_TAKEN) & 3;
127 yellowflag = (stat_items/CTF_YELLOW_FLAG_TAKEN) & 3;
128 pinkflag = (stat_items/CTF_PINK_FLAG_TAKEN) & 3;
129 neutralflag = (stat_items/CTF_NEUTRAL_FLAG_TAKEN) & 3;
131 ctf_oneflag = (stat_items & CTF_FLAG_NEUTRAL);
133 ctf_stalemate = (stat_items & CTF_STALEMATE);
135 mod_active = (redflag || blueflag || yellowflag || pinkflag || neutralflag || (stat_items & CTF_SHIELDED));
137 if (autocvar__hud_configure) {
144 ctf_oneflag = neutralflag = 0; // disable neutral flag in hud editor?
147 // when status CHANGES, set old status into prevstatus and current status into status
148 #define X(team) MACRO_BEGIN { \
149 if (team##flag != team##flag_prevframe) { \
150 team##flag_statuschange_time = time; \
151 team##flag_prevstatus = team##flag_prevframe; \
152 team##flag_prevframe = team##flag; \
154 team##flag_statuschange_elapsedtime = time - team##flag_statuschange_time; \
163 const float BLINK_FACTOR = 0.15;
164 const float BLINK_BASE = 0.85;
166 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
168 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
170 const float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
172 #define X(team, cond) \
173 string team##_icon = string_null, team##_icon_prevstatus = string_null; \
174 int team##_alpha, team##_alpha_prevstatus; \
175 team##_alpha = team##_alpha_prevstatus = 1; \
177 switch (team##flag) { \
178 case 1: team##_icon = "flag_" #team "_taken"; break; \
179 case 2: team##_icon = "flag_" #team "_lost"; break; \
180 case 3: team##_icon = "flag_" #team "_carrying"; team##_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break; \
182 if ((stat_items & CTF_SHIELDED) && (cond)) { \
183 team##_icon = "flag_" #team "_shielded"; \
185 team##_icon = string_null; \
189 switch (team##flag_prevstatus) { \
190 case 1: team##_icon_prevstatus = "flag_" #team "_taken"; break; \
191 case 2: team##_icon_prevstatus = "flag_" #team "_lost"; break; \
192 case 3: team##_icon_prevstatus = "flag_" #team "_carrying"; team##_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break; \
194 if (team##flag == 3) { \
195 team##_icon_prevstatus = "flag_" #team "_carrying"; /* make it more visible */\
196 } else if((stat_items & CTF_SHIELDED) && (cond)) { \
197 team##_icon_prevstatus = "flag_" #team "_shielded"; \
199 team##_icon_prevstatus = string_null; \
204 X(red, myteam != NUM_TEAM_1);
205 X(blue, myteam != NUM_TEAM_2);
206 X(yellow, myteam != NUM_TEAM_3 && team_count >= 3);
207 X(pink, myteam != NUM_TEAM_4 && team_count >= 4);
208 X(neutral, ctf_oneflag);
212 // hacky, but these aren't needed
213 red_icon = red_icon_prevstatus = blue_icon = blue_icon_prevstatus = yellow_icon = yellow_icon_prevstatus = pink_icon = pink_icon_prevstatus = string_null;
215 } else switch (team_count) {
217 case 2: fs = 0.5; fs2 = 0.5; fs3 = 0.5; break;
218 case 3: fs = 1; fs2 = 0.35; fs3 = 0.35; break;
219 case 4: fs = 0.75; fs2 = 0.25; fs3 = 0.5; break;
222 if (mySize_x > mySize_y) {
238 blueflag_pos = pos + eX * fs2 * size1;
239 yellowflag_pos = pos - eX * fs2 * size1;
240 pinkflag_pos = pos + eX * fs3 * size1;
244 redflag_pos = pos + eX * fs2 * size1;
246 yellowflag_pos = pos - eX * fs2 * size1;
247 pinkflag_pos = pos + eX * fs3 * size1;
251 redflag_pos = pos + eX * fs3 * size1;
252 blueflag_pos = pos - eX * fs2 * size1;
253 yellowflag_pos = pos;
254 pinkflag_pos = pos + eX * fs2 * size1;
258 redflag_pos = pos - eX * fs2 * size1;
259 blueflag_pos = pos + eX * fs3 * size1;
260 yellowflag_pos = pos + eX * fs2 * size1;
265 neutralflag_pos = pos;
266 flag_size = e1 * fs * size1 + e2 * size2;
268 #define X(team) MACRO_BEGIN { \
269 f = bound(0, team##flag_statuschange_elapsedtime * 2, 1); \
270 if (team##_icon_prevstatus && f < 1) \
271 drawpic_aspect_skin_expanding(team##flag_pos, team##_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * team##_alpha_prevstatus, DRAWFLAG_NORMAL, f); \
273 drawpic_aspect_skin(team##flag_pos, team##_icon, flag_size, '1 1 1', panel_fg_alpha * team##_alpha * f, DRAWFLAG_NORMAL); \
283 // Keyhunt HUD modicon section
286 void HUD_Mod_KH(vector pos, vector mySize)
288 mod_active = 1; // keyhunt should never hide the mod icons panel
290 // Read current state
292 int state = STAT(KH_KEYS);
294 int all_keys, team1_keys, team2_keys, team3_keys, team4_keys, dropped_keys, carrying_keys;
295 all_keys = team1_keys = team2_keys = team3_keys = team4_keys = dropped_keys = carrying_keys = 0;
297 for(i = 0; i < 4; ++i)
299 key_state = (bitshift(state, i * -5) & 31) - 1;
312 case NUM_TEAM_1: ++team1_keys; break;
313 case NUM_TEAM_2: ++team2_keys; break;
314 case NUM_TEAM_3: ++team3_keys; break;
315 case NUM_TEAM_4: ++team4_keys; break;
316 case 29: ++dropped_keys; break;
322 // Calculate slot measurements
326 if(all_keys == 4 && mySize.x * 0.5 < mySize.y && mySize.y * 0.5 < mySize.x)
328 // Quadratic arrangement
329 slot_size = eX * mySize.x * 0.5 + eY * mySize.y * 0.5;
331 KH_SLOTS[1] = pos + eX * slot_size.x;
332 KH_SLOTS[2] = pos + eY * slot_size.y;
333 KH_SLOTS[3] = pos + eX * slot_size.x + eY * slot_size.y;
337 if(mySize.x > mySize.y)
339 // Horizontal arrangement
340 slot_size = eX * mySize.x / all_keys + eY * mySize.y;
341 for(i = 0; i < all_keys; ++i)
342 KH_SLOTS[i] = pos + eX * slot_size.x * i;
346 // Vertical arrangement
347 slot_size = eX * mySize.x + eY * mySize.y / all_keys;
348 for(i = 0; i < all_keys; ++i)
349 KH_SLOTS[i] = pos + eY * slot_size.y * i;
353 // Make icons blink in case of RUN HERE
355 float blink = 0.6 + sin(2*M_PI*time) / 2.5; // Oscillate between 0.2 and 1
362 case NUM_TEAM_1: if(team1_keys == all_keys) alpha = blink; break;
363 case NUM_TEAM_2: if(team2_keys == all_keys) alpha = blink; break;
364 case NUM_TEAM_3: if(team3_keys == all_keys) alpha = blink; break;
365 case NUM_TEAM_4: if(team4_keys == all_keys) alpha = blink; break;
373 if(myteam == NUM_TEAM_1 && carrying_keys)
375 drawpic_aspect_skin(KH_SLOTS[i++], "kh_red_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
379 drawpic_aspect_skin(KH_SLOTS[i++], "kh_red_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
382 if(myteam == NUM_TEAM_2 && carrying_keys)
384 drawpic_aspect_skin(KH_SLOTS[i++], "kh_blue_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
388 drawpic_aspect_skin(KH_SLOTS[i++], "kh_blue_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
391 if(myteam == NUM_TEAM_3 && carrying_keys)
393 drawpic_aspect_skin(KH_SLOTS[i++], "kh_yellow_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
397 drawpic_aspect_skin(KH_SLOTS[i++], "kh_yellow_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
400 if(myteam == NUM_TEAM_4 && carrying_keys)
402 drawpic_aspect_skin(KH_SLOTS[i++], "kh_pink_carrying", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
406 drawpic_aspect_skin(KH_SLOTS[i++], "kh_pink_taken", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
408 while(dropped_keys--)
409 drawpic_aspect_skin(KH_SLOTS[i++], "kh_dropped", slot_size, '1 1 1', alpha, DRAWFLAG_NORMAL);
412 // Keepaway HUD mod icon
413 int kaball_prevstatus; // last remembered status
414 float kaball_statuschange_time; // time when the status changed
416 // we don't need to reset for keepaway since it immediately
417 // autocorrects prevstatus as to if the player has the ball or not
419 void HUD_Mod_Keepaway(vector pos, vector mySize)
421 mod_active = 1; // keepaway should always show the mod HUD
423 float BLINK_FACTOR = 0.15;
424 float BLINK_BASE = 0.85;
425 float BLINK_FREQ = 5;
426 float kaball_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
428 int stat_items = STAT(ITEMS);
429 int kaball = (stat_items/IT_KEY1) & 1;
431 if(kaball != kaball_prevstatus)
433 kaball_statuschange_time = time;
434 kaball_prevstatus = kaball;
437 vector kaball_pos, kaball_size;
439 if(mySize.x > mySize.y) {
440 kaball_pos = pos + eX * 0.25 * mySize.x;
441 kaball_size = eX * 0.5 * mySize.x + eY * mySize.y;
443 kaball_pos = pos + eY * 0.25 * mySize.y;
444 kaball_size = eY * 0.5 * mySize.y + eX * mySize.x;
447 float kaball_statuschange_elapsedtime = time - kaball_statuschange_time;
448 float f = bound(0, kaball_statuschange_elapsedtime*2, 1);
450 if(kaball_prevstatus && f < 1)
451 drawpic_aspect_skin_expanding(kaball_pos, "keepawayball_carrying", kaball_size, '1 1 1', panel_fg_alpha * kaball_alpha, DRAWFLAG_NORMAL, f);
454 drawpic_aspect_skin(pos, "keepawayball_carrying", eX * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL);
458 // Nexball HUD mod icon
459 void HUD_Mod_NexBall(vector pos, vector mySize)
461 float nb_pb_starttime, dt, p;
464 stat_items = STAT(ITEMS);
465 nb_pb_starttime = STAT(NB_METERSTART);
467 if (stat_items & IT_KEY1)
472 //Manage the progress bar if any
473 if (nb_pb_starttime > 0)
475 dt = (time - nb_pb_starttime) % nb_pb_period;
476 // one period of positive triangle
477 p = 2 * dt / nb_pb_period;
481 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);
484 if (stat_items & IT_KEY1)
485 drawpic_aspect_skin(pos, "nexball_carrying", eX * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
488 // Race/CTS HUD mod icons
489 float crecordtime_prev; // last remembered crecordtime
490 float crecordtime_change_time; // time when crecordtime last changed
491 float srecordtime_prev; // last remembered srecordtime
492 float srecordtime_change_time; // time when srecordtime last changed
494 float race_status_time;
495 int race_status_prev;
496 string race_status_name_prev;
498 // Check if the given name already exist in race rankings? In that case, where? (otherwise return 0)
499 int race_CheckName(string net_name)
502 for (i=RANKINGS_CNT-1;i>=0;--i)
503 if(grecordholder[i] == net_name)
508 void race_showTime(string text, vector pos, vector timeText_ofs, float theTime, vector textSize, float f)
510 drawstring_aspect(pos, text, textSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
511 drawstring_aspect(pos + timeText_ofs, TIME_ENCODED_TOSTRING(theTime), textSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
513 drawstring_aspect_expanding(pos, text, textSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
514 drawstring_aspect_expanding(pos + timeText_ofs, TIME_ENCODED_TOSTRING(theTime), textSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
518 void HUD_Mod_Race(vector pos, vector mySize)
520 mod_active = 1; // race should never hide the mod icons panel
522 me = playerslots[player_localnum];
524 score = me.(scores[ps_primary]);
526 if(!(scores_flags[ps_primary] & SFL_TIME) || teamplay) // race/cts record display on HUD
527 return; // no records in the actual race
529 // clientside personal record
531 if(gametype == MAPINFO_TYPE_CTS)
535 float t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
537 if(score && (score < t || !t)) {
538 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
539 if(autocvar_cl_autodemo_delete_keeprecords)
541 float f = autocvar_cl_autodemo_delete;
543 cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
547 if(t != crecordtime_prev) {
548 crecordtime_prev = t;
549 crecordtime_change_time = time;
552 vector textPos, medalPos;
554 if(mySize.x > mySize.y) {
556 squareSize = min(mySize.y, mySize.x/2);
557 textPos = pos + eX * 0.5 * max(0, mySize.x/2 - squareSize) + eY * 0.5 * (mySize.y - squareSize);
558 medalPos = pos + eX * 0.5 * max(0, mySize.x/2 - squareSize) + eX * 0.5 * mySize.x + eY * 0.5 * (mySize.y - squareSize);
561 squareSize = min(mySize.x, mySize.y/2);
562 textPos = pos + eY * 0.5 * max(0, mySize.y/2 - squareSize) + eX * 0.5 * (mySize.x - squareSize);
563 medalPos = pos + eY * 0.5 * max(0, mySize.y/2 - squareSize) + eY * 0.5 * mySize.y + eX * 0.5 * (mySize.x - squareSize);
565 vector textSize = eX * squareSize + eY * 0.25 * squareSize;
567 race_showTime(_("Personal best"), textPos, eY * 0.25 * squareSize, t, textSize, time - crecordtime_change_time);
570 t = race_server_record;
571 if(t != srecordtime_prev) {
572 srecordtime_prev = t;
573 srecordtime_change_time = time;
576 textPos += eY * 0.5 * squareSize;
577 race_showTime(_("Server best"), textPos, eY * 0.25 * squareSize, t, textSize, time - srecordtime_change_time);
579 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
580 race_status_time = time + 5;
581 race_status_prev = race_status;
582 if (race_status_name_prev)
583 strunzone(race_status_name_prev);
584 race_status_name_prev = strzone(race_status_name);
589 a = bound(0, race_status_time - time, 1);
592 s = textShortenToWidth(race_status_name, squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
596 rank = race_CheckName(race_status_name);
600 rankname = count_ordinal(rank);
603 namepos = medalPos + '0 0.8 0' * squareSize;
605 rankpos = medalPos + '0 0.15 0' * squareSize;
608 drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
609 else if(race_status == 1) {
610 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);
611 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
612 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
613 } else if(race_status == 2) {
614 if(race_status_name == entcs_GetName(player_localnum) || !race_myrank || race_myrank < rank)
615 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);
617 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);
618 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
619 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
620 } else if(race_status == 3) {
621 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);
622 drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
623 drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
626 if (race_status_time - time <= 0) {
627 race_status_prev = -1;
630 strunzone(race_status_name);
631 race_status_name = string_null;
632 if(race_status_name_prev)
633 strunzone(race_status_name_prev);
634 race_status_name_prev = string_null;
638 void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, int layout, int i)
640 TC(int, layout); TC(int, i);
643 vector color = '0 0 0';
647 stat = STAT(DOM_PPS_RED);
648 pic = "dom_icon_red";
652 stat = STAT(DOM_PPS_BLUE);
653 pic = "dom_icon_blue";
657 stat = STAT(DOM_PPS_YELLOW);
658 pic = "dom_icon_yellow";
663 stat = STAT(DOM_PPS_PINK);
664 pic = "dom_icon_pink";
668 float pps_ratio = stat / STAT(DOM_TOTAL_PPS);
670 if(mySize.x/mySize.y > aspect_ratio)
672 i = aspect_ratio * mySize.y;
673 myPos.x = myPos.x + (mySize.x - i) / 2;
678 i = 1/aspect_ratio * mySize.x;
679 myPos.y = myPos.y + (mySize.y - i) / 2;
683 if (layout) // show text too
686 color *= 0.5 + pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max
687 if (layout == 2) // average pps
688 drawstring_aspect(myPos + eX * mySize.y, ftos_decimals(stat, 2), eX * (2/3) * mySize.x + eY * mySize.y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
689 else // percentage of average pps
690 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);
694 drawpic_aspect_skin(myPos, pic, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
697 drawsetcliparea(myPos.x, myPos.y + mySize.y * (1 - pps_ratio), mySize.y, mySize.y * pps_ratio);
698 drawpic_aspect_skin(myPos, strcat(pic, "-highlighted"), '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
703 void HUD_Mod_Dom(vector myPos, vector mySize)
705 mod_active = 1; // required in each mod function that always shows something
707 int layout = autocvar_hud_panel_modicons_dom_layout;
710 aspect_ratio = (layout) ? 3 : 1;
711 rows = HUD_GetRowCount(team_count, mySize, aspect_ratio);
712 columns = ceil(team_count/rows);
715 float row = 0, column = 0;
716 vector pos, itemSize;
717 itemSize = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
718 for(i=0; i<team_count; ++i)
720 pos = myPos + eX * column * itemSize.x + eY * row * itemSize.y;
722 DrawDomItem(pos, itemSize, aspect_ratio, layout, i);
733 void HUD_ModIcons_SetFunc()
737 case MAPINFO_TYPE_KEYHUNT: HUD_ModIcons_GameType = HUD_Mod_KH; break;
738 case MAPINFO_TYPE_CTF: HUD_ModIcons_GameType = HUD_Mod_CTF; break;
739 case MAPINFO_TYPE_NEXBALL: HUD_ModIcons_GameType = HUD_Mod_NexBall; break;
740 case MAPINFO_TYPE_CTS:
741 case MAPINFO_TYPE_RACE: HUD_ModIcons_GameType = HUD_Mod_Race; break;
742 case MAPINFO_TYPE_CA:
743 case MAPINFO_TYPE_FREEZETAG: HUD_ModIcons_GameType = HUD_Mod_CA; break;
744 case MAPINFO_TYPE_DOMINATION: HUD_ModIcons_GameType = HUD_Mod_Dom; break;
745 case MAPINFO_TYPE_KEEPAWAY: HUD_ModIcons_GameType = HUD_Mod_Keepaway; break;
749 int mod_prev; // previous state of mod_active to check for a change
751 float mod_change; // "time" when mod_active changed
755 if(!autocvar__hud_configure)
757 if(!autocvar_hud_panel_modicons) return;
758 if(!HUD_ModIcons_GameType) return;
761 HUD_Panel_UpdateCvars();
763 draw_beginBoldFont();
765 if(mod_active != mod_prev) {
767 mod_prev = mod_active;
770 if(mod_active || autocvar__hud_configure)
771 mod_alpha = bound(0, (time - mod_change) * 2, 1);
773 mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
775 if (autocvar_hud_panel_modicons_dynamichud)
780 HUD_Panel_DrawBg(mod_alpha);
784 panel_pos += '1 1 0' * panel_bg_padding;
785 panel_size -= '2 2 0' * panel_bg_padding;
788 if(autocvar__hud_configure)
789 HUD_Mod_CTF(panel_pos, panel_size);
791 HUD_ModIcons_GameType(panel_pos, panel_size);