DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
UIScriptedMenu.c
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
3{
4 proto native UIMenuPanel GetSubMenu();
5 proto native UIMenuPanel GetParentMenu();
6 proto native UIMenuPanel GetVisibleMenu();
7 proto native void SetSubMenu(UIMenuPanel submenu);
8 proto native void SetParentMenu(UIMenuPanel parent);
9 proto native bool CanClose();
10 proto native bool CanCloseOnEscape();
12 proto native UIScriptedMenu EnterScriptedMenu(int id);
13
14 proto native void DestroySubmenu();
15 proto native bool IsAnyMenuVisible();
16 proto native bool IsVisible();
17
20 void OnVisibilityChanged(bool isVisible)
21 {
22 }
23
25 proto native void Close();
26
27 bool UseMouse() {
28 #ifdef PLATFORM_CONSOLE
30 #else
31 return true;
32 #endif
33 }
34
35 bool UseKeyboard() {
36 #ifdef PLATFORM_CONSOLE
38 #else
39 return true;
40 #endif
41 }
42
43 bool UseGamepad() {
44 return true;
45 }
46
48 int GetID() {
49 return MENU_UNKNOWN;
50 }
51
53 void Refresh()
54 {
55 }
56};
57
58//-----------------------------------------------------------------------------
60class UIScriptedMenu extends UIMenuPanel
61{
62 int m_id;
66 private float m_AnimAlphaValue;
67
69 {
70 return layoutRoot;
71 }
72
74 {
75 if (UseMouse())
76 {
79 }
80
81 if(UseKeyboard())
82 {
84 }
85
86 if(UseGamepad())
87 {
89 }
90 }
91
93 {
94 if (UseMouse())
95 {
97 }
98
99 if (GetParentMenu() && GetParentMenu().UseMouse())
100 {
102 }
103 else
104 {
106 }
107
108 if(UseKeyboard())
109 {
111 }
112
113 if(UseGamepad())
114 {
116 }
117 }
118
120 {
121 m_id = MENU_UNKNOWN;
122 }
123
125 {
126 }
127
129 void SetID(int id) {
130 m_id = id;
131 }
132
134 override int GetID() {
135 return m_id;
136 }
137
139 {
140 m_AnimAlphaValue = 0.3;
141 m_AnimAlphaWidget = widget;
142 }
143
144 //create widgets here and return layout root Widget
145 //widgets will be destroyed automatically by c++ side
147 {
148 return NULL;
149 }
150
151 void Cleanup()
152 {
153 }
154
155 //after show
156 void OnShow()
157 {
158 LockControls();
159 }
160
161 //after hide
162 void OnHide()
163 {
164 UnlockControls();
165 }
166
168 void Update(float timeslice)
169 {
170 #ifdef PLATFORM_CONSOLE
171 if ( m_AnimAlphaWidget )
172 {
173 float anim_speed = 1.2;
174 float anim_value_max = 1.0;
175 float anim_value_min = 0.3;
176 if ( m_AnimAlphaIsIncreasing )
177 {
178 m_AnimAlphaValue += anim_speed * timeslice;
179
180 if ( m_AnimAlphaValue >= anim_value_max )
181 {
182 m_AnimAlphaValue = anim_value_max;
183 m_AnimAlphaIsIncreasing = false;
184 }
185 }
186 else
187 {
188 m_AnimAlphaValue -= anim_speed * timeslice;
189
190 if ( m_AnimAlphaValue <= anim_value_min )
191 {
192 m_AnimAlphaValue = anim_value_min;
193 m_AnimAlphaIsIncreasing = true;
194 }
195 }
196
197
198 m_AnimAlphaWidget.SetAlpha( m_AnimAlphaValue );
199 }
200 #endif
201 }
202
203 // Moved to parent
205 //void Refresh()
206 //{
207 //}
208
209 proto native void SetFadingPanels(Widget panel0, Widget panel1, Widget panel2, Widget panel3, Widget panel4);
210
211 bool OnClick(Widget w, int x, int y, int button)
212 {
214 {
215 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
216 {
217 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnClick( w, x, y, button ) )
218 {
219 return true;
220 }
221 }
222 }
223
224 return false;
225 }
226 bool OnModalResult(Widget w, int x, int y, int code, int result)
227 {
229 {
230 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
231 {
232 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnModalResult( w, x, y, code, result ) )
233 {
234 return true;
235 }
236 }
237 }
238
239 return false;
240 }
241 bool OnDoubleClick(Widget w, int x, int y, int button)
242 {
244 {
245 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
246 {
247 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnDoubleClick( w, x, y, button ) )
248 {
249 return true;
250 }
251 }
252 }
253
254 return false;
255 }
256 bool OnSelect(Widget w, int x, int y)
257 {
259 {
260 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
261 {
262 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnSelect( w, x, y ) )
263 {
264 return true;
265 }
266 }
267 }
268
269 return false;
270 }
271 bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn)
272 {
274 {
275 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
276 {
277 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnItemSelected( w, x, y, row, column, oldRow, oldColumn ) )
278 {
279 return true;
280 }
281 }
282 }
283
284 return false;
285 }
286 bool OnFocus(Widget w, int x, int y)
287 {
289 {
290 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
291 {
292 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnFocus( w, x, y ) )
293 {
294 return true;
295 }
296 }
297 }
298
299 return false;
300 }
301 bool OnFocusLost(Widget w, int x, int y)
302 {
304 {
305 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
306 {
307 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnFocusLost( w, x, y ) )
308 {
309 return true;
310 }
311 }
312 }
313
314 return false;
315 }
316 bool OnMouseEnter(Widget w, int x, int y)
317 {
319 {
320 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
321 {
322 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnMouseEnter( w, x, y ) )
323 {
324 return true;
325 }
326 }
327 }
328
329 return false;
330 }
331 bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
332 {
334 {
335 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
336 {
337 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnMouseLeave( w, enterW, x, y ) )
338 {
339 return true;
340 }
341 }
342 }
343
344 return false;
345 }
346 bool OnMouseButtonDown(Widget w, int x, int y, int button)
347 {
349 {
350 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
351 {
352 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnMouseButtonDown( w, x, y, button ) )
353 {
354 return true;
355 }
356 }
357 }
358
359 return false;
360 }
361 bool OnMouseButtonUp(Widget w, int x, int y, int button)
362 {
364 {
365 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
366 {
367 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnMouseButtonUp( w, x, y, button ) )
368 {
369 return true;
370 }
371 }
372 }
373
374 return false;
375 }
376 bool OnMouseWheel(Widget w, int x, int y, int wheel)
377 {
379 {
380 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
381 {
382 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnMouseWheel( w, x, y, wheel ) )
383 {
384 return true;
385 }
386 }
387 }
388
389 return false;
390 }
391 bool OnController(Widget w, int control, int value)
392 {
394 {
395 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
396 {
397 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnController( w, control, value ) )
398 {
399 return true;
400 }
401 }
402 }
403
404 return false;
405 }
406 bool OnKeyDown(Widget w, int x, int y, int key)
407 {
409 {
410 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
411 {
412 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnKeyDown( w, x, y, key ) )
413 {
414 return true;
415 }
416 }
417 }
418
419 return false;
420 }
421 bool OnKeyUp(Widget w, int x, int y, int key)
422 {
424 {
425 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
426 {
427 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnKeyUp( w, x, y, key ) )
428 {
429 return true;
430 }
431 }
432 }
433
434 return false;
435 }
436 bool OnKeyPress(Widget w, int x, int y, int key)
437 {
439 {
440 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
441 {
442 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnKeyPress( w, x, y, key ) )
443 {
444 return true;
445 }
446 }
447 }
448
449 return false;
450 }
451 bool OnChange(Widget w, int x, int y, bool finished)
452 {
454 {
455 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
456 {
457 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnChange( w, x, y, finished ) )
458 {
459 return true;
460 }
461 }
462 }
463
464 return false;
465 }
466 bool OnDrag(Widget w, int x, int y)
467 {
469 {
470 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
471 {
472 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnDrag( w, x, y ) )
473 {
474 return true;
475 }
476 }
477 }
478
479 return false;
480 }
481 bool OnDragging(Widget w, int x, int y, Widget reciever)
482 {
484 {
485 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
486 {
487 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnDragging( w, x, y, reciever ) )
488 {
489 return true;
490 }
491 }
492 }
493
494 return false;
495 }
496 bool OnDraggingOver(Widget w, int x, int y, Widget reciever)
497 {
499 {
500 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
501 {
502 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnDraggingOver( w, x, y, reciever ) )
503 {
504 return true;
505 }
506 }
507 }
508
509 return false;
510 }
511 bool OnDrop(Widget w, int x, int y, Widget reciever)
512 {
514 {
515 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
516 {
517 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnDrop( w, x, y, reciever ) )
518 {
519 return true;
520 }
521 }
522 }
523
524 return false;
525 }
526 bool OnDropReceived(Widget w, int x, int y, Widget reciever)
527 {
529 {
530 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
531 {
532 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnDropReceived( w, x, y, reciever ) )
533 {
534 return true;
535 }
536 }
537 }
538
539 return false;
540 }
541
542 bool OnEvent(EventType eventType, Widget target, int parameter0, int parameter1)
543 {
545 {
546 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
547 {
548 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnEvent( eventType, target, parameter0, parameter1 ) )
549 {
550 return true;
551 }
552 }
553 }
554
555 return false;
556 }
557
559 {
560 return null;
561 }
562
563 bool OnXboxEvent(int xboxEvent)
564 {
565 return true;
566 }
567
569 void OnRPCEx(int rpc_type, ParamsReadContext ctx){}
570
571 void InitNoteWrite(EntityAI paper, EntityAI pen, string text = "") {}
572 void InitNoteRead(string text = "") {}
573 void InitMapItem(EntityAI item) {}
575};
Icon x
Icon y
proto native Input GetInput()
proto native UIManager GetUIManager()
proto native void ChangeGameFocus(int add, int input_device=-1)
Change game focus number.
proto native bool IsEnabledMouseAndKeyboardEvenOnServer()
TODO doc.
Definition EnScript.c:118
map: item x vector(index, width, height)
Definition EnWidgets.c:538
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
void ShowUICursor(bool visible)
Definition UIManager.c:246
Part of main menu hierarchy to create custom menus from script.
void UIScriptedMenu()
void InitMapItem(EntityAI item)
bool UseGamepad()
proto native UIMenuPanel GetVisibleMenu()
private float m_AnimAlphaValue
bool OnMouseWheel(Widget w, int x, int y, int wheel)
int GetID()
Returns MenuID.
Widget GetLayoutRoot()
void Update(float timeslice)
Per frame update, called from engine.
proto native void SetSubMenu(UIMenuPanel submenu)
Widget layoutRoot
bool OnEvent(EventType eventType, Widget target, int parameter0, int parameter1)
bool OnDragging(Widget w, int x, int y, Widget reciever)
void InitNoteRead(string text="")
bool OnFocusLost(Widget w, int x, int y)
proto native void DestroySubmenu()
void OnVisibilityChanged(bool isVisible)
proto native UIMenuPanel GetParentMenu()
void OnRPCEx(int rpc_type, ParamsReadContext ctx)
void LoadMapMarkers()
proto native void SetFadingPanels(Widget panel0, Widget panel1, Widget panel2, Widget panel3, Widget panel4)
Refresh request, called from anywhere.
proto native void Close()
Safe way to close window, using this function can even window safely close itself.
bool OnModalResult(Widget w, int x, int y, int code, int result)
bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
bool OnSelect(Widget w, int x, int y)
void InitNoteWrite(EntityAI paper, EntityAI pen, string text="")
bool OnKeyUp(Widget w, int x, int y, int key)
void SetWidgetAnimAlpha(Widget widget)
bool OnController(Widget w, int control, int value)
proto native void SetParentMenu(UIMenuPanel parent)
proto native bool CanCloseOnEscape()
bool OnKeyPress(Widget w, int x, int y, int key)
bool OnKeyDown(Widget w, int x, int y, int key)
void LockControls()
proto native bool CanClose()
bool OnXboxEvent(int xboxEvent)
bool OnDropReceived(Widget w, int x, int y, Widget reciever)
void UnlockControls()
bool OnDraggingOver(Widget w, int x, int y, Widget reciever)
proto native UIMenuPanel GetSubMenu()
bool OnClick(Widget w, int x, int y, int button)
bool OnDrag(Widget w, int x, int y)
proto native bool IsAnyMenuVisible()
void OnRPC(ParamsReadContext ctx)
proto native bool IsVisible()
void Refresh()
Refresh request, called from anywhere.
void ~UIScriptedMenu()
bool OnDoubleClick(Widget w, int x, int y, int button)
private Widget m_AnimAlphaWidget
void SetID(int id)
Sets MenuID.
bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn)
ScriptedWidgetEventHandler GetContextMenu()
override int GetID()
Returns MenuID.
bool OnMouseEnter(Widget w, int x, int y)
bool OnMouseButtonUp(Widget w, int x, int y, int button)
bool OnFocus(Widget w, int x, int y)
bool OnDrop(Widget w, int x, int y, Widget reciever)
bool OnChange(Widget w, int x, int y, bool finished)
private bool m_AnimAlphaIsIncreasing
bool OnMouseButtonDown(Widget w, int x, int y, int button)
proto native UIScriptedMenu EnterScriptedMenu(int id)
Create & open menu with specific id (see MenuID) and set this menu as its parent.
bool UseKeyboard()
override bool UseKeyboard()
override bool UseMouse()
override bool UseGamepad()
static map< int, UIScriptedWindow > GetActiveWindows()
proto native CGame GetGame()
const int INPUT_DEVICE_MOUSE
Definition constants.c:24
const int INPUT_DEVICE_GAMEPAD
Definition constants.c:28
const int INPUT_DEVICE_KEYBOARD
Definition constants.c:23
const int MENU_UNKNOWN
Definition constants.c:151
TypeID EventType
Definition EnWidgets.c:54