Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_EntitiesToolbarEditorUIComponent.c
Go to the documentation of this file.
3
5{
6 [Attribute("-1", uiwidget: UIWidgets.ComboBox, "Which entity types are accepted", enums: SCR_Enum.GetList(EEditableEntityType, new ParamEnum("<ALL>", "-1")) )]
8
9 [Attribute("0", UIWidgets.ComboBox, "List of entity types who are ignored even if 'm_Type' is valid.", "", ParamEnumArray.FromEnum(EEditableEntityType) )]
10 protected ref array<EEditableEntityType> m_aTypeBlackList;
11
12 [Attribute("0", uiwidget: UIWidgets.ComboBox, "Toolbar will show all entities of this state", enums: ParamEnumArray.FromEnum(EEditableEntityState))]
14
15 [Attribute(desc: "Order offsets applied to individual states. Can be used to sort items beyond just their type.")]
16 protected ref array<ref SCR_EntityToolbarStateOffset> m_aStateOffsets;
17
18 [Attribute("0", UIWidgets.Flags, "Entities with following flags will *NOT* not be shown.", enums: ParamEnumArray.FromEnum(EEditableEntityFlag))]
20
21 [Attribute(desc: "When enabled, only direct children of currently selected layer will be shown.")]
22 protected bool m_bOnlyDirectChildren;
23
24 [Attribute("0", uiwidget: UIWidgets.ComboBox, "Order in which entities will be sorted", enums: ParamEnumArray.FromEnum(EEditableEntityType))]
25 protected ref array<EEditableEntityType> m_aTypeOrder;
26
27 [Attribute(desc: "Name of tab widget which controls entity types.")]
28 protected string m_sTypeTabsWidgetName;
30 [Attribute(desc: "List of entity types matching tabs defined in 'm_sTypeTabsWidgetName' widget. Also includes black list which are ignored even if type is valid.")]
31 protected ref array<ref SCR_EntityToolbarTypeList> m_aEntityTypeTabs;
33 protected bool m_bHasTabs;
34 protected bool m_bHasEntities;
35 protected ref SCR_SortedArray<SCR_EditableEntityComponent> m_Entities = new SCR_SortedArray<SCR_EditableEntityComponent>();
44 protected int m_iTab;
45
46 bool m_queuedRefresh = false;
47
48 //------------------------------------------------------------------------------------------------
50 {
51 Widget itemWidget;
53 if (!CreateItem(itemWidget, item))
54 return null;
55
57 if (!entityLink)
58 {
59 Print(string.Format("'%1' must contain SCR_EditableEntityLinkUIComponent!", m_ItemLayout), LogLevel.WARNING);
60 itemWidget.RemoveFromHierarchy();
61 return null;
62 }
63
65 if (entityItem)
66 entityItem.SetEntity(entity, itemWidget, m_SlotManager);
67
68 entityLink.SetLinkedEntity(entity);
69 m_ItemsMap.Insert(entity, itemWidget);
70 itemWidget.SetName(entity.ToString());
71 return itemWidget;
72 }
73
74 //Many actions can request a refresh for the GM toolbar, but we should only refresh it once per frame.
75 protected void QueueRefresh()
76 {
78 return;
80 GetGame().GetCallqueue().CallLater(Refresh);
81 m_queuedRefresh = true;
82 }
83
84 //------------------------------------------------------------------------------------------------
85 protected void Clear()
86 {
87 m_ItemsMap.Clear();
88 m_SlotManager.ClearSlots();
89 }
90
91 //------------------------------------------------------------------------------------------------
92 protected void OnChanged(EEditableEntityState state, set<SCR_EditableEntityComponent> entitiesInsert, set<SCR_EditableEntityComponent> entitiesRemove)
93 {
95 }
96
97
98 //------------------------------------------------------------------------------------------------
99 protected void OnEditorSetSelection()
100 {
102 if (linkedComponent)
103 linkedComponent.m_RepeatEntity = m_HoverEntity;
104
105 CloseDialog();
106 }
107
108 //------------------------------------------------------------------------------------------------
109 protected void OnTypeTab(SCR_TabViewComponent tabView, SCR_TabViewContent tabContent, int index)
110 {
111 m_iTab = index;
112 m_Type = m_aEntityTypeTabs[index].GetType();
114
115 QueueRefresh();
116 }
117
118 //------------------------------------------------------------------------------------------------
119 override protected void ShowEntries(Widget contentWidget, int indexStart, int indexEnd)
120 {
121 Clear();
122
123 indexEnd = Math.Min(indexEnd, m_Entities.Count());
124 for (int i = indexStart; i < indexEnd; i++)
127 }
128 }
129
130 //------------------------------------------------------------------------------------------------
131 protected override bool IsUnique()
132 {
133 return true;
134 }
135
136 //------------------------------------------------------------------------------------------------
137 override protected void SetToolbarVisible(bool show)
138 {
139 super.SetToolbarVisible(show || m_bHasEntities);
140 }
141
142 //------------------------------------------------------------------------------------------------
143 override protected void Refresh()
144 {
145 if (m_State != -1)
146 {
148
149 set<SCR_EditableEntityComponent> entities = new set<SCR_EditableEntityComponent>();
150 int count = filter.GetEntities(entities);
151
152 m_bHasEntities = false;
153 m_Entities.Clear();
154 foreach (SCR_EditableEntityComponent entity: entities)
155 {
156 if (entity
157 && (!m_aTypeBlackList.Contains(entity.GetEntityType()))
158 && (m_FlagsBlacklist == 0 || (entity.GetEntityFlags() & m_FlagsBlacklist) == 0)
159 )
160 {
161 //--- Add only entities of desired type
162 if (m_Type == -1 || entity.GetEntityType() == m_Type)
163 {
164 int order = m_aTypeOrder.Find(entity.GetEntityType());
165 if (order == -1)
166 order = 100 + entity.GetEntityType();
167
168 foreach (SCR_EntityToolbarStateOffset stateOffset: m_aStateOffsets)
169 {
170 if (entity.HasEntityState(stateOffset.m_State))
171 order += stateOffset.m_iOrderOffset;
172 }
173
174 m_Entities.Insert(order, entity);
175 m_bHasEntities = true;
176 }
177 else
178 {
179 //--- Has entities even if tabs prevent them from being shown
181 }
182 }
183 }
184
185 if (m_Pagination)
186 m_Pagination.SetEntryCount(m_Entities.Count());
187 }
189 super.Refresh();
190 m_queuedRefresh = false;
191 }
192
193 //------------------------------------------------------------------------------------------------
194 override void OnRepeat()
195 {
196 if (!m_RepeatEntity)
197 return;
198
200 if (!filter)
201 return;
202
203 filter.Replace(m_RepeatEntity);
204 }
205
206 //------------------------------------------------------------------------------------------------
207 override protected void CopyPage(SCR_DialogEditorUIComponent linkedComponent)
208 {
210 if (m_TabView)
211 m_TabView.ShowTab(toolbar.m_iTab);
212
213 super.CopyPage(linkedComponent);
214 }
215
216 //------------------------------------------------------------------------------------------------
217 override void OnMenuUpdate(float timeSlice)
219 super.OnMenuUpdate(timeSlice);
220 m_HoverFilter.SetEntityUnderCursor(m_HoverEntity, true);
221 }
222
223 //------------------------------------------------------------------------------------------------
224 override bool OnFocus(Widget w, int x, int y)
225 {
227 if (link)
228 {
229 bool canTeleport = m_HoverEntity != null; //--- Don't teleport to selected entity when the list was just opened, would be impractical
231
232 vector pos;
233 if (canTeleport && m_HoverEntity.GetPos(pos))
234 {
236 if (camera)
237 {
239 if (teleportComponent)
240 teleportComponent.TeleportCamera(pos);
241 }
242 }
244
245 return super.OnFocus(w, x, y);
246 }
247
248 //------------------------------------------------------------------------------------------------
250 {
253
255 if (!m_HoverFilter)
256 return;
257
258 if (m_State != -1)
259 {
261 if (filter)
262 filter.GetOnChanged().Insert(OnChanged);
263 }
264
265 foreach (SCR_EntityToolbarStateOffset stateOffset: m_aStateOffsets)
266 {
268 if (filter)
269 filter.GetOnChanged().Insert(OnChanged);
270 }
271
272 InputManager inputManager = GetGame().GetInputManager();
273 if (inputManager)
274 inputManager.AddActionListener("EditorSetSelection", EActionTrigger.DOWN, OnEditorSetSelection);
275
277 {
278 Widget typeTabsWidget = w.FindAnyWidget(m_sTypeTabsWidgetName);
279 if (typeTabsWidget)
280 {
281 m_bHasTabs = true;
282 m_TabView = SCR_TabViewComponent.Cast(typeTabsWidget.FindHandler(SCR_TabViewComponent));
283
284 m_TabView.GetOnContentSelect().Insert(OnTypeTab);
285
286 //Init tab
287 if (m_aEntityTypeTabs.Count() > 0)
288 OnTypeTab(null, null, 0);
289 }
290 }
291
292 super.HandlerAttachedScripted(w);
293
294 if (m_bIsInDialog)
295 {
297 if (transformingManager)
298 transformingManager.GetOnTransformationStart().Insert(CloseDialog);
299 }
300 }
301
302 //------------------------------------------------------------------------------------------------
303 override void HandlerDeattached(Widget w)
304 {
305 super.HandlerDeattached(w);
306
307 if (m_State != -1)
308 {
310 if (filter)
311 filter.GetOnChanged().Remove(OnChanged);
312 }
313 foreach (SCR_EntityToolbarStateOffset stateOffset: m_aStateOffsets)
314 {
316 if (filter)
317 filter.GetOnChanged().Insert(OnChanged);
318 }
319
320 InputManager inputManager = GetGame().GetInputManager();
321 if (inputManager)
322 inputManager.RemoveActionListener("EditorSetSelection", EActionTrigger.DOWN, OnEditorSetSelection);
323
324 if (m_bIsInDialog)
325 {
327 if (transformingManager)
328 transformingManager.GetOnTransformationStart().Remove(CloseDialog);
329 }
330 }
331}
332
334class SCR_EntityToolbarTypeList
335{
336 [Attribute("-1", uiwidget: UIWidgets.ComboBox, "Entity type which are shown in tabs defined in 'm_sTypeTabsWidgetName' widget.", enums: SCR_Enum.GetList(EEditableEntityType, new ParamEnum("<ALL>", "-1")) )]
337 protected EEditableEntityType m_Type;
338
339 [Attribute("0", UIWidgets.ComboBox, "List of entity types who are ignored even if 'm_Type' is valid.", "", ParamEnumArray.FromEnum(EEditableEntityType) )]
340 protected ref array<EEditableEntityType> m_aTypeBlackList;
341
342 //------------------------------------------------------------------------------------------------
345 {
346 return m_Type;
347 }
348
349 //------------------------------------------------------------------------------------------------
351 void GetTypeBlackList(out notnull array<EEditableEntityType> blackList)
352 {
353 blackList = m_aTypeBlackList;
354 }
355}
356
359{
360 [Attribute("-1", uiwidget: UIWidgets.ComboBox, "Entity type which are shown in tabs defined in 'm_sTypeTabsWidgetName' widget.", enums: ParamEnumArray.FromEnum(EEditableEntityState) )]
361 EEditableEntityType m_State;
362
363 [Attribute()]
364 int m_iOrderOffset;
365}
ArmaReforgerScripted GetGame()
Definition game.c:1398
override EGadgetType GetType()
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
SCR_TabViewComponent m_TabView
ref map< SCR_EditableEntityComponent, Widget > m_ItemsMap
ref array< ref SCR_EntityToolbarTypeList > m_aEntityTypeTabs
ref SCR_SortedArray< SCR_EditableEntityComponent > m_Entities
ref array< EEditableEntityType > m_aTypeBlackList
EEditableEntityType m_Type
SCR_EditableEntityComponent m_HoverEntity
SCR_EntitiesToolbarEditorUIComponent SCR_BaseToolbarEditorUIComponent SCR_BaseContainerCustomTitleEnum(EEditableEntityType, "m_Type")
SCR_EditableEntityComponent m_RepeatEntity
SCR_EntitiesToolbarEditorUIComponent SCR_BaseToolbarEditorUIComponent BaseContainerProps()
bool Refresh()
SCR_HoverEditableEntityFilter m_HoverFilter
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
SCR_SlotServiceComponentClass m_SlotManager
Service with basic slot handling functionalities.
Input management system for user interactions.
Definition Math.c:13
ScriptInvokerBase< SCR_BaseEditableEntityFilter_OnChange > GetOnChanged()
bool Replace(SCR_EditableEntityComponent entityInsert, bool onlyDirect=false, bool keepExisting=false)
static SCR_BaseEditableEntityFilter GetInstance(EEditableEntityState state, bool showError=false)
int GetEntities(out set< SCR_EditableEntityComponent > entities, bool includeChildren=false, bool evaluate=true)
SCR_ExternalPaginationUIComponent m_Pagination
static SCR_ManualCamera GetCameraInstance()
SCR_DialogEditorUIComponent m_LinkedComponent
bool HasEntityState(EEditableEntityState state)
EEditableEntityType GetEntityType(IEntity owner=null)
SCR_EditableEntitySlotManagerUIComponent m_SlotManager
ref SCR_SortedArray< SCR_EditableEntityComponent > m_Entities
ref map< SCR_EditableEntityComponent, Widget > m_ItemsMap
Widget CreateItem(SCR_EditableEntityComponent entity)
void CopyPage(SCR_DialogEditorUIComponent linkedComponent)
ref array< ref SCR_EntityToolbarTypeList > m_aEntityTypeTabs
void OnChanged(EEditableEntityState state, set< SCR_EditableEntityComponent > entitiesInsert, set< SCR_EditableEntityComponent > entitiesRemove)
ref array< ref SCR_EntityToolbarStateOffset > m_aStateOffsets
void ShowEntries(Widget contentWidget, int indexStart, int indexEnd)
void OnTypeTab(SCR_TabViewComponent tabView, SCR_TabViewContent tabContent, int index)
void SetEntity(SCR_EditableEntityComponent entity, Widget widget, SCR_EditableEntitySlotManagerUIComponent slotManager)
SCR_BaseManualCameraComponent FindCameraComponent(typename type)
Teleport the camera to the cursor's world position.
Definition Types.c:486
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
EEditableEntityType
Defines type of SCR_EditableEntityComponent. Assigned automatically based on IEntity inheritance.
EEditableEntityFlag
Unique flags of the entity.
EEditableEntityState
SCR_FieldOfViewSettings Attribute
EActionTrigger