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