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

Go to the source code of this file.

Functions

void Container_addItem (entity me, entity other, vector theOrigin, vector theSize, float theAlpha)
void Container_addItemCentered (entity me, entity other, vector theSize, float theAlpha)
void Container_addItemRightCentered (entity me, entity other, vector theSize, float theAlpha)
void Container_draw (entity me)
void Container_enterLieSubitem (entity me, vector o, vector s, vector f, float a)
void Container_enterSubitem (entity me, entity sub)
void Container_focusLeave (entity me)
void Container_hideNotify (entity me)
entity Container_itemFromPoint (entity me, vector pos)
float Container_keyDown (entity me, float scan, float ascii, float shift)
float Container_keyUp (entity me, float scan, float ascii, float shift)
void Container_leaveSubitem (entity me)
float Container_mouseDrag (entity me, vector pos)
float Container_mouseMove (entity me, vector pos)
float Container_mouseRelease (entity me, vector pos)
void Container_moveItemAfter (entity me, entity other, entity dest)
entity Container_preferredFocusedGrandChild (entity me)
void Container_removeItem (entity me, entity other)
void Container_resizeNotify (entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
void Container_resizeNotifyLie (entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize,.vector originField,.vector sizeField,.vector fontScaleField)
void Container_saveFocus (entity me)
void Container_setAlphaOf (entity me, entity other, float theAlpha)
void Container_setFocus (entity me, entity other)
void Container_showNotify (entity me)

Function Documentation

◆ Container_addItem()

void Container_addItem ( entity me,
entity other,
vector theOrigin,
vector theSize,
float theAlpha )

Definition at line 232 of file container.qc.

233 {
234 if (other.parent) error("Can't add already added item!");
235
236 if (other.focusable) me.focusable = true;
237
238 if (theSize.x > 1)
239 {
240 theOrigin.x -= 0.5 * (theSize.x - 1);
241 theSize.x = 1;
242 }
243 if (theSize.y > 1)
244 {
245 theOrigin.y -= 0.5 * (theSize.y - 1);
246 theSize.y = 1;
247 }
248 theOrigin.x = bound(0, theOrigin.x, 1 - theSize.x);
249 theOrigin.y = bound(0, theOrigin.y, 1 - theSize.y);
250
251 other.parent = me;
252 other.Container_origin = theOrigin;
253 other.Container_size = theSize;
254
255 // don't call setAlphaOf, it would uneccessarily trigger showNotify
256 //me.setAlphaOf(me, other, theAlpha);
257 other.Container_alpha = theAlpha;
258
259 entity l = me.lastChild;
260
261 if (l) l.nextSibling = other;
262 else me.firstChild = other;
263
264 other.prevSibling = l;
265 other.nextSibling = NULL;
266 me.lastChild = other;
267 }
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
entity other
float bound(float min, float value, float max)
#define NULL
Definition post.qh:14
#define error
Definition pre.qh:6

References bound(), entity(), error, NULL, other, and vector.

◆ Container_addItemCentered()

void Container_addItemCentered ( entity me,
entity other,
vector theSize,
float theAlpha )

Definition at line 222 of file container.qc.

223 {
224 me.addItem(me, other, '0.5 0.5 0' - 0.5 * theSize, theSize, theAlpha);
225 }

References entity(), other, and vector.

◆ Container_addItemRightCentered()

void Container_addItemRightCentered ( entity me,
entity other,
vector theSize,
float theAlpha )

Definition at line 227 of file container.qc.

228 {
229 me.addItem(me, other, '1 0.5 0' - 0.5 * theSize, theSize, theAlpha);
230 }

References entity(), other, and vector.

◆ Container_draw()

void Container_draw ( entity me)

Definition at line 114 of file container.qc.

115 {
116 entity e;
117
118 me.focusable = false;
119 for (e = me.firstChild; e; e = e.nextSibling)
120 {
121 if (e.focusable) me.focusable = true;
122 if (e.Container_alpha < 0.003) // can't change color values anyway
123 continue;
124 me.enterSubitem(me, e);
125 e.draw(e);
126 me.leaveSubitem(me);
127 }
128
129 SUPER(Container).draw(me);
130 }
#define SUPER(cname)
Definition oo.qh:231

References entity(), and SUPER.

◆ Container_enterLieSubitem()

void Container_enterLieSubitem ( entity me,
vector o,
vector s,
vector f,
float a )

Definition at line 8 of file container.qc.

9 {
10 me.Container_save_shift = draw_shift;
11 me.Container_save_scale = draw_scale;
12 me.Container_save_alpha = draw_alpha;
13 me.Container_save_fontscale = draw_fontscale;
14
17 if (f != '0 0 0') draw_fontscale = boxToGlobalSize(f, draw_fontscale);
18 draw_alpha *= a;
19 }
vector boxToGlobalSize(vector v, vector theScale)
Definition draw.qc:53
vector boxToGlobal(vector v, vector theOrigin, vector theScale)
Definition draw.qc:45
vector draw_shift
Definition draw.qh:7
vector draw_scale
Definition draw.qh:8
#define draw_fontscale
Definition draw.qh:5
float draw_alpha
Definition draw.qh:9

References boxToGlobal(), boxToGlobalSize(), draw_alpha, draw_fontscale, draw_scale, draw_shift, entity(), and vector.

◆ Container_enterSubitem()

void Container_enterSubitem ( entity me,
entity sub )

Definition at line 3 of file container.qc.

4 {
5 me.enterLieSubitem(me, sub.Container_origin, sub.Container_size, sub.Container_fontscale, sub.Container_alpha);
6 }

References entity().

◆ Container_focusLeave()

void Container_focusLeave ( entity me)

Definition at line 132 of file container.qc.

133 {
134 me.setFocus(me, NULL);
135 }

References entity(), and NULL.

◆ Container_hideNotify()

void Container_hideNotify ( entity me)

Definition at line 38 of file container.qc.

39 {
40 entity e;
41 if (!me.shown) return;
42 me.shown = false;
43 for (e = me.firstChild; e; e = e.nextSibling)
44 if (e.Container_alpha > 0) e.hideNotify(e);
45 }

References entity().

◆ Container_itemFromPoint()

entity Container_itemFromPoint ( entity me,
vector pos )

Definition at line 97 of file container.qc.

98 {
99 entity e;
100 vector o, s;
101 for (e = me.lastChild; e; e = e.prevSibling)
102 {
103 o = e.Container_origin;
104 s = e.Container_size;
105 if (pos.x < o.x) continue;
106 if (pos.y < o.y) continue;
107 if (pos.x >= o.x + s.x) continue;
108 if (pos.y >= o.y + s.y) continue;
109 return e;
110 }
111 return NULL;
112 }
vector
Definition self.qh:92

References entity(), NULL, and vector.

◆ Container_keyDown()

float Container_keyDown ( entity me,
float scan,
float ascii,
float shift )

Definition at line 150 of file container.qc.

151 {
152 entity f = me.focusedChild;
153 if (f)
154 {
155 me.enterSubitem(me, f);
156 float r = f.keyDown(f, scan, ascii, shift);
157 me.leaveSubitem(me);
158 return r;
159 }
160 return 0;
161 }

References entity().

◆ Container_keyUp()

float Container_keyUp ( entity me,
float scan,
float ascii,
float shift )

Definition at line 137 of file container.qc.

138 {
139 entity f = me.focusedChild;
140 if (f)
141 {
142 me.enterSubitem(me, f);
143 float r = f.keyUp(f, scan, ascii, shift);
144 me.leaveSubitem(me);
145 return r;
146 }
147 return 0;
148 }

References entity().

◆ Container_leaveSubitem()

void Container_leaveSubitem ( entity me)

Definition at line 21 of file container.qc.

22 {
23 draw_shift = me.Container_save_shift;
24 draw_scale = me.Container_save_scale;
25 draw_alpha = me.Container_save_alpha;
26 draw_fontscale = me.Container_save_fontscale;
27 }

References draw_alpha, draw_fontscale, draw_scale, draw_shift, and entity().

◆ Container_mouseDrag()

float Container_mouseDrag ( entity me,
vector pos )

Definition at line 197 of file container.qc.

198 {
199 entity f = me.focusedChild;
200 if (f)
201 {
202 me.enterSubitem(me, f);
203 float r = f.mouseDrag(f, globalToBox(pos, f.Container_origin, f.Container_size));
204 me.leaveSubitem(me);
205 return r;
206 }
207 return 0;
208 }
vector globalToBox(vector v, vector theOrigin, vector theScale)
Definition draw.qc:30

References entity(), globalToBox(), and vector.

◆ Container_mouseMove()

float Container_mouseMove ( entity me,
vector pos )

Definition at line 163 of file container.qc.

164 {
165 entity f = me.focusedChild;
166 if (f)
167 {
168 me.enterSubitem(me, f);
169 float r = f.mouseMove(f, globalToBox(pos, f.Container_origin, f.Container_size));
170 me.leaveSubitem(me);
171 return r;
172 }
173 return 0;
174 }

References entity(), globalToBox(), and vector.

◆ Container_mouseRelease()

float Container_mouseRelease ( entity me,
vector pos )

Definition at line 209 of file container.qc.

210 {
211 entity f = me.focusedChild;
212 if (f)
213 {
214 me.enterSubitem(me, f);
215 float r = f.mouseRelease(f, globalToBox(pos, f.Container_origin, f.Container_size));
216 me.leaveSubitem(me);
217 return r;
218 }
219 return 0;
220 }

References entity(), globalToBox(), and vector.

◆ Container_moveItemAfter()

void Container_moveItemAfter ( entity me,
entity other,
entity dest )

Definition at line 329 of file container.qc.

330 {
331 // first: remove other from the chain
332 entity n, p;
333
334 if (other.parent != me) error("Can't move in wrong container!");
335
336 n = other.nextSibling;
337 p = other.prevSibling;
338
339 if (p) p.nextSibling = n;
340 else me.firstChild = n;
341
342 if (n) n.prevSibling = p;
343 else me.lastChild = p;
344
345 // now other got removed. Insert it behind dest now.
346 other.prevSibling = dest;
347 if (dest) other.nextSibling = dest.nextSibling;
348 else other.nextSibling = me.firstChild;
349
350 if (dest) dest.nextSibling = other;
351 else me.firstChild = other;
352
353 if (other.nextSibling) other.nextSibling.prevSibling = other;
354 else me.lastChild = other;
355 }
vector dest
Definition jumppads.qh:54

References dest, entity(), error, and other.

◆ Container_preferredFocusedGrandChild()

entity Container_preferredFocusedGrandChild ( entity me)

Definition at line 357 of file container.qc.

358 {
359 entity e, e2;
360 entity best = NULL;
361
362 for (e = me.firstChild; e; e = e.nextSibling)
363 {
364 if (e.instanceOfContainer)
365 {
366 e2 = e.preferredFocusedGrandChild(e);
367 if (e2)
368 if (!best || best.preferredFocusPriority < e2.preferredFocusPriority) best = e2;
369 }
370 if (e)
371 if (!best || best.preferredFocusPriority < e.preferredFocusPriority) best = e;
372 }
373
374 return best;
375 }
best
Definition all.qh:84

References best, entity(), and NULL.

◆ Container_removeItem()

void Container_removeItem ( entity me,
entity other )

Definition at line 269 of file container.qc.

270 {
271 if (other.parent != me) error("Can't remove from wrong container!");
272
273 if (other.focusable) me.focusable = false;
274
275 other.parent = NULL;
276
277 entity n, p;
278 n = other.nextSibling;
279 p = other.prevSibling;
280
281 if (p) p.nextSibling = n;
282 else me.firstChild = n;
283
284 if (n) n.prevSibling = p;
285 else me.lastChild = p;
286 }

References entity(), error, NULL, and other.

◆ Container_resizeNotify()

void Container_resizeNotify ( entity me,
vector relOrigin,
vector relSize,
vector absOrigin,
vector absSize )

Definition at line 92 of file container.qc.

93 {
94 me.resizeNotifyLie(me, relOrigin, relSize, absOrigin, absSize, Container_origin, Container_size, Container_fontscale);
95 }
vector Container_origin
Definition container.qh:43
vector Container_fontscale
Definition container.qh:45
vector Container_size
Definition container.qh:44

References Container_fontscale, Container_origin, Container_size, entity(), and vector.

◆ Container_resizeNotifyLie()

void Container_resizeNotifyLie ( entity me,
vector relOrigin,
vector relSize,
vector absOrigin,
vector absSize,
.vector originField,
.vector sizeField,
.vector fontScaleField )

Definition at line 60 of file container.qc.

61 {
62 entity e;
63 vector o, s;
64 float d;
65 for (e = me.firstChild; e; e = e.nextSibling)
66 {
67 o = e.(originField);
68 s = e.(sizeField);
69 me.enterLieSubitem(me, o, s, e.(fontScaleField), e.Container_alpha);
70 e.resizeNotify(e, o, s, boxToGlobal(o, absOrigin, absSize), boxToGlobalSize(s, absSize));
71 me.leaveSubitem(me);
72 }
73 do
74 {
75 d = 0;
76 for (e = me.firstChild; e; e = e.nextSibling)
77 if (e.resized)
78 {
79 e.resized = 0;
80 d = 1;
81 o = e.(originField);
82 s = e.(sizeField);
83 me.enterLieSubitem(me, o, s, e.(fontScaleField), e.Container_alpha);
84 e.resizeNotify(e, o, s, boxToGlobal(o, absOrigin, absSize), boxToGlobalSize(s, absSize));
85 me.leaveSubitem(me);
86 }
87 }
88 while (d);
89 SUPER(Container).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
90 }

References boxToGlobal(), boxToGlobalSize(), entity(), SUPER, and vector.

◆ Container_saveFocus()

void Container_saveFocus ( entity me)

Definition at line 322 of file container.qc.

323 {
324 me.savedFocus = me.focusedChild;
325
326 if (me.focusedChild.instanceOfContainer) me.focusedChild.saveFocus(me.focusedChild);
327 }

References entity().

◆ Container_setAlphaOf()

void Container_setAlphaOf ( entity me,
entity other,
float theAlpha )

Definition at line 47 of file container.qc.

48 {
49 if (theAlpha <= 0)
50 {
51 if (other.Container_alpha > 0) other.hideNotify(other);
52 }
53 else // value > 0
54 {
55 if (other.Container_alpha <= 0) other.showNotify(other);
56 }
57 other.Container_alpha = theAlpha;
58 }

References entity(), and other.

◆ Container_setFocus()

void Container_setFocus ( entity me,
entity other )

Definition at line 288 of file container.qc.

289 {
290 if (me.focusedChild == other) return;
291
292 if (me.focusedChild)
293 {
294 me.focusedChild.focused = false;
295 me.focusedChild.focusLeave(me.focusedChild);
296 me.focusedChild = NULL;
297 }
298
299 if (other)
300 {
301 if (!me.focused) error("Trying to set focus in a non-focused control!");
302
303 if (me.savedFocus)
304 {
305 me.focusedChild = me.savedFocus;
306 me.savedFocus = NULL;
307 me.focusedChild.focused = true;
308 me.focusedChild.focusEnter(me.focusedChild);
309
310 if (me.focusedChild.instanceOfContainer)
311 me.focusedChild.setFocus(me.focusedChild, me.focusedChild.savedFocus);
312 }
313 else
314 {
315 me.focusedChild = other;
316 me.focusedChild.focused = true;
317 me.focusedChild.focusEnter(me.focusedChild);
318 }
319 }
320 }

References entity(), error, NULL, and other.

Referenced by m_activate_window(), and XonoticScrollPanel::setFocus().

◆ Container_showNotify()

void Container_showNotify ( entity me)

Definition at line 29 of file container.qc.

30 {
31 entity e;
32 if (me.shown) return;
33 me.shown = true;
34 for (e = me.firstChild; e; e = e.nextSibling)
35 if (e.Container_alpha > 0) e.showNotify(e);
36 }

References entity().