Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_EntitiesToolbarEditorUIComponent.c
Go to the documentation of this file.
1 
3 
5 {
6  [Attribute("-1", uiwidget: UIWidgets.ComboBox, "Which entity types are accepted", enums: SCR_Enum.GetList(EEditableEntityType, new ParamEnum("<ALL>", "-1")) )]
7  protected EEditableEntityType m_Type;
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))]
13  protected EEditableEntityState m_State;
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))]
19  protected EEditableEntityFlag m_FlagsBlacklist;
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;
29 
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;
32 
33  protected bool m_bHasTabs;
34  protected bool m_bHasEntities;
35  protected ref SCR_SortedArray<SCR_EditableEntityComponent> m_Entities = new SCR_SortedArray<SCR_EditableEntityComponent>();
36 
37  protected ref map<SCR_EditableEntityComponent, Widget> m_ItemsMap = new map<SCR_EditableEntityComponent, Widget>();
38  protected SCR_HoverEditableEntityFilter m_HoverFilter;
39  protected SCR_EditableEntityComponent m_HoverEntity;
40  protected SCR_EditableEntityComponent m_RepeatEntity;
41  protected SCR_EditableEntitySlotManagerUIComponent m_SlotManager;
42  protected SCR_LayersEditorComponent m_LayersManager;
43  protected SCR_TabViewComponent m_TabView;
44  protected int m_iTab;
45 
46  //------------------------------------------------------------------------------------------------
47  protected Widget CreateItem(SCR_EditableEntityComponent entity)
48  {
49  Widget itemWidget;
51  if (!CreateItem(itemWidget, item))
52  return null;
53 
55  if (!entityLink)
56  {
57  Print(string.Format("'%1' must contain SCR_EditableEntityLinkUIComponent!", m_ItemLayout), LogLevel.WARNING);
58  itemWidget.RemoveFromHierarchy();
59  return null;
60  }
61 
63  if (entityItem)
64  entityItem.SetEntity(entity, itemWidget, m_SlotManager);
65 
66  entityLink.SetLinkedEntity(entity);
67  m_ItemsMap.Insert(entity, itemWidget);
68  itemWidget.SetName(entity.ToString());
69  return itemWidget;
70  }
71 
72  //------------------------------------------------------------------------------------------------
73  protected void Clear()
74  {
75  m_ItemsMap.Clear();
76  m_SlotManager.ClearSlots();
77  }
78 
79  //------------------------------------------------------------------------------------------------
80  protected void OnChanged(EEditableEntityState state, set<SCR_EditableEntityComponent> entitiesInsert, set<SCR_EditableEntityComponent> entitiesRemove)
81  {
82  Refresh();
83  }
84 
85  //------------------------------------------------------------------------------------------------
86  protected void OnEditorSetSelection()
87  {
88  SCR_EntitiesToolbarEditorUIComponent linkedComponent = SCR_EntitiesToolbarEditorUIComponent.Cast(m_LinkedComponent);
89  if (linkedComponent)
90  linkedComponent.m_RepeatEntity = m_HoverEntity;
91 
92  CloseDialog();
93  }
94 
95  //------------------------------------------------------------------------------------------------
96  protected void OnTypeTab(SCR_TabViewComponent tabView, SCR_TabViewContent tabContent, int index)
97  {
98  m_iTab = index;
99  m_Type = m_aEntityTypeTabs[index].GetType();
100  m_aEntityTypeTabs[index].GetTypeBlackList(m_aTypeBlackList);
101  Refresh();
102  }
103 
104  //------------------------------------------------------------------------------------------------
105  override protected void ShowEntries(Widget contentWidget, int indexStart, int indexEnd)
106  {
107  Clear();
108 
109  indexEnd = Math.Min(indexEnd, m_Entities.Count());
110  for (int i = indexStart; i < indexEnd; i++)
111  {
112  CreateItem(m_Entities[i]);
113  }
114  }
115 
116  //------------------------------------------------------------------------------------------------
117  protected override bool IsUnique()
118  {
119  return true;
120  }
121 
122  //------------------------------------------------------------------------------------------------
123  override protected void SetToolbarVisible(bool show)
124  {
125  super.SetToolbarVisible(show || m_bHasEntities);
126  }
127 
128  //------------------------------------------------------------------------------------------------
129  override protected void Refresh()
130  {
131  if (m_State != -1)
132  {
134 
135  set<SCR_EditableEntityComponent> entities = new set<SCR_EditableEntityComponent>();
136  int count = filter.GetEntities(entities);
137 
138  m_bHasEntities = false;
139  m_Entities.Clear();
140  foreach (SCR_EditableEntityComponent entity: entities)
141  {
142  if (entity
143  && (!m_aTypeBlackList.Contains(entity.GetEntityType()))
144  && (m_FlagsBlacklist == 0 || (entity.GetEntityFlags() & m_FlagsBlacklist) == 0)
145  )
146  {
147  //--- Add only entities of desired type
148  if (m_Type == -1 || entity.GetEntityType() == m_Type)
149  {
150  int order = m_aTypeOrder.Find(entity.GetEntityType());
151  if (order == -1)
152  order = 100 + entity.GetEntityType();
153 
154  foreach (SCR_EntityToolbarStateOffset stateOffset: m_aStateOffsets)
155  {
156  if (entity.HasEntityState(stateOffset.m_State))
157  order += stateOffset.m_iOrderOffset;
158  }
159 
160  m_Entities.Insert(order, entity);
161  m_bHasEntities = true;
162  }
163  else
164  {
165  //--- Has entities even if tabs prevent them from being shown
167  }
168  }
169  }
170 
171  if (m_Pagination)
172  m_Pagination.SetEntryCount(m_Entities.Count());
173  }
174  super.Refresh();
175  }
176 
177  //------------------------------------------------------------------------------------------------
178  override void OnRepeat()
179  {
180  if (!m_RepeatEntity)
181  return;
182 
183  SCR_BaseEditableEntityFilter filter = SCR_BaseEditableEntityFilter.GetInstance(EEditableEntityState.SELECTED); //--- ToDo: Don't hardcode?
184  if (!filter)
185  return;
186 
187  filter.Replace(m_RepeatEntity);
188  }
189 
190  //------------------------------------------------------------------------------------------------
191  override protected void CopyPage(SCR_DialogEditorUIComponent linkedComponent)
192  {
194  if (m_TabView)
195  m_TabView.ShowTab(toolbar.m_iTab);
196 
197  super.CopyPage(linkedComponent);
198  }
199 
200  //------------------------------------------------------------------------------------------------
201  override void OnMenuUpdate(float timeSlice)
202  {
203  super.OnMenuUpdate(timeSlice);
204  m_HoverFilter.SetEntityUnderCursor(m_HoverEntity, true);
205  }
206 
207  //------------------------------------------------------------------------------------------------
208  override bool OnFocus(Widget w, int x, int y)
209  {
211  if (link)
212  {
213  bool canTeleport = m_HoverEntity != null; //--- Don't teleport to selected entity when the list was just opened, would be impractical
214  m_HoverEntity = link.GetLinkedEntity();
215 
216  vector pos;
217  if (canTeleport && m_HoverEntity.GetPos(pos))
218  {
219  SCR_ManualCamera camera = SCR_CameraEditorComponent.GetCameraInstance();
220  if (camera)
221  {
223  if (teleportComponent)
224  teleportComponent.TeleportCamera(pos);
225  }
226  }
227  }
228 
229  return super.OnFocus(w, x, y);
230  }
231 
232  //------------------------------------------------------------------------------------------------
233  override void HandlerAttachedScripted(Widget w)
234  {
237 
239  if (!m_HoverFilter)
240  return;
241 
242  if (m_State != -1)
243  {
245  if (filter)
246  filter.GetOnChanged().Insert(OnChanged);
247  }
248 
249  foreach (SCR_EntityToolbarStateOffset stateOffset: m_aStateOffsets)
250  {
251  SCR_BaseEditableEntityFilter filter = SCR_BaseEditableEntityFilter.GetInstance(stateOffset.m_State, true);
252  if (filter)
253  filter.GetOnChanged().Insert(OnChanged);
254  }
255 
256  InputManager inputManager = GetGame().GetInputManager();
257  if (inputManager)
258  inputManager.AddActionListener("EditorSetSelection", EActionTrigger.DOWN, OnEditorSetSelection);
259 
260  if (m_sTypeTabsWidgetName)
261  {
262  Widget typeTabsWidget = w.FindAnyWidget(m_sTypeTabsWidgetName);
263  if (typeTabsWidget)
264  {
265  m_bHasTabs = true;
266  m_TabView = SCR_TabViewComponent.Cast(typeTabsWidget.FindHandler(SCR_TabViewComponent));
267 
268  m_TabView.GetOnContentSelect().Insert(OnTypeTab);
269 
270  //Init tab
271  if (m_aEntityTypeTabs.Count() > 0)
272  OnTypeTab(null, null, 0);
273  }
274  }
275 
276  super.HandlerAttachedScripted(w);
277 
278  if (m_bIsInDialog)
279  {
281  if (transformingManager)
282  transformingManager.GetOnTransformationStart().Insert(CloseDialog);
283  }
284  }
285 
286  //------------------------------------------------------------------------------------------------
287  override void HandlerDeattached(Widget w)
288  {
289  super.HandlerDeattached(w);
290 
291  if (m_State != -1)
292  {
294  if (filter)
295  filter.GetOnChanged().Remove(OnChanged);
296  }
297  foreach (SCR_EntityToolbarStateOffset stateOffset: m_aStateOffsets)
298  {
299  SCR_BaseEditableEntityFilter filter = SCR_BaseEditableEntityFilter.GetInstance(stateOffset.m_State);
300  if (filter)
301  filter.GetOnChanged().Insert(OnChanged);
302  }
303 
304  InputManager inputManager = GetGame().GetInputManager();
305  if (inputManager)
306  inputManager.RemoveActionListener("EditorSetSelection", EActionTrigger.DOWN, OnEditorSetSelection);
307 
308  if (m_bIsInDialog)
309  {
311  if (transformingManager)
312  transformingManager.GetOnTransformationStart().Remove(CloseDialog);
313  }
314  }
315 }
316 
318 class SCR_EntityToolbarTypeList
319 {
320  [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")) )]
321  protected EEditableEntityType m_Type;
322 
323  [Attribute("0", UIWidgets.ComboBox, "List of entity types who are ignored even if 'm_Type' is valid.", "", ParamEnumArray.FromEnum(EEditableEntityType) )]
324  protected ref array<EEditableEntityType> m_aTypeBlackList;
325 
326  //------------------------------------------------------------------------------------------------
329  {
330  return m_Type;
331  }
332 
333  //------------------------------------------------------------------------------------------------
335  void GetTypeBlackList(out notnull array<EEditableEntityType> blackList)
336  {
337  blackList = m_aTypeBlackList;
338  }
339 }
340 
343 {
344  [Attribute("-1", uiwidget: UIWidgets.ComboBox, "Entity type which are shown in tabs defined in 'm_sTypeTabsWidgetName' widget.", enums: ParamEnumArray.FromEnum(EEditableEntityState) )]
346 
347  [Attribute()]
348  int m_iOrderOffset;
349 }
EEditableEntityState
EEditableEntityState
Definition: EEditableEntityState.c:37
EEditableEntityFlag
EEditableEntityFlag
Unique flags of the entity.
Definition: EEditableEntityFlag.c:5
SCR_ManualCamera
Definition: SCR_ManualCamera.c:16
SCR_Enum
Definition: SCR_Enum.c:1
GetType
override EGadgetType GetType()
Definition: SCR_CampaignBuildingGadgetToolComponent.c:52
SCR_EntityToolbarItemEditorUIComponent
Definition: SCR_EntityToolbarItemEditorUIComponent.c:1
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_CameraEditorComponent
Definition: SCR_CameraEditorComponent.c:13
SCR_BaseContainerCustomTitleEnum
SCR_EntitiesToolbarEditorUIComponent SCR_BaseToolbarEditorUIComponent SCR_BaseContainerCustomTitleEnum(EEditableEntityType, "m_Type")
Definition: SCR_EntitiesToolbarEditorUIComponent.c:317
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_EntityToolbarStateOffset
Definition: SCR_EntitiesToolbarEditorUIComponent.c:342
m_TabView
protected SCR_TabViewComponent m_TabView
Definition: SCR_EntitiesToolbarEditorUIComponent.c:39
m_iTab
protected int m_iTab
Definition: SCR_EntitiesToolbarEditorUIComponent.c:40
SCR_TabViewComponent
Definition: SCR_TabViewComponent.c:13
m_aEntityTypeTabs
protected ref array< ref SCR_EntityToolbarTypeList > m_aEntityTypeTabs
Definition: SCR_EntitiesToolbarEditorUIComponent.c:27
m_ItemsMap
protected ref map< SCR_EditableEntityComponent, Widget > m_ItemsMap
Definition: SCR_EntitiesToolbarEditorUIComponent.c:33
m_aStateOffsets
protected ref array< ref SCR_EntityToolbarStateOffset > m_aStateOffsets
Definition: SCR_EntitiesToolbarEditorUIComponent.c:12
SCR_EditableEntitySlotManagerUIComponent
Definition: SCR_EditableEntitySlotManagerUIComponent.c:1
m_SlotManager
SCR_SlotServiceComponentClass m_SlotManager
Service with basic slot handling functionalities.
SCR_TransformingEditorComponent
Definition: SCR_TransformingEditorComponent.c:33
Attribute
typedef Attribute
Post-process effect of scripted camera.
m_aTypeOrder
protected ref array< EEditableEntityType > m_aTypeOrder
Definition: SCR_EntitiesToolbarEditorUIComponent.c:21
m_bHasEntities
protected bool m_bHasEntities
Definition: SCR_EntitiesToolbarEditorUIComponent.c:30
EEditableEntityType
EEditableEntityType
Defines type of SCR_EditableEntityComponent. Assigned automatically based on IEntity inheritance.
Definition: EEditableEntityType.c:5
m_LayersManager
protected SCR_LayersEditorComponent m_LayersManager
Definition: SCR_EntitiesToolbarEditorUIComponent.c:38
m_HoverFilter
protected SCR_HoverEditableEntityFilter m_HoverFilter
Definition: SCR_PreviewEntityEditorUIComponent.c:45
m_Type
protected EEditableEntityType m_Type
Definition: SCR_EntitiesToolbarEditorUIComponent.c:3
m_Entities
protected ref SCR_SortedArray< SCR_EditableEntityComponent > m_Entities
Definition: SCR_EntitiesToolbarEditorUIComponent.c:31
m_bHasTabs
protected bool m_bHasTabs
Definition: SCR_EntitiesToolbarEditorUIComponent.c:29
SCR_HoverEditableEntityFilter
Definition: SCR_HoverEditableEntityFilter.c:6
m_RepeatEntity
protected SCR_EditableEntityComponent m_RepeatEntity
Definition: SCR_EntitiesToolbarEditorUIComponent.c:36
m_HoverEntity
protected SCR_EditableEntityComponent m_HoverEntity
Definition: SCR_EntitiesToolbarEditorUIComponent.c:35
SCR_BaseEditableEntityFilter
Definition: SCR_BaseEditableEntityFilter.c:13
SCR_BaseToolbarItemEditorUIComponent
Definition: SCR_BaseToolbarItemEditorUIComponent.c:1
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
SCR_LayersEditorComponent
Definition: SCR_LayersEditorManager.c:11
SCR_EntitiesToolbarEditorUIComponent
Definition: SCR_EntitiesToolbarEditorUIComponent.c:4
m_State
private EEditableEntityState m_State
Definition: SCR_BaseEntitiesEditorUIEffect.c:3
m_aTypeBlackList
protected ref array< EEditableEntityType > m_aTypeBlackList
Definition: SCR_EntitiesToolbarEditorUIComponent.c:6
SCR_TeleportToCursorManualCameraComponent
Teleport the camera to the cursor's world position.
Definition: SCR_TeleportToCursorManualCameraComponent.c:5
SCR_DialogEditorUIComponent
Definition: SCR_DialogEditorUIComponent.c:3
m_FlagsBlacklist
private EManualCameraFlag m_FlagsBlacklist
Definition: SCR_BaseManualCameraComponent.c:9
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468
SCR_BaseToolbarEditorUIComponent
Definition: SCR_BaseToolbarEditorUIComponent.c:5