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_SelectionMenuDisplay.c
Go to the documentation of this file.
1
4
5
//------------------------------------------------------------------------------------------------
6
[
BaseContainerProps
()]
7
class
SCR_SelectionMenuDisplay
: SCR_InfoDisplayExtended
8
{
9
protected
const
float
FADE_IN_SPEED
=
UIConstants
.FADE_RATE_SUPER_FAST;
10
11
[
Attribute
(
""
,
".layout"
,
desc
:
"Base layout that should be used for all entries that doesn't need custom layout."
)]
12
protected
ResourceName
m_sEntryLayout
;
13
14
// Widget name refs
15
[
Attribute
(
""
)]
16
protected
string
m_sEntriesParent
;
17
18
// Menu and entries
19
protected
ref
SCR_SelectionMenu
m_Menu
;
20
21
protected
ref array<SCR_SelectionMenuEntry>
m_aEntries
= {};
22
protected
ref array<ref Widget>
m_aEntryWidgets
= {};
23
24
protected
SCR_SelectionMenuEntry
m_LastSelectedEntry
;
25
protected
int
m_iLastSelectedId
= -1;
26
27
// Widgets
28
protected
Widget
m_wEntriesParent
;
29
30
//------------------------------------------------------------------------------------------------
31
// Override
32
//------------------------------------------------------------------------------------------------
33
34
//------------------------------------------------------------------------------------------------
37
void
SetupMenu
(
SCR_SelectionMenu
menu)
38
{
39
// Clear callbacks for previous menu
40
if
(
m_Menu
)
41
{
42
m_Menu
.GetOnOpen().Remove(
OnMenuOpen
);
43
m_Menu
.GetOnClose().Remove(
OnMenuClose
);
44
m_Menu
.GetOnUpdateEntries().Remove(
OnMenuEntriesUpdate
);
45
m_Menu
.GetOnSelect().Remove(
OnMenuEntrySelected
);
46
m_Menu
.GetOnPerform().Remove(
OnMenuEntryPerform
);
47
}
48
49
// Register to new menu
50
m_Menu
= menu;
51
52
if
(!
m_Menu
)
53
{
54
DebugPrint
(
"DisplayInit"
,
"No menu was found!"
);
55
return
;
56
}
57
58
// Listen to menu
59
m_Menu
.GetOnOpen().Insert(
OnMenuOpen
);
60
m_Menu
.GetOnClose().Insert(
OnMenuClose
);
61
m_Menu
.GetOnUpdateEntries().Insert(
OnMenuEntriesUpdate
);
62
m_Menu
.GetOnSelect().Insert(
OnMenuEntrySelected
);
63
m_Menu
.GetOnPerform().Insert(
OnMenuEntryPerform
);
64
}
65
66
//------------------------------------------------------------------------------------------------
68
override
void
DisplayStartDraw
(
IEntity
owner)
69
{
70
super.DisplayStartDraw(owner);
71
72
// Find widgets
73
m_wEntriesParent
=
GetRootWidget
().FindAnyWidget(
m_sEntriesParent
);
74
}
75
76
//------------------------------------------------------------------------------------------------
77
override
void
DisplayOnSuspended
()
78
{
79
super.DisplayOnSuspended();
80
81
if
(
m_Menu
)
82
m_Menu
.Close();
83
}
84
85
//------------------------------------------------------------------------------------------------
86
// Custom
87
//------------------------------------------------------------------------------------------------
88
89
//------------------------------------------------------------------------------------------------
91
protected
void
FindMenu
() {}
92
93
//------------------------------------------------------------------------------------------------
95
protected
void
CreateEntryWidgets
()
96
{
97
if
(!
m_wEntriesParent
)
98
{
99
DebugPrint
(
"CreateEntryWidgets"
,
"Can't create entries due to missing parent!"
);
100
return
;
101
}
102
103
if
(!
m_aEntries
)
104
{
105
DebugPrint
(
"CreateEntryWidgets"
,
"Entries is null!"
);
106
return
;
107
}
108
109
for
(
int
i = 0, count =
m_aEntries
.Count(); i < count; i++)
110
{
111
// Pick custom resource
112
ResourceName
entryLayout =
m_aEntries
[i].GetCustomLayout();
113
if
(entryLayout.IsEmpty())
114
entryLayout =
m_sEntryLayout
;
115
116
// Create and setup
117
Widget
entry =
GetGame
().GetWorkspace().CreateWidgets(entryLayout,
m_wEntriesParent
);
118
m_aEntryWidgets
.Insert(entry);
119
SetupEntryWidget
(
m_aEntries
[i], entry, i);
120
121
// Setup component
122
SCR_SelectionMenuEntryComponent
entryComponent =
SCR_SelectionMenuEntryComponent
.Cast(
123
entry.FindHandler(
SCR_SelectionMenuEntryComponent
));
124
125
m_aEntries
[i].SetEntryComponent(entryComponent);
126
}
127
}
128
129
//------------------------------------------------------------------------------------------------
130
protected
void
CreateNewEntry
(
int
i)
131
{
132
// Pick custom resource
133
ResourceName
entryLayout =
m_aEntries
[i].GetCustomLayout();
134
if
(entryLayout.IsEmpty())
135
entryLayout =
m_sEntryLayout
;
136
137
// Create and setup
138
Widget
entry =
GetGame
().GetWorkspace().CreateWidgets(
m_sEntryLayout
,
m_wEntriesParent
);
139
m_aEntryWidgets
.Insert(entry);
140
//SetupEntryWidget(m_aEntries[i], entry, i);
141
142
// Setup component
143
SCR_SelectionMenuEntryComponent
entryComponent =
SCR_SelectionMenuEntryComponent
.Cast(
144
entry.FindHandler(
SCR_SelectionMenuEntryComponent
));
145
146
m_aEntries
[i].SetEntryComponent(entryComponent);
147
}
148
149
//------------------------------------------------------------------------------------------------
150
protected
void
RemoveEntry
(
Widget
entry,
int
id
)
151
{
152
m_aEntryWidgets
[
id
].RemoveFromHierarchy();
153
m_aEntryWidgets
.RemoveItem(entry);
154
}
155
156
//------------------------------------------------------------------------------------------------
160
protected
void
SetupEntryWidget
(notnull
SCR_SelectionMenuEntry
entry, notnull
Widget
widget,
int
id
){}
161
162
//------------------------------------------------------------------------------------------------
164
protected
void
ClearEntryWidgets
()
165
{
166
for
(
int
i = 0, count =
m_aEntryWidgets
.Count(); i < count; i++)
167
{
168
m_aEntryWidgets
[i].RemoveFromHierarchy();
169
}
170
171
m_aEntryWidgets
.Clear();
172
}
173
174
//------------------------------------------------------------------------------------------------
176
protected
bool
EntriesChanged
(array<ref SCR_SelectionMenuEntry> entries)
177
{
178
int
prevCount =
m_aEntries
.Count();
179
180
// Check entries count
181
if
(prevCount == 0 || prevCount != entries.Count())
182
{
183
m_aEntries
.Clear();
184
for
(
int
i = 0, count = entries.Count(); i < count; i++)
185
{
186
m_aEntries
.Insert(entries[i]);
187
}
188
189
return
true
;
190
}
191
192
// Fill up entries
193
array<SCR_SelectionMenuEntry> previousEntries = {};
194
195
for
(
int
i = 0; i < prevCount; i++)
196
{
197
previousEntries.Insert(
m_aEntries
[i]);
198
}
199
200
m_aEntries
.Clear();
201
202
for
(
int
i = 0, count = entries.Count(); i < count; i++)
203
{
204
m_aEntries
.Insert(entries[i]);
205
}
206
207
// Check if data is different
208
for
(
int
i = 0, count =
m_aEntries
.Count(); i < count; i++)
209
{
210
if
(previousEntries.IsEmpty() || !previousEntries.IsIndexValid(i))
211
return
true
;
212
213
if
(previousEntries[i] !=
m_aEntries
[i])
214
return
true
;
215
}
216
217
return
false
;
218
}
219
220
//------------------------------------------------------------------------------------------------
221
// Callbacks
222
//------------------------------------------------------------------------------------------------
223
224
//------------------------------------------------------------------------------------------------
225
protected
void
OnMenuOpen
()
226
{
227
Show
(
true
,
FADE_IN_SPEED
);
228
229
ClearEntryWidgets
();
230
CreateEntryWidgets
();
231
}
232
233
//------------------------------------------------------------------------------------------------
234
protected
void
OnMenuClose
()
235
{
236
Show
(
false
,
UIConstants
.FADE_RATE_FAST);
237
}
238
239
//------------------------------------------------------------------------------------------------
240
protected
void
OnMenuEntriesUpdate
(
SCR_SelectionMenu
menu, array<ref SCR_SelectionMenuEntry> entries)
241
{
242
// Update entries
243
if
(
EntriesChanged
(entries))
244
{
245
ClearEntryWidgets
();
246
CreateEntryWidgets
();
247
}
248
}
249
250
//------------------------------------------------------------------------------------------------
252
protected
void
OnMenuEntrySelected
(
SCR_SelectionMenu
menu,
SCR_SelectionMenuEntry
entry,
int
id
) {}
253
254
//------------------------------------------------------------------------------------------------
256
protected
void
OnMenuEntryPerform
(
SCR_SelectionMenu
menu,
SCR_SelectionMenuEntry
entry) {}
257
258
//------------------------------------------------------------------------------------------------
259
// API
260
//------------------------------------------------------------------------------------------------
261
262
//------------------------------------------------------------------------------------------------
263
SCR_SelectionMenu
GetMenu
()
264
{
265
return
m_Menu
;
266
}
267
268
//------------------------------------------------------------------------------------------------
269
// Debug
270
//------------------------------------------------------------------------------------------------
271
272
//------------------------------------------------------------------------------------------------
273
protected
void
DebugPrint
(
string
method,
string
msg)
274
{
275
Print
(
string
.Format(
"[SCR_SelectionMenuDisplay] - %1() - '%2'"
, method, msg),
LogLevel
.DEBUG);
276
}
277
};
id
AddonBuildInfoTool id
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
BaseContainerProps
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
Definition
SCR_AIAnimationWaypoint.c:14
GetRootWidget
Widget GetRootWidget()
Definition
SCR_ModularButtonComponent.c:189
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
IEntity
Definition
IEntity.c:13
ResourceName
Definition
ResourceName.c:13
SCR_SelectionMenuDisplay
Definition
SCR_SelectionMenuDisplay.c:8
SCR_SelectionMenuDisplay::DebugPrint
void DebugPrint(string method, string msg)
Definition
SCR_SelectionMenuDisplay.c:273
SCR_SelectionMenuDisplay::RemoveEntry
void RemoveEntry(Widget entry, int id)
Definition
SCR_SelectionMenuDisplay.c:150
SCR_SelectionMenuDisplay::m_aEntries
ref array< SCR_SelectionMenuEntry > m_aEntries
Definition
SCR_SelectionMenuDisplay.c:21
SCR_SelectionMenuDisplay::DisplayStartDraw
override void DisplayStartDraw(IEntity owner)
Setup menu.
Definition
SCR_SelectionMenuDisplay.c:68
SCR_SelectionMenuDisplay::ClearEntryWidgets
void ClearEntryWidgets()
Remove all entries from HUD layout.
Definition
SCR_SelectionMenuDisplay.c:164
SCR_SelectionMenuDisplay::CreateNewEntry
void CreateNewEntry(int i)
Definition
SCR_SelectionMenuDisplay.c:130
SCR_SelectionMenuDisplay::m_sEntryLayout
ResourceName m_sEntryLayout
Definition
SCR_SelectionMenuDisplay.c:12
SCR_SelectionMenuDisplay::SetupMenu
void SetupMenu(SCR_SelectionMenu menu)
Definition
SCR_SelectionMenuDisplay.c:37
SCR_SelectionMenuDisplay::m_Menu
ref SCR_SelectionMenu m_Menu
Definition
SCR_SelectionMenuDisplay.c:19
SCR_SelectionMenuDisplay::FADE_IN_SPEED
const float FADE_IN_SPEED
Definition
SCR_SelectionMenuDisplay.c:9
SCR_SelectionMenuDisplay::OnMenuEntrySelected
void OnMenuEntrySelected(SCR_SelectionMenu menu, SCR_SelectionMenuEntry entry, int id)
React on selected entry change.
Definition
SCR_SelectionMenuDisplay.c:252
SCR_SelectionMenuDisplay::OnMenuEntryPerform
void OnMenuEntryPerform(SCR_SelectionMenu menu, SCR_SelectionMenuEntry entry)
React on selected entry change.
Definition
SCR_SelectionMenuDisplay.c:256
SCR_SelectionMenuDisplay::GetMenu
SCR_SelectionMenu GetMenu()
Definition
SCR_SelectionMenuDisplay.c:263
SCR_SelectionMenuDisplay::OnMenuClose
void OnMenuClose()
Definition
SCR_SelectionMenuDisplay.c:234
SCR_SelectionMenuDisplay::m_sEntriesParent
string m_sEntriesParent
Definition
SCR_SelectionMenuDisplay.c:16
SCR_SelectionMenuDisplay::m_LastSelectedEntry
SCR_SelectionMenuEntry m_LastSelectedEntry
Definition
SCR_SelectionMenuDisplay.c:24
SCR_SelectionMenuDisplay::m_iLastSelectedId
int m_iLastSelectedId
Definition
SCR_SelectionMenuDisplay.c:25
SCR_SelectionMenuDisplay::FindMenu
void FindMenu()
Method ready for override to find menu at custom place.
Definition
SCR_SelectionMenuDisplay.c:91
SCR_SelectionMenuDisplay::OnMenuEntriesUpdate
void OnMenuEntriesUpdate(SCR_SelectionMenu menu, array< ref SCR_SelectionMenuEntry > entries)
Definition
SCR_SelectionMenuDisplay.c:240
SCR_SelectionMenuDisplay::m_wEntriesParent
Widget m_wEntriesParent
Definition
SCR_SelectionMenuDisplay.c:28
SCR_SelectionMenuDisplay::m_aEntryWidgets
ref array< ref Widget > m_aEntryWidgets
Definition
SCR_SelectionMenuDisplay.c:22
SCR_SelectionMenuDisplay::CreateEntryWidgets
void CreateEntryWidgets()
Will create entries in HUD layout.
Definition
SCR_SelectionMenuDisplay.c:95
SCR_SelectionMenuDisplay::DisplayOnSuspended
override void DisplayOnSuspended()
Definition
SCR_SelectionMenuDisplay.c:77
SCR_SelectionMenuDisplay::SetupEntryWidget
void SetupEntryWidget(notnull SCR_SelectionMenuEntry entry, notnull Widget widget, int id)
Definition
SCR_SelectionMenuDisplay.c:160
SCR_SelectionMenuDisplay::OnMenuOpen
void OnMenuOpen()
Definition
SCR_SelectionMenuDisplay.c:225
SCR_SelectionMenuDisplay::EntriesChanged
bool EntriesChanged(array< ref SCR_SelectionMenuEntry > entries)
Check if used data are still same.
Definition
SCR_SelectionMenuDisplay.c:176
SCR_SelectionMenuEntryComponent
Definition
SCR_SelectionMenuEntryComponent.c:7
SCR_SelectionMenuEntry
Definition
SCR_SelectionMenuEntry.c:8
SCR_SelectionMenu
Definition
SCR_SelectionMenu.c:7
UIConstants
Definition
Constants.c:151
Widget
Definition
Widget.c:13
Show
override void Show()
Definition
gameLib.c:262
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
scripts
Game
UI
HUD
SelectionMenu
SCR_SelectionMenuDisplay.c
Generated by
1.17.0