Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
infomessages.qc File Reference
#include "infomessages.qh"
#include <client/draw.qh>
#include <common/ent_cs.qh>
Include dependency graph for infomessages.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define InfoMessage(s)

Functions

string get_team_list (int team_mask, string suf_col)
void HUD_InfoMessages ()
void HUD_InfoMessages_Export (int fh)
int img_select (int group_id)
vector InfoMessages_drawstring (string s, vector pos, vector sz, float a, vector fontsize)

Variables

float autocvar_hud_panel_infomessages_group0 = 1
float autocvar_hud_panel_infomessages_group_fadetime = 0.4
float autocvar_hud_panel_infomessages_group_time = 6
const int IMG_COUNT = 1
int img_cur_msg [IMG_COUNT]
float img_fade [IMG_COUNT]
float img_time [IMG_COUNT]

Macro Definition Documentation

◆ InfoMessage

#define InfoMessage ( s)
Value:
MACRO_BEGIN \
pos = InfoMessages_drawstring(s, pos, mySize, ((img_curr_group >= 0) ? panel_fg_alpha * img_fade[img_curr_group] : panel_fg_alpha), fontsize); \
img_curr_group = -1; \
float panel_fg_alpha
Definition hud.qh:169
vector InfoMessages_drawstring(string s, vector pos, vector sz, float a, vector fontsize)
float img_fade[IMG_COUNT]
#define MACRO_END
Definition macro.qh:7

Definition at line 56 of file infomessages.qc.

56#define InfoMessage(s) MACRO_BEGIN \
57 pos = InfoMessages_drawstring(s, pos, mySize, ((img_curr_group >= 0) ? panel_fg_alpha * img_fade[img_curr_group] : panel_fg_alpha), fontsize); \
58 img_curr_group = -1; \
59MACRO_END

Referenced by HUD_InfoMessages(), and MUTATOR_HOOKFUNCTION().

Function Documentation

◆ get_team_list()

string get_team_list ( int team_mask,
string suf_col )

Definition at line 61 of file infomessages.qc.

62{
63 return strcat(
64 ((team_mask & BIT(0)) ? strcat(Team_ColoredFullName_WithSuffixColor(NUM_TEAM_1, suf_col), (team_mask >> 1) ? ", " : "") : ""),
65 ((team_mask & BIT(1)) ? strcat(Team_ColoredFullName_WithSuffixColor(NUM_TEAM_2, suf_col), (team_mask >> 2) ? ", " : "") : ""),
66 ((team_mask & BIT(2)) ? strcat(Team_ColoredFullName_WithSuffixColor(NUM_TEAM_3, suf_col), (team_mask >> 3) ? ", " : "") : ""),
67 ((team_mask & BIT(3)) ? Team_ColoredFullName_WithSuffixColor(NUM_TEAM_4, suf_col) : "")
68 );
69}
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition bits.qh:8
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
const int NUM_TEAM_2
Definition teams.qh:14
#define Team_ColoredFullName_WithSuffixColor(teamid, suf_col)
Definition teams.qh:231
const int NUM_TEAM_4
Definition teams.qh:16
const int NUM_TEAM_3
Definition teams.qh:15
const int NUM_TEAM_1
Definition teams.qh:13

References BIT, NUM_TEAM_1, NUM_TEAM_2, NUM_TEAM_3, NUM_TEAM_4, strcat(), and Team_ColoredFullName_WithSuffixColor.

Referenced by HUD_InfoMessages().

◆ HUD_InfoMessages()

void HUD_InfoMessages ( )

Definition at line 71 of file infomessages.qc.

72{
74 return;
75
77 vector pos = panel_pos;
78 vector mySize = panel_size;
79
82 else
86 {
87 pos += '1 1 0' * panel_bg_padding;
88 mySize -= '2 2 0' * panel_bg_padding;
89 }
90
91 vector fontsize = '0.2 0.2 0' * mySize.y;
92 int img_curr_group = -1;
93
95 {
96 string s;
98
100 {
101 if (spectatee_status == -1)
102 s = _("^1Observing");
103 else
104 s = sprintf(_("^1Spectating: ^7%s"), entcs_GetName(current_player));
105 InfoMessage(s);
106
108 {
109 img_curr_group = 0;
110 switch (img_select(img_curr_group) % 3)
111 {
112 default:
113 case 0:
114 if (spectatee_status == -1)
115 s = sprintf(_("^1Press ^3%s^1 to spectate"), getcommandkey(_("primary fire"), "+fire"));
116 else
117 s = sprintf(_("^1Press ^3%s^1 or ^3%s^1 for next or previous player"), getcommandkey(_("next weapon"), "weapnext"), getcommandkey(_("previous weapon"), "weapprev"));
118 break;
119 case 1:
120 if (spectatee_status == -1)
121 s = sprintf(_("^1Use ^3%s^1 or ^3%s^1 to change the speed"), getcommandkey(_("next weapon"), "weapnext"), getcommandkey(_("previous weapon"), "weapprev"));
122 else if (!observe_blocked)
123 s = sprintf(_("^1Press ^3%s^1 to observe, ^3%s^1 to change camera mode"), getcommandkey(_("secondary fire"), "+fire2"), getcommandkey(_("drop weapon"), "dropweapon"));
124 else
125 s = sprintf(_("^1Press ^3%s^1 to change camera mode"), getcommandkey(_("drop weapon"), "dropweapon"));
126 break;
127 case 2:
128 s = sprintf(_("^1Press ^3%s^1 for gametype info"), getcommandkey(_("server info"), "+show_info"));
129 break;
130 }
131 InfoMessage(s);
132 }
133
134 bool mutator_returnvalue = MUTATOR_CALLHOOK(DrawInfoMessages, pos, mySize, img_curr_group);
135 pos = M_ARGV(0, vector);
136 img_curr_group = M_ARGV(2, int);
137
138 if (!mutator_returnvalue && !wants_join)
139 InfoMessage(sprintf(_("^1Press ^3%s^1 to join"), getcommandkey(_("jump"), "+jump")));
140 }
141
142 if (wants_join > 0)
143 {
145 InfoMessage(sprintf(_("^2You're queued to join the %s%s^2 team"), Team_ColorCode(wants_join), Team_ColorName(wants_join)));
146 }
147 else if (wants_join < 0)
148 InfoMessage(sprintf(_("^2You're queued to join any available team")));
149
150 if (time < STAT(GAMESTARTTIME))
151 {
152 //we need to ceil, otherwise the countdown would be off by .5 when using round()
153 float countdown = ceil(STAT(GAMESTARTTIME) - time);
154 s = sprintf(_("^1Game starts in ^3%d^1 seconds"), countdown);
155 InfoMessage(s);
156 }
157
158 string blinkcolor = (time % 1 >= 0.5) ? "^1" : "^3";
159
160 if (warmup_stage)
161 {
162 InfoMessage(_("^2Currently in ^1warmup^2 stage!"));
163
164 int players_needed = 0;
165 Scoreboard_UpdatePlayerTeams(); // ensure numplayers, ts_min, ts_max are current
166 if (STAT(WARMUP_TIMELIMIT) <= 0 && srv_minplayers)
167 players_needed = srv_minplayers - numplayers;
168
169 if (players_needed > 0)
170 {
171 if (players_needed == 1)
172 s = _("^31^2 more player is needed for the match to start.");
173 else
174 s = sprintf(_("^3%d^2 more players are needed for the match to start."), players_needed);
175 InfoMessage(s);
176 }
177 else if (teamnagger && (ts_max - ts_min) >= teamnagger)
178 {
179 // ready won't end warmup so don't display that message
180 // see below for unbalanced teams warning
181 }
182 else if (!spectatee_status)
183 {
184 string ready_key = getcommandkey(_("ready"), "ready");
185 if (ready_waiting)
186 {
188 s = sprintf(_("%sPress ^3%s%s to end warmup"), blinkcolor, ready_key, blinkcolor);
189 else
190 s = _("^2Waiting for others to ready up to end warmup...");
191 }
192 else
193 s = sprintf(_("^2Press ^3%s^2 to end warmup"), ready_key);
194 InfoMessage(s);
195 }
196 }
197
198 // NOTE: this stat is used for missing players in ffa games
199 int missing_teams_mask = STAT(MISSING_TEAMS_MASK);
201 {
202 if (teamplay)
203 s = sprintf(_("%sNeed active players for: %s"), blinkcolor, get_team_list(missing_teams_mask, blinkcolor));
204 else
205 {
206 if (missing_teams_mask == 1)
207 s = sprintf(_("%sWaiting for 1 player to join..."), blinkcolor);
208 else
209 s = sprintf(_("%sWaiting for %d players to join..."), blinkcolor, missing_teams_mask);
210 }
211 InfoMessage(s);
212 }
213
214 if (teamplay && numplayers > 1 && teamnagger)
215 {
216 if (!warmup_stage) // in warmup this was done above
218
219 if ((ts_max - ts_min) >= teamnagger)
220 {
221 s = strcat(blinkcolor, _("Teams are unbalanced!"));
222 entity tm = GetTeam(myteam, false);
223 if (tm && tm.team != NUM_SPECTATOR && tm.team_size == ts_max)
224 s = strcat(s, sprintf(_(" Press ^3%s%s to adjust"), getcommandkey(_("team selection"), "team_selection_show"), blinkcolor));
225 fontsize *= 1.125; // perfect float
227 InfoMessage(s);
229 fontsize /= 1.125;
230 }
231 }
232
234 if (num_spectators)
235 //if (spectatee_status != -1)
236 {
237 s = ((spectatee_status) ? _("^1Spectating this player:") : _("^1Spectating you:"));
238 // InfoMessage(s)
239 string spec_name;
240 int limit = min(num_spectators, MAX_SPECTATORS);
241 for (int i = 0; i < limit; ++i)
242 {
243 spec_name = entcs_GetName(spectatorlist[i]);
244 if (i == 0)
245 s = strcat(s, " ^7", spec_name);
246 else
247 s = strcat("^7", spec_name);
248 InfoMessage(s);
249 }
250 }
251 }
252 else
253 {
254 InfoMessage(_("^7Press ^3ESC ^7to show HUD options."));
255 InfoMessage(_("^3Double-click ^7a panel for panel-specific options."));
256 InfoMessage(_("^3CTRL ^7to disable collision testing, ^3SHIFT ^7and"));
257 InfoMessage(_("^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments."));
258 }
259}
#define MUTATOR_CALLHOOK(id,...)
Definition base.qh:143
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define draw_beginBoldFont()
Definition draw.qh:4
#define draw_endBoldFont()
Definition draw.qh:5
entity GetTeam(int Team, bool add)
Definition main.qc:332
bool ready_waiting
Definition main.qh:143
int spectatorlist[MAX_SPECTATORS]
Definition main.qh:178
#define getcommandkey(cmd_name, command)
Definition main.qh:137
bool observe_blocked
Definition main.qh:115
int spectatee_status
the -1 disables HUD panels before CSQC receives necessary data
Definition main.qh:197
bool warmup_stage
Definition main.qh:120
int num_spectators
Definition main.qh:176
int srv_minplayers
Definition main.qh:125
bool ready_waiting_for_me
Definition main.qh:144
const int MAX_SPECTATORS
Definition main.qh:177
#define M_ARGV(x, type)
Definition events.qh:17
int missing_teams_mask
Definition stats.qh:85
float time
string entcs_GetName(int i)
Definition ent_cs.qh:151
int wants_join
Definition ent_cs.qh:73
int entcs_GetWantsJoin(int i)
Definition ent_cs.qh:106
void HUD_Panel_LoadCvars()
Definition hud.qc:215
void HUD_Scale_Enable()
Definition hud.qc:91
void HUD_Scale_Disable()
Definition hud.qc:84
vector panel_size
Definition hud.qh:163
int teamnagger
Definition hud.qh:126
float panel_bg_padding
Definition hud.qh:174
#define HUD_Panel_DrawBg()
Definition hud.qh:55
float current_player
Definition hud.qh:185
vector panel_pos
Definition hud.qh:162
bool autocvar__hud_configure
Definition hud_config.qh:3
string get_team_list(int team_mask, string suf_col)
float autocvar_hud_panel_infomessages_group0
int img_select(int group_id)
#define InfoMessage(s)
bool autocvar_hud_panel_infomessages
bool autocvar_hud_panel_infomessages_dynamichud
bool autocvar_cl_showspectators
#define STAT(...)
Definition stats.qh:82
float ceil(float f)
float min(float f,...)
void Scoreboard_UpdatePlayerTeams()
int ts_min
Definition scoreboard.qh:27
int numplayers
Definition scoreboard.qh:26
int ts_max
team size
Definition scoreboard.qh:27
vector
Definition self.qh:92
int myteam
Definition teams.qh:60
const int NUM_SPECTATOR
Definition teams.qh:23
string Team_ColorName(int teamid)
Definition teams.qh:89
int Team_IndexToTeam(int index)
Converts team index into team value.
Definition teams.qh:169
bool teamplay
Definition teams.qh:59
string Team_ColorCode(int teamid)
Definition teams.qh:63

References autocvar__hud_configure, autocvar_cl_showspectators, autocvar_hud_panel_infomessages, autocvar_hud_panel_infomessages_dynamichud, autocvar_hud_panel_infomessages_group0, ceil(), current_player, draw_beginBoldFont, draw_endBoldFont, entcs_GetName(), entcs_GetWantsJoin(), entity(), get_team_list(), getcommandkey, GetTeam(), HUD_Panel_DrawBg, HUD_Panel_LoadCvars(), HUD_Scale_Disable(), HUD_Scale_Enable(), img_select(), InfoMessage, M_ARGV, MAX_SPECTATORS, min(), missing_teams_mask, MUTATOR_CALLHOOK, myteam, NUM_SPECTATOR, num_spectators, numplayers, observe_blocked, panel_bg_padding, panel_pos, panel_size, ready_waiting, ready_waiting_for_me, Scoreboard_UpdatePlayerTeams(), spectatee_status, spectatorlist, srv_minplayers, STAT, strcat(), Team_ColorCode(), Team_ColorName(), Team_IndexToTeam(), teamnagger, teamplay, time, ts_max, ts_min, vector, wants_join, and warmup_stage.

◆ HUD_InfoMessages_Export()

void HUD_InfoMessages_Export ( int fh)

Definition at line 8 of file infomessages.qc.

9{
10 // allow saving cvars that aesthetically change the panel into hud skin files
11 HUD_Write_Cvar("hud_panel_infomessages_flip");
12}
#define HUD_Write_Cvar(cvar)
Definition hud_config.qh:40

References HUD_Write_Cvar.

◆ img_select()

int img_select ( int group_id)

Definition at line 22 of file infomessages.qc.

23{
25 if (time > img_time[group_id])
26 {
27 img_fade[group_id] = max(0, img_fade[group_id] - frametime / fadetime);
28 if (!img_fade[group_id])
29 {
30 ++img_cur_msg[group_id];
32 }
33 }
34 else
35 img_fade[group_id] = min(1, img_fade[group_id] + frametime / fadetime);
36 return img_cur_msg[group_id];
37}
float frametime
float autocvar_hud_panel_infomessages_group_fadetime
int img_cur_msg[IMG_COUNT]
float img_time[IMG_COUNT]
float autocvar_hud_panel_infomessages_group_time
float floor(float f)
float max(float f,...)
fadetime

References autocvar_hud_panel_infomessages_group_fadetime, autocvar_hud_panel_infomessages_group_time, fadetime, floor(), frametime, img_cur_msg, img_fade, img_time, max(), min(), and time.

Referenced by HUD_InfoMessages().

◆ InfoMessages_drawstring()

vector InfoMessages_drawstring ( string s,
vector pos,
vector sz,
float a,
vector fontsize )

Definition at line 39 of file infomessages.qc.

40{
42 float offset = 0;
44 {
45 s = getWrappedLine(sz.x - offset, fontsize, stringwidth_colors);
47 offset = sz.x - stringwidth_colors(s, fontsize) - offset;
48 drawcolorcodedstring(pos + eX * offset, s, fontsize, a, DRAWFLAG_NORMAL);
49 pos.y += fontsize.y;
50 offset = fontsize.x;
51 }
52 pos.y += fontsize.y * 0.25;
53 return pos;
54}
#define drawcolorcodedstring(position, text, scale, alpha, flag)
Definition draw.qh:30
string getWrappedLine(float maxWidth, vector theFontSize, textLengthUpToWidth_widthFunction_t tw)
Definition util.qc:995
string getWrappedLine_remaining
Definition util.qh:147
const float DRAWFLAG_NORMAL
bool autocvar_hud_panel_infomessages_flip
float stringwidth_colors(string s, vector theSize)
Definition string.qh:30
const vector eX
Definition vector.qh:44

References autocvar_hud_panel_infomessages_flip, drawcolorcodedstring, DRAWFLAG_NORMAL, eX, getWrappedLine(), getWrappedLine_remaining, stringwidth_colors(), and vector.

Variable Documentation

◆ autocvar_hud_panel_infomessages_group0

float autocvar_hud_panel_infomessages_group0 = 1

Definition at line 14 of file infomessages.qc.

Referenced by HUD_InfoMessages().

◆ autocvar_hud_panel_infomessages_group_fadetime

float autocvar_hud_panel_infomessages_group_fadetime = 0.4

Definition at line 15 of file infomessages.qc.

Referenced by img_select().

◆ autocvar_hud_panel_infomessages_group_time

float autocvar_hud_panel_infomessages_group_time = 6

Definition at line 16 of file infomessages.qc.

Referenced by img_select().

◆ IMG_COUNT

const int IMG_COUNT = 1

Definition at line 17 of file infomessages.qc.

◆ img_cur_msg

int img_cur_msg[IMG_COUNT]

Definition at line 19 of file infomessages.qc.

Referenced by img_select().

◆ img_fade

float img_fade[IMG_COUNT]

Definition at line 18 of file infomessages.qc.

Referenced by img_select().

◆ img_time

float img_time[IMG_COUNT]

Definition at line 20 of file infomessages.qc.

Referenced by img_select().