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_ActionsToolbarEditorUIComponent.c
Go to the documentation of this file.
1
//#define TOOLBAR_DEBUG
2
[
BaseContainerProps
(),
SCR_BaseContainerCustomTitleEnum
(
EEditorActionType
,
"m_ActionType"
)]
3
class
SCR_ActionsToolbarItemEditorUIComponent
4
{
5
[
Attribute
(
SCR_Enum
.GetDefault(
EEditorActionType
.ACTION), uiwidget:
UIWidgets
.ComboBox, enums: ParamEnumArray.FromEnum(
EEditorActionType
))]
6
EEditorActionType
m_ActionType
;
7
8
[
Attribute
(
params
:
"layout"
)]
9
ResourceName
m_Layout
;
10
}
11
13
14
class
SCR_ActionsToolbarEditorUIComponent :
SCR_BaseToolbarEditorUIComponent
15
{
16
[
Attribute
()]
17
protected
ref array<ref SCR_ActionsToolbarItemEditorUIComponent> m_aItemLayouts;
18
19
[
Attribute
(
params
:
"layout"
)]
20
protected
ResourceName
m_SeparatorLayout
;
21
22
protected
SCR_ToolbarActionsEditorComponent
m_EditorActionsComponent
;
23
protected
ref array<ref SCR_EditorActionData>
m_aActionData
= {};
24
protected
SCR_BaseEditorAction
m_RepeatAction
;
25
protected
int
m_iActionFlags
;
26
protected
ref
map<Widget, SCR_BaseEditorAction>
m_Actions
=
new
map<Widget, SCR_BaseEditorAction>
();
27
28
//------------------------------------------------------------------------------------------------
29
protected
Widget
CreateItem
(
SCR_EditorActionData
actionData)
30
{
31
SCR_BaseEditorAction
action = actionData.GetAction();
32
if
(!action)
33
return
null;
34
35
int
itemLayoutCount = m_aItemLayouts.Count();
36
if
(itemLayoutCount == 0)
37
return
null;
38
39
//--- Use first configured layout as default
40
m_ItemLayout = m_aItemLayouts[0].m_Layout;
41
42
//--- Find actual layout
43
for
(
int
i; i < itemLayoutCount; i++)
44
{
45
if
(action.
GetActionType
() == m_aItemLayouts[i].m_ActionType)
46
{
47
m_ItemLayout = m_aItemLayouts[i].m_Layout;
48
break
;
49
}
50
}
51
52
//--- Create layout
53
Widget
itemWidget;
54
SCR_BaseToolbarItemEditorUIComponent
item;
55
if
(!
CreateItem
(itemWidget, item))
56
return
null;
57
58
SCR_ActionToolbarItemEditorUIComponent
actionItem =
SCR_ActionToolbarItemEditorUIComponent
.Cast(item);
59
if
(actionItem)
60
actionItem.
SetAction
(action, itemWidget);
61
62
itemWidget.SetName(action.Type().ToString());
63
m_Actions
.Insert(itemWidget, action);
64
return
itemWidget;
65
}
66
67
//------------------------------------------------------------------------------------------------
68
override
protected
void
ShowEntries
(
Widget
contentWidget,
int
indexStart,
int
indexEnd)
69
{
70
indexEnd =
Math
.Min(indexEnd,
m_aActionData
.Count());
71
for
(
int
i = indexStart; i < indexEnd; i++)
72
{
73
if
(
m_aActionData
[i])
74
{
75
//--- Action
76
if
(
m_EditorActionsComponent
.ActionCanBeShown(
m_aActionData
[i].GetAction(),
vector
.Zero,
m_iActionFlags
))
77
{
78
Widget
itemWidget =
CreateItem
(
m_aActionData
[i]);
79
if
(itemWidget)
80
itemWidget.SetEnabled(
m_EditorActionsComponent
.ActionCanBePerformed(
m_aActionData
[i].GetAction(),
vector
.Zero,
m_iActionFlags
));
81
}
82
}
83
else
if
(i > indexStart && i < indexEnd - 1)
84
{
85
//--- Separator (not as first or last item)
86
GetGame
().GetWorkspace().CreateWidgets(
m_SeparatorLayout
, m_ItemsWidget);
87
}
88
}
89
}
90
91
//------------------------------------------------------------------------------------------------
92
override
protected
void
Refresh
()
93
{
94
int
count =
m_EditorActionsComponent
.GetAndEvaluateActions(
vector
.Zero,
m_aActionData
,
m_iActionFlags
);
95
96
//--- Add separators
97
EEditorActionGroup
group, prevGroup;
98
for
(
int
i = count - 1; i >= 0; i--)
99
{
100
group =
m_aActionData
[i].GetAction().GetActionGroup();
101
if
(group != prevGroup)
102
{
103
m_aActionData
.InsertAt(null, i + 1);
104
prevGroup = group;
105
if
(i != count - 1)
106
count++;
107
}
108
}
109
110
#ifdef WORKBENCH
111
int
debugCount =
DiagMenu
.GetValue(
SCR_DebugMenuID
.DEBUGUI_EDITOR_GUI_TOOLBAR_FILL);
112
if
(count > 0 && debugCount > 0)
113
{
114
for
(
int
i; i < debugCount; i++)
115
{
116
m_aActionData
.Insert(
m_aActionData
[i % count]);
117
}
118
count += debugCount;
119
}
120
#endif
121
122
if
(m_Pagination)
123
m_Pagination.SetEntryCount(count);
124
125
super.Refresh();
126
}
127
128
//------------------------------------------------------------------------------------------------
129
//~ Called when nightmode enabled changed to make sure the nightmode action is hidden if global night mode is enabled
130
protected
void
OnGlobalNightModeEnabledChanged
(
bool
enabled)
131
{
132
Refresh
();
133
}
134
135
//------------------------------------------------------------------------------------------------
136
override
void
OnRepeat
()
137
{
138
if
(
m_RepeatAction
)
139
m_EditorActionsComponent
.ActionPerformInstantly(
m_RepeatAction
);
140
}
141
142
//------------------------------------------------------------------------------------------------
143
override
bool
OnClick
(
Widget
w,
int
x,
int
y,
int
button)
144
{
145
super.OnClick(w, x, y, button);
146
147
if
(button != 0)
148
return
false
;
149
150
SCR_BaseEditorAction
action;
151
if
(
m_Actions
.Find(w, action))
152
{
153
m_EditorActionsComponent
.ActionPerformInstantly(action);
154
155
SCR_ActionsToolbarEditorUIComponent linkedComponent = SCR_ActionsToolbarEditorUIComponent.Cast(m_LinkedComponent);
156
if
(linkedComponent)
157
linkedComponent.m_RepeatAction = action;
158
}
159
160
if
(m_bIsInDialog)
161
{
162
EditorMenuBase
menu =
EditorMenuBase
.Cast(
GetMenu
());
163
if
(menu)
164
menu.CloseSelf();
165
}
166
167
return
false
;
168
}
169
170
//------------------------------------------------------------------------------------------------
171
override
void
HandlerAttachedScripted
(
Widget
w)
172
{
173
m_EditorActionsComponent
=
SCR_ToolbarActionsEditorComponent
.Cast(
SCR_ToolbarActionsEditorComponent
.GetInstance(
SCR_ToolbarActionsEditorComponent
,
true
));
174
if
(!
m_EditorActionsComponent
)
175
return
;
176
177
//--- Initialize all actions
178
array<SCR_BaseEditorAction> actions = {};
179
SCR_EditorToolbarAction
toolbarAction;
180
for
(
int
i = 0, count =
m_EditorActionsComponent
.GetActions(actions); i < count; i++)
181
{
182
toolbarAction =
SCR_EditorToolbarAction
.Cast(actions[i]);
183
if
(toolbarAction)
184
toolbarAction.OnInit(
this
);
185
}
186
187
//--- ToDo: Don't hardcode, but allow each action to set its refresh event
188
SCR_PlacingEditorComponent
placingManager =
SCR_PlacingEditorComponent
.Cast(
SCR_PlacingEditorComponent
.GetInstance(
SCR_PlacingEditorComponent
,
true
,
true
));
189
if
(placingManager)
190
placingManager.
GetOnSelectedPrefabChange
().Insert(
Refresh
);
191
192
SCR_EditorManagerEntity
editorManager =
SCR_EditorManagerEntity
.GetInstance();
193
if
(editorManager)
194
{
195
editorManager.GetOnCanEndGameChanged().Insert(
Refresh
);
196
editorManager.GetOnLimitedChange().Insert(
Refresh
);
197
}
198
199
SCR_BaseGameMode
gameMode =
SCR_BaseGameMode
.Cast(
GetGame
().
GetGameMode
());
200
if
(gameMode)
201
{
202
gameMode.
GetOnGameModeEnd
().Insert(
Refresh
);
203
204
SCR_NightModeGameModeComponent nightModeComponent = SCR_NightModeGameModeComponent.Cast(gameMode.FindComponent(SCR_NightModeGameModeComponent));
205
if
(nightModeComponent)
206
nightModeComponent.GetOnGlobalNightModeEnabledChanged().Insert(
OnGlobalNightModeEnabledChanged
);
207
}
208
209
super.HandlerAttachedScripted(w);
210
}
211
212
//------------------------------------------------------------------------------------------------
213
override
void
HandlerDeattached
(
Widget
w)
214
{
215
super.HandlerDeattached(w);
216
217
//--- Terminate all actions
218
if
(
m_EditorActionsComponent
)
219
{
220
array<SCR_BaseEditorAction> actions = {};
221
SCR_EditorToolbarAction
toolbarAction;
222
for
(
int
i = 0, count =
m_EditorActionsComponent
.GetActions(actions); i < count; i++)
223
{
224
toolbarAction =
SCR_EditorToolbarAction
.Cast(actions[i]);
225
if
(toolbarAction)
226
toolbarAction.OnExit(
this
);
227
}
228
}
229
230
SCR_PlacingEditorComponent
placingManager =
SCR_PlacingEditorComponent
.Cast(
SCR_PlacingEditorComponent
.GetInstance(
SCR_PlacingEditorComponent
,
false
,
true
));
231
if
(placingManager)
232
placingManager.
GetOnSelectedPrefabChange
().Remove(
Refresh
);
233
234
SCR_EditorManagerEntity
editorManager =
SCR_EditorManagerEntity
.GetInstance();
235
if
(editorManager)
236
{
237
editorManager.GetOnCanEndGameChanged().Remove(
Refresh
);
238
editorManager.GetOnLimitedChange().Remove(
Refresh
);
239
}
240
241
SCR_BaseGameMode
gameMode =
SCR_BaseGameMode
.Cast(
GetGame
().
GetGameMode
());
242
if
(gameMode)
243
{
244
gameMode.
GetOnGameModeEnd
().Remove(
Refresh
);
245
246
SCR_NightModeGameModeComponent nightModeComponent = SCR_NightModeGameModeComponent.Cast(gameMode.FindComponent(SCR_NightModeGameModeComponent));
247
if
(nightModeComponent)
248
nightModeComponent.GetOnGlobalNightModeEnabledChanged().Remove(
OnGlobalNightModeEnabledChanged
);
249
}
250
}
251
}
SCR_DebugMenuID
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition
DebugMenuID.c:4
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
BaseContainerProps
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
Definition
SCR_AIAnimationWaypoint.c:14
OnGlobalNightModeEnabledChanged
void OnGlobalNightModeEnabledChanged(bool enabled)
Definition
SCR_ActionsToolbarEditorUIComponent.c:130
m_Actions
ref map< Widget, SCR_BaseEditorAction > m_Actions
Definition
SCR_ActionsToolbarEditorUIComponent.c:26
m_EditorActionsComponent
SCR_ToolbarActionsEditorComponent m_EditorActionsComponent
Definition
SCR_ActionsToolbarEditorUIComponent.c:22
m_Layout
ResourceName m_Layout
Definition
SCR_ActionsToolbarEditorUIComponent.c:4
m_ActionType
EEditorActionType m_ActionType
Definition
SCR_ActionsToolbarEditorUIComponent.c:1
m_aActionData
ref array< ref SCR_EditorActionData > m_aActionData
Definition
SCR_ActionsToolbarEditorUIComponent.c:23
m_SeparatorLayout
ResourceName m_SeparatorLayout
Definition
SCR_ActionsToolbarEditorUIComponent.c:20
m_RepeatAction
SCR_BaseEditorAction m_RepeatAction
Definition
SCR_ActionsToolbarEditorUIComponent.c:24
m_iActionFlags
int m_iActionFlags
Definition
SCR_ActionsToolbarEditorUIComponent.c:25
EEditorActionType
EEditorActionType
Definition
SCR_BaseEditorAction.c:2
EEditorActionGroup
EEditorActionGroup
Definition
SCR_BaseEditorAction.c:8
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition
SCR_BaseGameModeComponent.c:15
SCR_BaseContainerCustomTitleEnum
class SCR_CampaignHintStorage SCR_BaseContainerCustomTitleEnum(EHint, "m_eHintId")
Definition
SCR_CampaignHintStorage.c:22
HandlerAttachedScripted
override void HandlerAttachedScripted(Widget w)
Definition
SCR_CursorEditorUIComponent.c:457
SCR_EditorManagerEntity
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
Definition
SCR_EditorManagerEntity.c:2211
Refresh
bool Refresh()
Definition
SCR_HintManagerComponent.c:188
OnClick
void OnClick()
On click callback.
Definition
SCR_MapToolMenuUI.c:143
GetMenu
SCR_RadialMenu GetMenu()
Definition
SCR_RadialMenuGameModeComponent.c:38
HandlerDeattached
override void HandlerDeattached(Widget w)
Definition
SCR_ServicesStatusDialogComponent.c:602
params
category params
Definition
SCR_SpherePointGeneratorPreviewComponent.c:21
DiagMenu
Diagnostic and developer menu system.
Definition
DiagMenu.c:18
EditorMenuBase
Definition
EditorMenuBase.c:8
Math
Definition
Math.c:13
ResourceName
Definition
ResourceName.c:13
SCR_ActionToolbarItemEditorUIComponent
Definition
SCR_ActionToolbarItemEditorUIComponent.c:2
SCR_ActionToolbarItemEditorUIComponent::SetAction
void SetAction(SCR_BaseEditorAction action, Widget widget)
Definition
SCR_ActionToolbarItemEditorUIComponent.c:32
SCR_ActionsToolbarItemEditorUIComponent
Definition
SCR_ActionsToolbarEditorUIComponent.c:4
SCR_BaseEditorAction
Definition
SCR_BaseEditorAction.c:25
SCR_BaseEditorAction::GetActionType
EEditorActionType GetActionType()
Definition
SCR_BaseEditorAction.c:119
SCR_BaseGameMode
Definition
SCR_BaseGameMode.c:139
SCR_BaseGameMode::GetOnGameModeEnd
ScriptInvoker GetOnGameModeEnd()
Definition
SCR_BaseGameMode.c:665
SCR_BaseToolbarEditorUIComponent
Definition
SCR_BaseToolbarEditorUIComponent.c:6
SCR_BaseToolbarEditorUIComponent::Refresh
void Refresh()
Definition
SCR_BaseToolbarEditorUIComponent.c:124
SCR_BaseToolbarEditorUIComponent::CreateItem
bool CreateItem(out Widget itemWidget, out SCR_BaseToolbarItemEditorUIComponent toolbarItem)
Definition
SCR_BaseToolbarEditorUIComponent.c:39
SCR_BaseToolbarEditorUIComponent::ShowEntries
void ShowEntries(Widget contentWidget, int indexStart, int indexEnd)
Definition
SCR_BaseToolbarEditorUIComponent.c:119
SCR_BaseToolbarItemEditorUIComponent
Definition
SCR_BaseToolbarItemEditorUIComponent.c:2
SCR_DialogEditorUIComponent::OnRepeat
void OnRepeat()
Definition
SCR_DialogEditorUIComponent.c:66
SCR_EditorActionData
Definition
SCR_BaseEditorAction.c:281
SCR_EditorToolbarAction
Definition
SCR_EditorToolbarAction.c:4
SCR_Enum
Definition
SCR_Enum.c:2
SCR_PlacingEditorComponent
Definition
SCR_PlacingEditorComponent.c:119
SCR_PlacingEditorComponent::GetOnSelectedPrefabChange
ScriptInvoker GetOnSelectedPrefabChange()
Definition
SCR_PlacingEditorComponent.c:1427
SCR_ToolbarActionsEditorComponent
Definition
SCR_ToolbarActionsEditorComponent.c:7
UIWidgets
Definition
attributes.c:40
Widget
Definition
Widget.c:13
map
Definition
Types.c:486
vector
Definition
vector.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
Attribute
class SCR_ActionsToolbarItemEditorUIComponent Attribute()] protected ref array< ref SCR_ActionsToolbarItemEditorUIComponent > m_aItemLayouts
Definition
SendGoalMessage.c:170
scripts
Game
Editor
UI
Components
Toolbar
SCR_ActionsToolbarEditorUIComponent.c
Generated by
1.17.0