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_CommandToolbarEditorUIComponent.c
Go to the documentation of this file.
1
2
3
class
SCR_CommandToolbarEditorUIComponent
:
SCR_BaseToolbarEditorUIComponent
4
{
5
[
Attribute
(
""
, uiwidget:
UIWidgets
.ComboBox, enums: ParamEnumArray.FromEnum(
EEditorActionGroup
))]
6
protected
ref array<EEditorActionGroup>
m_ActionGroups
;
7
8
[
Attribute
(
params
:
"layout"
)]
9
protected
ResourceName
m_SeparatorLayout
;
10
11
protected
SCR_CommandActionsEditorComponent
m_EditorActionsComponent
;
12
protected
SCR_BaseEditableEntityFilter
m_Filter
;
13
protected
ref array<ref SCR_EditorActionData>
m_aActionData
= {};
14
protected
ref array<ref SCR_BaseEditorAction>
m_aShortcuts
= {};
15
protected
ref
map<Widget, SCR_BaseEditorAction>
m_Actions
=
new
map<Widget, SCR_BaseEditorAction>
();
16
17
bool
m_queuedRefresh
=
false
;
18
//------------------------------------------------------------------------------------------------
19
protected
void
CreateItem
(
SCR_EditorActionData
actionData,
int
shortcutIndex)
20
{
21
Widget
itemWidget;
22
SCR_BaseToolbarItemEditorUIComponent
item;
23
if
(!
CreateItem
(itemWidget, item))
24
return
;
25
26
SCR_BaseEditorAction
action = actionData.GetAction();
27
if
(!action)
28
return
;
29
30
SCR_ActionToolbarItemEditorUIComponent
actionItem =
SCR_ActionToolbarItemEditorUIComponent
.Cast(item);
31
if
(actionItem)
32
actionItem.
SetAction
(action, itemWidget);
33
34
//--- Set shortcut reference - shown in GUI, but otherwise has no effect
35
action.
SetShortcutRef
(
string
.Format(
"EditorQuickCommand%1"
, shortcutIndex + 1));
36
m_aShortcuts
.InsertAt(action, shortcutIndex);
37
38
m_Actions
.Insert(itemWidget, action);
39
}
40
41
//------------------------------------------------------------------------------------------------
42
protected
void
OnEditorQuickCommand
(
int
index
)
43
{
44
if
(
m_aShortcuts
.Count() >=
index
)
45
m_EditorActionsComponent
.StartPlacing(
m_aShortcuts
[
index
- 1]);
46
}
47
protected
void
OnEditorQuickCommand1
() {
OnEditorQuickCommand
(1); }
48
protected
void
OnEditorQuickCommand2
() {
OnEditorQuickCommand
(2); }
49
protected
void
OnEditorQuickCommand3
() {
OnEditorQuickCommand
(3); }
50
protected
void
OnEditorQuickCommand4
() {
OnEditorQuickCommand
(4); }
51
protected
void
OnEditorQuickCommand5
() {
OnEditorQuickCommand
(5); }
52
protected
void
OnEditorQuickCommand6
() {
OnEditorQuickCommand
(6); }
53
protected
void
OnEditorQuickCommand7
() {
OnEditorQuickCommand
(7); }
54
protected
void
OnEditorQuickCommand8
() {
OnEditorQuickCommand
(8); }
55
protected
void
OnEditorQuickCommand9
() {
OnEditorQuickCommand
(9); }
56
protected
void
OnEditorQuickCommand10
() {
OnEditorQuickCommand
(10); }
57
//protected void OnEditorQuickCommand11() { OnEditorQuickCommand(11); }
58
//protected void OnEditorQuickCommand12() { OnEditorQuickCommand(12); }
59
60
//------------------------------------------------------------------------------------------------
61
override
protected
void
ShowEntries
(
Widget
contentWidget,
int
indexStart,
int
indexEnd)
62
{
63
if
(!
GetGame
().
GetInputManager
().IsUsingMouseAndKeyboard())
64
return
;
65
66
int
shortcutIndex;
67
indexEnd =
Math
.Min(indexEnd,
m_aActionData
.Count());
68
for
(
int
i = indexStart; i < indexEnd; i++)
69
{
70
if
(
m_aActionData
[i])
71
{
72
CreateItem
(
m_aActionData
[i], shortcutIndex);
73
shortcutIndex++;
74
}
75
else
if
(i > indexStart && i < indexEnd - 1)
76
{
77
//--- Separator (not as first or last item)
78
GetGame
().GetWorkspace().CreateWidgets(
m_SeparatorLayout
,
m_ItemsWidget
);
79
}
80
}
81
}
82
83
//Many actions can request a refresh for the GM toolbar, but we should only refresh it once per frame.
84
protected
void
QueueRefresh
()
85
{
86
if
(
m_queuedRefresh
)
87
return
;
88
89
GetGame
().GetCallqueue().CallLater(
Refresh
);
90
m_queuedRefresh
=
true
;
91
}
92
//------------------------------------------------------------------------------------------------
93
override
protected
void
Refresh
()
94
{
95
int
actionFlags;
96
m_EditorActionsComponent
.ValidateSelection(
false
);
97
int
count =
m_EditorActionsComponent
.GetAndEvaluateActions(
vector
.Zero,
m_aActionData
, actionFlags);
98
m_aShortcuts
.Clear();
99
100
//--- Filter by action group
101
for
(
int
i = count - 1; i >= 0; i--)
102
{
103
if
(!
m_ActionGroups
.Contains(
m_aActionData
[i].GetAction().GetActionGroup()))
104
{
105
m_aActionData
.Remove(i);
106
count--;
107
}
108
}
109
110
//--- Add separators
111
if
(
m_SeparatorLayout
)
112
{
113
EEditorActionGroup
group, prevGroup;
114
for
(
int
i = count - 1; i >= 0; i--)
115
{
116
group =
m_aActionData
[i].GetAction().GetActionGroup();
117
if
(group != prevGroup)
118
{
119
m_aActionData
.InsertAt(null, i + 1);
120
prevGroup = group;
121
if
(i != count - 1)
122
count++;
123
}
124
}
125
}
126
127
#ifdef WORKBENCH
128
int
debugCount =
DiagMenu
.GetValue(
SCR_DebugMenuID
.DEBUGUI_EDITOR_GUI_TOOLBAR_FILL);
129
if
(count > 0 && debugCount > 0)
130
{
131
for
(
int
i; i < debugCount; i++)
132
{
133
if
(
m_EditorActionsComponent
.ActionCanBeShown(
m_aActionData
[i].GetAction(),
vector
.Zero, actionFlags))
134
m_aActionData
.Insert(
m_aActionData
[i % count]);
135
}
136
count += debugCount;
137
}
138
#endif
139
140
if
(
m_Pagination
)
141
m_Pagination
.SetEntryCount(count);
142
143
super.Refresh();
144
145
m_queuedRefresh
=
false
;
146
}
147
148
//------------------------------------------------------------------------------------------------
152
protected
void
OnFilterChange
(
EEditableEntityState
state, set<SCR_EditableEntityComponent> entitiesInsert, set<SCR_EditableEntityComponent> entitiesRemove)
153
{
154
QueueRefresh
();
155
}
156
157
//------------------------------------------------------------------------------------------------
158
override
bool
IsUnique
()
159
{
160
return
false
;
161
}
162
163
//------------------------------------------------------------------------------------------------
164
override
void
OnInputDeviceIsGamepad
(
bool
isGamepad)
165
{
166
if
(!isGamepad)
167
{
168
m_Filter
.GetOnChanged().Insert(
OnFilterChange
);
169
QueueRefresh
();
170
}
171
else
172
{
173
m_Filter
.GetOnChanged().Remove(
OnFilterChange
);
174
DeleteAllItems
();
175
}
176
177
super.OnInputDeviceIsGamepad(isGamepad);
178
}
179
180
//------------------------------------------------------------------------------------------------
181
override
bool
OnClick
(
Widget
w,
int
x,
int
y,
int
button)
182
{
183
if
(button != 0)
184
return
false
;
185
186
SCR_BaseEditorAction
action;
187
if
(
m_Actions
.Find(w, action))
188
{
189
m_EditorActionsComponent
.StartPlacing(action);
190
}
191
return
false
;
192
}
193
194
//------------------------------------------------------------------------------------------------
195
override
void
HandlerAttachedScripted
(
Widget
w)
196
{
197
m_EditorActionsComponent
=
SCR_CommandActionsEditorComponent
.Cast(
SCR_CommandActionsEditorComponent
.GetInstance(
SCR_CommandActionsEditorComponent
,
true
));
198
if
(!
m_EditorActionsComponent
)
199
return
;
200
201
m_Filter
=
SCR_BaseEditableEntityFilter
.
GetInstance
(
EEditableEntityState
.COMMANDED,
true
);
//--- ToDo: Don't hardcode
202
if
(!
m_Filter
)
203
return
;
204
205
//--- Assign quick commands (cannot be parametrized, the function would not know which input action called it)
206
InputManager
inputManager =
GetGame
().GetInputManager();
207
inputManager.AddActionListener(
"EditorQuickCommand1"
,
EActionTrigger
.DOWN,
OnEditorQuickCommand1
);
208
inputManager.AddActionListener(
"EditorQuickCommand2"
,
EActionTrigger
.DOWN,
OnEditorQuickCommand2
);
209
inputManager.AddActionListener(
"EditorQuickCommand3"
,
EActionTrigger
.DOWN,
OnEditorQuickCommand3
);
210
inputManager.AddActionListener(
"EditorQuickCommand4"
,
EActionTrigger
.DOWN,
OnEditorQuickCommand4
);
211
inputManager.AddActionListener(
"EditorQuickCommand5"
,
EActionTrigger
.DOWN,
OnEditorQuickCommand5
);
212
inputManager.AddActionListener(
"EditorQuickCommand6"
,
EActionTrigger
.DOWN,
OnEditorQuickCommand6
);
213
inputManager.AddActionListener(
"EditorQuickCommand7"
,
EActionTrigger
.DOWN,
OnEditorQuickCommand7
);
214
inputManager.AddActionListener(
"EditorQuickCommand8"
,
EActionTrigger
.DOWN,
OnEditorQuickCommand8
);
215
inputManager.AddActionListener(
"EditorQuickCommand9"
,
EActionTrigger
.DOWN,
OnEditorQuickCommand9
);
216
inputManager.AddActionListener(
"EditorQuickCommand10"
,
EActionTrigger
.DOWN,
OnEditorQuickCommand10
);
217
//inputManager.AddActionListener("EditorQuickCommand11", EActionTrigger.DOWN, OnEditorQuickCommand11);
218
//inputManager.AddActionListener("EditorQuickCommand12", EActionTrigger.DOWN, OnEditorQuickCommand12);
219
220
OnInputDeviceIsGamepad
(!
GetGame
().
GetInputManager
().IsUsingMouseAndKeyboard());
221
222
super.HandlerAttachedScripted(w);
223
}
224
225
//------------------------------------------------------------------------------------------------
226
override
void
HandlerDeattached
(
Widget
w)
227
{
228
if
(
m_Filter
)
229
m_Filter
.GetOnChanged().Remove(
OnFilterChange
);
230
231
super.HandlerDeattached(w);
232
}
233
}
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
EEditorActionGroup
EEditorActionGroup
Definition
SCR_BaseEditorAction.c:8
GetInputManager
InputManager GetInputManager()
Definition
SCR_BaseManualCameraComponent.c:205
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition
SCR_DestructionSynchronizationComponent.c:17
params
category params
Definition
SCR_SpherePointGeneratorPreviewComponent.c:21
DiagMenu
Diagnostic and developer menu system.
Definition
DiagMenu.c:18
InputManager
Input management system for user interactions.
Definition
InputManager.c:20
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_BaseEditableEntityFilter
Definition
SCR_BaseEditableEntityFilter.c:14
SCR_BaseEditableEntityFilter::GetInstance
static SCR_BaseEditableEntityFilter GetInstance(EEditableEntityState state, bool showError=false)
Definition
SCR_BaseEditableEntityFilter.c:54
SCR_BaseEditorAction
Definition
SCR_BaseEditorAction.c:25
SCR_BaseEditorAction::SetShortcutRef
void SetShortcutRef(string shortcutRef)
Definition
SCR_BaseEditorAction.c:143
SCR_BaseToolbarEditorUIComponent
Definition
SCR_BaseToolbarEditorUIComponent.c:6
SCR_BaseToolbarEditorUIComponent::m_ItemsWidget
Widget m_ItemsWidget
Definition
SCR_BaseToolbarEditorUIComponent.c:22
SCR_BaseToolbarEditorUIComponent::DeleteAllItems
void DeleteAllItems()
Definition
SCR_BaseToolbarEditorUIComponent.c:78
SCR_BaseToolbarEditorUIComponent::m_Pagination
SCR_ExternalPaginationUIComponent m_Pagination
Definition
SCR_BaseToolbarEditorUIComponent.c:21
SCR_BaseToolbarItemEditorUIComponent
Definition
SCR_BaseToolbarItemEditorUIComponent.c:2
SCR_CommandActionsEditorComponent
Definition
SCR_CommandActionsEditorComponent.c:11
SCR_CommandToolbarEditorUIComponent
Definition
SCR_CommandToolbarEditorUIComponent.c:4
SCR_CommandToolbarEditorUIComponent::m_Actions
ref map< Widget, SCR_BaseEditorAction > m_Actions
Definition
SCR_CommandToolbarEditorUIComponent.c:15
SCR_CommandToolbarEditorUIComponent::OnEditorQuickCommand10
void OnEditorQuickCommand10()
Definition
SCR_CommandToolbarEditorUIComponent.c:56
SCR_CommandToolbarEditorUIComponent::OnInputDeviceIsGamepad
override void OnInputDeviceIsGamepad(bool isGamepad)
Definition
SCR_CommandToolbarEditorUIComponent.c:164
SCR_CommandToolbarEditorUIComponent::ShowEntries
void ShowEntries(Widget contentWidget, int indexStart, int indexEnd)
Definition
SCR_CommandToolbarEditorUIComponent.c:61
SCR_CommandToolbarEditorUIComponent::m_SeparatorLayout
ResourceName m_SeparatorLayout
Definition
SCR_CommandToolbarEditorUIComponent.c:9
SCR_CommandToolbarEditorUIComponent::OnEditorQuickCommand3
void OnEditorQuickCommand3()
Definition
SCR_CommandToolbarEditorUIComponent.c:49
SCR_CommandToolbarEditorUIComponent::OnFilterChange
void OnFilterChange(EEditableEntityState state, set< SCR_EditableEntityComponent > entitiesInsert, set< SCR_EditableEntityComponent > entitiesRemove)
Definition
SCR_CommandToolbarEditorUIComponent.c:152
SCR_CommandToolbarEditorUIComponent::Refresh
void Refresh()
Definition
SCR_CommandToolbarEditorUIComponent.c:93
SCR_CommandToolbarEditorUIComponent::m_Filter
SCR_BaseEditableEntityFilter m_Filter
Definition
SCR_CommandToolbarEditorUIComponent.c:12
SCR_CommandToolbarEditorUIComponent::m_aShortcuts
ref array< ref SCR_BaseEditorAction > m_aShortcuts
Definition
SCR_CommandToolbarEditorUIComponent.c:14
SCR_CommandToolbarEditorUIComponent::HandlerDeattached
override void HandlerDeattached(Widget w)
Definition
SCR_CommandToolbarEditorUIComponent.c:226
SCR_CommandToolbarEditorUIComponent::OnEditorQuickCommand8
void OnEditorQuickCommand8()
Definition
SCR_CommandToolbarEditorUIComponent.c:54
SCR_CommandToolbarEditorUIComponent::OnEditorQuickCommand2
void OnEditorQuickCommand2()
Definition
SCR_CommandToolbarEditorUIComponent.c:48
SCR_CommandToolbarEditorUIComponent::m_queuedRefresh
bool m_queuedRefresh
Definition
SCR_CommandToolbarEditorUIComponent.c:17
SCR_CommandToolbarEditorUIComponent::CreateItem
void CreateItem(SCR_EditorActionData actionData, int shortcutIndex)
Definition
SCR_CommandToolbarEditorUIComponent.c:19
SCR_CommandToolbarEditorUIComponent::IsUnique
override bool IsUnique()
Definition
SCR_CommandToolbarEditorUIComponent.c:158
SCR_CommandToolbarEditorUIComponent::OnEditorQuickCommand6
void OnEditorQuickCommand6()
Definition
SCR_CommandToolbarEditorUIComponent.c:52
SCR_CommandToolbarEditorUIComponent::OnEditorQuickCommand1
void OnEditorQuickCommand1()
Definition
SCR_CommandToolbarEditorUIComponent.c:47
SCR_CommandToolbarEditorUIComponent::OnEditorQuickCommand7
void OnEditorQuickCommand7()
Definition
SCR_CommandToolbarEditorUIComponent.c:53
SCR_CommandToolbarEditorUIComponent::QueueRefresh
void QueueRefresh()
Definition
SCR_CommandToolbarEditorUIComponent.c:84
SCR_CommandToolbarEditorUIComponent::HandlerAttachedScripted
override void HandlerAttachedScripted(Widget w)
Definition
SCR_CommandToolbarEditorUIComponent.c:195
SCR_CommandToolbarEditorUIComponent::OnEditorQuickCommand4
void OnEditorQuickCommand4()
Definition
SCR_CommandToolbarEditorUIComponent.c:50
SCR_CommandToolbarEditorUIComponent::OnEditorQuickCommand5
void OnEditorQuickCommand5()
Definition
SCR_CommandToolbarEditorUIComponent.c:51
SCR_CommandToolbarEditorUIComponent::m_ActionGroups
ref array< EEditorActionGroup > m_ActionGroups
Definition
SCR_CommandToolbarEditorUIComponent.c:6
SCR_CommandToolbarEditorUIComponent::m_aActionData
ref array< ref SCR_EditorActionData > m_aActionData
Definition
SCR_CommandToolbarEditorUIComponent.c:13
SCR_CommandToolbarEditorUIComponent::OnEditorQuickCommand9
void OnEditorQuickCommand9()
Definition
SCR_CommandToolbarEditorUIComponent.c:55
SCR_CommandToolbarEditorUIComponent::OnClick
override bool OnClick(Widget w, int x, int y, int button)
Definition
SCR_CommandToolbarEditorUIComponent.c:181
SCR_CommandToolbarEditorUIComponent::OnEditorQuickCommand
void OnEditorQuickCommand(int index)
Definition
SCR_CommandToolbarEditorUIComponent.c:42
SCR_CommandToolbarEditorUIComponent::m_EditorActionsComponent
SCR_CommandActionsEditorComponent m_EditorActionsComponent
Definition
SCR_CommandToolbarEditorUIComponent.c:11
SCR_EditorActionData
Definition
SCR_BaseEditorAction.c:281
UIWidgets
Definition
attributes.c:40
Widget
Definition
Widget.c:13
map
Definition
Types.c:486
vector
Definition
vector.c:13
EEditableEntityState
EEditableEntityState
Definition
EEditableEntityState.c:38
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
EActionTrigger
EActionTrigger
Definition
EActionTrigger.c:13
scripts
Game
Editor
UI
Components
Toolbar
SCR_CommandToolbarEditorUIComponent.c
Generated by
1.17.0