]> icculus.org git repositories - divverent/nexuiz.git/blob - data/menuqc/system/event_helper.qc
Revert first change in the trunk.
[divverent/nexuiz.git] / data / menuqc / system / event_helper.qc
1 // DP/Nex menu
2 // system/events.qc
3
4 // raise function
5 /* template
6
7 void( entity pEntity )  Raise_x =
8 {
9         local entity lOld;
10         if( !pEntity._y )
11                 return;
12
13         lOld = self;
14         self = pEntity;
15         self._y();
16         self = lOld;
17 };
18 */
19
20 void( entity pEntity ) Raise_Reinit =
21 {
22         local entity lOld;
23         if(!pEntity._reinit)
24                 return;
25
26         lOld = self;
27         self = pEntity;
28         self._reinit();
29         self = lOld;
30 };
31
32 void( entity pEntity ) Raise_Destroy =
33 {
34         local entity lOld;
35         if( !pEntity._destroy )
36                 return;
37
38         lOld = self;
39         self = pEntity;
40         self._destroy();
41         self = lOld;
42 };
43
44 bool( entity pEntity, float pKey, float pAscii) Raise_Key =
45 {
46         local entity lOld;
47         local bool   lResult;
48
49         if( !pEntity._key )
50                 return false;
51
52         lOld = self;
53         self = pEntity;
54         lResult = self._key( pKey, pAscii );
55         self = lOld;
56
57         return lResult;
58 };
59
60 void( entity pEntity ) Raise_Draw =
61 {
62         local entity lOld;
63         if( !pEntity._draw )
64                 return;
65
66         lOld = self;
67         self = pEntity;
68         self._draw();
69         self = lOld;
70 };
71
72 void( entity pEntity ) Raise_MouseEnter =
73 {
74         local entity lOld;
75         if( !pEntity._mouseEnter )
76                 return;
77
78         lOld = self;
79         self = pEntity;
80         self._mouseEnter();
81         self = lOld;
82 };
83
84 void( entity pEntity ) Raise_MouseLeave =
85 {
86         local entity lOld;
87         if( !pEntity._mouseLeave )
88                 return;
89
90         lOld = self;
91         self = pEntity;
92         self._mouseLeave();
93         self = lOld;
94 };
95
96 void( entity pEntity ) Raise_Update =
97 {
98         local entity lOld;
99         if( !pEntity._update )
100                 return;
101
102         lOld = self;
103         self = pEntity;
104         self._update();
105         self = lOld;
106 };
107
108 void( entity pEntity, bool pSelect, bool pUser ) Raise_Select =
109 {
110         local entity lOld;
111         if( !pEntity._select )
112                 return;
113
114         lOld = self;
115         self = pEntity;
116         self._select( pSelect, pUser );
117         self = lOld;
118 };
119
120 // safe call control function functions
121 // default control functions
122 /* template
123
124 void() CtCall_x =
125 {
126         if( self.y )
127                 self.y();
128 };
129
130 */
131 void()  CtCall_Init =
132 {
133         if( self.init )
134                 self.init();
135 };
136
137 void()  CtCall_Reinit =
138 {
139         if( self.reinit )
140                 self.reinit();
141 };
142
143 void() CtCall_Destroy =
144 {
145         if( self.destroy )
146                 self.destroy();
147 };
148
149 bool( float pKey, float pAscii )  CtCall_Key =
150 {
151         if( self.key )
152                 return self.key( pKey, pAscii );
153         return false;
154 };
155
156 void()  CtCall_Draw =
157 {
158         if( self.draw )
159                 self.draw();
160 };
161
162 void()  CtCall_MouseEnter =
163 {
164         if( self.mouseEnter )
165                 self.mouseEnter();
166 };
167
168 void()  CtCall_MouseLeave =
169 {
170         if( self.mouseLeave )
171                 self.mouseLeave();
172 };
173
174 void()  CtCall_Action =
175 {
176         if( self.action )
177                 self.action();
178 };
179
180 void() CtCall_Update =
181 {
182         if( self.update )
183                 self.update();
184 }
185
186 void( bool pSelect, bool pUser ) CtCall_Select =
187 {
188         if( self.select )
189                 self.select( pSelect, pUser );
190 };
191
192 // default control functions
193 /* template (expect DefCt_Key)
194
195 void(void) defct_x =
196 {
197         CtCall_x();
198 };
199
200 */
201 // defct_init not needed cause its the same like the type function
202
203 void() DefCt_Reinit =
204 {
205 };
206
207 void() DefCt_Destroy =
208 {
209 };
210
211 bool( float pKey, float pAscii ) DefCt_Key =
212 {
213         return false;
214 };
215
216 void() DefCt_Draw =
217 {
218 };
219
220 void() DefCt_MouseEnter =
221 {
222 };
223
224 void() DefCt_MouseLeave =
225 {
226 };
227
228 void()  DefCt_Action =
229 {
230 };
231
232 void( float pSelect, bool pUser )  DefCt_Select =
233 {
234 };
235
236 void()  DefCt_Update =
237 {
238 };
239
240 // default key function
241 /*void(float keynr, float ascii)        def_keyevent =
242 {
243         if(keynr == K_ESCAPE)
244         {
245                 // move up to the parent
246                 menu_selectup();
247         } else if(keynr == K_LEFTARROW || keynr == K_UPARROW)
248         {
249                 // move to the previous element
250                 menu_loopprev();
251
252                 if(Menu_ActiveItem == self)
253                 {
254                         if(self._prev)
255                         {
256                                 Menu_ActiveItem = self._prev;
257                                 menu_selectdown();
258                                 if(Menu_ActiveItem != self._prev)
259                                 {
260                                         return;
261                                 }
262                         }
263                         Menu_ActiveItem = self;
264                 }
265         } else if(keynr == K_RIGHTARROW || keynr == K_DOWNARROW)
266         {
267                 // move to the  next element
268                 menu_loopnext();
269
270                 if(Menu_ActiveItem == self)
271                 {
272                         if(self._next)
273                         {
274                                 Menu_ActiveItem = self._next;
275                                 menu_selectdown();
276                                 if(Menu_ActiveItem != self._next)
277                                 {
278                                         return;
279                                 }
280                         }
281                         Menu_ActiveItem = self;
282                 }
283         } else if(keynr == K_ENTER || keynr == K_MOUSE1)
284         {
285                 if(self._action)
286                         self._action();
287                 // move to the child menu
288                 menu_selectdown();
289         }
290 };*/