]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/item.qc
Merge branch 'Mario/warmup_timer' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / item.qc
1 #include "item.qh"
2
3 #include "item/container.qh"
4 #include "item/borderimage.qh"
5
6         METHOD(MenuItem, destroy, void(MenuItem this))
7         {
8                 // free memory associated with this
9         }
10
11         METHOD(MenuItem, relinquishFocus, void(MenuItem this))
12         {
13                 entity par = this.parent;
14                 if (!par) return;
15                 if (par.instanceOfContainer) par.setFocus(par, NULL);
16         }
17
18         METHOD(MenuItem, resizeNotify, void(MenuItem this, vector relOrigin, vector relSize, vector absOrigin, vector absSize))
19         {
20                 this.origin = absOrigin;
21                 this.size = absSize;
22         }
23
24         int autocvar_menu_showboxes;
25         METHOD(MenuItem, draw, void(MenuItem this))
26         {
27                 if (!autocvar_menu_showboxes) return;
28                 vector rgb = '1 0 1';
29                 float a = fabs(autocvar_menu_showboxes);
30
31                 // don't draw containers and border images
32                 if (this.instanceOfContainer || this.instanceOfBorderImage)
33                 {
34                         rgb = '0 0 0';
35                         a = 0;
36                 }
37
38                 #if 0
39                         // hack to detect multi drawing
40                         float r = random() * 3;
41                         if (r >= 2) rgb = '1 0 0';
42                         else if (r >= 1) rgb = '0 1 0';
43                         else rgb = '0 0 1';
44                 #endif
45                 if (autocvar_menu_showboxes < 0)
46                 {
47                         draw_Fill('0 0 0', '0.5 0.5 0', rgb, a);
48                         draw_Fill('0.5 0.5 0', '0.5 0.5 0', rgb, a);
49                 }
50                 else if (autocvar_menu_showboxes > 0)
51                 {
52                         draw_Fill('0 0 0', '1 1 0', rgb, a);
53                 }
54         }
55
56         METHOD(MenuItem, showNotify, void(MenuItem this))
57         {}
58
59         METHOD(MenuItem, hideNotify, void(MenuItem this))
60         {}
61
62         METHOD(MenuItem, keyDown, float(MenuItem this, float scan, float ascii, float shift))
63         {
64                 return 0;  // unhandled
65         }
66
67         METHOD(MenuItem, keyUp, float(MenuItem this, float scan, float ascii, float shift))
68         {
69                 return 0;  // unhandled
70         }
71
72         METHOD(MenuItem, mouseMove, float(MenuItem this, vector pos))
73         {
74                 return 0;  // unhandled
75         }
76
77         METHOD(MenuItem, mousePress, bool(MenuItem this, vector pos))
78         {
79                 return false;  // unhandled
80         }
81
82         METHOD(MenuItem, mouseDrag, float(MenuItem this, vector pos))
83         {
84                 return 0;  // unhandled
85         }
86
87         METHOD(MenuItem, mouseRelease, float(MenuItem this, vector pos))
88         {
89                 return 0;  // unhandled
90         }
91
92     void m_play_focus_sound();
93
94         METHOD(MenuItem, focusEnter, void(MenuItem this))
95         {
96                 if (this.allowFocusSound) m_play_focus_sound();
97         }
98
99         METHOD(MenuItem, focusLeave, void(MenuItem this))
100         {}
101
102         METHOD(MenuItem, toString, string(MenuItem this))
103         {
104                 return string_null;
105         }