Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
optionsmenu.c
Go to the documentation of this file.
1
class
OptionsMenu
extends
UIScriptedMenu
2
{
3
const
int
MODAL_ID_DEFAULT = 100;
4
const
int
DIALOG_TAB_OFFSET
= 1400;
5
6
protected
TabberUI
m_Tabber
;
7
protected
ref OptionsMenuGame
m_GameTab
;
8
protected
ref OptionsMenuSounds
m_SoundsTab
;
9
protected
ref OptionsMenuVideo
m_VideoTab
;
10
protected
ref OptionsMenuControls
m_ControlsTab
;
11
12
protected
ref
GameOptions
m_Options
;
13
14
protected
ButtonWidget
m_Apply
;
15
protected
ButtonWidget
m_Back
;
16
protected
ButtonWidget
m_Reset
;
//undo
17
protected
ButtonWidget
m_Defaults
;
//defaults
18
19
protected
Widget
m_Details
;
20
protected
TextWidget
m_Version
;
21
22
protected
int
m_ActiveTabIdx
= 0;
23
protected
bool
m_ModalLock
;
24
protected
bool
m_CanApplyOrReset
;
25
protected
bool
m_CanToggle
;
26
27
#ifdef PLATFORM_MSSTORE
28
protected
ButtonWidget m_GamepadControls;
29
protected
ButtonWidget m_KeyboardBindings;
30
#endif
31
32
void
OptionsMenu
()
33
{
34
35
}
36
37
override
Widget
Init
()
38
{
39
m_Options
=
new
GameOptions
();
40
41
#ifdef PLATFORM_MSSTORE
42
layoutRoot =
g_Game
.GetWorkspace().CreateWidgets(
"gui/layouts/new_ui/options/msstore/options_menu.layout"
, null);
43
#else
44
#ifdef PLATFORM_XBOX
45
layoutRoot =
g_Game
.GetWorkspace().CreateWidgets(
"gui/layouts/new_ui/options/xbox/options_menu.layout"
, null);
46
#else
47
#ifdef PLATFORM_PS4
48
layoutRoot =
g_Game
.GetWorkspace().CreateWidgets(
"gui/layouts/new_ui/options/ps/options_menu.layout"
, null);
49
#else
50
#ifdef PLATFORM_WINDOWS
51
layoutRoot =
g_Game
.GetWorkspace().CreateWidgets(
"gui/layouts/new_ui/options/pc/options_menu.layout"
, null);
52
#endif
53
#endif
54
#endif
55
#endif
56
57
layoutRoot.FindAnyWidget(
"Tabber"
).GetScript(
m_Tabber
);
58
59
m_Details
= layoutRoot.FindAnyWidget(
"settings_details"
);
60
m_Version
=
TextWidget
.Cast(layoutRoot.FindAnyWidget(
"version"
));
61
62
m_GameTab
=
new
OptionsMenuGame(layoutRoot.FindAnyWidget(
"Tab_0"
),
m_Details
,
m_Options
,
this
);
63
m_SoundsTab
=
new
OptionsMenuSounds(layoutRoot.FindAnyWidget(
"Tab_1"
),
m_Details
,
m_Options
,
this
);
64
65
#ifdef PLATFORM_MSSTORE
66
m_VideoTab
=
new
OptionsMenuVideo(layoutRoot.FindAnyWidget(
"Tab_2"
),
m_Details
,
m_Options
,
this
);
67
m_ControlsTab
=
new
OptionsMenuControls(layoutRoot.FindAnyWidget(
"Tab_3"
),
m_Details
,
m_Options
,
this
);
68
m_GamepadControls = ButtonWidget.Cast(layoutRoot.FindAnyWidget(
"gamepad_controls"
));
69
m_KeyboardBindings = ButtonWidget.Cast(layoutRoot.FindAnyWidget(
"keyboard_bindings"
));
70
#else
71
#ifdef PLATFORM_XBOX
72
m_ControlsTab
=
new
OptionsMenuControls(layoutRoot.FindAnyWidget(
"Tab_2"
),
m_Details
,
m_Options
,
this
);
73
#else
74
m_VideoTab
=
new
OptionsMenuVideo(layoutRoot.FindAnyWidget(
"Tab_2"
),
m_Details
,
m_Options
,
this
);
75
m_ControlsTab
=
new
OptionsMenuControls(layoutRoot.FindAnyWidget(
"Tab_3"
),
m_Details
,
m_Options
,
this
);
76
#endif
77
#endif
78
79
m_Apply
= ButtonWidget.Cast(layoutRoot.FindAnyWidget(
"apply"
));
80
m_Back
= ButtonWidget.Cast(layoutRoot.FindAnyWidget(
"back"
));
81
m_Reset
= ButtonWidget.Cast(layoutRoot.FindAnyWidget(
"reset"
));
82
m_Defaults
= ButtonWidget.Cast(layoutRoot.FindAnyWidget(
"defaults"
));
83
84
m_ModalLock
=
false
;
85
m_CanApplyOrReset
=
false
;
86
m_CanToggle
=
false
;
87
88
string
version;
89
g_Game
.GetVersion(version);
90
#ifdef PLATFORM_CONSOLE
91
version =
"#main_menu_version"
+
" "
+ version +
" ("
+
g_Game
.GetDatabaseID() +
")"
;
92
#else
93
version =
"#main_menu_version"
+
" "
+ version;
94
#endif
95
m_Version
.SetText(version);
96
97
#ifdef PLATFORM_WINDOWS
98
SetFocus
(layoutRoot);
99
#else
100
ToggleFocus
();
101
#endif
102
103
m_Tabber
.m_OnTabSwitch.Insert(
OnTabSwitch
);
104
m_Tabber
.m_OnAttemptTabSwitch.Insert(
OnAttemptTabSwitch
);
105
106
g_Game
.GetMission().GetOnInputPresetChanged().Insert(
OnInputPresetChanged
);
107
g_Game
.GetMission().GetOnInputDeviceChanged().Insert(
OnInputDeviceChanged
);
108
OnChanged
();
109
110
return
layoutRoot;
111
}
112
113
void
~OptionsMenu
()
114
{
115
}
116
117
protected
void
OnInputPresetChanged
()
118
{
119
#ifdef PLATFORM_CONSOLE
120
UpdateControlsElementVisibility
();
121
#endif
122
}
123
124
protected
void
OnInputDeviceChanged
(
EInputDeviceType
pInputDeviceType)
125
{
126
#ifdef PLATFORM_CONSOLE
127
bool
mk =
g_Game
.GetInput().IsEnabledMouseAndKeyboard();
128
bool
mkServer =
g_Game
.GetInput().IsEnabledMouseAndKeyboardEvenOnServer();
129
130
switch
(pInputDeviceType)
131
{
132
case
EInputDeviceType
.CONTROLLER:
133
if
(mk && mkServer)
134
{
135
g_Game
.GetUIManager().ShowUICursor(
false
);
136
}
137
break
;
138
139
default
:
140
if
(mk && mkServer)
141
{
142
g_Game
.GetUIManager().ShowUICursor(
true
);
143
}
144
break
;
145
}
146
147
UpdateControlsElementVisibility
();
148
#endif
149
}
150
151
override
bool
OnClick
(
Widget
w,
int
x
,
int
y
,
int
button)
152
{
153
if
(button ==
MouseState
.LEFT)
154
{
155
switch
(w)
156
{
157
#ifdef PLATFORM_MSSTORE
158
case
m_GamepadControls:
159
{
160
EnterScriptedMenu(
MENU_XBOX_CONTROLS
);
161
return
true
;
162
}
163
164
case
m_KeyboardBindings:
165
{
166
EnterScriptedMenu(
MENU_KEYBINDINGS
);
167
return
true
;
168
}
169
#endif
170
171
case
m_Apply
:
172
{
173
Apply
();
174
return
true
;
175
}
176
case
m_Back
:
177
{
178
Back
();
179
return
true
;
180
}
181
case
m_Reset
:
182
{
183
ResetCurrentTab
();
184
return
true
;
185
}
186
case
m_Defaults
:
187
{
188
//SetToDefaults();
189
PerformSetToDefaults
();
190
return
true
;
191
}
192
}
193
}
194
return
false
;
195
}
196
197
void
OnTabSwitch
(
int
tab)
198
{
199
switch
(tab)
200
{
201
case
0:
202
{
203
m_GameTab
.Focus();
204
break
;
205
}
206
case
1:
207
{
208
m_SoundsTab
.Focus();
209
break
;
210
}
211
case
2:
212
{
213
#ifdef PLATFORM_XBOX
214
m_ControlsTab
.Focus();
215
#else
216
m_VideoTab
.Focus();
217
#endif
218
break
;
219
}
220
case
3:
221
{
222
#ifndef PLATFORM_XBOX
223
m_ControlsTab
.Focus();
224
#endif
225
break
;
226
}
227
}
228
229
m_ActiveTabIdx
= tab;
230
}
231
232
void
Apply
()
233
{
234
if
(
m_ControlsTab
.IsChanged())
235
m_ControlsTab
.Apply();
236
237
if
(
m_SoundsTab
.IsChanged())
238
m_SoundsTab
.Apply();
239
240
if
(
m_GameTab
.IsChanged())
241
m_GameTab
.Apply();
242
243
if
(
m_Options
.IsChanged() ||
m_GameTab
.IsChanged())
244
{
245
m_Options
.Test();
246
m_Options
.Apply();
247
}
248
249
// save input configuration
250
GetUApi
().
Export
();
251
252
if
(
g_Game
.GetInput().IsEnabledMouseAndKeyboard())
//useless on consoles
253
{
254
m_Apply
.SetFlags(
WidgetFlags
.IGNOREPOINTER);
255
ColorDisable
(
m_Apply
);
256
m_Reset
.SetFlags(
WidgetFlags
.IGNOREPOINTER);
257
ColorDisable
(
m_Reset
);
258
}
259
260
m_CanApplyOrReset
=
false
;
261
#ifdef PLATFORM_CONSOLE
262
UpdateControlsElements
();
263
UpdateControlsElementVisibility
();
264
265
IngameHud hud;
266
if
(
g_Game
.GetMission() &&
Class
.
CastTo
(hud,
g_Game
.GetMission().GetHud()))
267
{
268
hud.ShowQuickBar(
g_Game
.GetInput().IsEnabledMouseAndKeyboardEvenOnServer());
269
}
270
#endif
271
272
if
(
m_Options
.NeedRestart())
273
g_Game
.GetUIManager().ShowDialog(
"#main_menu_configure"
,
"#menu_restart_needed"
, 117, DBT_YESNO, DBB_YES, DMT_QUESTION,
this
);
274
}
275
276
void
Back
()
277
{
278
if
(!
g_Game
.GetUIManager().IsDialogVisible() && !
g_Game
.GetUIManager().IsModalVisible())
279
{
280
if
(
IsAnyTabChanged
())
281
{
282
g_Game
.GetUIManager().ShowDialog(
"#main_menu_configure"
,
"#main_menu_configure_desc"
, 1337, DBT_YESNO, DBB_YES, DMT_QUESTION,
this
);
283
#ifdef PLATFORM_CONSOLE
284
UpdateControlsElements
();
285
#endif
286
}
287
else
288
{
289
m_Options
.Revert();
290
g_Game
.EndOptionsVideo();
291
g_Game
.GetUIManager().Back();
292
}
293
}
294
}
295
296
void
OnAttemptTabSwitch
(
int
source,
int
target)
297
{
298
bool
changed =
IsAnyTabChanged
();
299
if
(changed)
300
{
301
if
(!
g_Game
.GetUIManager().IsDialogVisible() && !
g_Game
.GetUIManager().IsModalVisible())
302
{
303
int
id
= target +
DIALOG_TAB_OFFSET
;
304
g_Game
.GetUIManager().ShowDialog(
"#main_menu_configure"
,
"#main_menu_configure_desc"
,
id
, DBT_YESNO, DBB_YES, DMT_QUESTION,
this
);
305
#ifdef PLATFORM_CONSOLE
306
UpdateControlsElements
();
307
#endif
308
}
309
}
310
else
311
{
312
ResetCurrentTab
();
313
}
314
315
m_Tabber
.SetCanSwitch(!changed);
316
}
317
318
bool
IsAnyTabChanged
()
319
{
320
bool
changed = (
m_Options
.IsChanged() ||
m_GameTab
.IsChanged() ||
m_SoundsTab
.IsChanged() ||
m_ControlsTab
.IsChanged());
321
#ifndef PLATFORM_XBOX
322
changed |=
m_VideoTab
.IsChanged();
323
#endif
324
325
return
changed;
326
}
327
328
void
OnChanged
()
329
{
330
bool
changed =
IsAnyTabChanged
();
331
332
if
(
g_Game
.GetInput().IsEnabledMouseAndKeyboard())
333
{
334
if
(changed)
335
{
336
m_Reset
.ClearFlags(
WidgetFlags
.IGNOREPOINTER);
337
ColorNormal
(
m_Reset
);
338
m_Apply
.ClearFlags(
WidgetFlags
.IGNOREPOINTER);
339
ColorNormal
(
m_Apply
);
340
}
341
else
342
{
343
m_Apply
.SetFlags(
WidgetFlags
.IGNOREPOINTER);
344
ColorDisable
(
m_Apply
);
345
m_Reset
.SetFlags(
WidgetFlags
.IGNOREPOINTER);
346
ColorDisable
(
m_Reset
);
347
}
348
}
349
350
m_CanApplyOrReset
= changed;
351
#ifdef PLATFORM_CONSOLE
352
UpdateControlsElements
();
353
UpdateControlsElementVisibility
();
354
#endif
355
356
m_Tabber
.AlignTabbers();
357
}
358
359
//resets it all
360
void
Reset
()
361
{
362
m_Options
.Revert();
363
m_GameTab
.Revert();
364
m_SoundsTab
.Revert();
365
m_ControlsTab
.Revert();
366
#ifndef PLATFORM_XBOX
367
m_VideoTab
.Revert();
368
#endif
369
370
if
(
m_Options
.IsChanged())
371
m_Options
.Revert();
372
373
if
(
g_Game
.GetInput().IsEnabledMouseAndKeyboard())
374
{
375
m_Apply
.SetFlags(
WidgetFlags
.IGNOREPOINTER);
376
ColorDisable
(
m_Apply
);
377
m_Reset
.SetFlags(
WidgetFlags
.IGNOREPOINTER);
378
ColorDisable
(
m_Reset
);
379
}
380
381
m_CanApplyOrReset
=
false
;
382
#ifdef PLATFORM_CONSOLE
383
UpdateControlsElements
();
384
UpdateControlsElementVisibility
();
385
#endif
386
}
387
388
void
ResetCurrentTab
()
389
{
390
if
(
m_Options
.IsChanged())
391
{
392
m_Options
.Revert();
393
}
394
395
switch
(
m_ActiveTabIdx
)
396
{
397
case
0:
398
{
399
m_GameTab
.Revert();
400
break
;
401
}
402
case
1:
403
{
404
m_SoundsTab
.Revert();
405
break
;
406
}
407
case
2:
408
{
409
#ifdef PLATFORM_XBOX
410
m_ControlsTab
.Revert();
411
#else
412
m_VideoTab
.Revert();
413
#endif
414
break
;
415
}
416
case
3:
417
{
418
#ifndef PLATFORM_XBOX
419
m_ControlsTab
.Revert();
420
#endif
421
break
;
422
}
423
}
424
425
if
(
m_Options
.IsChanged())
426
{
427
m_Options
.Revert();
428
}
429
430
if
(
g_Game
.GetInput().IsEnabledMouseAndKeyboard())
431
{
432
m_Apply
.SetFlags(
WidgetFlags
.IGNOREPOINTER);
433
ColorDisable
(
m_Apply
);
434
m_Reset
.SetFlags(
WidgetFlags
.IGNOREPOINTER);
435
ColorDisable
(
m_Reset
);
436
}
437
438
m_CanApplyOrReset
=
false
;
439
#ifdef PLATFORM_CONSOLE
440
UpdateControlsElements
();
441
UpdateControlsElementVisibility
();
442
#endif
443
444
m_Tabber
.AlignTabbers();
445
}
446
447
void
SetToDefaults
()
448
{
449
if
(!
g_Game
.GetUIManager().IsDialogVisible() && !
g_Game
.GetUIManager().IsModalVisible())
450
{
451
g_Game
.GetUIManager().ShowDialog(
"#menu_default_cap"
,
"TODO - reset options to default"
,
MODAL_ID_DEFAULT
, DBT_YESNO, DBB_YES, DMT_QUESTION,
this
);
452
}
453
}
454
455
void
FocusLastActiveTab
()
456
{
457
switch
(
m_ActiveTabIdx
)
458
{
459
case
0:
460
m_GameTab
.Focus();
461
break
;
462
463
case
1:
464
m_SoundsTab
.Focus();
465
break
;
466
467
case
2:
468
#ifdef PLATFORM_XBOX
469
m_ControlsTab
.Focus();
470
#else
471
m_VideoTab
.Focus();
472
#endif
473
break
;
474
475
case
3:
476
#ifndef PLATFORM_XBOX
477
m_ControlsTab
.Focus();
478
#endif
479
break
;
480
}
481
}
482
483
void
PerformSetToDefaults
()
484
{
485
switch
(
m_ActiveTabIdx
)
486
{
487
case
0:
488
m_GameTab
.SetToDefaults();
489
break
;
490
491
case
1:
492
m_SoundsTab
.SetToDefaults();
493
break
;
494
495
case
2:
496
#ifdef PLATFORM_XBOX
497
m_ControlsTab
.SetToDefaults();
498
#else
499
m_VideoTab
.SetToDefaults();
500
#endif
501
break
;
502
503
case
3:
504
#ifndef PLATFORM_XBOX
505
m_ControlsTab
.SetToDefaults();
506
#endif
507
break
;
508
}
509
510
if
(
g_Game
.GetInput().IsEnabledMouseAndKeyboard())
511
{
512
m_Reset
.ClearFlags(
WidgetFlags
.IGNOREPOINTER);
513
ColorNormal
(
m_Reset
);
514
m_Apply
.ClearFlags(
WidgetFlags
.IGNOREPOINTER);
515
ColorNormal
(
m_Apply
);
516
}
517
518
m_CanApplyOrReset
=
true
;
519
#ifdef PLATFORM_CONSOLE
520
UpdateControlsElements
();
521
UpdateControlsElementVisibility
();
522
#endif
523
}
524
525
void
SliderFocus
()
526
{
527
#ifdef PLATFORM_CONSOLE
528
m_CanToggle
=
false
;
529
UpdateControlsElements
();
530
#endif
531
}
532
533
void
ToggleFocus
()
534
{
535
#ifdef PLATFORM_CONSOLE
536
m_CanToggle
=
true
;
537
UpdateControlsElements
();
538
#endif
539
}
540
542
void
ToggleDependentOptions
(
int
mode,
bool
state)
543
{
544
m_GameTab
.ToggleDependentOptions(mode,state);
545
m_SoundsTab
.ToggleDependentOptions(mode,state);
546
m_ControlsTab
.ToggleDependentOptions(mode,state);
547
#ifndef PLATFORM_XBOX
548
m_VideoTab
.ToggleDependentOptions(mode,state);
549
#endif
550
}
551
552
void
ReloadOptions
()
553
{
554
m_Options
=
new
GameOptions
();
555
556
if
(
m_GameTab
)
557
m_GameTab
.SetOptions(
m_Options
);
558
if
(
m_SoundsTab
)
559
m_SoundsTab
.SetOptions(
m_Options
);
560
if
(
m_ControlsTab
)
561
m_ControlsTab
.SetOptions(
m_Options
);
562
563
#ifndef PLATFORM_XBOX
564
if
(
m_VideoTab
)
565
m_VideoTab
.SetOptions(
m_Options
);
566
#endif
567
}
568
569
void
ReloadVideoOptions
()
570
{
571
#ifndef PLATFORM_XBOX
572
if
(
m_VideoTab
)
573
m_VideoTab
.SetOptions(
m_Options
);
574
#endif
575
}
576
577
override
bool
OnModalResult
(
Widget
w,
int
x
,
int
y
,
int
code,
int
result)
578
{
579
bool
ret =
false
;
580
581
if
(code == 1337)
582
{
583
if
(result == 2)
584
{
585
m_Options
.Revert();
586
g_Game
.EndOptionsVideo();
587
g_Game
.GetUIManager().Back();
588
}
589
ret =
true
;
590
}
591
else
if
(code == 117)
592
{
593
g_Game
.RequestRestart(
IDC_MAIN_QUIT
);
594
}
595
else
if
(code ==
MODAL_ID_DEFAULT
)
596
{
597
if
(result == 2)
598
{
599
PerformSetToDefaults
();
600
}
601
}
602
else
if
(code >=
DIALOG_TAB_OFFSET
)
603
{
604
if
(result == 2)
605
{
606
int
id
= code -
DIALOG_TAB_OFFSET
;
607
//m_Options.Revert();
608
ResetCurrentTab
();
609
m_Tabber
.PerformSwitchTab(
id
);
610
}
611
ret =
true
;
612
}
613
614
m_ModalLock
= ret;
//prevents dialog being shown on the next update
615
return
ret;
616
}
617
618
override
bool
OnMouseEnter
(
Widget
w,
int
x
,
int
y
)
619
{
620
if
(w &&
IsFocusable
(w))
621
{
622
ColorHighlight
(w);
623
return
true
;
624
}
625
return
false
;
626
}
627
628
override
bool
OnMouseLeave
(
Widget
w,
Widget
enterW,
int
x
,
int
y
)
629
{
630
if
(w &&
IsFocusable
(w))
631
{
632
ColorNormal
(w);
633
return
true
;
634
}
635
return
false
;
636
}
637
638
override
bool
OnFocus
(
Widget
w,
int
x
,
int
y
)
639
{
640
if
(w &&
IsFocusable
(w))
641
{
642
ColorHighlight
(w);
643
return
true
;
644
}
645
else
if
(
y
== 1)
646
{
647
SliderFocus
();
648
}
649
else
650
{
651
ToggleFocus
();
652
}
653
654
return
false
;
655
}
656
657
override
bool
OnFocusLost
(
Widget
w,
int
x
,
int
y
)
658
{
659
if
(w &&
IsFocusable
(w))
660
{
661
ColorNormal
(w);
662
return
true
;
663
}
664
return
false
;
665
}
666
667
bool
IsFocusable
(
Widget
w)
668
{
669
if
(w)
670
{
671
return
(w ==
m_Apply
|| w ==
m_Back
|| w ==
m_Reset
|| w ==
m_Defaults
);
672
}
673
return
false
;
674
}
675
676
override
void
Refresh
()
677
{
678
string
version;
679
g_Game
.GetVersion(version);
680
#ifdef PLATFORM_CONSOLE
681
version =
"#main_menu_version"
+
" "
+ version +
" ("
+
g_Game
.GetDatabaseID() +
")"
;
682
#else
683
version =
"#main_menu_version"
+
" "
+ version;
684
#endif
685
686
m_Version
.SetText(version);
687
688
#ifdef PLATFORM_CONSOLE
689
OnInputDeviceChanged
(
g_Game
.GetInput().GetCurrentInputDevice());
690
UpdateControlsElementVisibility
();
691
#endif
692
}
693
694
override
void
OnShow
()
695
{
696
super.OnShow();
697
#ifdef PLATFORM_MSSTORE
698
// MSStore: When going back from keybindings/gamepad controls, game tab somehow gained focus.
699
// Focus last active tab
700
FocusLastActiveTab
();
701
#else
702
m_GameTab
.Focus();
703
#endif
704
Refresh
();
705
}
706
707
override
void
Update
(
float
timeslice)
708
{
709
super.Update(timeslice);
710
711
if
(
m_ModalLock
)
712
{
713
m_ModalLock
=
false
;
714
#ifdef PLATFORM_CONSOLE
715
UpdateControlsElements
();
716
#endif
717
return
;
718
}
719
720
if
(
g_Game
.GetUIManager().IsDialogVisible())
721
{
722
return
;
723
}
724
725
if
(
GetUApi
().GetInputByID(UAUITabLeft).LocalPress())
726
{
727
m_Tabber
.PreviousTab();
728
}
729
else
if
(
GetUApi
().GetInputByID(UAUITabRight).LocalPress())
730
{
731
m_Tabber
.NextTab();
732
}
733
else
if
(
GetUApi
().GetInputByID(UAUICtrlX).LocalPress())
734
{
735
if
(
m_CanApplyOrReset
)
736
{
737
Apply
();
738
}
739
}
740
else
if
(
GetUApi
().GetInputByID(UAUICredits).LocalPress())
741
{
742
if
(
m_CanApplyOrReset
)
743
{
744
ResetCurrentTab
();
745
}
746
747
}
748
else
if
(
GetUApi
().GetInputByID(UAUICtrlY).LocalPress())
749
{
750
PerformSetToDefaults
();
751
}
752
else
if
(
GetUApi
().GetInputByID(UAUIBack).LocalPress())
753
{
754
Back
();
755
}
756
}
757
758
//Coloring functions (Until WidgetStyles are useful)
759
void
ColorHighlight
(
Widget
w)
760
{
761
if
((w.GetFlags() &
WidgetFlags
.IGNOREPOINTER) ==
WidgetFlags
.IGNOREPOINTER)
762
{
763
return
;
764
}
765
766
if
(w.IsInherited(ButtonWidget))
767
{
768
ButtonWidget button = ButtonWidget.Cast(w);
769
button.SetTextColor(
ARGB
(255, 200, 0, 0));
770
}
771
772
w.SetColor(
ARGB
(255, 0, 0, 0));
773
774
TextWidget
text1 =
TextWidget
.Cast(w.FindAnyWidget(w.GetName() +
"_text"
));
775
TextWidget
text2 =
TextWidget
.Cast(w.FindAnyWidget(w.GetName() +
"_label"
));
776
TextWidget
text3 =
TextWidget
.Cast(w.FindAnyWidget(w.GetName() +
"_text_1"
));
777
ImageWidget image = ImageWidget.Cast(w.FindAnyWidget(w.GetName() +
"_image"
));
778
Widget
option =
Widget
.Cast(w.FindAnyWidget(w.GetName() +
"_option_wrapper"
));
779
Widget
option_label = w.FindAnyWidget(
"option_label"
);
780
781
if
(text1)
782
{
783
text1.SetColor(
ARGB
(255, 255, 0, 0));
784
}
785
786
if
(text2)
787
{
788
text2.SetColor(
ARGB
(255, 255, 0, 0));
789
}
790
791
if
(text3)
792
{
793
text3.SetColor(
ARGB
(255, 255, 0, 0));
794
w.SetAlpha(1);
795
}
796
797
if
(image)
798
{
799
image.SetColor(
ARGB
(255, 200, 0, 0));
800
}
801
802
if
(option)
803
{
804
option.SetColor(
ARGB
(255, 255, 0, 0));
805
}
806
807
if
(option_label)
808
{
809
option_label.SetColor(
ARGB
(255, 255, 0, 0));
810
}
811
}
812
813
void
ColorNormal
(
Widget
w)
814
{
815
if
((w.GetFlags() &
WidgetFlags
.IGNOREPOINTER) ==
WidgetFlags
.IGNOREPOINTER)
816
{
817
return
;
818
}
819
820
if
(w.IsInherited(ButtonWidget))
821
{
822
ButtonWidget button = ButtonWidget.Cast(w);
823
button.SetTextColor(
ARGB
(255, 255, 255, 255));
824
}
825
826
TextWidget
text1 =
TextWidget
.Cast(w.FindAnyWidget(w.GetName() +
"_text"
));
827
TextWidget
text2 =
TextWidget
.Cast(w.FindAnyWidget(w.GetName() +
"_text_1"
));
828
TextWidget
text3 =
TextWidget
.Cast(w.FindAnyWidget(w.GetName() +
"_label"
));
829
ImageWidget image = ImageWidget.Cast(w.FindAnyWidget(w.GetName() +
"_image"
));
830
Widget
option = w.FindAnyWidget(w.GetName() +
"_option_wrapper"
);
831
Widget
option_label = w.FindAnyWidget(
"option_label"
);
832
833
if
(text1)
834
{
835
text1.SetColor(
ARGB
(255, 255, 255, 255));
836
}
837
838
if
(text2)
839
{
840
text2.SetColor(
ARGB
(255, 255, 255, 255));
841
}
842
843
if
(text3)
844
{
845
text3.SetColor(
ARGB
(255, 255, 255, 255));
846
w.SetAlpha(0);
847
}
848
849
if
(image)
850
{
851
image.SetColor(
ARGB
(255, 255, 255, 255));
852
}
853
854
if
(option)
855
{
856
option.SetColor(
ARGB
(150, 255, 255, 255));
857
}
858
859
if
(option_label)
860
{
861
option_label.SetColor(
ARGB
(255, 255, 255, 255));
862
}
863
}
864
865
void
ColorDisable
(
Widget
w)
866
{
867
#ifdef PLATFORM_WINDOWS
868
SetFocus
(null);
869
#endif
870
871
if
(w)
872
{
873
ButtonWidget button = ButtonWidget.Cast(w);
874
if
(button)
875
{
876
button.SetTextColor(
ColorManager
.
COLOR_DISABLED_TEXT
);
877
}
878
}
879
}
880
881
protected
void
UpdateControlsElements
()
882
{
883
#ifdef PLATFORM_CONSOLE
884
RichTextWidget
toolbar_text =
RichTextWidget
.Cast(layoutRoot.FindAnyWidget(
"ContextToolbarText"
));
885
string
text =
""
;
886
if
(
g_Game
.GetUIManager().IsDialogVisible() ||
g_Game
.GetUIManager().IsDialogQueued())
887
{
888
text +=
string
.
Format
(
" %1"
,
InputUtils
.
GetRichtextButtonIconFromInputAction
(
"UAUISelect"
,
"#dialog_confirm"
, EUAINPUT_DEVICE_CONTROLLER,
InputUtils
.
ICON_SCALE_TOOLBAR
));
889
890
}
891
else
892
{
893
if
(
m_CanToggle
)
894
{
895
text +=
string
.
Format
(
" %1"
,
InputUtils
.
GetRichtextButtonIconFromInputAction
(
"UAUISelect"
,
"#dialog_change"
, EUAINPUT_DEVICE_CONTROLLER,
InputUtils
.
ICON_SCALE_TOOLBAR
));
896
}
897
if
(
m_CanApplyOrReset
)
898
{
899
text +=
string
.
Format
(
" %1"
,
InputUtils
.
GetRichtextButtonIconFromInputAction
(
"UAUICtrlX"
,
"#STR_settings_menu_root_toolbar_bg_ConsoleToolbar_Apply_ApplyText0"
, EUAINPUT_DEVICE_CONTROLLER,
InputUtils
.
ICON_SCALE_TOOLBAR
));
900
}
901
text +=
string
.
Format
(
" %1"
,
InputUtils
.
GetRichtextButtonIconFromInputAction
(
"UAUICtrlY"
,
"#menu_default"
, EUAINPUT_DEVICE_CONTROLLER,
InputUtils
.
ICON_SCALE_TOOLBAR
));
902
if
(
m_CanApplyOrReset
)
903
{
904
text +=
string
.
Format
(
" %1"
,
InputUtils
.
GetRichtextButtonIconFromInputAction
(
"UAUICredits"
,
"#menu_undo"
, EUAINPUT_DEVICE_CONTROLLER,
InputUtils
.
ICON_SCALE_TOOLBAR
));
905
}
906
}
907
text +=
string
.
Format
(
" %1"
,
InputUtils
.
GetRichtextButtonIconFromInputAction
(
"UAUIBack"
,
"#STR_settings_menu_root_toolbar_bg_ConsoleToolbar_Back_BackText0"
, EUAINPUT_DEVICE_CONTROLLER,
InputUtils
.
ICON_SCALE_TOOLBAR
));
908
toolbar_text.SetText(text);
909
#endif
910
}
911
912
protected
void
UpdateControlsElementVisibility
()
913
{
914
bool
toolbarShow =
false
;
915
#ifdef PLATFORM_CONSOLE
916
toolbarShow = !
g_Game
.GetInput().IsEnabledMouseAndKeyboardEvenOnServer() ||
g_Game
.GetInput().GetCurrentInputDevice() ==
EInputDeviceType
.CONTROLLER;
917
#endif
918
919
layoutRoot.FindAnyWidget(
"toolbar_bg"
).Show(toolbarShow);
920
layoutRoot.FindAnyWidget(
"play_panel_root"
).Show(!toolbarShow);
921
}
922
}
Class
Super root of all classes in Enforce script.
Definition
enscript.c:11
ColorManager
Definition
colormanager.c:2
ColorManager::COLOR_DISABLED_TEXT
static int COLOR_DISABLED_TEXT
Definition
colormanager.c:11
GameOptions
Definition
gameplay.c:1461
InputUtils
Definition
inpututils.c:2
InputUtils::ICON_SCALE_TOOLBAR
static const float ICON_SCALE_TOOLBAR
Definition
inpututils.c:15
InputUtils::GetRichtextButtonIconFromInputAction
static string GetRichtextButtonIconFromInputAction(notnull UAInput pInput, string pLocalizedDescription, int pInputDeviceType=EUAINPUT_DEVICE_CONTROLLER, float pScale=ICON_SCALE_NORMAL, bool pVertical=false)
Definition
inpututils.c:167
RichTextWidget
Definition
gameplay.c:317
TextWidget
Definition
enwidgets.c:220
UAInputAPI::Export
proto native void Export()
UIScriptedMenu
Xbox menu.
Definition
dayzgame.c:64
UIScriptedMenu::OnInputPresetChanged
void OnInputPresetChanged()
Definition
controlsxboxnew.c:63
UIScriptedMenu::m_CanToggle
bool m_CanToggle
Definition
optionsmenu.c:25
UIScriptedMenu::m_Details
Widget m_Details
Definition
optionsmenu.c:19
UIScriptedMenu::SetToDefaults
void SetToDefaults()
Definition
optionsmenu.c:447
UIScriptedMenu::UpdateControlsElementVisibility
void UpdateControlsElementVisibility()
Definition
controlsxboxnew.c:545
UIScriptedMenu::Update
override void Update(float timeslice)
Definition
optionsmenu.c:707
UIScriptedMenu::m_Reset
ButtonWidget m_Reset
Definition
cameratoolsmenu.c:45
UIScriptedMenu::m_ControlsTab
ref OptionsMenuControls m_ControlsTab
Definition
optionsmenu.c:10
UIScriptedMenu::ColorDisable
void ColorDisable(Widget w)
Definition
ingamemenu.c:383
UIScriptedMenu::Refresh
override void Refresh()
Definition
optionsmenu.c:676
UIScriptedMenu::m_CanApplyOrReset
bool m_CanApplyOrReset
Definition
optionsmenu.c:24
UIScriptedMenu::Reset
void Reset()
Definition
optionsmenu.c:360
UIScriptedMenu::ReloadVideoOptions
void ReloadVideoOptions()
Definition
optionsmenu.c:569
UIScriptedMenu::ToggleFocus
void ToggleFocus()
Definition
optionsmenu.c:533
UIScriptedMenu::m_SoundsTab
ref OptionsMenuSounds m_SoundsTab
Definition
optionsmenu.c:8
UIScriptedMenu::OnShow
override void OnShow()
Definition
optionsmenu.c:694
UIScriptedMenu::OnMouseLeave
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Definition
optionsmenu.c:628
UIScriptedMenu::MODAL_ID_DEFAULT
const int MODAL_ID_DEFAULT
Definition
keybindingsmenu.c:23
UIScriptedMenu::m_VideoTab
ref OptionsMenuVideo m_VideoTab
Definition
optionsmenu.c:9
UIScriptedMenu::OnChanged
void OnChanged()
Definition
optionsmenu.c:328
UIScriptedMenu::PerformSetToDefaults
void PerformSetToDefaults()
deprecated, resets all (as before ~1.20)
Definition
keybindingsmenu.c:544
UIScriptedMenu::ReloadOptions
void ReloadOptions()
Definition
optionsmenu.c:552
UIScriptedMenu::m_ActiveTabIdx
int m_ActiveTabIdx
Definition
optionsmenu.c:22
UIScriptedMenu::m_Version
TextWidget m_Version
Definition
ingamemenuxbox.c:36
UIScriptedMenu::OnAttemptTabSwitch
void OnAttemptTabSwitch(int source, int target)
Definition
optionsmenu.c:296
UIScriptedMenu::Apply
void Apply()
renames character
Definition
charactercreationmenu.c:191
UIScriptedMenu::m_Back
ButtonWidget m_Back
Definition
controlsxboxnew.c:35
UIScriptedMenu::m_Tabber
TabberUI m_Tabber
Definition
keybindingsmenu.c:3
UIScriptedMenu::OnInputDeviceChanged
void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
Definition
controlsxboxnew.c:71
UIScriptedMenu::SliderFocus
void SliderFocus()
Definition
optionsmenu.c:525
UIScriptedMenu::ColorNormal
void ColorNormal(Widget w)
Definition
controlsxboxnew.c:471
UIScriptedMenu::m_Defaults
ButtonWidget m_Defaults
Definition
keybindingsmenu.c:13
UIScriptedMenu::ResetCurrentTab
void ResetCurrentTab()
Definition
optionsmenu.c:388
UIScriptedMenu::OnTabSwitch
void OnTabSwitch(int tab)
Definition
optionsmenu.c:197
UIScriptedMenu::Init
override Widget Init()
Definition
optionsmenu.c:37
UIScriptedMenu::m_Options
Widget m_Options
Definition
mainmenuconsoles.c:21
UIScriptedMenu::OnModalResult
override bool OnModalResult(Widget w, int x, int y, int code, int result)
Definition
optionsmenu.c:577
UIScriptedMenu::m_GameTab
ref OptionsMenuGame m_GameTab
Definition
optionsmenu.c:7
UIScriptedMenu::UpdateControlsElements
void UpdateControlsElements()
Definition
controlsxboxnew.c:535
UIScriptedMenu::DIALOG_TAB_OFFSET
const int DIALOG_TAB_OFFSET
Definition
optionsmenu.c:4
UIScriptedMenu::IsAnyTabChanged
bool IsAnyTabChanged()
Definition
optionsmenu.c:318
UIScriptedMenu::OnFocusLost
override bool OnFocusLost(Widget w, int x, int y)
Definition
optionsmenu.c:657
UIScriptedMenu::IsFocusable
bool IsFocusable(Widget w)
Definition
cameratoolsmenu.c:960
UIScriptedMenu::OnMouseEnter
override bool OnMouseEnter(Widget w, int x, int y)
Definition
optionsmenu.c:618
UIScriptedMenu::~OptionsMenu
void ~OptionsMenu()
Definition
optionsmenu.c:113
UIScriptedMenu::OptionsMenu
void OptionsMenu()
Definition
optionsmenu.c:32
UIScriptedMenu::ColorHighlight
void ColorHighlight(Widget w)
Definition
controlsxboxnew.c:454
UIScriptedMenu::OnFocus
override bool OnFocus(Widget w, int x, int y)
Definition
optionsmenu.c:638
UIScriptedMenu::Back
void Back()
Definition
controlsxboxnew.c:96
UIScriptedMenu::m_ModalLock
bool m_ModalLock
Definition
optionsmenu.c:23
UIScriptedMenu::FocusLastActiveTab
void FocusLastActiveTab()
Definition
optionsmenu.c:455
UIScriptedMenu::OnClick
override bool OnClick(Widget w, int x, int y, int button)
Definition
optionsmenu.c:151
UIScriptedMenu::m_Apply
Widget m_Apply
Definition
charactercreationmenu.c:14
UIScriptedMenu::ToggleDependentOptions
void ToggleDependentOptions(int mode, bool state)
Controls visibility and sometimes even state of specific, dependent options across sub-menus.
Definition
optionsmenu.c:542
Widget
Definition
enwidgets.c:190
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
Class::CastTo
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
MENU_KEYBINDINGS
const int MENU_KEYBINDINGS
Definition
constants.c:203
MENU_XBOX_CONTROLS
const int MENU_XBOX_CONTROLS
Definition
constants.c:197
MouseState
MouseState
Definition
ensystem.c:311
string::Format
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
IDC_MAIN_QUIT
const int IDC_MAIN_QUIT
Definition
constants.c:144
WidgetFlags
WidgetFlags
Definition
enwidgets.c:58
SetFocus
proto native void SetFocus(Widget w)
x
Icon x
y
Icon y
EInputDeviceType
EInputDeviceType
Definition
input.c:3
ARGB
int ARGB(int a, int r, int g, int b)
Definition
proto.c:322
GetUApi
proto native UAInputAPI GetUApi()
Games
Dayz
scripts
5_mission
gui
newui
options
optionsmenu.c
Generated by
1.17.0