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

Go to the source code of this file.

Functions

void HUD_Notify (bool should_draw)
void HUD_Notify_Export (int fh)
void HUD_Notify_Push (string icon, string attacker, string victim)

Function Documentation

◆ HUD_Notify()

void HUD_Notify ( bool should_draw)

Definition at line 57 of file notify.qc.

58{
59 if (!should_draw)
60 return;
62 return;
63
65
67 {
68 float minalpha = 1;
69 if (notify_count == 0)
70 minalpha = 0; // hide if empty
73 {
74 minalpha = 0.5; // transparent if it may overlap the scoreboard
75 }
76 float f = max(minalpha, (1 - scoreboard_fade_alpha));
77 if (f <= 0)
78 return;
79 panel_bg_alpha *= f;
80 panel_fg_alpha *= f;
81 }
82
85 else
88
90 return;
91
92 vector pos = panel_pos;
94
96 {
97 pos += '1 1 0' * panel_bg_padding;
98 size -= '2 2 0' * panel_bg_padding;
99 }
100
102 if (intermission) // fade out in half the time
105 float icon_aspect = max(1, autocvar_hud_panel_notify_icon_aspect);
106
107 int entry_count = bound(1, floor(NOTIFY_MAX_ENTRIES * size.y / size.x), NOTIFY_MAX_ENTRIES);
108 float entry_height = size.y / entry_count;
109
110 float panel_width_half = size.x * 0.5;
111 float icon_width_half = entry_height * icon_aspect * 0.5;
112 float name_maxwidth = panel_width_half - icon_width_half - size.x * NOTIFY_ICON_MARGIN;
113
114 vector font_size = '0.5 0.5 0' * entry_height * autocvar_hud_panel_notify_fontsize;
115 vector icon_size = vec2(icon_aspect, 1) * entry_height;
116 vector icon_left = eX * (panel_width_half - icon_width_half);
117 vector attacker_right = eX * name_maxwidth;
118 vector victim_left = eX * (size.x - name_maxwidth);
119
120 vector attacker_pos, victim_pos, icon_pos;
121 string attacker, victim, icon;
122
123 int i, step, limit;
125 {
126 // Order items from the top down
127 i = 0;
128 step = +1;
129 limit = entry_count;
130 }
131 else
132 {
133 // Order items from the bottom up
134 i = entry_count - 1;
135 step = -1;
136 limit = -1;
137 }
138
139 float alpha;
140 vector name_top;
141 int count = 0;
142 for (int j = notify_index; i != limit; i += step, ++j, ++count)
143 {
145 {
146 attacker = sprintf(_("Player %d"), count + 1);
147 victim = sprintf(_("Player %d"), count + 2);
148 icon = REGISTRY_GET(Weapons, min(WEP_FIRST + count * 2, WEP_LAST)).model2;
149 alpha = bound(0, 1.2 - count / entry_count, 1);
150 }
151 else
152 {
153 if (j == NOTIFY_MAX_ENTRIES)
154 j = 0;
155
156 if (notify_times[j] + fade_start > time)
157 alpha = 1;
158 else if (fade_time != 0)
159 {
161 if (alpha == 0)
162 break;
163 }
164 else
165 break;
166
167 attacker = notify_attackers[j];
168 victim = notify_victims[j];
169 icon = notify_icons[j];
170 }
171
172 if (icon != "" && victim != "")
173 {
174 name_top = eY * (i * entry_height + 0.5 * (entry_height - font_size.y));
175
176 icon_pos = pos + icon_left + eY * i * entry_height;
177 drawpic_aspect_skin(icon_pos, icon, icon_size, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
178
179 victim = textShortenToWidth(ColorTranslateRGB(victim), name_maxwidth, font_size, stringwidth_colors);
180 victim_pos = pos + victim_left + name_top;
181 drawcolorcodedstring(victim_pos, victim, font_size, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
182
183 if (attacker != "")
184 {
185 attacker = textShortenToWidth(ColorTranslateRGB(attacker), name_maxwidth, font_size, stringwidth_colors);
186 attacker_pos = pos + attacker_right - eX * stringwidth(attacker, true, font_size) + name_top;
187 drawcolorcodedstring(attacker_pos, attacker, font_size, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
188 }
189 }
190 }
191
193}
#define drawcolorcodedstring(position, text, scale, alpha, flag)
Definition draw.qh:30
#define drawpic_aspect_skin(pos, pic, sz, color, theAlpha, drawflag)
Definition draw.qh:78
float count
Definition powerups.qc:22
float alpha
Definition items.qc:13
float fade_start
Definition item.qh:86
string textShortenToWidth(string theText, float maxWidth, vector theFontSize, textLengthUpToWidth_widthFunction_t tw)
Definition util.qc:1171
const float DRAWFLAG_NORMAL
float time
vector size
float intermission
#define stringwidth
Weapons
Definition guide.qh:113
void HUD_Panel_LoadCvars()
Definition hud.qc:215
void HUD_Scale_Enable()
Definition hud.qc:91
void HUD_Scale_Disable()
Definition hud.qc:84
const float NOTIFY_ICON_MARGIN
Definition hud.qh:425
vector panel_size
Definition hud.qh:163
float notify_times[NOTIFY_MAX_ENTRIES]
Definition hud.qh:429
float panel_fg_alpha
Definition hud.qh:169
string notify_icons[NOTIFY_MAX_ENTRIES]
Definition hud.qh:432
float panel_bg_padding
Definition hud.qh:174
const int NOTIFY_MAX_ENTRIES
Definition hud.qh:424
int notify_count
Definition hud.qh:428
#define HUD_Panel_DrawBg()
Definition hud.qh:55
int notify_index
Definition hud.qh:427
string notify_attackers[NOTIFY_MAX_ENTRIES]
Definition hud.qh:430
vector panel_pos
Definition hud.qh:162
float panel_bg_alpha
Definition hud.qh:170
string notify_victims[NOTIFY_MAX_ENTRIES]
Definition hud.qh:431
bool autocvar__hud_configure
Definition hud_config.qh:3
float bound(float min, float value, float max)
float min(float f,...)
float floor(float f)
float max(float f,...)
float autocvar_hud_panel_notify_flip
Definition notify.qh:7
bool autocvar_hud_panel_notify
Definition notify.qh:4
float autocvar_hud_panel_notify_time
Definition notify.qh:9
float autocvar_hud_panel_notify_fontsize
Definition notify.qh:8
bool autocvar_hud_panel_notify_dynamichud
Definition notify.qh:5
float autocvar_hud_panel_notify_fadetime
Definition notify.qh:6
float autocvar_hud_panel_notify_icon_aspect
Definition notify.qh:10
#define REGISTRY_GET(id, i)
Definition registry.qh:43
float scoreboard_right
Definition scoreboard.qh:24
float scoreboard_top
Definition scoreboard.qh:21
float scoreboard_left
Definition scoreboard.qh:23
float scoreboard_fade_alpha
Definition scoreboard.qh:17
float scoreboard_bottom
Definition scoreboard.qh:22
vector
Definition self.qh:92
float fade_time
Definition common.qh:23
ERASEABLE string ColorTranslateRGB(string s)
Definition string.qh:196
float stringwidth_colors(string s, vector theSize)
Definition string.qh:30
const vector eY
Definition vector.qh:45
ERASEABLE float boxesoverlap(vector m1, vector m2, vector m3, vector m4)
requires that m2>m1 in all coordinates, and that m4>m3
Definition vector.qh:73
const vector eX
Definition vector.qh:44
#define vec2(...)
Definition vector.qh:90
float intermission_time
Definition view.qh:131
#define WEP_LAST
Definition all.qh:343
const int WEP_FIRST
Definition all.qh:342

References alpha, autocvar__hud_configure, autocvar_hud_panel_notify, autocvar_hud_panel_notify_dynamichud, autocvar_hud_panel_notify_fadetime, autocvar_hud_panel_notify_flip, autocvar_hud_panel_notify_fontsize, autocvar_hud_panel_notify_icon_aspect, autocvar_hud_panel_notify_time, bound(), boxesoverlap(), ColorTranslateRGB(), count, drawcolorcodedstring, DRAWFLAG_NORMAL, drawpic_aspect_skin, eX, eY, fade_start, fade_time, floor(), HUD_Panel_DrawBg, HUD_Panel_LoadCvars(), HUD_Scale_Disable(), HUD_Scale_Enable(), intermission, intermission_time, max(), min(), notify_attackers, notify_count, NOTIFY_ICON_MARGIN, notify_icons, notify_index, NOTIFY_MAX_ENTRIES, notify_times, notify_victims, panel_bg_alpha, panel_bg_padding, panel_fg_alpha, panel_pos, panel_size, REGISTRY_GET, scoreboard_bottom, scoreboard_fade_alpha, scoreboard_left, scoreboard_right, scoreboard_top, size, stringwidth, stringwidth_colors(), textShortenToWidth(), time, vec2, vector, Weapons, WEP_FIRST, and WEP_LAST.

◆ HUD_Notify_Export()

void HUD_Notify_Export ( int fh)

Definition at line 9 of file notify.qc.

10{
11 // allow saving cvars that aesthetically change the panel into hud skin files
12 HUD_Write_Cvar("hud_panel_notify_flip");
13 HUD_Write_Cvar("hud_panel_notify_fontsize");
14 HUD_Write_Cvar("hud_panel_notify_time");
15 HUD_Write_Cvar("hud_panel_notify_fadetime");
16 HUD_Write_Cvar("hud_panel_notify_icon_aspect");
17}
#define HUD_Write_Cvar(cvar)
Definition hud_config.qh:40

References HUD_Write_Cvar.

◆ HUD_Notify_Push()

void HUD_Notify_Push ( string icon,
string attacker,
string victim )

Definition at line 19 of file notify.qc.

20{
21 if (icon == "")
22 return;
23
26
27 if (notify_index == -1)
29
30 // Free old strings
37
38 // Allocate new strings
39 if (victim != "")
40 {
43 }
44 else
45 {
46 // In case of a notification without a victim, the attacker
47 // is displayed on the victim's side. Instead of special
48 // treatment later on, we can simply switch them here.
51 }
52
55}
void strunzone(string s)
string strzone(string s)
string string_null
Definition nil.qh:9

References notify_attackers, notify_count, notify_icons, notify_index, NOTIFY_MAX_ENTRIES, notify_times, notify_victims, string_null, strunzone(), strzone(), and time.

Referenced by Local_Notification_HUD_Notify_Push(), and minigame_prompt().