Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
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 proto native bool IsClosing();
18
19#ifdef FEATURE_CURSOR
21 proto native bool IsCreatedHidden();
22#endif
23
26 void OnVisibilityChanged(bool isVisible)
27 {
28 }
29
31 proto native void Close();
32
33 bool UseMouse() {
34 #ifdef PLATFORM_CONSOLE
35 return g_Game.GetInput().IsEnabledMouseAndKeyboardEvenOnServer();
36 #else
37 return true;
38 #endif
39 }
40
41 bool UseKeyboard() {
42 #ifdef PLATFORM_CONSOLE
43 return g_Game.GetInput().IsEnabledMouseAndKeyboardEvenOnServer();
44 #else
45 return true;
46 #endif
47 }
48
49 bool UseGamepad() {
50 return true;
51 }
52
54 int GetID() {
55 return MENU_UNKNOWN;
56 }
57
59 void Refresh()
60 {
61 }
62};
63
64//-----------------------------------------------------------------------------
66class UIScriptedMenu extends UIMenuPanel
67{
68 int m_id;
72 private float m_AnimAlphaValue;
73 private ScriptInvoker m_PlayerDeathInvoker; //DayZPlayer::GetOnDeathStart -> used to keep track of and ensure proper callback handling
74
76 {
77 return layoutRoot;
78 }
79
81 {
82#ifdef FEATURE_CURSOR
83 if (IsCreatedHidden())
84 return;
85#endif
86
87 if (UseMouse())
88 {
89 g_Game.GetInput().ChangeGameFocus(1, INPUT_DEVICE_MOUSE);
90 g_Game.GetUIManager().ShowUICursor(true);
91 }
92
93 if (UseKeyboard())
94 {
95 g_Game.GetInput().ChangeGameFocus(1, INPUT_DEVICE_KEYBOARD);
96 }
97
98 if (UseGamepad())
99 {
100 g_Game.GetInput().ChangeGameFocus(1, INPUT_DEVICE_GAMEPAD);
101 }
102 }
103
105 {
106#ifdef FEATURE_CURSOR
107 if (IsCreatedHidden())
108 return;
109#endif
110
111 if (UseMouse())
112 {
113 g_Game.GetInput().ChangeGameFocus(-1, INPUT_DEVICE_MOUSE);
114 }
115
117 {
118 g_Game.GetUIManager().ShowUICursor(true);
119 }
120 else
121 {
122 g_Game.GetUIManager().ShowUICursor(false);
123 }
124
125 if(UseKeyboard())
126 {
127 g_Game.GetInput().ChangeGameFocus(-1, INPUT_DEVICE_KEYBOARD);
128 }
129
130 if(UseGamepad())
131 {
132 g_Game.GetInput().ChangeGameFocus(-1, INPUT_DEVICE_GAMEPAD);
133 }
134 }
135
137 {
139 }
140
142 {
143 }
144
146 void SetID(int id) {
147 m_id = id;
148 }
149
151 override int GetID() {
152 return m_id;
153 }
154
156 {
157 m_AnimAlphaValue = 0.3;
158 m_AnimAlphaWidget = widget;
159 }
160
161 //create widgets here and return layout root Widget
162 //widgets will be destroyed automatically by c++ side
164 {
165 return NULL;
166 }
167
168 void Cleanup()
169 {
170 }
171
172 //after show
173 void OnShow()
174 {
175 LockControls();
176 if (IsHandlingPlayerDeathEvent() && g_Game && g_Game.GetPlayer())
177 {
178 m_PlayerDeathInvoker = g_Game.GetPlayer().GetOnDeathStart();
180 }
181 }
182
183 //after hide
184 void OnHide()
185 {
187 if (m_PlayerDeathInvoker) // Only ever registered while `IsHandlingPlayerDeathEvent`. Remove callback directly.
188 {
189 m_PlayerDeathInvoker.Remove( OnPlayerDeath, EScriptInvokerRemoveFlags.NONE );
191 }
192 }
193
195 void Update(float timeslice)
196 {
197 #ifdef PLATFORM_CONSOLE
198 if ( m_AnimAlphaWidget )
199 {
200 float anim_speed = 1.2;
201 float anim_value_max = 1.0;
202 float anim_value_min = 0.3;
204 {
205 m_AnimAlphaValue += anim_speed * timeslice;
206
207 if ( m_AnimAlphaValue >= anim_value_max )
208 {
209 m_AnimAlphaValue = anim_value_max;
211 }
212 }
213 else
214 {
215 m_AnimAlphaValue -= anim_speed * timeslice;
216
217 if ( m_AnimAlphaValue <= anim_value_min )
218 {
219 m_AnimAlphaValue = anim_value_min;
221 }
222 }
223
224
226 }
227 #endif
228 }
229
230 // Moved to parent
232 //void Refresh()
233 //{
234 //}
235
236 proto native void SetFadingPanels(Widget panel0, Widget panel1, Widget panel2, Widget panel3, Widget panel4);
237
238 bool OnClick(Widget w, int x, int y, int button)
239 {
241 {
242 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
243 {
244 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnClick( w, x, y, button ) )
245 {
246 return true;
247 }
248 }
249 }
250
251 return false;
252 }
253 bool OnModalResult(Widget w, int x, int y, int code, int result)
254 {
256 {
257 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
258 {
259 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnModalResult( w, x, y, code, result ) )
260 {
261 return true;
262 }
263 }
264 }
265
266 return false;
267 }
268 bool OnDoubleClick(Widget w, int x, int y, int button)
269 {
271 {
272 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
273 {
274 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnDoubleClick( w, x, y, button ) )
275 {
276 return true;
277 }
278 }
279 }
280
281 return false;
282 }
283 bool OnSelect(Widget w, int x, int y)
284 {
286 {
287 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
288 {
289 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnSelect( w, x, y ) )
290 {
291 return true;
292 }
293 }
294 }
295
296 return false;
297 }
298 bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn)
299 {
301 {
302 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
303 {
304 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnItemSelected( w, x, y, row, column, oldRow, oldColumn ) )
305 {
306 return true;
307 }
308 }
309 }
310
311 return false;
312 }
313 bool OnFocus(Widget w, int x, int y)
314 {
316 {
317 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
318 {
319 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnFocus( w, x, y ) )
320 {
321 return true;
322 }
323 }
324 }
325
326 return false;
327 }
328 bool OnFocusLost(Widget w, int x, int y)
329 {
331 {
332 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
333 {
334 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnFocusLost( w, x, y ) )
335 {
336 return true;
337 }
338 }
339 }
340
341 return false;
342 }
343 bool OnMouseEnter(Widget w, int x, int y)
344 {
346 {
347 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
348 {
349 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnMouseEnter( w, x, y ) )
350 {
351 return true;
352 }
353 }
354 }
355
356 return false;
357 }
358 bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
359 {
361 {
362 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
363 {
364 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnMouseLeave( w, enterW, x, y ) )
365 {
366 return true;
367 }
368 }
369 }
370
371 return false;
372 }
373 bool OnMouseButtonDown(Widget w, int x, int y, int button)
374 {
376 {
377 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
378 {
379 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnMouseButtonDown( w, x, y, button ) )
380 {
381 return true;
382 }
383 }
384 }
385
386 return false;
387 }
388 bool OnMouseButtonUp(Widget w, int x, int y, int button)
389 {
391 {
392 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
393 {
394 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnMouseButtonUp( w, x, y, button ) )
395 {
396 return true;
397 }
398 }
399 }
400
401 return false;
402 }
403 bool OnMouseWheel(Widget w, int x, int y, int wheel)
404 {
406 {
407 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
408 {
409 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnMouseWheel( w, x, y, wheel ) )
410 {
411 return true;
412 }
413 }
414 }
415
416 return false;
417 }
418 bool OnController(Widget w, int control, int value)
419 {
421 {
422 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
423 {
424 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnController( w, control, value ) )
425 {
426 return true;
427 }
428 }
429 }
430
431 return false;
432 }
433 bool OnKeyDown(Widget w, int x, int y, int key)
434 {
436 {
437 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
438 {
439 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnKeyDown( w, x, y, key ) )
440 {
441 return true;
442 }
443 }
444 }
445
446 return false;
447 }
448 bool OnKeyUp(Widget w, int x, int y, int key)
449 {
451 {
452 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
453 {
454 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnKeyUp( w, x, y, key ) )
455 {
456 return true;
457 }
458 }
459 }
460
461 return false;
462 }
463 bool OnKeyPress(Widget w, int x, int y, int key)
464 {
466 {
467 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
468 {
469 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnKeyPress( w, x, y, key ) )
470 {
471 return true;
472 }
473 }
474 }
475
476 return false;
477 }
478 bool OnChange(Widget w, int x, int y, bool finished)
479 {
481 {
482 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
483 {
484 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnChange( w, x, y, finished ) )
485 {
486 return true;
487 }
488 }
489 }
490
491 return false;
492 }
493 bool OnDrag(Widget w, int x, int y)
494 {
496 {
497 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
498 {
499 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnDrag( w, x, y ) )
500 {
501 return true;
502 }
503 }
504 }
505
506 return false;
507 }
508 bool OnDragging(Widget w, int x, int y, Widget reciever)
509 {
511 {
512 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
513 {
514 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnDragging( w, x, y, reciever ) )
515 {
516 return true;
517 }
518 }
519 }
520
521 return false;
522 }
523 bool OnDraggingOver(Widget w, int x, int y, Widget reciever)
524 {
526 {
527 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
528 {
529 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnDraggingOver( w, x, y, reciever ) )
530 {
531 return true;
532 }
533 }
534 }
535
536 return false;
537 }
538 bool OnDrop(Widget w, int x, int y, Widget reciever)
539 {
541 {
542 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
543 {
544 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnDrop( w, x, y, reciever ) )
545 {
546 return true;
547 }
548 }
549 }
550
551 return false;
552 }
553 bool OnDropReceived(Widget w, int x, int y, Widget reciever)
554 {
556 {
557 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
558 {
559 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnDropReceived( w, x, y, reciever ) )
560 {
561 return true;
562 }
563 }
564 }
565
566 return false;
567 }
568
569 bool OnEvent(EventType eventType, Widget target, int parameter0, int parameter1)
570 {
572 {
573 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
574 {
575 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnEvent( eventType, target, parameter0, parameter1 ) )
576 {
577 return true;
578 }
579 }
580 }
581
582 return false;
583 }
584
586 {
587 return null;
588 }
589
590 bool OnXboxEvent(int xboxEvent)
591 {
592 return true;
593 }
594
596 void OnRPCEx(int rpc_type, ParamsReadContext ctx){}
597
598 void InitNoteWrite(EntityAI paper, EntityAI pen, string text = "") {}
599 void InitNoteRead(string text = "") {}
600 void InitMapItem(EntityAI item) {}
602
604 {
605 return true;
606 }
607
609 {
610 Close();
611 }
612};
TODO doc.
Definition enscript.c:118
ScriptInvoker Class provide list of callbacks usage:
Definition tools.c:116
map: item x vector(index, width, height)
Definition enwidgets.c:657
Part of main menu hierarchy to create custom menus from script.
void UIScriptedMenu()
void InitMapItem(EntityAI item)
bool UseGamepad()
bool m_AnimAlphaIsIncreasing
proto native UIMenuPanel GetVisibleMenu()
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)
If visibility of application is changed. On console it is called when application is suspended or con...
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="")
void OnPlayerDeath()
proto native bool IsClosing()
bool OnKeyUp(Widget w, int x, int y, int key)
void SetWidgetAnimAlpha(Widget widget)
bool IsHandlingPlayerDeathEvent()
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()
Widget m_AnimAlphaWidget
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()
ScriptInvoker m_PlayerDeathInvoker
bool OnDoubleClick(Widget w, int x, int y, int button)
void SetID(int id)
Sets MenuID.
bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn)
ScriptedWidgetEventHandler GetContextMenu()
float m_AnimAlphaValue
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)
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()
Xbox menu.
Definition dayzgame.c:64
override bool UseKeyboard()
override bool UseMouse()
override bool IsHandlingPlayerDeathEvent()
Definition dayzgame.c:104
override bool UseGamepad()
static map< int, UIScriptedWindow > GetActiveWindows()
DayZGame g_Game
Definition dayzgame.c:3942
Serializer ParamsReadContext
Definition gameplay.c:15
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:173
TypeID EventType
Definition enwidgets.c:55
Icon x
Icon y
void Close()