Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_EditableEntityUIInfo.c
Go to the documentation of this file.
3{
4 [Attribute(params: "edds imageset", uiwidget: UIWidgets.ResourcePickerThumbnail)]
5 private ResourceName m_Image;
6
7 [Attribute()]
8 private FactionKey m_sFaction;
9
10 [Attribute("1", UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(EEditableEntityLabel), desc: "Entity labels configured by developers, changes will be applied when updating editable entities")]
11 private ref array<EEditableEntityLabel> m_aAuthoredLabels;
12
13 [Attribute("1", UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(EEditableEntityLabel), desc: "Autoconfigured labels, for manual changes edit AuthoredLabels array instead")]
14 private ref array<EEditableEntityLabel> m_aAutoLabels;
15
16 [Attribute("", category: "Editable Entity", desc: "Define budget costs")]
17 private ref array<ref SCR_EntityBudgetValue> m_EntityBudgetCost;
18
19 [Attribute("", category: "Editable Entity", desc: "Autoconfigured budget costs of child entities (group/composition entities)")]
20 private ref array<ref SCR_EntityBudgetValue> m_EntityChildrenBudgetCost;
21
22 [Attribute(category: "Editable Entity", params: "et", desc: "Prefab this entity extends.")]
24
25 [Attribute("1", UIWidgets.Auto, category: "Visualization", desc: "Asset card in content browser should occupy the full available area.")]
27
29
30 //--- Hidden vars, used only in content browser where they're filled from component source
33
34 //~ Hotfix to make sure Entity names that are not localized get a default fallback name
35 static const LocalizedString EDITABLE_ENTITY_FALLBACK_NAME = "#AR-AttributesDialog_TitlePage_Entity_Text";
36
37 //------------------------------------------------------------------------------------------------
38 //~ Hotfix to make sure Entity names that are not localized get a default fallback name
40 {
41 //~ If empty string, placeholder string it will use the the fallback string so the name at least is localized.
42 //~ It checks for '(' as all placeholder names check for it as checking for '#' will override the string for modders
43 if (Name.IsEmpty() || Name[0] == "(")
45
46 return Name;
47 }
48
49 //------------------------------------------------------------------------------------------------
54
55 //------------------------------------------------------------------------------------------------
57 {
58 return m_Image;
59 }
60
61 //------------------------------------------------------------------------------------------------
63 {
64 return 0;
65 }
66
67 //------------------------------------------------------------------------------------------------
69 {
70 if (m_sFactionKeyOverride.IsEmpty())
71 return m_sFaction;
72
74 }
75
77 {
78 return m_sFaction;
79 }
80
81 //------------------------------------------------------------------------------------------------
83 {
84 m_sFactionKeyOverride = newKey;
85 }
86
87 //------------------------------------------------------------------------------------------------
89 {
90 FactionManager factionManager = GetGame().GetFactionManager();
91 if (factionManager)
92 return factionManager.GetFactionByKey(GetFactionKey());
93 else
94 return null;
95 }
96
97 //------------------------------------------------------------------------------------------------
101 int GetEntityLabels(out notnull array<EEditableEntityLabel> entityLabels)
102 {
103 entityLabels.InsertAll(m_aAutoLabels);
104 entityLabels.InsertAll(m_aAuthoredLabels);
105 return entityLabels.Count();
106 }
107
108 //------------------------------------------------------------------------------------------------
113 {
114 if (m_aAutoLabels.Contains(label))
115 return true;
116
117 if (m_aAuthoredLabels.Contains(label))
118 return true;
119
120 return false;
121 }
122
123 //------------------------------------------------------------------------------------------------
126 bool GetEntityBudgetCost(out notnull array<ref SCR_EntityBudgetValue> outBudgets)
127 {
128 SCR_EntityBudgetValue.MergeBudgetCosts(outBudgets, m_EntityBudgetCost);
129 return !outBudgets.IsEmpty();
130 }
131
132 //------------------------------------------------------------------------------------------------
134 void GetEntityAndChildrenBudgetCost(out notnull array<ref SCR_EntityBudgetValue> outBudgets)
135 {
136 SCR_EntityBudgetValue.MergeBudgetCosts(outBudgets, m_EntityBudgetCost);
137 SCR_EntityBudgetValue.MergeBudgetCosts(outBudgets, m_EntityChildrenBudgetCost);
138 }
139
140 //------------------------------------------------------------------------------------------------
142 void GetEntityChildrenBudgetCost(out notnull array<ref SCR_EntityBudgetValue> outBudgets)
143 {
144 SCR_EntityBudgetValue.MergeBudgetCosts(outBudgets, m_EntityChildrenBudgetCost);
145 }
146
147 //------------------------------------------------------------------------------------------------
151 {
152 return m_SlotPrefab;
153 }
154
155 //------------------------------------------------------------------------------------------------
162
163 //------------------------------------------------------------------------------------------------
168 {
169 return (m_EntityFlags & flag) == flag;
170 }
171
172 //------------------------------------------------------------------------------------------------
178 bool SetAssetImageTo(ImageWidget imageWidget)
179 {
180 if (!imageWidget || m_Image.IsEmpty())
181 return false;
182
183 imageWidget.LoadImageTexture(0, m_Image);
184
186 {
187 OverlaySlot.SetVerticalAlign(imageWidget, LayoutVerticalAlign.Stretch);
188 OverlaySlot.SetHorizontalAlign(imageWidget, LayoutHorizontalAlign.Stretch);
189 }
190
191 return true;
192 }
193
194 //------------------------------------------------------------------------------------------------
202
203 //------------------------------------------------------------------------------------------------
204 protected override void CopyFrom(SCR_UIName source)
205 {
206 SCR_EditableEntityUIInfo editableEntitySource = SCR_EditableEntityUIInfo.Cast(source);
207 if (editableEntitySource)
208 {
209 m_Image = editableEntitySource.m_Image;
210 m_sFaction = editableEntitySource.m_sFaction;
211 m_aAuthoredLabels = editableEntitySource.m_aAuthoredLabels;
212 m_aAutoLabels = editableEntitySource.m_aAutoLabels;
213 m_EntityBudgetCost = editableEntitySource.m_EntityBudgetCost;
214 m_EntityChildrenBudgetCost = editableEntitySource.m_EntityChildrenBudgetCost;
215 m_SlotPrefab = editableEntitySource.m_SlotPrefab;
217 }
218
219 super.CopyFrom(source);
220 }
221
222 //------------------------------------------------------------------------------------------------
227 {
228 if (prefab.IsEmpty())
229 return null;
230
231 Resource entityResource = BaseContainerTools.LoadContainer(prefab);
232 if (!entityResource.IsValid())
233 {
234 Print(string.Format("Provided prefab '%1' is invalid!", prefab), LogLevel.ERROR);
235 return null;
236 }
237
239 if (!editableEntitySource)
240 {
241 Print(string.Format("Prefab '%1' is missing SCR_EditableEntityComponent!", prefab), LogLevel.ERROR);
242 return null;
243 }
244
246 if (!info)
247 Print(string.Format("Prefab '%1' is missing UI info in SCR_EditableEntityComponent!", prefab), LogLevel.ERROR);
248
249 return info;
250 }
251}
EEditableEntityLabel
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
static IEntityComponentSource GetEditableEntitySource(Resource entityResource)
static EEditableEntityFlag GetEntityFlags(IEntityComponentSource componentSource)
bool HasEntityLabel(EEditableEntityLabel label)
static const LocalizedString EDITABLE_ENTITY_FALLBACK_NAME
void InitFromSource(IEntityComponentSource componentSource)
bool HasEntityFlag(EEditableEntityFlag flag)
override void CopyFrom(SCR_UIName source)
void GetEntityAndChildrenBudgetCost(out notnull array< ref SCR_EntityBudgetValue > outBudgets)
Get Entity and its children budgets.
int GetEntityLabels(out notnull array< EEditableEntityLabel > entityLabels)
EEditableEntityType GetEntityType()
void OverrideFactionKey(FactionKey newKey)
bool SetAssetImageTo(ImageWidget imageWidget)
bool GetEntityBudgetCost(out notnull array< ref SCR_EntityBudgetValue > outBudgets)
static SCR_EditableEntityUIInfo ExtractEditableUIInfoFromPrefab(ResourceName prefab)
EEditableEntityType GetEntityTypex()
override LocalizedString GetName()
void GetEntityChildrenBudgetCost(out notnull array< ref SCR_EntityBudgetValue > outBudgets)
Get only Entity's children budget costs, i.e. cost of entities inside a composition entitiy.
LocalizedString Name
Definition SCR_UIName.c:8
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.
SCR_FieldOfViewSettings Attribute
LayoutHorizontalAlign
LayoutVerticalAlign