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
13 vector HUD_Timer_Color(float timeleft)
16 return '1 1 1'; //white
17 else if(timeleft >= 60)
18 return '1 1 0'; //yellow
25 if(!autocvar__hud_configure)
27 if(!autocvar_hud_panel_timer) return;
30 HUD_Panel_LoadCvars();
38 if (autocvar_hud_panel_timer_dynamichud)
44 pos += '1 1 0' * panel_bg_padding;
45 mySize -= '2 2 0' * panel_bg_padding;
49 string subtimer = string_null;
50 string subtext = string_null;
51 float timelimit, timeleft, overtimes;
52 float round_timelimit, round_timeleft;
53 vector timer_size, subtext_size, subtimer_size;
54 vector timer_color = '1 1 1';
55 vector subtimer_color = '1 1 1';
57 // Calculate timelimit
60 timelimit = STAT(WARMUP_TIMELIMIT);
62 timelimit = STAT(TIMELIMIT) * 60;
66 timelimit = STAT(TIMELIMIT) * 60;
69 // Calculate time left
70 timeleft = timelimit + STAT(GAMESTARTTIME) - time;
71 if (!autocvar_hud_panel_timer_unbound)
72 timeleft = bound(0, timeleft, timelimit);
73 timeleft = ceil(timeleft);
76 if(!intermission_time && !warmup_stage && timelimit > 0)
77 timer_color = HUD_Timer_Color(timeleft);
80 if (intermission_time) {
81 timer = seconds_tostring(max(0, floor(intermission_time - STAT(GAMESTARTTIME))));
82 } else if (autocvar_hud_panel_timer_increment || timelimit <= 0) {
83 float time_elapsed = floor(time - STAT(GAMESTARTTIME));
84 if (!autocvar_hud_panel_timer_unbound)
85 time_elapsed = max(0, time_elapsed);
87 timer = seconds_tostring(time_elapsed);
89 timer = seconds_tostring(timeleft);
92 // Round-based game modes
93 if(STAT(ROUNDSTARTTIME))
95 round_timelimit = STAT(ROUND_TIMELIMIT);
97 // Calculate round time left
98 round_timeleft = round_timelimit + STAT(ROUNDSTARTTIME) - time;
99 if (!autocvar_hud_panel_timer_unbound)
100 round_timeleft = bound(0, round_timeleft, round_timelimit);
101 round_timeleft = ceil(round_timeleft);
104 if(!intermission_time && round_timelimit > 0)
105 subtimer_color = HUD_Timer_Color(round_timeleft);
108 if (intermission_time) {
109 subtimer = seconds_tostring(max(0, floor(intermission_time - STAT(ROUNDSTARTTIME))));
110 } else if (autocvar_hud_panel_timer_increment || round_timelimit <= 0) {
111 float round_time_elapsed = floor(time - STAT(ROUNDSTARTTIME));
112 if (!autocvar_hud_panel_timer_unbound)
113 round_time_elapsed = max(0, round_time_elapsed);
115 subtimer = seconds_tostring(round_time_elapsed);
117 subtimer = seconds_tostring(round_timeleft);
122 overtimes = STAT(OVERTIMESADDED);
124 if(warmup_stage || autocvar__hud_configure)
125 subtext = _("Warmup");
126 else if(intermission_time)
127 subtext = _("Intermission");
128 else if(STAT(TIMEOUT_STATUS))
129 subtext = _("Timeout");
130 else if (overtimes >= 2)
131 subtext = sprintf(_("Overtime #%d"), overtimes);
133 subtext = _("Overtime");
135 subtext_size = vec2(mySize.x, mySize.y / 3);
136 timer_size = vec2(mySize.x, mySize.y - subtext_size.y);
137 subtimer_size = vec2(mySize.x / 3, mySize.y - subtext_size.y);
139 panel_size.y -= subtext_size.y;
143 timer_size.x -= subtimer_size.x;
144 drawstring_aspect(pos + eX * timer_size.x, subtimer, subtimer_size, subtimer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
147 drawstring_aspect(pos, timer, timer_size, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
150 drawstring_aspect(pos + eY * timer_size.y, subtext, subtext_size, '1 0 0', panel_fg_alpha, DRAWFLAG_NORMAL);