1 #include "infomessages.qh"
3 #include <common/ent_cs.qh>
4 #include <common/mapinfo.qh>
6 // Info messages panel (#14)
8 float autocvar_hud_panel_infomessages_group_fadetime = 0.4;
9 float autocvar_hud_panel_infomessages_group_time = 6;
10 const int IMG_COUNT = 1; // number of InfoMessage Groups
11 float img_fade[IMG_COUNT];
12 int img_id[IMG_COUNT];
13 float img_time[IMG_COUNT];
15 int img_select(int group_id, int msg_cnt)
17 float fadetime = max(0.001, autocvar_hud_panel_infomessages_group_fadetime);
18 if(time > img_time[group_id])
20 img_fade[group_id] = max(0, img_fade[group_id] - frametime / fadetime);
21 if(!img_fade[group_id])
24 img_time[group_id] = floor(time) + autocvar_hud_panel_infomessages_group_time;
28 img_fade[group_id] = min(1, img_fade[group_id] + frametime / fadetime);
29 return img_id[group_id] % msg_cnt;
32 float stringwidth_colors(string s, vector theSize);
33 vector InfoMessages_drawstring(string s, vector pos, vector sz, float a, vector fontsize)
35 getWrappedLine_remaining = s;
37 while(getWrappedLine_remaining)
39 s = getWrappedLine(sz.x - offset, fontsize, stringwidth_colors);
40 if(autocvar_hud_panel_infomessages_flip)
41 offset = sz.x - stringwidth_colors(s, fontsize) - offset;
42 drawcolorcodedstring(pos + eX * offset, s, fontsize, a, DRAWFLAG_NORMAL);
49 #define InfoMessage(s, a) pos = InfoMessages_drawstring(s, pos, mySize, a, fontsize)
51 void HUD_InfoMessages()
53 if(!autocvar__hud_configure)
55 if(!autocvar_hud_panel_infomessages) return;
58 HUD_Panel_UpdateCvars();
63 if (autocvar_hud_panel_infomessages_dynamichud)
70 pos += '1 1 0' * panel_bg_padding;
71 mySize -= '2 2 0' * panel_bg_padding;
74 vector fontsize = '0.2 0.2 0' * mySize.y;
76 if(!autocvar__hud_configure)
81 if(spectatee_status == -1)
84 s = sprintf(_("^1Spectating: ^7%s"), entcs_GetName(current_player));
85 InfoMessage(s, panel_fg_alpha);
88 switch(img_select(img_group, 3))
92 if(spectatee_status == -1)
93 s = sprintf(_("^1Press ^3%s^1 to spectate"), getcommandkey(_("primary fire"), "+fire"));
95 s = sprintf(_("^1Press ^3%s^1 or ^3%s^1 for next or previous player"), getcommandkey(_("next weapon"), "weapnext"), getcommandkey(_("previous weapon"), "weapprev"));
98 if(spectatee_status == -1)
99 s = sprintf(_("^1Use ^3%s^1 or ^3%s^1 to change the speed"), getcommandkey(_("next weapon"), "weapnext"), getcommandkey(_("previous weapon"), "weapprev"));
101 s = sprintf(_("^1Press ^3%s^1 to observe, ^3%s^1 to change camera mode"), getcommandkey(_("secondary fire"), "+fire2"), getcommandkey(_("drop weapon"), "dropweapon"));
104 s = sprintf(_("^1Press ^3%s^1 for gamemode info"), getcommandkey(_("server info"), "+show_info"));
107 InfoMessage(s, img_fade[img_group] * panel_fg_alpha);
109 if(gametype == MAPINFO_TYPE_LMS)
112 sk = playerslots[player_localnum];
113 if(sk.(scores[ps_primary]) >= 666)
114 s = _("^1Match has already begun");
115 else if(sk.(scores[ps_primary]) > 0)
116 s = _("^1You have no more lives left");
118 s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey(_("jump"), "+jump"));
121 s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey(_("jump"), "+jump"));
122 InfoMessage(s, panel_fg_alpha);
125 if (time < STAT(GAMESTARTTIME))
127 //we need to ceil, otherwise the countdown would be off by .5 when using round()
128 float countdown = ceil(STAT(GAMESTARTTIME) - time);
129 s = sprintf(_("^1Game starts in ^3%d^1 seconds"), countdown);
130 InfoMessage(s, panel_fg_alpha);
135 s = _("^2Currently in ^1warmup^2 stage!");
136 InfoMessage(s, panel_fg_alpha);
145 if(ready_waiting && !spectatee_status)
147 if(ready_waiting_for_me)
150 s = sprintf(_("%sPress ^3%s%s to end warmup"), blinkcolor, getcommandkey(_("ready"), "ready"), blinkcolor);
152 s = sprintf(_("%sPress ^3%s%s once you are ready"), blinkcolor, getcommandkey(_("ready"), "ready"), blinkcolor);
157 s = _("^2Waiting for others to ready up to end warmup...");
159 s = _("^2Waiting for others to ready up...");
161 InfoMessage(s, panel_fg_alpha);
163 else if(warmup_stage && !spectatee_status)
165 s = sprintf(_("^2Press ^3%s^2 to end warmup"), getcommandkey(_("ready"), "ready"));
166 InfoMessage(s, panel_fg_alpha);
169 if(teamplay && !spectatee_status && gametype != MAPINFO_TYPE_CA && teamnagger)
171 float ts_min = 0, ts_max = 0;
172 entity tm = teams.sort_next;
175 for (; tm.sort_next; tm = tm.sort_next)
177 if(!tm.team_size || tm.team == NUM_SPECTATOR)
179 if(!ts_min) ts_min = tm.team_size;
180 else ts_min = min(ts_min, tm.team_size);
181 if(!ts_max) ts_max = tm.team_size;
182 else ts_max = max(ts_max, tm.team_size);
184 if ((ts_max - ts_min) > 1)
186 s = strcat(blinkcolor, _("Teamnumbers are unbalanced!"));
187 tm = GetTeam(myteam, false);
188 if (tm && tm.team != NUM_SPECTATOR && tm.team_size == ts_max)
189 s = strcat(s, sprintf(_(" Press ^3%s%s to adjust"), getcommandkey(_("team menu"), "menu_showteamselect"), blinkcolor));
190 InfoMessage(s, panel_fg_alpha);
197 InfoMessage(_("^7Press ^3ESC ^7to show HUD options."), panel_fg_alpha);
198 InfoMessage(_("^3Doubleclick ^7a panel for panel-specific options."), panel_fg_alpha);
199 InfoMessage(_("^3CTRL ^7to disable collision testing, ^3SHIFT ^7and"), panel_fg_alpha);
200 InfoMessage(_("^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments."), panel_fg_alpha);