Remove pointless checks for intermission in the infomessages panel, this panel is...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud / panel / infomessages.qc
1 // Info messages panel (#14)
2
3 #define drawInfoMessage(s) MACRO_BEGIN {                                                                                                                                                        \
4         if(autocvar_hud_panel_infomessages_flip)                                                                                                                                                \
5                 o.x = pos.x + mySize.x - stringwidth(s, true, fontsize);                                                                                                        \
6         drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);                                                                                                               \
7         o.y += fontsize.y;                                                                                                                                                                                              \
8 } MACRO_END
9 void HUD_InfoMessages()
10 {
11         if(!autocvar__hud_configure)
12         {
13                 if(!autocvar_hud_panel_infomessages) return;
14         }
15
16         HUD_Panel_UpdateCvars();
17         vector pos, mySize;
18         pos = panel_pos;
19         mySize = panel_size;
20
21         HUD_Panel_DrawBg(1);
22         if(panel_bg_padding)
23         {
24                 pos += '1 1 0' * panel_bg_padding;
25                 mySize -= '2 2 0' * panel_bg_padding;
26         }
27
28         // always force 5:1 aspect
29         vector newSize = '0 0 0';
30         if(mySize.x/mySize.y > 5)
31         {
32                 newSize.x = 5 * mySize.y;
33                 newSize.y = mySize.y;
34
35                 pos.x = pos.x + (mySize.x - newSize.x) / 2;
36         }
37         else
38         {
39                 newSize.y = 1/5 * mySize.x;
40                 newSize.x = mySize.x;
41
42                 pos.y = pos.y + (mySize.y - newSize.y) / 2;
43         }
44
45         mySize = newSize;
46         entity tm;
47         vector o;
48         o = pos;
49
50         vector fontsize;
51         fontsize = '0.20 0.20 0' * mySize.y;
52
53         float a;
54         a = panel_fg_alpha;
55
56         string s;
57         if(!autocvar__hud_configure)
58         {
59                 if(spectatee_status)
60                 {
61                         a = 1;
62                         if(spectatee_status == -1)
63                                 s = _("^1Observing");
64                         else
65                                 s = sprintf(_("^1Spectating: ^7%s"), entcs_GetName(current_player));
66                         drawInfoMessage(s);
67
68                         if(spectatee_status == -1)
69                                 s = sprintf(_("^1Press ^3%s^1 to spectate"), getcommandkey("primary fire", "+fire"));
70                         else
71                                 s = sprintf(_("^1Press ^3%s^1 or ^3%s^1 for next or previous player"), getcommandkey("next weapon", "weapnext"), getcommandkey("previous weapon", "weapprev"));
72                         drawInfoMessage(s);
73
74                         if(spectatee_status == -1)
75                                 s = sprintf(_("^1Use ^3%s^1 or ^3%s^1 to change the speed"), getcommandkey("next weapon", "weapnext"), getcommandkey("previous weapon", "weapprev"));
76                         else
77                                 s = sprintf(_("^1Press ^3%s^1 to observe"), getcommandkey("secondary fire", "+fire2"));
78                         drawInfoMessage(s);
79
80                         s = sprintf(_("^1Press ^3%s^1 for gamemode info"), getcommandkey("server info", "+show_info"));
81                         drawInfoMessage(s);
82
83                         if(gametype == MAPINFO_TYPE_LMS)
84                         {
85                                 entity sk;
86                                 sk = playerslots[player_localnum];
87                                 if(sk.(scores[ps_primary]) >= 666)
88                                         s = _("^1Match has already begun");
89                                 else if(sk.(scores[ps_primary]) > 0)
90                                         s = _("^1You have no more lives left");
91                                 else
92                                         s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
93                         }
94                         else
95                                 s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
96                         drawInfoMessage(s);
97                 }
98
99                 if (time < STAT(GAMESTARTTIME))
100                 {
101                         //we need to ceil, otherwise the countdown would be off by .5 when using round()
102                         float countdown = ceil(STAT(GAMESTARTTIME) - time);
103                         s = sprintf(_("^1Game starts in ^3%d^1 seconds"), countdown);
104                         drawInfoMessage(s);
105                 }
106
107                 if(warmup_stage)
108                 {
109                         s = _("^2Currently in ^1warmup^2 stage!");
110                         drawInfoMessage(s);
111                 }
112
113                 string blinkcolor;
114                 if(time % 1 >= 0.5)
115                         blinkcolor = "^1";
116                 else
117                         blinkcolor = "^3";
118
119                 if(ready_waiting && !spectatee_status)
120                 {
121                         if(ready_waiting_for_me)
122                         {
123                                 if(warmup_stage)
124                                         s = sprintf(_("%sPress ^3%s%s to end warmup"), blinkcolor, getcommandkey("ready", "ready"), blinkcolor);
125                                 else
126                                         s = sprintf(_("%sPress ^3%s%s once you are ready"), blinkcolor, getcommandkey("ready", "ready"), blinkcolor);
127                         }
128                         else
129                         {
130                                 if(warmup_stage)
131                                         s = _("^2Waiting for others to ready up to end warmup...");
132                                 else
133                                         s = _("^2Waiting for others to ready up...");
134                         }
135                         drawInfoMessage(s);
136                 }
137                 else if(warmup_stage && !spectatee_status)
138                 {
139                         s = sprintf(_("^2Press ^3%s^2 to end warmup"), getcommandkey("ready", "ready"));
140                         drawInfoMessage(s);
141                 }
142
143                 if(teamplay && !spectatee_status && gametype != MAPINFO_TYPE_CA && teamnagger)
144                 {
145                         float ts_min = 0, ts_max = 0;
146                         tm = teams.sort_next;
147                         if (tm)
148                         {
149                                 for (; tm.sort_next; tm = tm.sort_next)
150                                 {
151                                         if(!tm.team_size || tm.team == NUM_SPECTATOR)
152                                                 continue;
153                                         if(!ts_min) ts_min = tm.team_size;
154                                         else ts_min = min(ts_min, tm.team_size);
155                                         if(!ts_max) ts_max = tm.team_size;
156                                         else ts_max = max(ts_max, tm.team_size);
157                                 }
158                                 if ((ts_max - ts_min) > 1)
159                                 {
160                                         s = strcat(blinkcolor, _("Teamnumbers are unbalanced!"));
161                                         tm = GetTeam(myteam, false);
162                                         if (tm)
163                                         if (tm.team != NUM_SPECTATOR)
164                                         if (tm.team_size == ts_max)
165                                                 s = strcat(s, sprintf(_(" Press ^3%s%s to adjust"), getcommandkey("team menu", "menu_showteamselect"), blinkcolor));
166                                         drawInfoMessage(s);
167                                 }
168                         }
169                 }
170         }
171         else
172         {
173                 s = _("^7Press ^3ESC ^7to show HUD options.");
174                 drawInfoMessage(s);
175                 s = _("^3Doubleclick ^7a panel for panel-specific options.");
176                 drawInfoMessage(s);
177                 s = _("^3CTRL ^7to disable collision testing, ^3SHIFT ^7and");
178                 drawInfoMessage(s);
179                 s = _("^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.");
180                 drawInfoMessage(s);
181         }
182 }