3 #include <client/draw.qh>
4 #include <client/view.qh>
8 void HUD_Timer_Export(int fh)
10 // allow saving cvars that aesthetically change the panel into hud skin files
15 if(!autocvar__hud_configure)
17 if(!autocvar_hud_panel_timer) return;
20 HUD_Panel_LoadCvars();
28 if (autocvar_hud_panel_timer_dynamichud)
34 pos += '1 1 0' * panel_bg_padding;
35 mySize -= '2 2 0' * panel_bg_padding;
38 string timer, subtimer, subtext;
39 float timelimit, timeleft, minutesLeft, overtimes;
40 float round_timelimit, round_timeleft;
42 // Calculate timelimit
45 timelimit = STAT(WARMUP_TIMELIMIT);
47 timelimit = STAT(TIMELIMIT) * 60;
48 else if(timelimit == -1)
53 timelimit = STAT(TIMELIMIT) * 60;
56 // Calculate time left
57 timeleft = bound(0, timelimit + STAT(GAMESTARTTIME) - time, timelimit);
58 timeleft = ceil(timeleft);
60 minutesLeft = floor(timeleft / 60);
64 if(intermission_time || minutesLeft >= 5 || warmup_stage || timelimit == 0)
65 timer_color = '1 1 1'; //white
66 else if(minutesLeft >= 1)
67 timer_color = '1 1 0'; //yellow
69 timer_color = '1 0 0'; //red
72 if (intermission_time) {
73 timer = seconds_tostring(max(0, floor(intermission_time - STAT(GAMESTARTTIME))));
74 } else if (autocvar_hud_panel_timer_increment || timelimit == 0) {
75 float time_elapsed = floor(time - STAT(GAMESTARTTIME));
76 timer = seconds_tostring(max(0, time_elapsed));
78 timer = seconds_tostring(timeleft);
82 if(STAT(ROUNDSTARTTIME))
84 round_timelimit = STAT(ROUND_TIMELIMIT);
86 if (autocvar_hud_panel_timer_increment || round_timelimit <= 0) {
87 float round_time_elapsed = floor(time - STAT(ROUNDSTARTTIME));
88 subtimer = seconds_tostring(max(0, round_time_elapsed));
90 round_timeleft = bound(0, round_timelimit + STAT(ROUNDSTARTTIME) - time, round_timelimit);
91 round_timeleft = ceil(round_timeleft);
93 subtimer = seconds_tostring(round_timeleft);
97 subtimer = string_null;
100 overtimes = STAT(OVERTIMESADDED);
104 else if(overtimes == 1)
105 subtext = "Overtime";
106 else if (overtimes > 1)
107 subtext = sprintf("Overtime #%d", overtimes);
109 subtext = string_null;
111 vector timer_size, subtext_size, subtimer_size;
113 subtext_size = vec2(mySize.x, mySize.y / 3);
114 timer_size = vec2(mySize.x, mySize.y - subtext_size.y);
115 subtimer_size = vec2(mySize.x / 3, mySize.y - subtext_size.y);
117 panel_size.y -= subtext_size.y;
121 timer_size.x -= subtimer_size.x;
122 drawstring_aspect(pos + eX * timer_size.x, subtimer, subtimer_size, '1 1 0', panel_fg_alpha, DRAWFLAG_NORMAL);
125 drawstring_aspect(pos, timer, timer_size, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
128 drawstring_aspect(pos + eY * timer_size.y, subtext, subtext_size, '1 0 0', panel_fg_alpha, DRAWFLAG_NORMAL);