8 private string m_sEntityNameWidgetName;
14 private string m_sEnityImageWidgetName;
17 protected string m_sIconSlotWidgetName;
20 protected string m_sModIndicatorWidgetName;
23 protected string m_sModIndicatorIconName;
26 protected string m_sExceedBudgetLayoutName;
29 protected string m_sExceedBudgetIconName;
32 protected string m_sBudgetCostLayoutName;
35 protected string m_sBudgetCostTextName;
38 protected string m_sImageOverlayName;
41 protected string m_sAreaName;
44 protected ref array<string> m_aFactionColorNames;
47 protected ref array<EEditableEntityLabelGroup> m_sTraitLabelGroups;
50 protected ref array<string> m_sTraitNames;
53 private ref Color m_DisabledColor;
56 protected ref array<ResourceName> m_ImageOverlayTextures;
58 protected ref ImageWidget m_EntityImageWidget;
60 protected Widget m_BudgetCostLayout;
61 protected Widget m_ExceedBudgetLayout;
62 protected ref ScriptInvoker Event_OnCardInit =
new ScriptInvoker();
65 private Widget m_wWidget;
69 protected int m_iPrefabIndex;
71 protected ref ScriptInvoker m_OnHover =
new ScriptInvoker();
72 protected ref ScriptInvoker m_OnFocus =
new ScriptInvoker();
79 ScriptInvoker GetOnCardInit()
81 return Event_OnCardInit;
89 m_BudgetCostLayout = m_wWidget.FindAnyWidget(m_sBudgetCostLayoutName);
90 if (!m_BudgetCostLayout)
93 if (!entityBudgetCost)
94 m_BudgetCostLayout.SetVisible(
false);
97 m_BudgetCostLayout.SetVisible(
true);
98 TextWidget budgetCostTextWidget = TextWidget.Cast(m_BudgetCostLayout.FindAnyWidget(m_sBudgetCostTextName));
99 if (budgetCostTextWidget)
100 budgetCostTextWidget.SetText(entityBudgetCost.GetBudgetValue().ToString());
107 void UpdateBlockingBudget(
SCR_UIInfo blockingBudgetInfo =
null)
109 if (!m_ExceedBudgetLayout)
112 bool canPlace = blockingBudgetInfo ==
null;
114 m_EntityImageWidget.SetSaturation(canPlace);
115 m_ExceedBudgetLayout.SetVisible(!canPlace);
117 ImageWidget exceedBudgetIcon = ImageWidget.Cast(m_ExceedBudgetLayout.FindWidget(m_sExceedBudgetIconName));
118 if (blockingBudgetInfo)
119 blockingBudgetInfo.SetIconTo(exceedBudgetIcon);
128 void InitCard(
int prefabID,
SCR_UIInfo info, ResourceName prefab,
SCR_UIInfo blockingBudgetInfo =
null)
133 m_iPrefabIndex = prefabID;
135 TextWidget entityNameWidget = TextWidget.Cast(m_wWidget.FindAnyWidget(m_sEntityNameWidgetName));
142 info.SetNameTo(entityNameWidget);
148 Faction faction = infoCard.GetFaction();
152 foreach (
string factionColorName: m_aFactionColorNames)
154 factionColor = m_wWidget.FindAnyWidget(factionColorName);
156 factionColor.SetColor(Color.FromInt(faction.GetFactionColor().PackToInt()));
161 Widget iconSlotWidget = m_wWidget.FindAnyWidget(m_sIconSlotWidgetName);
170 array<ref SCR_EntitiesEditorUIRule> entityRules = entityUIConfig.GetRules();
175 iconSlot.CreateWidget(infoCard, rule);
183 m_EntityImageWidget = ImageWidget.Cast(m_wWidget.FindAnyWidget(m_sEnityImageWidgetName));
184 if (m_EntityImageWidget)
185 infoCard.SetAssetImageTo(m_EntityImageWidget);
187 ImageWidget imageOverlayWidget = ImageWidget.Cast(m_wWidget.FindAnyWidget(m_sImageOverlayName));
188 if (imageOverlayWidget && !m_ImageOverlayTextures.IsEmpty())
190 int textureIndex = m_iPrefabIndex % m_ImageOverlayTextures.Count();
191 imageOverlayWidget.LoadImageTexture(0, m_ImageOverlayTextures[textureIndex]);
194 m_ExceedBudgetLayout = m_wWidget.FindAnyWidget(m_sExceedBudgetLayoutName);
197 UpdateBlockingBudget(blockingBudgetInfo);
202 ImageWidget traitIcon;
206 if (!contentBrowser || contentBrowser.AreFactionsShownOnContentCards())
208 if (FindTraitIcon(traitIndex, traitWidget, traitIcon))
210 traitWidget.SetVisible(
true);
211 traitIcon.LoadImageTexture(0, faction.GetUIInfo().GetIconPath());
222 editorMode = modeEntity.GetModeType();
230 array<EEditableEntityLabel> labels = {};
232 for (
int i, count = infoCard.GetEntityLabels(labels); i < count; i++)
234 if (!core.GetLabelUIInfoIfValid(labels[i], editorMode, labelInfo))
237 if (core.GetLabelGroupType(labels[i], labelGroup) && m_sTraitLabelGroups.Contains(labelGroup) && labelInfo.HasIcon())
239 if (FindTraitIcon(traitIndex, traitWidget, traitIcon))
241 traitWidget.SetVisible(
true);
242 labelInfo.SetIconTo(traitIcon);
246 tooltip.SetInfo(labelInfo);
260 Widget areaWidget = m_wWidget.FindAnyWidget(m_sAreaName);
268 if (entityNameWidget && prefab)
270 string path = prefab.GetPath();
271 array<string> pathNames = {};
272 path.Split(
"/", pathNames,
true);
273 entityNameWidget.SetText(pathNames[pathNames.Count() - 1]);
278 Widget modIndicator = m_wWidget.FindAnyWidget(m_sModIndicatorWidgetName);
281 array<string> modList = SCR_AddonTool.GetResourceAddons(prefab,
true);
283 modIndicator.SetVisible(modList.Count() > 0);
285 modIndicator.SetVisible(
false);
290 Event_OnCardInit.Invoke(m_iPrefabIndex);
294 protected bool FindTraitIcon(out
int outIndex, out Widget traitWidget, out ImageWidget traitIcon)
296 if (m_sTraitNames && outIndex < m_sTraitNames.Count())
298 traitWidget = m_wWidget.FindAnyWidget(m_sTraitNames[outIndex]);
301 traitIcon = ImageWidget.Cast(traitWidget.FindAnyWidget(
"Trait"));
331 Widget GetButtonWidget()
337 override bool OnMouseEnter(Widget w,
int x,
int y)
340 m_OnHover.Invoke(m_wWidget, m_iPrefabIndex,
true);
346 override bool OnMouseLeave(Widget w, Widget enterW,
int x,
int y)
349 m_OnHover.Invoke(m_wWidget, m_iPrefabIndex,
false);
357 ScriptInvoker GetOnHover()
363 override bool OnFocus(Widget w,
int x,
int y)
366 m_OnFocus.Invoke(m_wWidget, m_iPrefabIndex,
true);
372 override bool OnFocusLost(Widget w,
int x,
int y)
375 m_OnFocus.Invoke(m_wWidget, m_iPrefabIndex,
false);
383 ScriptInvoker GetOnFocus()
392 return m_iPrefabIndex;
396 override void HandlerAttached(Widget w)