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_WidgetTools.c
Go to the documentation of this file.
1
class
SCR_WidgetTools
2
{
9
static
Widget
FindWidgetInChildren(
Widget
w,
WidgetType
type
)
10
{
11
if
(w.GetTypeID() ==
type
)
12
return
w;
13
14
Widget
candidate;
15
w = w.GetChildren();
16
while
(w)
17
{
18
candidate = FindWidgetInChildren(w,
type
);
19
if
(candidate)
20
return
candidate;
21
22
w = w.GetSibling();
23
}
24
return
null;
25
}
32
static
Widget
FindWidgetInChildren(
Widget
w,
typename
type
)
33
{
34
if
(w.FindHandler(
type
))
35
return
w;
36
37
Widget
result;
38
w = w.GetChildren();
39
while
(w)
40
{
41
result = FindWidgetInChildren(w,
type
);
42
if
(result)
43
return
result;
44
45
w = w.GetSibling();
46
}
47
return
null;
48
}
55
static
Widget
FindWidgetInParents(
Widget
w,
WidgetType
type
)
56
{
57
while
(w)
58
{
59
if
(w.GetTypeID() ==
type
)
60
return
w;
61
62
w = w.GetParent();
63
}
64
return
null;
65
}
66
73
static
ScriptedWidgetEventHandler
FindHandlerInChildren(
Widget
w,
typename
type
)
74
{
75
ScriptedWidgetEventHandler
component = w.FindHandler(
type
);
76
if
(component)
77
return
component;
78
79
w = w.GetChildren();
80
while
(w)
81
{
82
component = FindHandlerInChildren(w,
type
);
83
if
(component)
84
return
component;
85
86
w = w.GetSibling();
87
}
88
return
null;
89
}
96
static
ScriptedWidgetEventHandler
FindHandlerInParents(
Widget
w,
typename
type
)
97
{
98
ScriptedWidgetEventHandler
component;
99
while
(w)
100
{
101
component = w.FindHandler(
type
);
102
if
(component)
103
return
component;
104
105
w = w.GetParent();
106
}
107
return
null;
108
}
115
static
bool
InHierarchy(
Widget
w,
Widget
parent)
116
{
117
while
(w)
118
{
119
if
(w == parent)
120
return
true
;
121
122
w = w.GetParent();
123
}
124
return
false
;
125
}
132
static
bool
IsChildOf(
Widget
w, notnull
Widget
parent, out
int
depth = 0)
133
{
134
int
nStepsUp;
135
while
(w)
136
{
137
if
(w == parent && nStepsUp > 0)
138
{
139
depth = nStepsUp;
140
return
true
;
141
}
142
143
w = w.GetParent();
144
nStepsUp++;
145
}
146
return
false
;
147
}
152
static
void
RemoveChildrenFromHierarchy(
Widget
w)
153
{
154
Widget
child = w.GetChildren();
155
while
(child)
156
{
157
child.RemoveFromHierarchy();
158
child = child.GetSibling();
159
}
160
}
167
static
MenuBase
FindMenu(
Widget
w)
168
{
169
if
(!w)
170
return
null;
171
172
MenuManager
menuManager =
GetGame
().GetMenuManager();
173
if
(!menuManager)
174
return
null;
175
176
if
(!InHierarchy(w,
GetGame
().GetWorkspace()))
177
{
178
Debug
.Error2(
"SCR_WidgetTools.GetMenu()"
,
string
.Format(
"Cannot find menu of widget '%1', it's not initialized yet. Are you perhaps calling it too early, e.g., from HandlerAttached()?"
, w.GetName()));
179
return
null;
180
}
181
182
MenuBase
menuCandidate;
183
array<ScriptMenuPresetEnum> values = {};
184
for
(
int
i, count =
SCR_Enum
.GetEnumValues(
ChimeraMenuPreset
, values); i < count; i++)
185
{
186
menuCandidate = menuManager.
FindMenuByPreset
(values[i]);
187
if
(menuCandidate && InHierarchy(w, menuCandidate.GetRootWidget()))
188
return
menuCandidate;
189
}
190
return
null;
191
}
192
199
static
string
GetHierarchyLog(
Widget
w,
string
delimiter =
" / "
)
200
{
201
string
log;
202
while
(w)
203
{
204
if
(log.IsEmpty())
205
log = w.GetName();
206
else
207
log = w.GetName() + delimiter + log;
208
209
w = w.GetParent();
210
}
211
return
log;
212
}
213
221
static
ScriptedWidgetEventHandler
FindHandlerOnWidget(
Widget
root,
string
widgetName,
typename
type
)
222
{
223
if
(!root)
224
return
null;
225
226
Widget
w = root.FindAnyWidget(widgetName);
227
if
(!w)
228
return
null;
229
230
return
w.FindHandler(
type
);
231
}
232
};
ChimeraMenuPreset
ChimeraMenuPreset
Menu presets.
Definition
ChimeraMenuBase.c:4
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
type
EDamageType type
Definition
SCR_DestructibleTreeV2.c:32
Debug
Definition
Debug.c:13
MenuBase
Definition
MenuBase.c:32
MenuManager
Definition
MenuManager.c:13
MenuManager::FindMenuByPreset
proto external MenuBase FindMenuByPreset(ScriptMenuPresetEnum preset)
Finds first menu/dialog with given preset index, or nullptr when there is no such menu opened.
SCR_Enum
Definition
SCR_Enum.c:2
SCR_WidgetTools
Definition
SCR_WidgetTools.c:2
ScriptedWidgetEventHandler
Definition
ScriptedWidgetEventHandler.c:19
Widget
Definition
Widget.c:13
WidgetType
Definition
EnWidgets.c:13
scripts
Game
Global
SCR_WidgetTools.c
Generated by
1.17.0