DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
UIScriptedMenu.c
См. документацию.
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
18#ifdef FEATURE_CURSOR
20 proto native bool IsCreatedHidden();
21#endif
22
25 void OnVisibilityChanged(bool isVisible)
26 {
27 }
28
30 proto native void Close();
31
32 bool UseMouse() {
33 #ifdef PLATFORM_CONSOLE
35 #else
36 return true;
37 #endif
38 }
39
40 bool UseKeyboard() {
41 #ifdef PLATFORM_CONSOLE
43 #else
44 return true;
45 #endif
46 }
47
48 bool UseGamepad() {
49 return true;
50 }
51
53 int GetID() {
54 return MENU_UNKNOWN;
55 }
56
58 void Refresh()
59 {
60 }
61};
62
63//-----------------------------------------------------------------------------
65class UIScriptedMenu extends UIMenuPanel
66{
67 int m_id;
71 private float m_AnimAlphaValue;
72 private ScriptInvoker m_PlayerDeathInvoker; //DayZPlayer::GetOnDeathStart -> used to keep track of and ensure proper callback handling
73
75 {
76 return layoutRoot;
77 }
78
80 {
81#ifdef FEATURE_CURSOR
82 if (IsCreatedHidden())
83 return;
84#endif
85
86 if (UseMouse())
87 {
90 }
91
92 if (UseKeyboard())
93 {
95 }
96
97 if (UseGamepad())
98 {
100 }
101 }
102
104 {
105#ifdef FEATURE_CURSOR
106 if (IsCreatedHidden())
107 return;
108#endif
109
110 if (UseMouse())
111 {
113 }
114
116 {
118 }
119 else
120 {
122 }
123
124 if(UseKeyboard())
125 {
127 }
128
129 if(UseGamepad())
130 {
132 }
133 }
134
136 {
138 }
139
141 {
142 }
143
145 void SetID(int id) {
146 m_id = id;
147 }
148
150 override int GetID() {
151 return m_id;
152 }
153
155 {
156 m_AnimAlphaValue = 0.3;
157 m_AnimAlphaWidget = widget;
158 }
159
160 //create widgets here and return layout root Widget
161 //widgets will be destroyed automatically by c++ side
163 {
164 return NULL;
165 }
166
167 void Cleanup()
168 {
169 }
170
171 //after show
172 void OnShow()
173 {
174 LockControls();
175 if (IsHandlingPlayerDeathEvent() && g_Game && g_Game.GetPlayer())
176 {
177 m_PlayerDeathInvoker = g_Game.GetPlayer().GetOnDeathStart();
179 }
180 }
181
182 //after hide
183 void OnHide()
184 {
186 if (m_PlayerDeathInvoker) // Only ever registered while `IsHandlingPlayerDeathEvent`. Remove callback directly.
187 {
188 m_PlayerDeathInvoker.Remove( OnPlayerDeath, EScriptInvokerRemoveFlags.NONE );
190 }
191 }
192
194 void Update(float timeslice)
195 {
196 #ifdef PLATFORM_CONSOLE
197 if ( m_AnimAlphaWidget )
198 {
199 float anim_speed = 1.2;
200 float anim_value_max = 1.0;
201 float anim_value_min = 0.3;
203 {
204 m_AnimAlphaValue += anim_speed * timeslice;
205
206 if ( m_AnimAlphaValue >= anim_value_max )
207 {
208 m_AnimAlphaValue = anim_value_max;
210 }
211 }
212 else
213 {
214 m_AnimAlphaValue -= anim_speed * timeslice;
215
216 if ( m_AnimAlphaValue <= anim_value_min )
217 {
218 m_AnimAlphaValue = anim_value_min;
220 }
221 }
222
223
225 }
226 #endif
227 }
228
229 // Moved to parent
231 //void Refresh()
232 //{
233 //}
234
235 proto native void SetFadingPanels(Widget panel0, Widget panel1, Widget panel2, Widget panel3, Widget panel4);
236
237 bool OnClick(Widget w, int x, int y, int button)
238 {
240 {
241 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
242 {
243 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnClick( w, x, y, button ) )
244 {
245 return true;
246 }
247 }
248 }
249
250 return false;
251 }
252 bool OnModalResult(Widget w, int x, int y, int code, int result)
253 {
255 {
256 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
257 {
258 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnModalResult( w, x, y, code, result ) )
259 {
260 return true;
261 }
262 }
263 }
264
265 return false;
266 }
267 bool OnDoubleClick(Widget w, int x, int y, int button)
268 {
270 {
271 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
272 {
273 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnDoubleClick( w, x, y, button ) )
274 {
275 return true;
276 }
277 }
278 }
279
280 return false;
281 }
282 bool OnSelect(Widget w, int x, int y)
283 {
285 {
286 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
287 {
288 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnSelect( w, x, y ) )
289 {
290 return true;
291 }
292 }
293 }
294
295 return false;
296 }
297 bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn)
298 {
300 {
301 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
302 {
303 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnItemSelected( w, x, y, row, column, oldRow, oldColumn ) )
304 {
305 return true;
306 }
307 }
308 }
309
310 return false;
311 }
312 bool OnFocus(Widget w, int x, int y)
313 {
315 {
316 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
317 {
318 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnFocus( w, x, y ) )
319 {
320 return true;
321 }
322 }
323 }
324
325 return false;
326 }
327 bool OnFocusLost(Widget w, int x, int y)
328 {
330 {
331 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
332 {
333 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnFocusLost( w, x, y ) )
334 {
335 return true;
336 }
337 }
338 }
339
340 return false;
341 }
342 bool OnMouseEnter(Widget w, int x, int y)
343 {
345 {
346 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
347 {
348 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnMouseEnter( w, x, y ) )
349 {
350 return true;
351 }
352 }
353 }
354
355 return false;
356 }
357 bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
358 {
360 {
361 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
362 {
363 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnMouseLeave( w, enterW, x, y ) )
364 {
365 return true;
366 }
367 }
368 }
369
370 return false;
371 }
372 bool OnMouseButtonDown(Widget w, int x, int y, int button)
373 {
375 {
376 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
377 {
378 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnMouseButtonDown( w, x, y, button ) )
379 {
380 return true;
381 }
382 }
383 }
384
385 return false;
386 }
387 bool OnMouseButtonUp(Widget w, int x, int y, int button)
388 {
390 {
391 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
392 {
393 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnMouseButtonUp( w, x, y, button ) )
394 {
395 return true;
396 }
397 }
398 }
399
400 return false;
401 }
402 bool OnMouseWheel(Widget w, int x, int y, int wheel)
403 {
405 {
406 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
407 {
408 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnMouseWheel( w, x, y, wheel ) )
409 {
410 return true;
411 }
412 }
413 }
414
415 return false;
416 }
417 bool OnController(Widget w, int control, int value)
418 {
420 {
421 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
422 {
423 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnController( w, control, value ) )
424 {
425 return true;
426 }
427 }
428 }
429
430 return false;
431 }
432 bool OnKeyDown(Widget w, int x, int y, int key)
433 {
435 {
436 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
437 {
438 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnKeyDown( w, x, y, key ) )
439 {
440 return true;
441 }
442 }
443 }
444
445 return false;
446 }
447 bool OnKeyUp(Widget w, int x, int y, int key)
448 {
450 {
451 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
452 {
453 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnKeyUp( w, x, y, key ) )
454 {
455 return true;
456 }
457 }
458 }
459
460 return false;
461 }
462 bool OnKeyPress(Widget w, int x, int y, int key)
463 {
465 {
466 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
467 {
468 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnKeyPress( w, x, y, key ) )
469 {
470 return true;
471 }
472 }
473 }
474
475 return false;
476 }
477 bool OnChange(Widget w, int x, int y, bool finished)
478 {
480 {
481 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
482 {
483 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnChange( w, x, y, finished ) )
484 {
485 return true;
486 }
487 }
488 }
489
490 return false;
491 }
492 bool OnDrag(Widget w, int x, int y)
493 {
495 {
496 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
497 {
498 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnDrag( w, x, y ) )
499 {
500 return true;
501 }
502 }
503 }
504
505 return false;
506 }
507 bool OnDragging(Widget w, int x, int y, Widget reciever)
508 {
510 {
511 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
512 {
513 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnDragging( w, x, y, reciever ) )
514 {
515 return true;
516 }
517 }
518 }
519
520 return false;
521 }
522 bool OnDraggingOver(Widget w, int x, int y, Widget reciever)
523 {
525 {
526 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
527 {
528 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnDraggingOver( w, x, y, reciever ) )
529 {
530 return true;
531 }
532 }
533 }
534
535 return false;
536 }
537 bool OnDrop(Widget w, int x, int y, Widget reciever)
538 {
540 {
541 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
542 {
543 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnDrop( w, x, y, reciever ) )
544 {
545 return true;
546 }
547 }
548 }
549
550 return false;
551 }
552 bool OnDropReceived(Widget w, int x, int y, Widget reciever)
553 {
555 {
556 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
557 {
558 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnDropReceived( w, x, y, reciever ) )
559 {
560 return true;
561 }
562 }
563 }
564
565 return false;
566 }
567
568 bool OnEvent(EventType eventType, Widget target, int parameter0, int parameter1)
569 {
571 {
572 for ( int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++ )
573 {
574 if ( UIScriptedWindow.GetActiveWindows().GetElement( i ).OnEvent( eventType, target, parameter0, parameter1 ) )
575 {
576 return true;
577 }
578 }
579 }
580
581 return false;
582 }
583
585 {
586 return null;
587 }
588
589 bool OnXboxEvent(int xboxEvent)
590 {
591 return true;
592 }
593
595 void OnRPCEx(int rpc_type, ParamsReadContext ctx){}
596
597 void InitNoteWrite(EntityAI paper, EntityAI pen, string text = "") {}
598 void InitNoteRead(string text = "") {}
599 void InitMapItem(EntityAI item) {}
601
603 {
604 return true;
605 }
606
608 {
609 Close();
610 }
611};
DayZGame g_Game
Определения DayZGame.c:3868
Icon x
Icon y
void Close()
@ Count
Определения RandomGeneratorSyncManager.c:8
proto native UIManager GetUIManager()
proto native Input GetInput()
Определения Building.c:6
proto native void ChangeGameFocus(int add, int input_device=-1)
Change game focus number.
proto native bool IsEnabledMouseAndKeyboardEvenOnServer()
TODO doc.
Определения EnScript.c:118
ScriptInvoker Class provide list of callbacks usage:
Определения tools.c:116
map: item x vector(index, width, height)
Определения EnWidgets.c:651
void ShowUICursor(bool visible)
Определения UIManager.c:244
bool UseKeyboard()
Определения UIScriptedMenu.c:40
void ~UIScriptedMenu()
Определения UIScriptedMenu.c:140
proto native bool IsAnyMenuVisible()
bool OnDropReceived(Widget w, int x, int y, Widget reciever)
Определения UIScriptedMenu.c:552
proto native UIMenuPanel GetVisibleMenu()
bool OnXboxEvent(int xboxEvent)
Определения UIScriptedMenu.c:589
bool OnClick(Widget w, int x, int y, int button)
Определения UIScriptedMenu.c:237
Widget layoutRoot
Определения UIScriptedMenu.c:68
float m_AnimAlphaValue
Определения UIScriptedMenu.c:71
proto native void SetParentMenu(UIMenuPanel parent)
bool OnDrag(Widget w, int x, int y)
Определения UIScriptedMenu.c:492
void OnRPCEx(int rpc_type, ParamsReadContext ctx)
Определения UIScriptedMenu.c:595
override int GetID()
Returns MenuID.
Определения UIScriptedMenu.c:150
Widget Init()
Определения UIScriptedMenu.c:162
ScriptedWidgetEventHandler GetContextMenu()
Определения UIScriptedMenu.c:584
proto native void SetSubMenu(UIMenuPanel submenu)
Widget m_AnimAlphaWidget
Определения UIScriptedMenu.c:69
bool OnDrop(Widget w, int x, int y, Widget reciever)
Определения UIScriptedMenu.c:537
void OnHide()
Определения UIScriptedMenu.c:183
proto native UIMenuPanel GetSubMenu()
void SetWidgetAnimAlpha(Widget widget)
Определения UIScriptedMenu.c:154
void UnlockControls()
Определения UIScriptedMenu.c:103
int m_id
Определения UIScriptedMenu.c:67
bool IsHandlingPlayerDeathEvent()
Определения UIScriptedMenu.c:602
bool OnFocusLost(Widget w, int x, int y)
Определения UIScriptedMenu.c:327
bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn)
Определения UIScriptedMenu.c:297
proto native void DestroySubmenu()
bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Определения UIScriptedMenu.c:357
ScriptInvoker m_PlayerDeathInvoker
Определения UIScriptedMenu.c:72
proto native void SetFadingPanels(Widget panel0, Widget panel1, Widget panel2, Widget panel3, Widget panel4)
Refresh request, called from anywhere.
bool UseMouse()
Определения UIScriptedMenu.c:32
void OnRPC(ParamsReadContext ctx)
Определения UIScriptedMenu.c:594
void InitNoteRead(string text="")
Определения UIScriptedMenu.c:598
bool OnKeyDown(Widget w, int x, int y, int key)
Определения UIScriptedMenu.c:432
bool OnDoubleClick(Widget w, int x, int y, int button)
Определения UIScriptedMenu.c:267
bool UseGamepad()
Определения UIScriptedMenu.c:48
proto native bool IsVisible()
bool OnChange(Widget w, int x, int y, bool finished)
Определения UIScriptedMenu.c:477
bool m_AnimAlphaIsIncreasing
Определения UIScriptedMenu.c:70
proto native UIScriptedMenu EnterScriptedMenu(int id)
Create & open menu with specific id (see MenuID) and set this menu as its parent.
bool OnSelect(Widget w, int x, int y)
Определения UIScriptedMenu.c:282
bool OnKeyUp(Widget w, int x, int y, int key)
Определения UIScriptedMenu.c:447
bool OnFocus(Widget w, int x, int y)
Определения UIScriptedMenu.c:312
bool OnDragging(Widget w, int x, int y, Widget reciever)
Определения UIScriptedMenu.c:507
void Refresh()
Refresh request, called from anywhere.
Определения UIScriptedMenu.c:58
void Cleanup()
Определения UIScriptedMenu.c:167
bool OnController(Widget w, int control, int value)
Определения UIScriptedMenu.c:417
void OnVisibilityChanged(bool isVisible)
Определения UIScriptedMenu.c:25
void InitMapItem(EntityAI item)
Определения UIScriptedMenu.c:599
proto native bool CanClose()
void LoadMapMarkers()
Определения UIScriptedMenu.c:600
void InitNoteWrite(EntityAI paper, EntityAI pen, string text="")
Определения UIScriptedMenu.c:597
int GetID()
Returns MenuID.
Определения UIScriptedMenu.c:53
void UIScriptedMenu()
Определения UIScriptedMenu.c:135
void Update(float timeslice)
Per frame update, called from engine.
Определения UIScriptedMenu.c:194
bool OnMouseEnter(Widget w, int x, int y)
Определения UIScriptedMenu.c:342
bool OnModalResult(Widget w, int x, int y, int code, int result)
Определения UIScriptedMenu.c:252
void OnShow()
Определения UIScriptedMenu.c:172
bool OnEvent(EventType eventType, Widget target, int parameter0, int parameter1)
Определения UIScriptedMenu.c:568
bool OnDraggingOver(Widget w, int x, int y, Widget reciever)
Определения UIScriptedMenu.c:522
bool OnMouseWheel(Widget w, int x, int y, int wheel)
Определения UIScriptedMenu.c:402
bool OnMouseButtonUp(Widget w, int x, int y, int button)
Определения UIScriptedMenu.c:387
void LockControls()
Определения UIScriptedMenu.c:79
proto native bool CanCloseOnEscape()
proto native UIMenuPanel GetParentMenu()
void OnPlayerDeath()
Определения UIScriptedMenu.c:607
void SetID(int id)
Sets MenuID.
Определения UIScriptedMenu.c:145
proto native void Close()
Safe way to close window, using this function can even window safely close itself.
bool OnMouseButtonDown(Widget w, int x, int y, int button)
Определения UIScriptedMenu.c:372
bool OnKeyPress(Widget w, int x, int y, int key)
Определения UIScriptedMenu.c:462
Widget GetLayoutRoot()
Определения UIScriptedMenu.c:74
Part of main menu hierarchy to create custom menus from script.
Определения UIScriptedMenu.c:3
override bool IsHandlingPlayerDeathEvent()
Определения DayZGame.c:104
override bool UseMouse()
Определения GesturesMenu.c:274
override bool UseGamepad()
Определения GesturesMenu.c:279
override bool UseKeyboard()
Определения ChatInputMenu.c:24
Определения DayZGame.c:64
static map< int, UIScriptedWindow > GetActiveWindows()
Определения UIScriptedWindow.c:37
Определения EnWidgets.c:190
Serializer ParamsReadContext
Определения gameplay.c:15
proto native CGame GetGame()
const int INPUT_DEVICE_MOUSE
Определения constants.c:24
const int INPUT_DEVICE_GAMEPAD
Определения constants.c:28
const int INPUT_DEVICE_KEYBOARD
Определения constants.c:23
const int MENU_UNKNOWN
Определения constants.c:173
TypeID EventType
Определения EnWidgets.c:55