6 protected string m_sImageWidgetName;
9 protected string m_sImageOverlayWidgetName;
12 protected string m_sFactionWidgetName;
15 protected string m_sDetailsNameWidgetName;
18 protected string m_sHeaderTypeName;
21 protected string m_sAssetCardWidgetName;
24 protected string m_sColorBarName;
27 protected ref Color m_cPlayerColor;
29 [
Attribute(
"{96EFE81470EF9AA5}Configs/Editor/Tooltips/EntityTooltips.conf",
desc:
"Holds all entity tooltip data")]
32 protected SCR_EntityTooltipDetailType m_DetailType;
35 override void UpdateTooltip(Managed instance =
null)
43 override bool SetTooltip(
SCR_UIInfo info, Managed instance =
null)
52 int playerID = entity.GetPlayerID();
53 bool showImage =
true;
57 Print(
"'SCR_EntityTooltipEditorUIComponent' is missing m_EntityTooltipConfig! meaning tooltips cannot be displayed!", LogLevel.ERROR);
62 Widget detailsWidget = widget.FindAnyWidget(m_sDetailsNameWidgetName);
65 array<ref SCR_EntityTooltipDetailType> detailTypes = {};
68 foreach (SCR_EntityTooltipDetailType detailType: detailTypes)
70 if (detailType.CreateDetailType(entityType, detailsWidget, entity, showImage))
77 detailsWidget.SetVisible(m_DetailType !=
null);
84 TextWidget nameWidget = TextWidget.Cast(widget.FindAnyWidget(m_sNameWidgetName));
89 nameWidget.SetText(
GetGame().GetPlayerManager().GetPlayerName(playerID));
91 Widget colorBar = widget.FindAnyWidget(m_sColorBarName);
93 colorBar.SetColor(m_cPlayerColor);
97 if (!info.SetNameTo(nameWidget))
98 nameWidget.SetText(
string.Format(
"ERROR: Unknown %1",
typename.EnumToString(
EEditableEntityType, entityType)));
103 if (callsignComponent)
105 TextWidget callsignWidget = TextWidget.Cast(widget.FindAnyWidget(m_sHeaderTypeName));
106 string company, platoon, squad, character, format;
107 bool setCallsign = callsignComponent.GetCallsignNames(company, platoon, squad, character, format);
109 if (callsignWidget && setCallsign)
111 callsignWidget.SetTextFormat(format, company, platoon, squad, character);
112 callsignWidget.SetVisible(
true);
117 Color factionColor = Color.FromInt(Color.WHITE);
118 Faction faction = entity.GetFaction();
121 factionColor = faction.GetFactionColor();
123 else if (playerID > 0)
128 faction = factionManager.GetPlayerFaction(playerID);
131 factionColor = faction.GetFactionColor();
135 ImageWidget factionWidget = ImageWidget.Cast(widget.FindAnyWidget(m_sFactionWidgetName));
138 factionWidget.SetColor(factionColor);
139 factionWidget.SetOpacity(0.6);
151 Widget slotWidget = widget.FindAnyWidget(m_sIconWidgetName);
156 if (slotManager && slot)
159 slotManager.InsertSlotExternal(entity, slot);
163 Print(
string.Format(
"SCR_EditableEntityBaseSlotUIComponent and/or SCR_EditableEntitySlotManagerUIComponent is missing on tooltip widget '%1'!", widget.GetName()), LogLevel.WARNING);
168 if (editableEntityInfo && showImage)
170 ImageWidget imageWidget = ImageWidget.Cast(widget.FindAnyWidget(m_sImageWidgetName));
171 if (imageWidget && editableEntityInfo.GetImage())
173 bool foundImage = imageWidget.LoadImageTexture(0, editableEntityInfo.GetImage());
174 imageWidget.SetVisible(foundImage);
176 Widget imageOverlay = widget.FindAnyWidget(m_sImageOverlayWidgetName);
178 imageOverlay = imageWidget;
180 imageOverlay.SetVisible(foundImage);
202 class SCR_EntityTooltipDetailType
208 protected ResourceName m_DetailLayout;
214 protected bool m_bShowImage;
217 protected string m_sDetailLayoutName;
220 protected string m_sDetailLayoutFrame;
223 protected ref array<ref SCR_EntityTooltipDetail> m_aDetails;
232 if (detail.NeedUpdate())
233 detail.UpdateDetail(entity);
249 showImage = m_bShowImage;
250 bool showDetails =
false;
251 WorkspaceWidget workspace = parent.GetWorkspace();
256 TextWidget detailName =
null;
259 if (detail.GetShowLabel())
261 detailWidget = workspace.CreateWidgets(m_DetailLayout, parent);;
262 detailFrame = detailWidget.FindAnyWidget(m_sDetailLayoutFrame);
263 detailName = TextWidget.Cast(detailWidget.FindAnyWidget(m_sDetailLayoutName));
268 detailFrame = parent;
271 if (detail.CreateDetail(entity, detailFrame, detailName, detail.GetShowLabel()))
274 detail.UpdateDetail(entity);
276 else if (detailWidget)
278 detailWidget.RemoveFromHierarchy();