Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_EditableEntitySlotManagerUIComponent.c
Go to the documentation of this file.
2 {
3  [Attribute()]
4  protected ref SCR_EditableEntityUIConfig m_EditableEntityUI;
5 
6  [Attribute(desc: "List of only states which will be tracked. When empty, all states will be tracked.\nUsed to show only specific icons, e.g., only the default one (RENDERED) and player overlay (PLAYER).", uiwidget: UIWidgets.Flags, enums: ParamEnumArray.FromEnum(EEditableEntityState))]
7  protected EEditableEntityState m_WhitelistedStates;
8 
9  [Attribute(desc: "List of states which will not be tracked, even when they're part of Editable Entity UI config.", uiwidget: UIWidgets.Flags, enums: ParamEnumArray.FromEnum(EEditableEntityState))]
10  protected EEditableEntityState m_BlacklistedStates;
11 
12  [Attribute(desc: "States which are considered always active.\nUsed for example to force RENDERED state even for entities which are not shown in the scene.", uiwidget: UIWidgets.Flags, enums: ParamEnumArray.FromEnum(EEditableEntityState))]
13  protected EEditableEntityState m_ForcedStates;
14 
15  [Attribute("0", desc: "Register all entities which meet the rules at the beginning.")]
16  protected bool m_bAddAllEntities;
17 
18  protected EEditableEntityState m_States;
19  protected ref map<SCR_EditableEntityComponent, SCR_EditableEntityBaseSlotUIComponent> m_mEntitySlots = new map<SCR_EditableEntityComponent, SCR_EditableEntityBaseSlotUIComponent>();
20  protected bool m_bInteractive;
21 
22  protected ref map<SCR_EntitiesEditorUIRule, ref SCR_EditableEntityUIRuleTracker> m_RuleTrackers;// = new map<SCR_EntitiesEditorUIRule, ref SCR_EditableEntityUIRuleTracker>();
23 
24  //------------------------------------------------------------------------------------------------
26  EEditableEntityState GetForcedStates()
27  {
28  return m_ForcedStates;
29  }
30 
32  //--- Registration
34 
35  //------------------------------------------------------------------------------------------------
40  SCR_EditableEntityBaseSlotUIComponent FindSlot(SCR_EditableEntityComponent entity, bool createIfNull = false)
41  {
43  m_mEntitySlots.Find(entity, slot);
44  return slot;
45  }
46 
47  //------------------------------------------------------------------------------------------------
52  bool DeleteSlot(SCR_EditableEntityComponent entity, bool forced = false)
53  {
54  //--- If some other state is active, don't unregister
55  if (!forced && (entity.GetEntityStates() | m_ForcedStates) & m_States)
56  return false;
57 
58  //--- Unregister
60  if (m_mEntitySlots.Find(entity, entitySlot))
61  {
62  entitySlot.DeleteSlot();
63  m_mEntitySlots.Remove(entity);
64  return true;
65  }
66  else
67  {
68  return false;
69  }
70  }
71 
72  //------------------------------------------------------------------------------------------------
77  {
78  slot.InitSlot(entity);
79  m_mEntitySlots.Insert(entity, slot);
80  }
81 
82  //------------------------------------------------------------------------------------------------
86  void InsertSlotExternal(SCR_EditableEntityComponent entity, SCR_EditableEntityBaseSlotUIComponent slot)
87  {
88  if (m_mEntitySlots.Contains(entity))
89  {
90  entity.Log("Attempting to create duplicate GUI slot for editable entity. Duplicates are not allowed!", true, LogLevel.WARNING);
91  return;
92  }
93 
94  slot.InitSlot(entity);
95  m_mEntitySlots.Insert(entity, slot);
96 
97  InitSlotManager();
98 
99  set<SCR_EditableEntityComponent> entities = new set<SCR_EditableEntityComponent>();
100  entities.Insert(entity);
101 
102  if (m_RuleTrackers)
103  {
104  foreach (SCR_EditableEntityUIRuleTracker ruleTracker : m_RuleTrackers)
105  {
106  ruleTracker.AddEntity(entity);
107  //ruleTracker.OnChanged(entity.GetEntityStates(), entities, null);
108  }
109  }
110  }
111 
112  //------------------------------------------------------------------------------------------------
114  void ClearSlots()
115  {
116  m_mEntitySlots.Clear();
117  }
118 
119  //------------------------------------------------------------------------------------------------
120  protected SCR_EditableEntityBaseSlotUIComponent GetEntitySlot(Widget w)
121  {
123  while (w)
124  {
126  if (entityUI)
127  return entityUI;
128 
129  w = w.GetParent();
130  }
131 
132  return null;
133  }
134 
135  //------------------------------------------------------------------------------------------------
137  void InitSlotManager()
138  {
139  if (m_RuleTrackers)
140  return;
141 
143  if (!entityManager)
144  return;
145 
146  //--- Init rules
147  SCR_EditableEntityUIConfig entityUIConfig = SCR_EditableEntityUIConfig.GetConfig(m_EditableEntityUI);
148  if (entityUIConfig)
149  {
150  array<ref SCR_EntitiesEditorUIRule> rules = entityUIConfig.GetRules();
151  if (rules && !rules.IsEmpty())
152  {
154  m_RuleTrackers = new map<SCR_EntitiesEditorUIRule, ref SCR_EditableEntityUIRuleTracker>();
155  foreach (SCR_EntitiesEditorUIRule rule: rules)
156  {
157  //--- Passes when all states are whitelisted (or no whitelist is defined) and when there is at least one state not blacklisted
158  EEditableEntityState states = rule.GetStates();
159  if ((m_WhitelistedStates == 0 || (states & m_WhitelistedStates)) && (states & ~m_BlacklistedStates) != 0)
160  {
161  ruleTracker = new SCR_EditableEntityUIRuleTracker(rule, this, m_bAddAllEntities);
162  m_RuleTrackers.Insert(rule, ruleTracker);
163  m_bInteractive |= rule.IsInteractive();
164 
165  if (!rule.IsDependent())
166  m_States |= states;
167  }
168  }
169  }
170  else
171  {
172  Print("UI rules not defined in SCR_EditableEntityUIConfig!", LogLevel.WARNING);
173  }
174  }
175  else
176  {
177  Print("SCR_EditableEntityUIConfig not defined!", LogLevel.WARNING);
178  }
179  }
180 
182  //--- Default methods
184 
185  //------------------------------------------------------------------------------------------------
186  override bool IsUnique()
187  {
188  return false;
189  }
190 
191  //------------------------------------------------------------------------------------------------
192  override void HandlerAttachedScripted(Widget w)
193  {
194  super.HandlerAttachedScripted(w);
195  if (SCR_Global.IsEditMode()) return; //--- Run-time only
196 
197  InitSlotManager();
198  }
199 
200  //------------------------------------------------------------------------------------------------
201  override void HandlerDeattached(Widget w)
202  {
203  super.HandlerDeattached(w);
204  if (SCR_Global.IsEditMode())
205  return; //--- Run-time only
206 
207  if (m_RuleTrackers)
208  {
209  SCR_EditableEntityUIConfig entityUIConfig = SCR_EditableEntityUIConfig.GetConfig(m_EditableEntityUI);
210  if (entityUIConfig)
211  {
213  foreach (SCR_EntitiesEditorUIRule rule: entityUIConfig.GetRules())
214  {
215  if (m_RuleTrackers.Find(rule, ruleTracker) && ruleTracker)
216  {
217  m_RuleTrackers.Remove(rule);
218  delete ruleTracker;
219  }
220  }
221  }
222  }
223  }
224 }
EEditableEntityState
EEditableEntityState
Definition: EEditableEntityState.c:37
SCR_EntitiesManagerEditorComponent
Definition: SCR_EntitiesManagerEditorComponent.c:13
SCR_EntitiesEditorUIRule
Definition: SCR_EditableEntityUIRule.c:8
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_EditableEntityBaseSlotUIComponent
Definition: SCR_EditableEntityBaseSlotUIComponent.c:6
SCR_EditableEntityUIRuleTracker
Definition: SCR_EditableEntityUIRuleTracker.c:8
SCR_EditableEntitySlotManagerUIComponent
Definition: SCR_EditableEntitySlotManagerUIComponent.c:1
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_EditableEntitySceneSlotUIComponent
Definition: SCR_EditableEntitySceneSlotUIComponent.c:1
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
SCR_BaseEditorUIComponent
Definition: SCR_BaseEditorUIComponent.c:3
SCR_Global
Definition: Functions.c:6
SCR_EditableEntityUIConfig
Definition: SCR_EntitiesEditorUIConfig.c:7