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