Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_SelectionMenu.c
Go to the documentation of this file.
1
//------------------------------------------------------------------------------------------------
5
[
BaseContainerProps
(configRoot:
true
)]
6
class
SCR_SelectionMenu
7
{
8
protected
const
int
OPEN_DELAY
= 200;
9
10
// Attributes
11
[
Attribute
()]
12
protected
ref
SCR_SelectionMenuInputs
m_Inputs
;
13
14
[
Attribute
()]
15
protected
string
m_sOpenSound
;
16
17
[
Attribute
()]
18
protected
string
m_sCloseSound
;
19
20
[
Attribute
()]
21
protected
string
m_sSelectionSound
;
22
23
[
Attribute
()]
24
protected
string
m_sPerformSound
;
25
26
[
Attribute
()]
27
protected
string
m_sEnterCategorySound
;
28
29
[
Attribute
()]
30
protected
string
m_sLeaveCategorySound
;
31
32
// Variables
33
protected
SCR_SelectionMenuDisplay
m_Display
;
34
35
protected
ref array<ref SCR_SelectionMenuEntry>
m_aRootEntries
= {};
// 1st layer of entries
36
protected
ref array<ref SCR_SelectionMenuEntry>
m_aEntries
= {};
// Current layer entries
37
protected
SCR_SelectionMenuEntry
m_SelectedEntry
;
38
protected
int
m_iSelectedEntryId
;
39
40
protected
ref
SCR_SelectionMenuControllerInputs
m_ControllerInputs
;
41
protected
bool
m_bOpened
;
42
protected
bool
m_bEntryPerformed
;
43
protected
bool
m_bUsingAlternativeToggle
;
44
protected
bool
m_bClosingMenu
;
45
protected
bool
m_bOpenedForTime
;
46
47
// Categories and multi layering
48
protected
ref array<SCR_SelectionMenuCategoryEntry>
m_aSelectedCategories
= {};
49
50
// Events
51
protected
ref
ScriptInvoker<SCR_SelectionMenu>
m_OnBeforeOpen
;
52
protected
ref
ScriptInvoker<SCR_SelectionMenu>
m_OnOpen
;
53
protected
ref
ScriptInvoker<SCR_SelectionMenu>
m_OnClose
;
54
protected
ref
ScriptInvoker<SCR_SelectionMenu, SCR_SelectionMenuEntry, int>
m_OnSelect
;
55
protected
ref
ScriptInvoker<SCR_SelectionMenu, SCR_SelectionMenuEntry>
m_OnPerform
;
56
protected
ref
ScriptInvoker<SCR_SelectionMenu, SCR_SelectionMenuCategoryEntry, int>
m_OnOpenCategory
;
57
58
protected
ref
ScriptInvoker<SCR_SelectionMenu, SCR_SelectionMenuEntry>
m_OnAddEntry
;
59
protected
ref
ScriptInvoker<SCR_SelectionMenu, SCR_SelectionMenuEntry>
m_OnRemoveEntry
;
60
protected
ref
ScriptInvoker<SCR_SelectionMenu, array<ref SCR_SelectionMenuEntry>
>
m_OnUpdateEntries
;
61
62
protected
ref
ScriptInvoker<SCR_SelectionMenu, SCR_SelectionMenuControllerInputs>
m_OnControllerChanged
;
63
protected
ref
ScriptInvoker<SCR_SelectionMenu, SelectionMenuFailReason>
m_OnOpenFailed
;
64
65
//------------------------------------------------------------------------------------------------
66
protected
void
InvokeOnBeforeOpen
()
67
{
68
if
(
m_OnBeforeOpen
)
69
m_OnBeforeOpen
.Invoke(
this
);
70
}
71
72
//------------------------------------------------------------------------------------------------
73
ScriptInvoker
GetOnBeforeOpen
()
74
{
75
if
(!
m_OnBeforeOpen
)
76
m_OnBeforeOpen
=
new
ScriptInvoker
();
77
78
return
m_OnBeforeOpen
;
79
}
80
81
//------------------------------------------------------------------------------------------------
82
protected
void
InvokeOnOpen
()
83
{
84
if
(
m_OnOpen
)
85
m_OnOpen
.Invoke(
this
);
86
}
87
88
//------------------------------------------------------------------------------------------------
89
ScriptInvoker
GetOnOpen
()
90
{
91
if
(!
m_OnOpen
)
92
m_OnOpen
=
new
ScriptInvoker
();
93
94
return
m_OnOpen
;
95
}
96
97
//------------------------------------------------------------------------------------------------
98
protected
void
InvokeOnClose
()
99
{
100
if
(
m_OnClose
)
101
m_OnClose
.Invoke(
this
);
102
}
103
104
//------------------------------------------------------------------------------------------------
105
ScriptInvoker
GetOnClose
()
106
{
107
if
(!
m_OnClose
)
108
m_OnClose
=
new
ScriptInvoker
();
109
110
return
m_OnClose
;
111
}
112
113
//------------------------------------------------------------------------------------------------
114
protected
void
InvokeOnSelect
(
SCR_SelectionMenuEntry
entry,
int
id
)
115
{
116
if
(
m_OnSelect
)
117
m_OnSelect
.Invoke(
this
, entry,
id
);
118
}
119
120
//------------------------------------------------------------------------------------------------
121
ScriptInvoker
GetOnSelect
()
122
{
123
if
(!
m_OnSelect
)
124
m_OnSelect
=
new
ScriptInvoker
();
125
126
return
m_OnSelect
;
127
}
128
129
//------------------------------------------------------------------------------------------------
130
ScriptInvoker
GetOnOpenFailed
()
131
{
132
if
(!
m_OnOpenFailed
)
133
m_OnOpenFailed
=
new
ScriptInvoker
();
134
135
return
m_OnOpenFailed
;
136
}
137
138
//------------------------------------------------------------------------------------------------
139
protected
void
InvokeOnPerform
(
SCR_SelectionMenuEntry
entry)
140
{
141
if
(
m_OnPerform
)
142
m_OnPerform
.Invoke(
this
, entry);
143
}
144
145
//------------------------------------------------------------------------------------------------
146
ScriptInvoker
GetOnPerform
()
147
{
148
if
(!
m_OnPerform
)
149
m_OnPerform
=
new
ScriptInvoker
();
150
151
return
m_OnPerform
;
152
}
153
154
//------------------------------------------------------------------------------------------------
155
protected
void
InvokeOnOpenCategory
(
SCR_SelectionMenuCategoryEntry
entry,
int
level)
156
{
157
if
(
m_OnOpenCategory
)
158
m_OnOpenCategory
.Invoke(
this
, entry, level);
159
}
160
161
//------------------------------------------------------------------------------------------------
162
ScriptInvoker
GetOnOpenCategory
()
163
{
164
if
(!
m_OnOpenCategory
)
165
m_OnOpenCategory
=
new
ScriptInvoker
();
166
167
return
m_OnOpenCategory
;
168
}
169
170
//------------------------------------------------------------------------------------------------
171
protected
void
InvokeOnAddEntry
(
SCR_SelectionMenuEntry
entry)
172
{
173
if
(
m_OnAddEntry
)
174
m_OnAddEntry
.Invoke(
this
, entry);
175
}
176
177
//------------------------------------------------------------------------------------------------
178
ScriptInvoker
GetOnAddEntry
()
179
{
180
if
(!
m_OnAddEntry
)
181
m_OnAddEntry
=
new
ScriptInvoker
();
182
183
return
m_OnAddEntry
;
184
}
185
186
//------------------------------------------------------------------------------------------------
187
protected
void
InvokeOnRemoveEntry
(
SCR_SelectionMenuEntry
entry)
188
{
189
if
(
m_OnRemoveEntry
)
190
m_OnRemoveEntry
.Invoke(
this
, entry);
191
}
192
193
//------------------------------------------------------------------------------------------------
194
ScriptInvoker
GetOnRemoveEntry
()
195
{
196
if
(!
m_OnRemoveEntry
)
197
m_OnRemoveEntry
=
new
ScriptInvoker
();
198
199
return
m_OnRemoveEntry
;
200
}
201
202
//------------------------------------------------------------------------------------------------
203
protected
void
InvokeOnUpdateEntries
(array<ref SCR_SelectionMenuEntry> entries)
204
{
205
if
(
m_OnUpdateEntries
)
206
m_OnUpdateEntries
.Invoke(
this
, entries);
207
}
208
209
//------------------------------------------------------------------------------------------------
210
ScriptInvoker
GetOnUpdateEntries
()
211
{
212
if
(!
m_OnUpdateEntries
)
213
m_OnUpdateEntries
=
new
ScriptInvoker
();
214
215
return
m_OnUpdateEntries
;
216
}
217
218
//------------------------------------------------------------------------------------------------
219
protected
void
InvokeOnControllerChanged
(
SCR_SelectionMenuControllerInputs
inputs)
220
{
221
if
(
m_OnControllerChanged
)
222
m_OnControllerChanged
.Invoke(
this
, inputs);
223
}
224
225
//------------------------------------------------------------------------------------------------
226
ScriptInvoker
GetOnControllerChanged
()
227
{
228
if
(!
m_OnControllerChanged
)
229
m_OnControllerChanged
=
new
ScriptInvoker
();
230
231
return
m_OnControllerChanged
;
232
}
233
234
//------------------------------------------------------------------------------------------------
235
// Custom methods
236
//------------------------------------------------------------------------------------------------
237
238
//------------------------------------------------------------------------------------------------
239
void
Open
()
240
{
241
InvokeOnBeforeOpen
();
242
243
// Prevent opening emtpy menu
244
if
(
m_ControllerInputs
.m_bPreventEmptyMenuOpen &&
m_aEntries
.IsEmpty())
245
{
246
if
(
m_OnOpenFailed
)
247
m_OnOpenFailed
.Invoke(
this
,
SCR_ESelectionMenuFailReason
.MENU_EMPTY);
248
return
;
249
}
250
251
if
(
m_bOpened
)
252
{
253
if
(
m_OnOpenFailed
)
254
m_OnOpenFailed
.Invoke(
this
,
SCR_ESelectionMenuFailReason
.MENU_ALREADY_OPEN);
255
return
;
256
}
257
258
m_bOpened
=
true
;
259
m_bEntryPerformed
=
false
;
260
m_bClosingMenu
=
false
;
261
m_bUsingAlternativeToggle
=
false
;
262
263
// Call later to set opened for time to allow closing after reaching the delay
264
m_bOpenedForTime
=
false
;
265
266
if
(!
m_ControllerInputs
.m_sToggleActionAlternative.IsEmpty())
267
GetGame
().GetCallqueue().CallLater(
AllowClosing
,
OPEN_DELAY
);
268
else
269
AllowClosing
();
// Allow closing immidiatelly when toggle is not set
270
271
// Start on root
272
if
(
m_ControllerInputs
.m_bOpenInRoot)
273
OpenInRoot
();
274
275
OnOpen
();
276
277
InvokeOnOpen
();
278
PlaySound
(
m_sOpenSound
);
279
280
// Call update in next frame to be sure item preview is prepared
281
GetGame
().GetCallqueue().CallLater(
UpdateEntries
);
282
}
283
284
//------------------------------------------------------------------------------------------------
286
protected
void
AllowClosing
()
287
{
288
// Set true to state that time for allow closing has already passed
289
m_bOpenedForTime
=
true
;
290
291
// Close menu if closing was requested before it was possible
292
if
(
m_bClosingMenu
&& !
m_bUsingAlternativeToggle
)
293
{
294
Close
();
295
return
;
296
}
297
298
m_bClosingMenu
=
false
;
299
}
300
301
//------------------------------------------------------------------------------------------------
303
protected
void
OnOpen
(){}
304
305
//------------------------------------------------------------------------------------------------
307
void
Close
()
308
{
309
m_bClosingMenu
=
true
;
310
311
if
(!
m_bOpenedForTime
)
312
return
;
313
314
// Perform
315
if
(
m_ControllerInputs
&&
m_ControllerInputs
.m_bPerformOnClose &&
m_SelectedEntry
&& !
m_bEntryPerformed
)
316
PerformEntry
(
m_SelectedEntry
);
317
318
m_bOpened
=
false
;
319
m_bUsingAlternativeToggle
=
false
;
320
OnClose
();
321
322
InvokeOnClose
();
323
324
if
(!
m_bEntryPerformed
|| !
m_SelectedEntry
)
325
PlaySound
(
m_sCloseSound
);
326
}
327
328
//------------------------------------------------------------------------------------------------
330
protected
void
OnClose
(){}
331
332
//------------------------------------------------------------------------------------------------
333
void
Update
(
float
timeSlice)
334
{
335
// Context
336
if
(
m_bOpened
)
337
GetGame
().GetInputManager().ActivateContext(
m_Inputs
.m_sContext);
338
339
if
(
m_ControllerInputs
)
340
GetGame
().GetInputManager().ActivateContext(
m_ControllerInputs
.m_sControllerContext);
341
342
OnUpdate
(timeSlice);
343
}
344
345
//------------------------------------------------------------------------------------------------
347
protected
void
OnUpdate
(
float
timeSlice){}
348
349
//------------------------------------------------------------------------------------------------
350
void
Init
()
351
{
352
Close
();
353
}
354
355
//------------------------------------------------------------------------------------------------
356
protected
void
PlaySound
(
string
sound)
357
{
358
if
(!sound.IsEmpty())
359
SCR_UISoundEntity
.SoundEvent(sound);
360
}
361
362
//------------------------------------------------------------------------------------------------
363
// Entries handling
364
//------------------------------------------------------------------------------------------------
365
366
//------------------------------------------------------------------------------------------------
368
protected
void
SelectEntry
() {}
369
370
//------------------------------------------------------------------------------------------------
371
void
PerformEntry
(notnull
SCR_SelectionMenuEntry
entry)
372
{
373
if
(!entry.IsEnabled())
374
return
;
375
376
// Is category entry
377
SCR_SelectionMenuCategoryEntry
category
=
SCR_SelectionMenuCategoryEntry
.Cast(entry);
378
379
entry.Perform();
380
381
// Generic entry
382
if
(!
category
)
383
{
384
m_bEntryPerformed
=
true
;
385
386
if
(
m_ControllerInputs
.m_bCloseOnPerform)
387
Close
();
388
}
389
390
// Category
391
if
(
category
)
392
{
393
if
(!
m_bClosingMenu
)
394
OpenCategoryEntry
(
category
);
395
// Perform default action on closing
396
397
return
;
398
}
399
400
PlaySound
(
m_sPerformSound
);
401
402
InvokeOnPerform
(entry);
403
404
if
(!
category
&& !
m_bClosingMenu
)
405
m_bEntryPerformed
=
false
;
406
}
407
408
//------------------------------------------------------------------------------------------------
410
protected
void
OpenCategoryEntry
(notnull
SCR_SelectionMenuCategoryEntry
category
)
411
{
412
//AddEntries(category.GetEntries(), true);
413
414
m_aSelectedCategories
.Insert(
category
);
415
416
// Repopulate entries
417
m_aEntries
.Clear();
418
419
for
(
int
i = 0, count =
category
.GetEntries().Count(); i < count; i++)
420
{
421
m_aEntries
.Insert(
category
.GetEntries()[i]);
422
}
423
424
// Update
425
InvokeOnOpenCategory
(
category
,
m_aSelectedCategories
.Count());
426
InvokeOnUpdateEntries
(
category
.GetEntries());
427
428
PlaySound
(
m_sEnterCategorySound
);
429
}
430
431
//------------------------------------------------------------------------------------------------
432
protected
void
LeaveCategory
()
433
{
434
SCR_SelectionMenuCategoryEntry
category
=
CurrentCategory
();
435
if
(!
category
)
436
return
;
437
438
m_aSelectedCategories
.RemoveItem(
category
);
439
440
category
=
CurrentCategory
();
441
m_aEntries
.Clear();
442
443
444
// Repopulate entries with previous entry
445
if
(
category
)
446
{
447
array<ref SCR_SelectionMenuEntry> catEntries =
category
.GetEntries();
448
449
// Previous category
450
for
(
int
i = 0, count = catEntries.Count(); i < count; i++)
451
{
452
m_aEntries
.Insert(catEntries[i]);
453
}
454
}
455
else
456
{
457
// Root
458
for
(
int
i = 0, count =
m_aRootEntries
.Count(); i < count; i++)
459
{
460
m_aEntries
.Insert(
m_aRootEntries
[i]);
461
}
462
}
463
464
InvokeOnOpenCategory
(
category
,
m_aSelectedCategories
.Count());
465
InvokeOnUpdateEntries
(
m_aEntries
);
466
467
PlaySound
(
m_sLeaveCategorySound
);
468
}
469
470
//------------------------------------------------------------------------------------------------
472
protected
void
OpenInRoot
()
473
{
474
m_aSelectedCategories
.Clear();
475
m_aEntries
.Clear();
476
477
for
(
int
i = 0, count =
m_aRootEntries
.Count(); i < count; i++)
478
{
479
m_aEntries
.Insert(
m_aRootEntries
[i]);
480
}
481
482
InvokeOnOpenCategory
(null, 0);
483
InvokeOnUpdateEntries
(
m_aEntries
);
484
}
485
486
//------------------------------------------------------------------------------------------------
489
void
AddEntry
(
SCR_SelectionMenuEntry
entry = null)
490
{
491
if
(!entry)
492
{
493
SCR_SelectionMenuEntry
newEntry =
new
SCR_SelectionMenuEntry
();
494
m_aRootEntries
.Insert(newEntry);
495
return
;
496
}
497
498
m_aRootEntries
.Insert(entry);
499
500
// Update entries
501
if
(!
CurrentCategory
())
502
{
503
m_aEntries
.Insert(entry);
504
InvokeOnAddEntry
(entry);
505
InvokeOnUpdateEntries
(
m_aEntries
);
506
}
507
}
508
509
//------------------------------------------------------------------------------------------------
511
void
AddCategoryEntry
(
SCR_SelectionMenuCategoryEntry
category
= null)
512
{
513
SCR_SelectionMenuEntry
entry =
category
;
514
515
if
(!entry)
516
entry =
new
SCR_SelectionMenuCategoryEntry
();
517
518
AddEntry
(entry);
519
}
520
521
//------------------------------------------------------------------------------------------------
524
void
AddEntries
(notnull array<ref SCR_SelectionMenuEntry> entries,
bool
replace =
false
)
525
{
526
// Clear
527
if
(replace)
528
{
529
m_aRootEntries
.Clear();
530
531
if
(!
CurrentCategory
())
532
m_aEntries
.Clear();
533
}
534
535
// Add
536
for
(
int
i = 0, count = entries.Count(); i < count; i++)
537
{
538
AddEntry
(entries[i]);
539
}
540
541
if
(!
CurrentCategory
())
542
InvokeOnUpdateEntries
(
m_aEntries
);
543
544
UpdateEntries
();
545
}
546
547
//------------------------------------------------------------------------------------------------
549
void
UpdateEntries
()
550
{
551
InvokeOnUpdateEntries
(
m_aEntries
);
552
553
foreach
(
SCR_SelectionMenuEntry
entry :
m_aEntries
)
554
{
555
if
(entry)
556
entry.Update();
557
}
558
}
559
560
//------------------------------------------------------------------------------------------------
562
void
UpdateSelectedEntries
(notnull array<ref SCR_SelectionMenuEntry> entries)
563
{
564
InvokeOnUpdateEntries
(entries);
565
566
foreach
(
SCR_SelectionMenuEntry
entry : entries)
567
{
568
if
(entry)
569
entry.Update();
570
}
571
}
572
573
//------------------------------------------------------------------------------------------------
575
void
RemoveEntry
(notnull
SCR_SelectionMenuEntry
entry)
576
{
577
m_aRootEntries
.RemoveItem(entry);
578
579
// Update entries
580
if
(!
CurrentCategory
())
581
{
582
m_aEntries
.RemoveItem(entry);
583
InvokeOnUpdateEntries
(
m_aEntries
);
584
}
585
}
586
587
//------------------------------------------------------------------------------------------------
589
void
ClearEntries
()
590
{
591
m_aRootEntries
.Clear();
592
593
// Update entries
594
if
(!
CurrentCategory
())
595
{
596
m_aEntries
.Clear();
597
InvokeOnUpdateEntries
(
m_aEntries
);
598
}
599
}
600
601
//------------------------------------------------------------------------------------------------
604
SCR_SelectionMenuCategoryEntry
CurrentCategory
()
605
{
606
if
(
m_aSelectedCategories
.IsEmpty())
607
return
null;
608
609
return
m_aSelectedCategories
[
m_aSelectedCategories
.Count() - 1];
610
}
611
612
//------------------------------------------------------------------------------------------------
614
void
SetMenuDisplay
(
SCR_SelectionMenuDisplay
display = null)
615
{
616
m_Display
= display;
617
618
if
(display)
619
display.SetupMenu(
this
);
620
}
621
622
//------------------------------------------------------------------------------------------------
623
// Inputs
624
//------------------------------------------------------------------------------------------------
625
626
//------------------------------------------------------------------------------------------------
628
protected
void
AddActionListeners
()
629
{
630
if
(
m_ControllerInputs
.m_bCloseOnReleaseOpen)
631
GetGame
().GetInputManager().AddActionListener(
m_ControllerInputs
.m_sOpenAction,
EActionTrigger
.UP,
OnOpenInputRelease
);
632
633
if
(!
m_ControllerInputs
.m_sToggleActionAlternative.IsEmpty())
634
GetGame
().GetInputManager().AddActionListener(
m_ControllerInputs
.m_sToggleActionAlternative,
EActionTrigger
.DOWN,
OnAlternativeToggleInput
);
635
636
if
(!
m_Inputs
.m_sPerformAction.IsEmpty())
637
GetGame
().GetInputManager().AddActionListener(
m_Inputs
.m_sPerformAction,
EActionTrigger
.DOWN,
OnPerformInput
);
638
639
if
(!
m_Inputs
.m_sBackAction.IsEmpty())
640
GetGame
().GetInputManager().AddActionListener(
m_Inputs
.m_sBackAction,
EActionTrigger
.DOWN,
OnBackInput
);
641
}
642
643
//------------------------------------------------------------------------------------------------
645
protected
void
RemoveActionListeners
()
646
{
647
if
(!
m_ControllerInputs
|| !
m_Inputs
)
648
return
;
649
650
GetGame
().GetInputManager().RemoveActionListener(
m_ControllerInputs
.m_sOpenAction,
EActionTrigger
.UP,
OnOpenInputRelease
);
651
GetGame
().GetInputManager().RemoveActionListener(
m_ControllerInputs
.m_sToggleActionAlternative,
EActionTrigger
.DOWN,
OnAlternativeToggleInput
);
652
GetGame
().GetInputManager().RemoveActionListener(
m_Inputs
.m_sPerformAction,
EActionTrigger
.DOWN,
OnPerformInput
);
653
GetGame
().GetInputManager().RemoveActionListener(
m_Inputs
.m_sBackAction,
EActionTrigger
.DOWN,
OnBackInput
);
654
}
655
656
//------------------------------------------------------------------------------------------------
658
protected
void
OnOpenInputRelease
(
float
value,
EActionTrigger
reason
)
659
{
660
if
(
m_bUsingAlternativeToggle
)
661
return
;
662
663
Close
();
664
}
665
666
//------------------------------------------------------------------------------------------------
668
protected
void
OnPerformInput
()
669
{
670
if
(
m_SelectedEntry
)
671
PerformEntry
(
m_SelectedEntry
);
672
}
673
674
//------------------------------------------------------------------------------------------------
675
protected
void
OnBackInput
()
676
{
677
// Prevent entry performing
678
m_SelectedEntry
= null;
679
680
// Should close on top level
681
if
(
CurrentCategory
())
682
{
683
LeaveCategory
();
684
}
685
else
686
{
687
// Close on top level
688
Close
();
689
}
690
}
691
692
//------------------------------------------------------------------------------------------------
693
protected
void
OnAlternativeToggleInput
()
694
{
695
m_bUsingAlternativeToggle
=
true
;
696
}
697
698
//------------------------------------------------------------------------------------------------
699
// API
700
//------------------------------------------------------------------------------------------------
701
702
//------------------------------------------------------------------------------------------------
703
bool
IsOpened
()
704
{
705
return
m_bOpened
;
706
}
707
708
//------------------------------------------------------------------------------------------------
710
void
SetController
(
IEntity
owner,
SCR_SelectionMenuControllerInputs
controls)
711
{
712
if
(controls)
713
controls.m_Owner = owner;
714
715
if
(
m_ControllerInputs
!= controls)
716
InvokeOnControllerChanged
(controls);
717
718
m_ControllerInputs
= controls;
719
}
720
721
//------------------------------------------------------------------------------------------------
722
SCR_SelectionMenuControllerInputs
GetControllerInputs
()
723
{
724
return
m_ControllerInputs
;
725
}
726
727
//------------------------------------------------------------------------------------------------
728
SCR_SelectionMenuEntry
GetSelectionEntry
()
729
{
730
return
m_SelectedEntry
;
731
}
732
733
//------------------------------------------------------------------------------------------------
734
int
GetSelectedEntryId
()
735
{
736
return
m_iSelectedEntryId
;
737
}
738
739
//------------------------------------------------------------------------------------------------
740
bool
GetEntryPerformed
()
741
{
742
return
m_bEntryPerformed
;
743
}
744
745
//------------------------------------------------------------------------------------------------
746
array<ref SCR_SelectionMenuEntry>
GetEntries
()
747
{
748
array<ref SCR_SelectionMenuEntry> entries = {};
749
750
for
(
int
i = 0, count =
m_aEntries
.Count(); i < count; i++)
751
{
752
entries.Insert(
m_aEntries
[i]);
753
}
754
755
return
entries;
756
}
757
758
//------------------------------------------------------------------------------------------------
759
int
GetEntryCount
()
760
{
761
if
(!
m_aEntries
)
762
return
0;
763
764
return
m_aEntries
.Count();
765
}
766
767
//------------------------------------------------------------------------------------------------
768
bool
HasDisplay
()
769
{
770
return
m_Display
!= null;
771
}
772
773
//------------------------------------------------------------------------------------------------
774
// Debug
775
//------------------------------------------------------------------------------------------------
776
777
//------------------------------------------------------------------------------------------------
778
protected
void
DebugPrint
(
string
method,
string
msg)
779
{
780
Print
(
string
.Format(
"[SCR_SelectionMenu] - %1() - '%2'"
, method, msg),
LogLevel
.DEBUG);
781
}
782
};
783
784
//------------------------------------------------------------------------------------------------
788
[
BaseContainerProps
(configRoot:
true
)]
789
class
SCR_SelectionMenuInputs
790
{
791
[
Attribute
(
""
,
desc
:
"Input context used for menu controls"
)]
792
string
m_sContext;
793
794
[
Attribute
(
""
,
desc
:
"Action used for closing menu or moving back between the layers"
)]
795
string
m_sBackAction;
796
797
[
Attribute
(
""
,
desc
:
"Input action used for performing selected entry"
)]
798
string
m_sPerformAction;
799
800
//------------------------------------------------------------------------------------------------
802
void
Init
() {}
803
};
804
805
//------------------------------------------------------------------------------------------------
811
[
BaseContainerProps
(configRoot:
true
)]
812
class
SCR_SelectionMenuControllerInputs
813
{
814
IEntity
m_Owner;
815
816
[
Attribute
(
""
,
desc
:
"Input context used for extra menu controls from controller entity"
)]
817
string
m_sControllerContext;
818
819
[
Attribute
(
""
,
desc
:
"Action for opening (and closing) radial menu"
)]
820
string
m_sOpenAction;
821
822
[
Attribute
(
""
,
desc
:
"Alternative action for always toggling menu"
)]
823
string
m_sToggleActionAlternative;
824
825
[
Attribute
(
"1"
,
desc
:
"If this field is checked - Menu is closed if open input is released. Otherwise separate close input has to be used"
)]
826
bool
m_bCloseOnReleaseOpen;
827
828
[
Attribute
(
"1"
,
desc
:
"If this field is checked - Perform entry(call entry action) when closing menu and having selected entry"
)]
829
bool
m_bPerformOnClose;
830
831
[
Attribute
(
"0"
,
desc
:
"If this field is checked - Close the menu after performing the entry (selecting enabled entry)"
)]
832
bool
m_bCloseOnPerform;
833
834
[
Attribute
(
"1"
,
desc
:
"Checked - on opening menu is always filled with root entries. Otherwise menu will stay in last category."
)]
835
bool
m_bOpenInRoot;
836
837
[
Attribute
(
"0"
,
desc
:
"If checked, menu won't open if there are no entries in the menu"
)]
838
bool
m_bPreventEmptyMenuOpen;
839
840
[
Attribute
(
"1"
,
UIWidgets
.Slider,
desc
:
"Unchecked will prevent opening of radial menu while character is unconcious."
)]
841
bool
m_bShowWhileUnconcious;
842
843
//------------------------------------------------------------------------------------------------
844
void
SCR_SelectionMenuOpening(
string
openAction =
""
)
845
{
846
if
(!openAction.IsEmpty())
847
m_sOpenAction = openAction;
848
}
849
850
//------------------------------------------------------------------------------------------------
852
bool
IsControllingMenu(
IEntity
controller)
853
{
854
return
controller == m_Owner;
855
}
856
};
857
858
//------------------------------------------------------------------------------------------------
862
[
BaseContainerProps
(configRoot:
true
)]
863
class
SCR_SelectionMenuData
864
{
865
[
Attribute
()]
866
protected
ref array<ref SCR_SelectionMenuEntry>
m_aEntries
;
867
868
//------------------------------------------------------------------------------------------------
869
array<ref SCR_SelectionMenuEntry>
GetEntries
()
870
{
871
array<ref SCR_SelectionMenuEntry> entries = {};
872
873
for
(
int
i = 0, count =
m_aEntries
.Count(); i < count; i++)
874
{
875
entries.Insert(
m_aEntries
[i]);
876
}
877
878
return
entries;
879
}
880
};
881
882
//------------------------------------------------------------------------------------------------
885
class
SCR_SelectionMenuPreviewAttributes
:
BaseItemAttributeData
886
{
887
[
Attribute
(
"10"
)]
888
float
m_fCustomFov;
889
890
[
Attribute
(
"-1"
,
desc
:
"Adjust how final render preview size should be big by current icon size multiplicaiton"
)]
891
float
m_fIconSizeXMultiplier;
892
893
[
Attribute
(
desc
:
"If true colorize item shadow in Radial Menu to medical color"
)]
894
bool
m_bShowMedicalColor;
895
};
896
898
enum
SCR_ESelectionMenuFailReason
899
{
900
UNKNOWN
,
901
MENU_EMPTY
,
902
MENU_ALREADY_OPEN
903
}
Init
override void Init()
Definition
CharacterCameraHandlerComponent.c:40
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
BaseContainerProps
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
Definition
SCR_AIAnimationWaypoint.c:14
OnUpdate
override void OnUpdate()
Definition
SCR_MapMarkerSquadLeader.c:333
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
SCR_ESelectionMenuFailReason
SCR_ESelectionMenuFailReason
Enum of reason why the menu did not open.
Definition
SCR_SelectionMenu.c:899
MENU_EMPTY
@ MENU_EMPTY
Definition
SCR_SelectionMenu.c:901
MENU_ALREADY_OPEN
@ MENU_ALREADY_OPEN
Definition
SCR_SelectionMenu.c:902
category
params category
Definition
SCR_VehicleDamageManagerComponent.c:302
reason
string reason
Definition
ServerBrowserMenuCallbacks.c:41
BaseItemAttributeData
Definition
BaseItemAttributeData.c:13
IEntity
Definition
IEntity.c:13
SCR_SelectionMenuCategoryEntry
Definition
SCR_SelectionMenuCategory.c:7
SCR_SelectionMenuControllerInputs
Definition
SCR_SelectionMenu.c:813
SCR_SelectionMenuData
Definition
SCR_SelectionMenu.c:864
SCR_SelectionMenuData::GetEntries
array< ref SCR_SelectionMenuEntry > GetEntries()
Definition
SCR_SelectionMenu.c:869
SCR_SelectionMenuData::m_aEntries
ref array< ref SCR_SelectionMenuEntry > m_aEntries
Definition
SCR_SelectionMenu.c:866
SCR_SelectionMenuDisplay
Definition
SCR_SelectionMenuDisplay.c:8
SCR_SelectionMenuEntry
Definition
SCR_SelectionMenuEntry.c:8
SCR_SelectionMenu
Definition
SCR_SelectionMenu.c:7
SCR_SelectionMenu::m_OnControllerChanged
ref ScriptInvoker< SCR_SelectionMenu, SCR_SelectionMenuControllerInputs > m_OnControllerChanged
Definition
SCR_SelectionMenu.c:62
SCR_SelectionMenu::InvokeOnClose
void InvokeOnClose()
Definition
SCR_SelectionMenu.c:98
SCR_SelectionMenu::m_sLeaveCategorySound
string m_sLeaveCategorySound
Definition
SCR_SelectionMenu.c:30
SCR_SelectionMenu::GetSelectedEntryId
int GetSelectedEntryId()
Definition
SCR_SelectionMenu.c:734
SCR_SelectionMenu::m_OnRemoveEntry
ref ScriptInvoker< SCR_SelectionMenu, SCR_SelectionMenuEntry > m_OnRemoveEntry
Definition
SCR_SelectionMenu.c:59
SCR_SelectionMenu::IsOpened
bool IsOpened()
Definition
SCR_SelectionMenu.c:703
SCR_SelectionMenu::m_OnOpen
ref ScriptInvoker< SCR_SelectionMenu > m_OnOpen
Definition
SCR_SelectionMenu.c:52
SCR_SelectionMenu::AllowClosing
void AllowClosing()
Allow closing after some time in order to have alternative toggle action with double press.
Definition
SCR_SelectionMenu.c:286
SCR_SelectionMenu::InvokeOnUpdateEntries
void InvokeOnUpdateEntries(array< ref SCR_SelectionMenuEntry > entries)
Definition
SCR_SelectionMenu.c:203
SCR_SelectionMenu::DebugPrint
void DebugPrint(string method, string msg)
Definition
SCR_SelectionMenu.c:778
SCR_SelectionMenu::GetOnSelect
ScriptInvoker GetOnSelect()
Definition
SCR_SelectionMenu.c:121
SCR_SelectionMenu::GetOnClose
ScriptInvoker GetOnClose()
Definition
SCR_SelectionMenu.c:105
SCR_SelectionMenu::m_SelectedEntry
SCR_SelectionMenuEntry m_SelectedEntry
Definition
SCR_SelectionMenu.c:37
SCR_SelectionMenu::GetOnControllerChanged
ScriptInvoker GetOnControllerChanged()
Definition
SCR_SelectionMenu.c:226
SCR_SelectionMenu::OnPerformInput
void OnPerformInput()
On select input handle entry selection and moving into layers.
Definition
SCR_SelectionMenu.c:668
SCR_SelectionMenu::OnBackInput
void OnBackInput()
Definition
SCR_SelectionMenu.c:675
SCR_SelectionMenu::m_OnPerform
ref ScriptInvoker< SCR_SelectionMenu, SCR_SelectionMenuEntry > m_OnPerform
Definition
SCR_SelectionMenu.c:55
SCR_SelectionMenu::m_sOpenSound
string m_sOpenSound
Definition
SCR_SelectionMenu.c:15
SCR_SelectionMenu::GetOnRemoveEntry
ScriptInvoker GetOnRemoveEntry()
Definition
SCR_SelectionMenu.c:194
SCR_SelectionMenu::m_iSelectedEntryId
int m_iSelectedEntryId
Definition
SCR_SelectionMenu.c:38
SCR_SelectionMenu::SetController
void SetController(IEntity owner, SCR_SelectionMenuControllerInputs controls)
Set controller entity and controls.
Definition
SCR_SelectionMenu.c:710
SCR_SelectionMenu::m_OnClose
ref ScriptInvoker< SCR_SelectionMenu > m_OnClose
Definition
SCR_SelectionMenu.c:53
SCR_SelectionMenu::m_sEnterCategorySound
string m_sEnterCategorySound
Definition
SCR_SelectionMenu.c:27
SCR_SelectionMenu::m_aRootEntries
ref array< ref SCR_SelectionMenuEntry > m_aRootEntries
Definition
SCR_SelectionMenu.c:35
SCR_SelectionMenu::OnOpen
void OnOpen()
Empty method called on open ready for override.
Definition
SCR_SelectionMenu.c:303
SCR_SelectionMenu::AddActionListeners
void AddActionListeners()
Add all action listeners for basic menu control.
Definition
SCR_SelectionMenu.c:628
SCR_SelectionMenu::m_OnOpenFailed
ref ScriptInvoker< SCR_SelectionMenu, SelectionMenuFailReason > m_OnOpenFailed
Definition
SCR_SelectionMenu.c:63
SCR_SelectionMenu::UpdateEntries
void UpdateEntries()
Invoke data update for all entries.
Definition
SCR_SelectionMenu.c:549
SCR_SelectionMenu::HasDisplay
bool HasDisplay()
Definition
SCR_SelectionMenu.c:768
SCR_SelectionMenu::GetOnOpenFailed
ScriptInvoker GetOnOpenFailed()
Definition
SCR_SelectionMenu.c:130
SCR_SelectionMenu::GetOnOpen
ScriptInvoker GetOnOpen()
Definition
SCR_SelectionMenu.c:89
SCR_SelectionMenu::m_bEntryPerformed
bool m_bEntryPerformed
Definition
SCR_SelectionMenu.c:42
SCR_SelectionMenu::m_aEntries
ref array< ref SCR_SelectionMenuEntry > m_aEntries
Definition
SCR_SelectionMenu.c:36
SCR_SelectionMenu::OpenInRoot
void OpenInRoot()
Clear open categories and use entries from root.
Definition
SCR_SelectionMenu.c:472
SCR_SelectionMenu::m_OnAddEntry
ref ScriptInvoker< SCR_SelectionMenu, SCR_SelectionMenuEntry > m_OnAddEntry
Definition
SCR_SelectionMenu.c:58
SCR_SelectionMenu::m_Inputs
ref SCR_SelectionMenuInputs m_Inputs
Definition
SCR_SelectionMenu.c:12
SCR_SelectionMenu::m_ControllerInputs
ref SCR_SelectionMenuControllerInputs m_ControllerInputs
Definition
SCR_SelectionMenu.c:40
SCR_SelectionMenu::m_OnUpdateEntries
ref ScriptInvoker< SCR_SelectionMenu, array< ref SCR_SelectionMenuEntry > > m_OnUpdateEntries
Definition
SCR_SelectionMenu.c:60
SCR_SelectionMenu::m_aSelectedCategories
ref array< SCR_SelectionMenuCategoryEntry > m_aSelectedCategories
Definition
SCR_SelectionMenu.c:48
SCR_SelectionMenu::AddEntry
void AddEntry(SCR_SelectionMenuEntry entry=null)
Definition
SCR_SelectionMenu.c:489
SCR_SelectionMenu::OnAlternativeToggleInput
void OnAlternativeToggleInput()
Definition
SCR_SelectionMenu.c:693
SCR_SelectionMenu::GetOnAddEntry
ScriptInvoker GetOnAddEntry()
Definition
SCR_SelectionMenu.c:178
SCR_SelectionMenu::m_OnBeforeOpen
ref ScriptInvoker< SCR_SelectionMenu > m_OnBeforeOpen
Definition
SCR_SelectionMenu.c:51
SCR_SelectionMenu::RemoveActionListeners
void RemoveActionListeners()
Remove all action listeners for basic menu control.
Definition
SCR_SelectionMenu.c:645
SCR_SelectionMenu::ClearEntries
void ClearEntries()
Clear all entries and invoke data update.
Definition
SCR_SelectionMenu.c:589
SCR_SelectionMenu::GetEntryCount
int GetEntryCount()
Definition
SCR_SelectionMenu.c:759
SCR_SelectionMenu::OPEN_DELAY
const int OPEN_DELAY
Definition
SCR_SelectionMenu.c:8
SCR_SelectionMenu::m_bOpened
bool m_bOpened
Definition
SCR_SelectionMenu.c:41
SCR_SelectionMenu::InvokeOnControllerChanged
void InvokeOnControllerChanged(SCR_SelectionMenuControllerInputs inputs)
Definition
SCR_SelectionMenu.c:219
SCR_SelectionMenu::InvokeOnSelect
void InvokeOnSelect(SCR_SelectionMenuEntry entry, int id)
Definition
SCR_SelectionMenu.c:114
SCR_SelectionMenu::m_Display
SCR_SelectionMenuDisplay m_Display
Definition
SCR_SelectionMenu.c:33
SCR_SelectionMenu::GetOnOpenCategory
ScriptInvoker GetOnOpenCategory()
Definition
SCR_SelectionMenu.c:162
SCR_SelectionMenu::GetControllerInputs
SCR_SelectionMenuControllerInputs GetControllerInputs()
Definition
SCR_SelectionMenu.c:722
SCR_SelectionMenu::m_OnSelect
ref ScriptInvoker< SCR_SelectionMenu, SCR_SelectionMenuEntry, int > m_OnSelect
Definition
SCR_SelectionMenu.c:54
SCR_SelectionMenu::GetOnUpdateEntries
ScriptInvoker GetOnUpdateEntries()
Definition
SCR_SelectionMenu.c:210
SCR_SelectionMenu::InvokeOnOpen
void InvokeOnOpen()
Definition
SCR_SelectionMenu.c:82
SCR_SelectionMenu::m_OnOpenCategory
ref ScriptInvoker< SCR_SelectionMenu, SCR_SelectionMenuCategoryEntry, int > m_OnOpenCategory
Definition
SCR_SelectionMenu.c:56
SCR_SelectionMenu::Update
void Update(float timeSlice)
Definition
SCR_SelectionMenu.c:333
SCR_SelectionMenu::PlaySound
void PlaySound(string sound)
Definition
SCR_SelectionMenu.c:356
SCR_SelectionMenu::LeaveCategory
void LeaveCategory()
Definition
SCR_SelectionMenu.c:432
SCR_SelectionMenu::Open
void Open()
Definition
SCR_SelectionMenu.c:239
SCR_SelectionMenu::GetEntryPerformed
bool GetEntryPerformed()
Definition
SCR_SelectionMenu.c:740
SCR_SelectionMenu::GetOnBeforeOpen
ScriptInvoker GetOnBeforeOpen()
Definition
SCR_SelectionMenu.c:73
SCR_SelectionMenu::InvokeOnBeforeOpen
void InvokeOnBeforeOpen()
Definition
SCR_SelectionMenu.c:66
SCR_SelectionMenu::Init
void Init()
Definition
SCR_SelectionMenu.c:350
SCR_SelectionMenu::OpenCategoryEntry
void OpenCategoryEntry(notnull SCR_SelectionMenuCategoryEntry category)
Specific peform action for category to change menu content.
Definition
SCR_SelectionMenu.c:410
SCR_SelectionMenu::m_bClosingMenu
bool m_bClosingMenu
Definition
SCR_SelectionMenu.c:44
SCR_SelectionMenu::InvokeOnRemoveEntry
void InvokeOnRemoveEntry(SCR_SelectionMenuEntry entry)
Definition
SCR_SelectionMenu.c:187
SCR_SelectionMenu::AddEntries
void AddEntries(notnull array< ref SCR_SelectionMenuEntry > entries, bool replace=false)
Definition
SCR_SelectionMenu.c:524
SCR_SelectionMenu::m_bUsingAlternativeToggle
bool m_bUsingAlternativeToggle
Definition
SCR_SelectionMenu.c:43
SCR_SelectionMenu::GetOnPerform
ScriptInvoker GetOnPerform()
Definition
SCR_SelectionMenu.c:146
SCR_SelectionMenu::OnOpenInputRelease
void OnOpenInputRelease(float value, EActionTrigger reason)
On open input handle menu closing.
Definition
SCR_SelectionMenu.c:658
SCR_SelectionMenu::OnUpdate
void OnUpdate(float timeSlice)
Empty method called on update ready for override.
Definition
SCR_SelectionMenu.c:347
SCR_SelectionMenu::GetSelectionEntry
SCR_SelectionMenuEntry GetSelectionEntry()
Definition
SCR_SelectionMenu.c:728
SCR_SelectionMenu::CurrentCategory
SCR_SelectionMenuCategoryEntry CurrentCategory()
Definition
SCR_SelectionMenu.c:604
SCR_SelectionMenu::m_sSelectionSound
string m_sSelectionSound
Definition
SCR_SelectionMenu.c:21
SCR_SelectionMenu::InvokeOnOpenCategory
void InvokeOnOpenCategory(SCR_SelectionMenuCategoryEntry entry, int level)
Definition
SCR_SelectionMenu.c:155
SCR_SelectionMenu::Close
void Close()
Callback when close is requested.
Definition
SCR_SelectionMenu.c:307
SCR_SelectionMenu::SelectEntry
void SelectEntry()
Generic method for custom entry selection based on used interface.
Definition
SCR_SelectionMenu.c:368
SCR_SelectionMenu::OnClose
void OnClose()
Empty method called on close ready for override.
Definition
SCR_SelectionMenu.c:330
SCR_SelectionMenu::m_bOpenedForTime
bool m_bOpenedForTime
Definition
SCR_SelectionMenu.c:45
SCR_SelectionMenu::InvokeOnAddEntry
void InvokeOnAddEntry(SCR_SelectionMenuEntry entry)
Definition
SCR_SelectionMenu.c:171
SCR_SelectionMenu::PerformEntry
void PerformEntry(notnull SCR_SelectionMenuEntry entry)
Definition
SCR_SelectionMenu.c:371
SCR_SelectionMenu::UpdateSelectedEntries
void UpdateSelectedEntries(notnull array< ref SCR_SelectionMenuEntry > entries)
Invoke data update for selected entries.
Definition
SCR_SelectionMenu.c:562
SCR_SelectionMenu::m_sCloseSound
string m_sCloseSound
Definition
SCR_SelectionMenu.c:18
SCR_SelectionMenu::SetMenuDisplay
void SetMenuDisplay(SCR_SelectionMenuDisplay display=null)
Find and setup display used for menu.
Definition
SCR_SelectionMenu.c:614
SCR_SelectionMenu::m_sPerformSound
string m_sPerformSound
Definition
SCR_SelectionMenu.c:24
SCR_SelectionMenu::GetEntries
array< ref SCR_SelectionMenuEntry > GetEntries()
Definition
SCR_SelectionMenu.c:746
SCR_SelectionMenu::AddCategoryEntry
void AddCategoryEntry(SCR_SelectionMenuCategoryEntry category=null)
Add empty or custom category entry.
Definition
SCR_SelectionMenu.c:511
SCR_SelectionMenu::RemoveEntry
void RemoveEntry(notnull SCR_SelectionMenuEntry entry)
Remove selected entry and invoke data update.
Definition
SCR_SelectionMenu.c:575
SCR_SelectionMenu::InvokeOnPerform
void InvokeOnPerform(SCR_SelectionMenuEntry entry)
Definition
SCR_SelectionMenu.c:139
SCR_SelectionMenuInputs
Definition
SCR_SelectionMenu.c:790
SCR_SelectionMenuPreviewAttributes
Definition
SCR_SelectionMenu.c:886
SCR_UISoundEntity
Definition
SCR_UISoundEntity.c:8
UIWidgets
Definition
attributes.c:40
Print
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
LogLevel
Enum with severity of the logging message.
Definition
LogLevel.c:14
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
EActionTrigger
EActionTrigger
Definition
EActionTrigger.c:13
UNKNOWN
@ UNKNOWN
Definition
EPlatform.c:24
ScriptInvoker
ScriptInvokerBase< func > ScriptInvoker
Definition
tools.c:134
scripts
Game
UI
HUD
SelectionMenu
SCR_SelectionMenu.c
Generated by
1.17.0