Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_EditableEntitySlotManagerUIComponent.c
Go to the documentation of this file.
2{
3 [Attribute()]
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))]
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))]
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))]
14
15 [Attribute("0", desc: "Register all entities which meet the rules at the beginning.")]
16 protected bool m_bAddAllEntities;
17
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 //------------------------------------------------------------------------------------------------
30
32 //--- Registration
34
35 //------------------------------------------------------------------------------------------------
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 //------------------------------------------------------------------------------------------------
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
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 //------------------------------------------------------------------------------------------------
115 {
116 m_mEntitySlots.Clear();
117 }
118
119 //------------------------------------------------------------------------------------------------
121 {
123 while (w)
124 {
126 if (entityUI)
127 return entityUI;
128
129 w = w.GetParent();
130 }
131
132 return null;
133 }
134
135 //------------------------------------------------------------------------------------------------
138 {
139 if (m_RuleTrackers)
140 return;
141
143 if (!entityManager)
144 return;
145
146 //--- Init rules
148 if (entityUIConfig)
149 {
150 array<ref SCR_EntitiesEditorUIRule> rules = entityUIConfig.GetRules();
151 if (rules && !rules.IsEmpty())
152 {
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 //------------------------------------------------------------------------------------------------
193 {
194 super.HandlerAttachedScripted(w);
195 if (SCR_Global.IsEditMode()) return; //--- Run-time only
196
198 }
199
200 //------------------------------------------------------------------------------------------------
201 override void HandlerDeattached(Widget w)
202 {
203 super.HandlerDeattached(w);
205 return; //--- Run-time only
206
207 if (m_RuleTrackers)
208 {
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}
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
void InitSlot(SCR_EditableEntityComponent entity)
void Log(string prefix="", bool onlyDirect=false, LogLevel logLevel=LogLevel.DEBUG)
ref map< SCR_EntitiesEditorUIRule, ref SCR_EditableEntityUIRuleTracker > m_RuleTrackers
bool DeleteSlot(SCR_EditableEntityComponent entity, bool forced=false)
SCR_EditableEntityBaseSlotUIComponent FindSlot(SCR_EditableEntityComponent entity, bool createIfNull=false)
void InsertSlot(SCR_EditableEntityComponent entity, SCR_EditableEntityBaseSlotUIComponent slot)
SCR_EditableEntityBaseSlotUIComponent GetEntitySlot(Widget w)
ref map< SCR_EditableEntityComponent, SCR_EditableEntityBaseSlotUIComponent > m_mEntitySlots
void InsertSlotExternal(SCR_EditableEntityComponent entity, SCR_EditableEntityBaseSlotUIComponent slot)
static SCR_EditableEntityUIConfig GetConfig(SCR_EditableEntityUIConfig config=null)
array< ref SCR_EntitiesEditorUIRule > GetRules()
static bool IsEditMode()
Definition Functions.c:1566
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
EEditableEntityState
SCR_FieldOfViewSettings Attribute