]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/hud/panel/timer.qc
Don't reset bindmap on connection, no longer needed since the map vote selection...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud / panel / timer.qc
1 #include "timer.qh"
2
3 #include <client/draw.qh>
4 #include <client/view.qh>
5
6 // Timer (#5)
7
8 void HUD_Timer_Export(int fh)
9 {
10         // allow saving cvars that aesthetically change the panel into hud skin files
11 }
12
13 void HUD_Timer()
14 {
15         if(!autocvar__hud_configure)
16         {
17                 if(!autocvar_hud_panel_timer) return;
18         }
19
20         HUD_Panel_LoadCvars();
21
22         draw_beginBoldFont();
23
24         vector pos, mySize;
25         pos = panel_pos;
26         mySize = panel_size;
27
28         if (autocvar_hud_panel_timer_dynamichud)
29                 HUD_Scale_Enable();
30         else
31                 HUD_Scale_Disable();
32         HUD_Panel_DrawBg();
33         if(panel_bg_padding)
34         {
35                 pos += '1 1 0' * panel_bg_padding;
36                 mySize -= '2 2 0' * panel_bg_padding;
37         }
38
39         string timer;
40         float timelimit, timeleft, minutesLeft;
41
42         timelimit = STAT(TIMELIMIT);
43
44         if (autocvar_hud_panel_timer_unbound){
45                 timeleft = max(0, timelimit * 60 + STAT(GAMESTARTTIME) - time);
46         } else {
47                 timeleft = bound(0, timelimit * 60 + STAT(GAMESTARTTIME) - time, timelimit * 60);
48         }
49         timeleft = ceil(timeleft);
50
51         minutesLeft = floor(timeleft / 60);
52
53         float warmup_timeleft = 0;
54         if(warmup_stage)
55         {
56                 float warmup_timelimit = STAT(WARMUP_TIMELIMIT);
57                 if(warmup_timelimit > 0)
58                         warmup_timeleft = max(0, warmup_timelimit - time + STAT(GAMESTARTTIME));
59                 else if(warmup_timelimit == 0)
60                         warmup_timeleft = timeleft;
61                 warmup_timeleft = ceil(warmup_timeleft);
62         }
63
64         vector timer_color;
65         if(intermission_time || minutesLeft >= 5 || warmup_stage || timelimit == 0)
66                 timer_color = '1 1 1'; //white
67         else if(minutesLeft >= 1)
68                 timer_color = '1 1 0'; //yellow
69         else
70                 timer_color = '1 0 0'; //red
71
72         if (intermission_time) {
73                 timer = seconds_tostring(max(0, floor(intermission_time - STAT(GAMESTARTTIME))));
74         } else if (warmup_stage && warmup_timeleft >= 60) {
75                 timer = _("WARMUP");
76         } else if (autocvar_hud_panel_timer_increment || (!warmup_stage && timelimit == 0) || (warmup_stage && warmup_timeleft <= 0)) {
77                 if (time < STAT(GAMESTARTTIME))
78                         if (autocvar_hud_panel_timer_unbound){
79                                 timer = seconds_tostring(-(STAT(GAMESTARTTIME) - time));
80                         } else {
81                                 timer = seconds_tostring(0); //while restart is still active, show 00:00
82                         }
83                 else
84                         timer = seconds_tostring(floor(time - STAT(GAMESTARTTIME)));
85         } else {
86                 if(warmup_stage)
87                         timer = seconds_tostring(warmup_timeleft);
88                 else
89                         timer = seconds_tostring(timeleft);
90         }
91
92         drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
93
94         draw_endBoldFont();
95 }