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_ModesEditorUIComponent.c
Go to the documentation of this file.
1
2
3
class
SCR_ModesEditorUIComponent
:
SCR_DialogEditorUIComponent
4
{
5
//Rename to active modes
6
protected
ref array<EEditorMode>
m_aActiveModes
= {};
7
protected
ref SCR_SortedArray<SCR_EditorModePrefab>
m_aOrderedEditorModePrefabs
=
new
SCR_SortedArray<SCR_EditorModePrefab>();
8
//Combobox
9
protected
SCR_CustomDropdownEditorUIComponent
m_DropdownWidget
;
10
11
protected
SCR_EditorManagerEntity
m_EditorManager
;
12
13
// //------------------------------------------------------------------------------------------------
14
// protected override bool IsUnique()
15
// {
16
// return false;
17
// }
18
19
//------------------------------------------------------------------------------------------------
20
protected
void
OnModeAdd
(
SCR_EditorModeEntity
modeEntity)
21
{
22
if
(!modeEntity)
23
return
;
24
25
m_aActiveModes
.Insert(modeEntity.GetModeType());
26
RefreshModes
();
27
}
28
29
//------------------------------------------------------------------------------------------------
30
protected
void
OnModeRemove
(
SCR_EditorModeEntity
modeEntity)
31
{
32
if
(!modeEntity)
33
return
;
34
35
int
index
=
m_aActiveModes
.Find(modeEntity.GetModeType());
36
if
(
index
< 0)
37
return
;
38
39
m_aActiveModes
.Remove(
index
);
40
RefreshModes
();
41
}
42
43
//------------------------------------------------------------------------------------------------
44
protected
void
CreateDropdown
()
45
{
46
//m_DropdownWidget.ClearAll();
47
if
(!
m_EditorManager
)
48
return
;
49
50
SCR_EditorModeEntity
currentModeEntity =
m_EditorManager
.GetCurrentModeEntity();
51
52
int
count =
m_aOrderedEditorModePrefabs
.Count();
53
54
for
(
int
i = 0; i < count; ++i)
55
{
56
SCR_EditorModeUIInfo
info =
m_aOrderedEditorModePrefabs
[i].GetInfo();
57
58
if
(info)
59
{
60
m_DropdownWidget
.AddItem(info, info.
GetModeColor
());
61
62
if
(currentModeEntity && currentModeEntity.GetModeType() ==
m_aOrderedEditorModePrefabs
[i].GetMode())
63
m_DropdownWidget
.SetCurrentItem(i,
false
);
64
}
65
66
}
67
68
RefreshModes
();
69
}
70
71
//------------------------------------------------------------------------------------------------
72
protected
void
OnModeSelected
(
SCR_CustomDropdownEditorUIComponent
dropdown,
int
index
)
73
{
74
if
(!
m_EditorManager
)
75
return
;
76
77
m_EditorManager
.SetCurrentMode(
m_aOrderedEditorModePrefabs
[
index
].GetMode());
78
m_DropdownWidget
.CloseDropdown();
79
}
80
81
//------------------------------------------------------------------------------------------------
82
protected
void
OnModeChange
(
SCR_EditorModeEntity
currentModeEntity,
SCR_EditorModeEntity
prevModeEntity)
83
{
84
//Close if dialog or close list if not (mainly for if mode is forced changed)
85
if
(
m_bIsInDialog
)
86
CloseDialog
();
87
88
if
(!
m_EditorManager
)
89
return
;
90
91
WorkspaceWidget
workspace =
GetGame
().GetWorkspace();
92
if
(workspace)
93
{
94
if
(workspace.GetFocusedWidget() ==
m_DropdownWidget
.GetRootWidget())
95
workspace.SetFocusedWidget(null);
96
}
97
98
RefreshModes
();
99
}
100
101
//------------------------------------------------------------------------------------------------
102
protected
void
RefreshModes
()
103
{
104
SCR_EditorModeEntity
currentModeEntity =
m_EditorManager
.GetCurrentModeEntity();
105
if
(!currentModeEntity)
106
return
;
107
108
int
modeCount = 0;
109
110
int
count =
m_aOrderedEditorModePrefabs
.Count();
111
for
(
int
i = 0; i < count; ++i)
112
{
113
m_DropdownWidget
.SetItemVisible(i,
m_aActiveModes
.Contains(
m_aOrderedEditorModePrefabs
[i].GetMode()));
114
115
if
(!
m_aActiveModes
.Contains(
m_aOrderedEditorModePrefabs
[i].GetMode()))
116
continue
;
117
118
modeCount++;
119
120
//Set combobox selected element
121
if
(currentModeEntity.GetModeType() ==
m_aOrderedEditorModePrefabs
[i].GetMode())
122
m_DropdownWidget
.SetCurrentItem(i,
false
);
123
}
124
125
//m_DropdownWidget.SetDropdownEnable(modeCount > 1);
126
}
127
128
//------------------------------------------------------------------------------------------------
129
protected
override
void
OnDialogOpened
(
SCR_DialogEditorUIComponent
linkedComponent)
130
{
131
super.OnDialogOpened(linkedComponent);
132
//m_DropdownWidget.AllowFocus(true);
133
134
int
selected = 0;
135
136
if
(
m_EditorManager
)
137
{
138
EEditorMode
currentMode =
m_EditorManager
.GetCurrentMode();
139
int
count =
m_aOrderedEditorModePrefabs
.Count();
140
141
for
(
int
i = 0; i < count; ++i)
142
{
143
if
(
m_aOrderedEditorModePrefabs
[i].GetMode() == currentMode)
144
{
145
selected = i;
146
break
;
147
}
148
}
149
150
}
151
}
152
153
//---- REFACTOR NOTE START: Set current mode might be more clear?
154
155
//------------------------------------------------------------------------------------------------
156
protected
void
SetSiblingMode
(
int
relIndex)
157
{
158
if
(!
m_EditorManager
||
m_EditorManager
.IsModeChangeRequested())
159
return
;
160
161
array<EEditorMode> modes = {};
162
int
modesCount =
m_EditorManager
.GetModes(modes);
163
if
(modesCount <= 1)
164
return
;
165
166
int
index
= modes.Find(
m_EditorManager
.GetCurrentMode()) + relIndex;
167
m_EditorManager
.SetCurrentMode(modes[(
index
+ modesCount) % modesCount])
168
}
169
170
//---- REFACTOR NOTE END ----
171
172
//------------------------------------------------------------------------------------------------
173
protected
void
OnEditorModePrev
(
float
value,
EActionTrigger
reason
)
174
{
175
SetSiblingMode
(-1);
176
}
177
178
//------------------------------------------------------------------------------------------------
179
protected
void
OnEditorModeNext
(
float
value,
EActionTrigger
reason
)
180
{
181
SetSiblingMode
(1);
182
}
183
184
//------------------------------------------------------------------------------------------------
185
override
void
OnRepeat
()
186
{
187
if
(
m_EditorManager
)
188
m_EditorManager
.RestorePreviousMode();
189
}
190
191
//------------------------------------------------------------------------------------------------
192
override
void
OnInputDeviceIsGamepad
(
bool
isGamepad)
193
{
194
if
(
m_bIsInDialog
)
195
CloseDialog
();
196
197
m_DropdownWidget
.CloseDropdown();
198
}
199
200
//------------------------------------------------------------------------------------------------
201
protected
void
OnDropdownOpen
(
SCR_CustomDropdownEditorUIComponent
dropdown)
202
{
203
if
(
m_bIsInDialog
)
204
m_CanCloseWithToggleAction
=
false
;
205
206
}
207
208
//------------------------------------------------------------------------------------------------
209
protected
void
OnDropdownClosed
(
SCR_CustomDropdownEditorUIComponent
dropdown)
210
{
211
if
(
m_bIsInDialog
)
212
{
213
m_CanCloseWithToggleAction
=
true
;
214
CloseDialog
();
215
}
216
}
217
218
//------------------------------------------------------------------------------------------------
219
override
void
HandlerAttachedScripted
(
Widget
w)
220
{
221
super.HandlerAttachedScripted(w);
222
223
SCR_EditorManagerCore
core =
SCR_EditorManagerCore
.Cast(
SCR_EditorManagerCore
.GetInstance(
SCR_EditorManagerCore
));
224
if
(!core)
225
return
;
226
227
m_EditorManager
=
SCR_EditorManagerEntity
.GetInstance();
228
if
(!
m_EditorManager
)
229
return
;
230
231
m_DropdownWidget
=
SCR_CustomDropdownEditorUIComponent
.Cast(w.FindHandler(
SCR_CustomDropdownEditorUIComponent
));
232
if
(!
m_DropdownWidget
)
233
return
;
234
235
//~Hotfix for border always showing
236
Widget
border = w.FindAnyWidget(
"Border"
);
237
if
(border)
238
border.SetOpacity(0);
239
240
m_DropdownWidget
.GetOnChanged().Insert(
OnModeSelected
);
241
m_DropdownWidget
.GetOnOpened().Insert(
OnDropdownOpen
);
242
243
array<SCR_EditorModeEntity> modeEntities = {};
244
int
modesCount =
m_EditorManager
.GetModeEntities(modeEntities);
245
for
(
int
i = 0; i < modesCount; i++)
246
{
247
OnModeAdd
(modeEntities[i]);
248
}
249
250
//Create combobox
251
core.
GetBaseModePrefabs
(
m_aOrderedEditorModePrefabs
, -1,
true
);
252
CreateDropdown
();
253
254
SCR_EditorModeEntity
currentModeEntity =
m_EditorManager
.GetCurrentModeEntity();
255
256
m_EditorManager
.GetOnModeAdd().Insert(
OnModeAdd
);
257
m_EditorManager
.GetOnModeRemove().Insert(
OnModeRemove
);
258
m_EditorManager
.GetOnModeChange().Insert(
OnModeChange
);
259
260
InputManager
inputManager =
GetGame
().GetInputManager();
261
if
(inputManager)
262
{
263
inputManager.AddActionListener(
"EditorModePrev"
,
EActionTrigger
.PRESSED,
OnEditorModePrev
);
264
inputManager.AddActionListener(
"EditorModeNext"
,
EActionTrigger
.PRESSED,
OnEditorModeNext
);
265
}
266
}
267
268
//------------------------------------------------------------------------------------------------
269
override
void
HandlerDeattached
(
Widget
w)
270
{
271
super.HandlerDeattached(w);
272
273
if
(
m_EditorManager
)
274
{
275
m_EditorManager
.GetOnModeAdd().Remove(
OnModeAdd
);
276
m_EditorManager
.GetOnModeRemove().Remove(
OnModeRemove
);
277
m_EditorManager
.GetOnModeChange().Remove(
OnModeChange
);
278
}
279
280
InputManager
inputManager =
GetGame
().GetInputManager();
281
if
(inputManager)
282
{
283
inputManager.RemoveActionListener(
"EditorModePrev"
,
EActionTrigger
.PRESSED,
OnEditorModePrev
);
284
inputManager.RemoveActionListener(
"EditorModeNext"
,
EActionTrigger
.PRESSED,
OnEditorModeNext
);
285
}
286
287
if
(
m_DropdownWidget
)
288
{
289
m_DropdownWidget
.GetOnChanged().Remove(
OnModeSelected
);
290
m_DropdownWidget
.GetOnOpened().Remove(
OnDropdownOpen
);
291
m_DropdownWidget
.GetOnClosed().Remove(
OnDropdownClosed
);
292
}
293
}
294
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition
SCR_DestructionSynchronizationComponent.c:17
SCR_EditorManagerEntity
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
Definition
SCR_EditorManagerEntity.c:2211
reason
string reason
Definition
ServerBrowserMenuCallbacks.c:41
InputManager
Input management system for user interactions.
Definition
InputManager.c:20
SCR_CustomDropdownEditorUIComponent
Definition
SCR_CustomDropdownEditorUIComponent.c:2
SCR_DialogEditorUIComponent
Definition
SCR_DialogEditorUIComponent.c:4
SCR_DialogEditorUIComponent::m_CanCloseWithToggleAction
bool m_CanCloseWithToggleAction
Definition
SCR_DialogEditorUIComponent.c:18
SCR_DialogEditorUIComponent::m_bIsInDialog
bool m_bIsInDialog
Definition
SCR_DialogEditorUIComponent.c:17
SCR_DialogEditorUIComponent::CloseDialog
void CloseDialog()
Definition
SCR_DialogEditorUIComponent.c:77
SCR_EditorManagerCore
Core component to manage SCR_EditorManagerEntity.
Definition
SCR_EditorManagerCore.c:6
SCR_EditorManagerCore::GetBaseModePrefabs
int GetBaseModePrefabs(out notnull array< SCR_EditorModePrefab > outPrefabs, EEditorModeFlag flags=-1, bool coreOnly=false)
Definition
SCR_EditorManagerCore.c:316
SCR_EditorModeEntity
Definition
SCR_EditorModeEntity.c:23
SCR_EditorModeUIInfo
Definition
SCR_EditorModeUIInfo.c:3
SCR_EditorModeUIInfo::GetModeColor
Color GetModeColor()
Definition
SCR_EditorModeUIInfo.c:11
SCR_ModesEditorUIComponent
Definition
SCR_ModesEditorUIComponent.c:4
SCR_ModesEditorUIComponent::m_EditorManager
SCR_EditorManagerEntity m_EditorManager
Definition
SCR_ModesEditorUIComponent.c:11
SCR_ModesEditorUIComponent::SetSiblingMode
void SetSiblingMode(int relIndex)
Definition
SCR_ModesEditorUIComponent.c:156
SCR_ModesEditorUIComponent::RefreshModes
void RefreshModes()
Definition
SCR_ModesEditorUIComponent.c:102
SCR_ModesEditorUIComponent::OnModeSelected
void OnModeSelected(SCR_CustomDropdownEditorUIComponent dropdown, int index)
Definition
SCR_ModesEditorUIComponent.c:72
SCR_ModesEditorUIComponent::OnEditorModePrev
void OnEditorModePrev(float value, EActionTrigger reason)
Definition
SCR_ModesEditorUIComponent.c:173
SCR_ModesEditorUIComponent::HandlerAttachedScripted
override void HandlerAttachedScripted(Widget w)
Definition
SCR_ModesEditorUIComponent.c:219
SCR_ModesEditorUIComponent::OnModeChange
void OnModeChange(SCR_EditorModeEntity currentModeEntity, SCR_EditorModeEntity prevModeEntity)
Definition
SCR_ModesEditorUIComponent.c:82
SCR_ModesEditorUIComponent::OnRepeat
override void OnRepeat()
Definition
SCR_ModesEditorUIComponent.c:185
SCR_ModesEditorUIComponent::m_DropdownWidget
SCR_CustomDropdownEditorUIComponent m_DropdownWidget
Definition
SCR_ModesEditorUIComponent.c:9
SCR_ModesEditorUIComponent::OnModeRemove
void OnModeRemove(SCR_EditorModeEntity modeEntity)
Definition
SCR_ModesEditorUIComponent.c:30
SCR_ModesEditorUIComponent::CreateDropdown
void CreateDropdown()
Definition
SCR_ModesEditorUIComponent.c:44
SCR_ModesEditorUIComponent::OnDropdownOpen
void OnDropdownOpen(SCR_CustomDropdownEditorUIComponent dropdown)
Definition
SCR_ModesEditorUIComponent.c:201
SCR_ModesEditorUIComponent::m_aOrderedEditorModePrefabs
ref SCR_SortedArray< SCR_EditorModePrefab > m_aOrderedEditorModePrefabs
Definition
SCR_ModesEditorUIComponent.c:7
SCR_ModesEditorUIComponent::OnModeAdd
void OnModeAdd(SCR_EditorModeEntity modeEntity)
Definition
SCR_ModesEditorUIComponent.c:20
SCR_ModesEditorUIComponent::m_aActiveModes
ref array< EEditorMode > m_aActiveModes
Definition
SCR_ModesEditorUIComponent.c:6
SCR_ModesEditorUIComponent::OnInputDeviceIsGamepad
override void OnInputDeviceIsGamepad(bool isGamepad)
Definition
SCR_ModesEditorUIComponent.c:192
SCR_ModesEditorUIComponent::OnEditorModeNext
void OnEditorModeNext(float value, EActionTrigger reason)
Definition
SCR_ModesEditorUIComponent.c:179
SCR_ModesEditorUIComponent::OnDialogOpened
override void OnDialogOpened(SCR_DialogEditorUIComponent linkedComponent)
Definition
SCR_ModesEditorUIComponent.c:129
SCR_ModesEditorUIComponent::HandlerDeattached
override void HandlerDeattached(Widget w)
Definition
SCR_ModesEditorUIComponent.c:269
SCR_ModesEditorUIComponent::OnDropdownClosed
void OnDropdownClosed(SCR_CustomDropdownEditorUIComponent dropdown)
Definition
SCR_ModesEditorUIComponent.c:209
Widget
Definition
Widget.c:13
WorkspaceWidget
Definition
WorkspaceWidget.c:16
EEditorMode
EEditorMode
Editor mode that defines overall functionality.
Definition
EEditorMode.c:6
EActionTrigger
EActionTrigger
Definition
EActionTrigger.c:13
scripts
Game
Editor
UI
Components
Common
SCR_ModesEditorUIComponent.c
Generated by
1.17.0