DayZ 1.24
Loading...
Searching...
No Matches
UIScriptedMenu.c
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
3{
13
17
18#ifdef FEATURE_CURSOR
21#endif
22
26 {
27 }
28
31
32 bool UseMouse()
33 {
34#ifdef PLATFORM_CONSOLE
35 return GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer();
36#else
37 return true;
38#endif
39 }
40
42 {
43#ifdef PLATFORM_CONSOLE
44 return GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer();
45#else
46 return true;
47#endif
48 }
49
51 {
52 return true;
53 }
54
56 int GetID()
57 {
58 return MENU_UNKNOWN;
59 }
60
62 void Refresh()
63 {
64 }
65};
66
67//-----------------------------------------------------------------------------
69class UIScriptedMenu extends UIMenuPanel
70{
71 int m_id;
75 private float m_AnimAlphaValue;
76
78 {
79 return layoutRoot;
80 }
81
83 {
84#ifdef FEATURE_CURSOR
85 if (IsCreatedHidden())
86 return;
87#endif
88
89 if (UseMouse())
90 {
91 GetGame().GetInput().ChangeGameFocus(1, INPUT_DEVICE_MOUSE);
92 GetGame().GetUIManager().ShowUICursor(true);
93 }
94
95 if (UseKeyboard())
96 GetGame().GetInput().ChangeGameFocus(1, INPUT_DEVICE_KEYBOARD);
97
98 if (UseGamepad())
99 GetGame().GetInput().ChangeGameFocus(1, INPUT_DEVICE_GAMEPAD);
100 }
101
103 {
104#ifdef FEATURE_CURSOR
105 if (IsCreatedHidden())
106 return;
107#endif
108
109 if (UseMouse())
110 GetGame().GetInput().ChangeGameFocus(-1, INPUT_DEVICE_MOUSE);
111
112 if (GetParentMenu() && GetParentMenu().UseMouse())
113 GetGame().GetUIManager().ShowUICursor(true);
114 else
115 GetGame().GetUIManager().ShowUICursor(false);
116
117 if (UseKeyboard())
118 GetGame().GetInput().ChangeGameFocus(-1, INPUT_DEVICE_KEYBOARD);
119
120 if (UseGamepad())
121 GetGame().GetInput().ChangeGameFocus(-1, INPUT_DEVICE_GAMEPAD);
122 }
123
125 {
126 m_id = MENU_UNKNOWN;
127 }
128
130 {
131 }
132
134 void SetID(int id)
135 {
136 m_id = id;
137 }
138
140 override int GetID()
141 {
142 return m_id;
143 }
144
146 {
147 m_AnimAlphaValue = 0.3;
148 m_AnimAlphaWidget = widget;
149 }
150
151 //create widgets here and return layout root Widget
152 //widgets will be destroyed automatically by c++ side
154 {
155 return NULL;
156 }
157
158 void Cleanup()
159 {
160 }
161
162 //after show
163 void OnShow()
164 {
165 LockControls();
166 }
167
168 //after hide
169 void OnHide()
170 {
171 UnlockControls();
172 }
173
175 void Update(float timeslice)
176 {
177#ifdef PLATFORM_CONSOLE
178 if (m_AnimAlphaWidget)
179 {
180 float anim_speed = 1.2;
181 float anim_value_max = 1.0;
182 float anim_value_min = 0.3;
183 if (m_AnimAlphaIsIncreasing)
184 {
185 m_AnimAlphaValue += anim_speed * timeslice;
186
187 if (m_AnimAlphaValue >= anim_value_max)
188 {
189 m_AnimAlphaValue = anim_value_max;
190 m_AnimAlphaIsIncreasing = false;
191 }
192 }
193 else
194 {
195 m_AnimAlphaValue -= anim_speed * timeslice;
196
197 if (m_AnimAlphaValue <= anim_value_min)
198 {
199 m_AnimAlphaValue = anim_value_min;
200 m_AnimAlphaIsIncreasing = true;
201 }
202 }
203
204
205 m_AnimAlphaWidget.SetAlpha(m_AnimAlphaValue);
206 }
207#endif
208 }
209
210 // Moved to parent
212 //void Refresh()
213 //{
214 //}
215
217
218 bool OnClick(Widget w, int x, int y, int button)
219 {
221 {
222 for (int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++)
223 {
224 if (UIScriptedWindow.GetActiveWindows().GetElement(i).OnClick(w, x, y, button))
225 return true;
226 }
227 }
228
229 return false;
230 }
231 bool OnModalResult(Widget w, int x, int y, int code, int result)
232 {
234 {
235 for (int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++)
236 {
237 if (UIScriptedWindow.GetActiveWindows().GetElement(i).OnModalResult(w, x, y, code, result))
238 return true;
239 }
240 }
241
242 return false;
243 }
244 bool OnDoubleClick(Widget w, int x, int y, int button)
245 {
247 {
248 for (int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++)
249 {
250 if (UIScriptedWindow.GetActiveWindows().GetElement(i).OnDoubleClick(w, x, y, button))
251 return true;
252 }
253 }
254
255 return false;
256 }
257 bool OnSelect(Widget w, int x, int y)
258 {
260 {
261 for (int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++)
262 {
263 if (UIScriptedWindow.GetActiveWindows().GetElement(i).OnSelect(w, x, y))
264 return true;
265 }
266 }
267
268 return false;
269 }
270 bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn)
271 {
273 {
274 for (int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++)
275 {
276 if (UIScriptedWindow.GetActiveWindows().GetElement(i).OnItemSelected(w, x, y, row, column, oldRow, oldColumn))
277 return true;
278 }
279 }
280
281 return false;
282 }
283 bool OnFocus(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).OnFocus(w, x, y))
290 return true;
291 }
292 }
293
294 return false;
295 }
296 bool OnFocusLost(Widget w, int x, int y)
297 {
299 {
300 for (int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++)
301 {
302 if (UIScriptedWindow.GetActiveWindows().GetElement(i).OnFocusLost(w, x, y))
303 return true;
304 }
305 }
306
307 return false;
308 }
309 bool OnMouseEnter(Widget w, int x, int y)
310 {
312 {
313 for (int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++)
314 {
315 if (UIScriptedWindow.GetActiveWindows().GetElement(i).OnMouseEnter(w, x, y))
316 return true;
317 }
318 }
319
320 return false;
321 }
323 {
325 {
326 for (int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++)
327 {
328 if (UIScriptedWindow.GetActiveWindows().GetElement(i).OnMouseLeave(w, enterW, x, y))
329 return true;
330 }
331 }
332
333 return false;
334 }
335 bool OnMouseButtonDown(Widget w, int x, int y, int button)
336 {
338 {
339 for (int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++)
340 {
341 if (UIScriptedWindow.GetActiveWindows().GetElement(i).OnMouseButtonDown(w, x, y, button))
342 return true;
343 }
344 }
345
346 return false;
347 }
348 bool OnMouseButtonUp(Widget w, int x, int y, int button)
349 {
351 {
352 for (int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++)
353 {
354 if (UIScriptedWindow.GetActiveWindows().GetElement(i).OnMouseButtonUp(w, x, y, button))
355 return true;
356 }
357 }
358
359 return false;
360 }
361 bool OnMouseWheel(Widget w, int x, int y, int wheel)
362 {
364 {
365 for (int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++)
366 {
367 if (UIScriptedWindow.GetActiveWindows().GetElement(i).OnMouseWheel(w, x, y, wheel))
368 return true;
369 }
370 }
371
372 return false;
373 }
375 {
377 {
378 for (int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++)
379 {
380 if (UIScriptedWindow.GetActiveWindows().GetElement(i).OnController(w, control, value))
381 return true;
382 }
383 }
384
385 return false;
386 }
387 bool OnKeyDown(Widget w, int x, int y, int key)
388 {
390 {
391 for (int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++)
392 {
393 if (UIScriptedWindow.GetActiveWindows().GetElement(i).OnKeyDown(w, x, y, key))
394 return true;
395 }
396 }
397
398 return false;
399 }
400 bool OnKeyUp(Widget w, int x, int y, int key)
401 {
403 {
404 for (int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++)
405 {
406 if (UIScriptedWindow.GetActiveWindows().GetElement(i).OnKeyUp(w, x, y, key))
407 return true;
408 }
409 }
410
411 return false;
412 }
413 bool OnKeyPress(Widget w, int x, int y, int key)
414 {
416 {
417 for (int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++)
418 {
419 if (UIScriptedWindow.GetActiveWindows().GetElement(i).OnKeyPress(w, x, y, key))
420 return true;
421 }
422 }
423
424 return false;
425 }
426 bool OnChange(Widget w, int x, int y, bool finished)
427 {
429 {
430 for (int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++)
431 {
432 if (UIScriptedWindow.GetActiveWindows().GetElement(i).OnChange(w, x, y, finished))
433 return true;
434 }
435 }
436
437 return false;
438 }
439 bool OnDrag(Widget w, int x, int y)
440 {
442 {
443 for (int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++)
444 {
445 if (UIScriptedWindow.GetActiveWindows().GetElement(i).OnDrag(w, x, y))
446 return true;
447 }
448 }
449
450 return false;
451 }
453 {
455 {
456 for (int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++)
457 {
458 if (UIScriptedWindow.GetActiveWindows().GetElement(i).OnDragging(w, x, y, reciever))
459 return true;
460 }
461 }
462
463 return false;
464 }
466 {
468 {
469 for (int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++)
470 {
471 if (UIScriptedWindow.GetActiveWindows().GetElement(i).OnDraggingOver(w, x, y, reciever))
472 return true;
473 }
474 }
475
476 return false;
477 }
478 bool OnDrop(Widget w, int x, int y, Widget reciever)
479 {
481 {
482 for (int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++)
483 {
484 if (UIScriptedWindow.GetActiveWindows().GetElement(i).OnDrop(w, x, y, reciever))
485 return true;
486 }
487 }
488
489 return false;
490 }
492 {
494 {
495 for (int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++)
496 {
497 if (UIScriptedWindow.GetActiveWindows().GetElement(i).OnDropReceived(w, x, y, reciever))
498 return true;
499 }
500 }
501
502 return false;
503 }
504
506 {
508 {
509 for (int i = 0; i < UIScriptedWindow.GetActiveWindows().Count(); i++)
510 {
512 return true;
513 }
514 }
515
516 return false;
517 }
518
523
525 {
526 return true;
527 }
528
531
533 void InitNoteRead(string text = "") {}
536};
Icon x
Icon y
TODO doc.
Definition EnScript.c:118
map: item x vector(index, width, height)
Definition EnWidgets.c:651
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
Part of main menu hierarchy to create custom menus from script.
bool UseKeyboard()
void ~UIScriptedMenu()
proto native bool IsAnyMenuVisible()
bool OnDropReceived(Widget w, int x, int y, Widget reciever)
proto native UIMenuPanel GetVisibleMenu()
bool OnXboxEvent(int xboxEvent)
bool OnClick(Widget w, int x, int y, int button)
Widget layoutRoot
float m_AnimAlphaValue
proto native void SetParentMenu(UIMenuPanel parent)
bool OnDrag(Widget w, int x, int y)
void OnRPCEx(int rpc_type, ParamsReadContext ctx)
override int GetID()
Returns MenuID.
ScriptedWidgetEventHandler GetContextMenu()
proto native void SetSubMenu(UIMenuPanel submenu)
Widget m_AnimAlphaWidget
bool OnDrop(Widget w, int x, int y, Widget reciever)
proto native UIMenuPanel GetSubMenu()
void SetWidgetAnimAlpha(Widget widget)
void UnlockControls()
bool OnFocusLost(Widget w, int x, int y)
bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn)
proto native void DestroySubmenu()
bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
proto native void SetFadingPanels(Widget panel0, Widget panel1, Widget panel2, Widget panel3, Widget panel4)
Refresh request, called from anywhere.
void OnRPC(ParamsReadContext ctx)
void InitNoteRead(string text="")
bool OnKeyDown(Widget w, int x, int y, int key)
bool OnDoubleClick(Widget w, int x, int y, int button)
bool UseGamepad()
proto native bool IsVisible()
bool OnChange(Widget w, int x, int y, bool finished)
bool m_AnimAlphaIsIncreasing
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)
bool OnKeyUp(Widget w, int x, int y, int key)
bool OnFocus(Widget w, int x, int y)
bool OnDragging(Widget w, int x, int y, Widget reciever)
void Refresh()
Refresh request, called from anywhere.
bool OnController(Widget w, int control, int value)
void OnVisibilityChanged(bool isVisible)
void InitMapItem(EntityAI item)
proto native bool CanClose()
void LoadMapMarkers()
void InitNoteWrite(EntityAI paper, EntityAI pen, string text="")
int GetID()
Returns MenuID.
void UIScriptedMenu()
void Update(float timeslice)
Per frame update, called from engine.
bool OnMouseEnter(Widget w, int x, int y)
bool OnModalResult(Widget w, int x, int y, int code, int result)
bool OnEvent(EventType eventType, Widget target, int parameter0, int parameter1)
bool OnDraggingOver(Widget w, int x, int y, Widget reciever)
bool OnMouseWheel(Widget w, int x, int y, int wheel)
bool OnMouseButtonUp(Widget w, int x, int y, int button)
void LockControls()
proto native bool CanCloseOnEscape()
proto native UIMenuPanel GetParentMenu()
void SetID(int id)
Sets MenuID.
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)
bool OnKeyPress(Widget w, int x, int y, int key)
Widget GetLayoutRoot()
override bool UseMouse()
override bool UseGamepad()
override bool UseKeyboard()
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:163