Dayz Explorer 1.28.160049
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 GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer();
36 #else
37 return true;
38 #endif
39 }
40
41 bool UseKeyboard() {
42 #ifdef PLATFORM_CONSOLE
43 return GetGame().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;
69 Widget layoutRoot;
70 private Widget m_AnimAlphaWidget;
71 private bool m_AnimAlphaIsIncreasing;
72 private float m_AnimAlphaValue;
73 private ScriptInvoker m_PlayerDeathInvoker; //DayZPlayer::GetOnDeathStart -> used to keep track of and ensure proper callback handling
74
75 Widget GetLayoutRoot()
76 {
77 return layoutRoot;
78 }
79
80 void LockControls()
81 {
82#ifdef FEATURE_CURSOR
83 if (IsCreatedHidden())
84 return;
85#endif
86
87 if (UseMouse())
88 {
89 GetGame().GetInput().ChangeGameFocus(1, INPUT_DEVICE_MOUSE);
90 GetGame().GetUIManager().ShowUICursor(true);
91 }
92
93 if (UseKeyboard())
94 {
95 GetGame().GetInput().ChangeGameFocus(1, INPUT_DEVICE_KEYBOARD);
96 }
97
98 if (UseGamepad())
99 {
100 GetGame().GetInput().ChangeGameFocus(1, INPUT_DEVICE_GAMEPAD);
101 }
102 }
103
104 void UnlockControls()
105 {
106#ifdef FEATURE_CURSOR
107 if (IsCreatedHidden())
108 return;
109#endif
110
111 if (UseMouse())
112 {
113 GetGame().GetInput().ChangeGameFocus(-1, INPUT_DEVICE_MOUSE);
114 }
115
116 if (GetParentMenu() && GetParentMenu().UseMouse())
117 {
118 GetGame().GetUIManager().ShowUICursor(true);
119 }
120 else
121 {
122 GetGame().GetUIManager().ShowUICursor(false);
123 }
124
125 if(UseKeyboard())
126 {
127 GetGame().GetInput().ChangeGameFocus(-1, INPUT_DEVICE_KEYBOARD);
128 }
129
130 if(UseGamepad())
131 {
132 GetGame().GetInput().ChangeGameFocus(-1, INPUT_DEVICE_GAMEPAD);
133 }
134 }
135
136 void UIScriptedMenu()
137 {
138 m_id = MENU_UNKNOWN;
139 }
140
141 void ~UIScriptedMenu()
142 {
143 }
144
146 void SetID(int id) {
147 m_id = id;
148 }
149
151 override int GetID() {
152 return m_id;
153 }
154
155 void SetWidgetAnimAlpha( Widget widget )
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
163 Widget Init()
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();
179 m_PlayerDeathInvoker.Insert( OnPlayerDeath );
180 }
181 }
182
183 //after hide
184 void OnHide()
185 {
186 UnlockControls();
187 if (m_PlayerDeathInvoker) // Only ever registered while `IsHandlingPlayerDeathEvent`. Remove callback directly.
188 {
189 m_PlayerDeathInvoker.Remove( OnPlayerDeath, EScriptInvokerRemoveFlags.NONE );
190 m_PlayerDeathInvoker = null;
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;
203 if ( m_AnimAlphaIsIncreasing )
204 {
205 m_AnimAlphaValue += anim_speed * timeslice;
206
207 if ( m_AnimAlphaValue >= anim_value_max )
208 {
209 m_AnimAlphaValue = anim_value_max;
210 m_AnimAlphaIsIncreasing = false;
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;
220 m_AnimAlphaIsIncreasing = true;
221 }
222 }
223
224
225 m_AnimAlphaWidget.SetAlpha( m_AnimAlphaValue );
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 {
240 if ( UIScriptedWindow.GetActiveWindows() )
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 {
255 if ( UIScriptedWindow.GetActiveWindows() )
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 {
270 if ( UIScriptedWindow.GetActiveWindows() )
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 {
285 if ( UIScriptedWindow.GetActiveWindows() )
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 {
300 if ( UIScriptedWindow.GetActiveWindows() )
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 {
315 if ( UIScriptedWindow.GetActiveWindows() )
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 {
330 if ( UIScriptedWindow.GetActiveWindows() )
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 {
345 if ( UIScriptedWindow.GetActiveWindows() )
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 {
360 if ( UIScriptedWindow.GetActiveWindows() )
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 {
375 if ( UIScriptedWindow.GetActiveWindows() )
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 {
390 if ( UIScriptedWindow.GetActiveWindows() )
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 {
405 if ( UIScriptedWindow.GetActiveWindows() )
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 {
420 if ( UIScriptedWindow.GetActiveWindows() )
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 {
435 if ( UIScriptedWindow.GetActiveWindows() )
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 {
450 if ( UIScriptedWindow.GetActiveWindows() )
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 {
465 if ( UIScriptedWindow.GetActiveWindows() )
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 {
480 if ( UIScriptedWindow.GetActiveWindows() )
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 {
495 if ( UIScriptedWindow.GetActiveWindows() )
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 {
510 if ( UIScriptedWindow.GetActiveWindows() )
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 {
525 if ( UIScriptedWindow.GetActiveWindows() )
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 {
540 if ( UIScriptedWindow.GetActiveWindows() )
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 {
555 if ( UIScriptedWindow.GetActiveWindows() )
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 {
571 if ( UIScriptedWindow.GetActiveWindows() )
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
585 ScriptedWidgetEventHandler GetContextMenu()
586 {
587 return null;
588 }
589
590 bool OnXboxEvent(int xboxEvent)
591 {
592 return true;
593 }
594
595 void OnRPC(ParamsReadContext ctx){}
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) {}
601 void LoadMapMarkers() {}
602
604 {
605 return true;
606 }
607
608 void OnPlayerDeath()
609 {
610 Close();
611 }
612};
TODO doc.
Definition enscript.c:118
ScriptInvoker Class provide list of callbacks usage:
Definition tools.c:116
Serialization general interface. Serializer API works with:
Definition serializer.c:56
Part of main menu hierarchy to create custom menus from script.
override bool OnMouseEnter(Widget w, int x, int y)
override void OnShow()
override bool OnFocus(Widget w, int x, int y)
override void Update(float timeslice)
Definition dayzgame.c:69
override void OnRPCEx(int rpc_type, ParamsReadContext ctx)
override void LoadMapMarkers()
Definition mapmenu.c:322
override bool IsHandlingPlayerDeathEvent()
Definition dayzgame.c:104
override bool UseMouse()
override void InitMapItem(EntityAI item)
Definition mapmenu.c:168
override bool OnKeyPress(Widget w, int x, int y, int key)
override void OnHide()
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
override bool OnFocusLost(Widget w, int x, int y)
override bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
override bool OnKeyDown(Widget w, int x, int y, int key)
override bool OnMouseButtonDown(Widget w, int x, int y, int button)
override bool UseGamepad()
override void InitNoteRead(string text="")
Definition notemenu.c:39
override Widget Init()
Definition bookmenu.c:11
override bool OnClick(Widget w, int x, int y, int button)
Definition bookmenu.c:34
override bool OnModalResult(Widget w, int x, int y, int code, int result)
Definition ingamemenu.c:262
override void InitNoteWrite(EntityAI paper, EntityAI pen, string text="")
Definition notemenu.c:62
override bool OnController(Widget w, int control, int value)
override void OnEvent(EventType eventTypeId, Param params)
Handles VON-related events.
DayZGame g_Game
Definition dayzgame.c:3868
int GetID()
Get the ID registered in SEffectManager.
Definition effect.c:561
void SetID(int id)
Set the ID registered in SEffectManager.
Definition effect.c:552
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:173
TypeID EventType
Definition enwidgets.c:55
Icon x
Icon y
override ContextMenu GetContextMenu()
void Close()
override void OnRPC(ParamsReadContext ctx)
void Cleanup()
Definition ppemanager.c:70