]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/item.qc
Merge branch 'Mario/qc_updates' into TimePath/csqc_prediction
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / item.qc
1 #ifdef INTERFACE
2 CLASS(Item) EXTENDS(Object)
3         METHOD(Item, draw, void(entity))
4         METHOD(Item, keyDown, float(entity, float, float, float))
5         METHOD(Item, keyUp, float(entity, float, float, float))
6         METHOD(Item, mouseMove, float(entity, vector))
7         METHOD(Item, mousePress, float(entity, vector))
8         METHOD(Item, mouseDrag, float(entity, vector))
9         METHOD(Item, mouseRelease, float(entity, vector))
10         METHOD(Item, focusEnter, void(entity))
11         METHOD(Item, focusLeave, void(entity))
12         METHOD(Item, resizeNotify, void(entity, vector, vector, vector, vector))
13         METHOD(Item, relinquishFocus, void(entity))
14         METHOD(Item, showNotify, void(entity))
15         METHOD(Item, hideNotify, void(entity))
16         METHOD(Item, toString, string(entity))
17         METHOD(Item, destroy, void(entity))
18         ATTRIB(Item, focused, float, 0)
19         ATTRIB(Item, focusable, float, 0)
20         ATTRIB(Item, parent, entity, NULL)
21         ATTRIB(Item, preferredFocusPriority, float, 0)
22         ATTRIB(Item, origin, vector, '0 0 0')
23         ATTRIB(Item, size, vector, '0 0 0')
24         ATTRIB(Item, tooltip, string, string_null)
25 ENDCLASS(Item)
26 #endif
27
28 #ifdef IMPLEMENTATION
29 void Item_destroy(entity me)
30 {
31         // free memory associated with me
32 }
33
34 void Item_relinquishFocus(entity me)
35 {
36         if(me.parent)
37                 if(me.parent.instanceOfContainer)
38                         me.parent.setFocus(me.parent, NULL);
39 }
40
41 void Item_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
42 {
43         me.origin = absOrigin;
44         me.size = absSize;
45 }
46
47 float autocvar_menu_showboxes;
48 void Item_draw(entity me)
49 {
50         if(autocvar_menu_showboxes)
51         {
52                 vector rgb = '1 0 1';
53                 float a = fabs(autocvar_menu_showboxes);
54
55                 // don't draw containers and border images
56                 if(me.instanceOfContainer || me.instanceOfBorderImage)
57                 {
58                         rgb = '0 0 0';
59                         a = 0;
60                 }
61
62 #if 0
63                 // hack to detect multi drawing
64                 float r = random() * 3;
65                 if(r >= 2)
66                         rgb = '1 0 0';
67                 else if(r >= 1)
68                         rgb = '0 1 0';
69                 else
70                         rgb = '0 0 1';
71 #endif
72                 if(autocvar_menu_showboxes < 0)
73                 {
74                         draw_Fill('0 0 0', '0.5 0.5 0', rgb, a);
75                         draw_Fill('0.5 0.5 0', '0.5 0.5 0', rgb, a);
76                 }
77                 if(autocvar_menu_showboxes > 0)
78                 {
79                         draw_Fill('0 0 0', '1 1 0', rgb, a);
80                 }
81         }
82 }
83
84 void Item_showNotify(entity me)
85 {
86 }
87
88 void Item_hideNotify(entity me)
89 {
90 }
91
92 float Item_keyDown(entity me, float scan, float ascii, float shift)
93 {
94         return 0; // unhandled
95 }
96
97 float Item_keyUp(entity me, float scan, float ascii, float shift)
98 {
99         return 0; // unhandled
100 }
101
102 float Item_mouseMove(entity me, vector pos)
103 {
104         return 0; // unhandled
105 }
106
107 float Item_mousePress(entity me, vector pos)
108 {
109         return 0; // unhandled
110 }
111
112 float Item_mouseDrag(entity me, vector pos)
113 {
114         return 0; // unhandled
115 }
116
117 float Item_mouseRelease(entity me, vector pos)
118 {
119         return 0; // unhandled
120 }
121
122 void Item_focusEnter(entity me)
123 {
124 }
125
126 void Item_focusLeave(entity me)
127 {
128 }
129
130 string Item_toString(entity me)
131 {
132         return string_null;
133 }
134 #endif