Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_EntityTooltipEditorUIComponent.c
Go to the documentation of this file.
1 
4 {
5  [Attribute()]
6  protected string m_sImageWidgetName;
7 
8  [Attribute()]
9  protected string m_sImageOverlayWidgetName;
10 
11  [Attribute()]
12  protected string m_sFactionWidgetName;
13 
14  [Attribute()]
15  protected string m_sDetailsNameWidgetName;
16 
17  [Attribute()]
18  protected string m_sHeaderTypeName;
19 
20  [Attribute()]
21  protected string m_sAssetCardWidgetName;
22 
23  [Attribute("StyleBar")]
24  protected string m_sColorBarName;
25 
26  [Attribute()]
27  protected ref Color m_cPlayerColor;
28 
29  [Attribute("{96EFE81470EF9AA5}Configs/Editor/Tooltips/EntityTooltips.conf", desc: "Holds all entity tooltip data")]
30  protected ref SCR_EntityTooltipConfig m_EntityTooltipConfig;
31 
32  protected SCR_EntityTooltipDetailType m_DetailType;
33 
34  //------------------------------------------------------------------------------------------------
35  override void UpdateTooltip(Managed instance = null)
36  {
38  if (m_DetailType)
39  m_DetailType.UpdateDetailType(entity);
40  }
41 
42  //------------------------------------------------------------------------------------------------
43  override bool SetTooltip(SCR_UIInfo info, Managed instance = null)
44  {
45  //--- Get entity
47  if (!entity)
48  return false;
49 
50  EEditableEntityType entityType = entity.GetEntityType();
51  Widget widget = GetWidget();
52  int playerID = entity.GetPlayerID();
53  bool showImage = true;
54 
56  {
57  Print("'SCR_EntityTooltipEditorUIComponent' is missing m_EntityTooltipConfig! meaning tooltips cannot be displayed!", LogLevel.ERROR);
58  return false;
59  }
60 
61  //--- Entity details
62  Widget detailsWidget = widget.FindAnyWidget(m_sDetailsNameWidgetName);
63  if (detailsWidget)
64  {
65  array<ref SCR_EntityTooltipDetailType> detailTypes = {};
66  m_EntityTooltipConfig.GetTooltipData(detailTypes);
67 
68  foreach (SCR_EntityTooltipDetailType detailType: detailTypes)
69  {
70  if (detailType.CreateDetailType(entityType, detailsWidget, entity, showImage))
71  {
72  m_DetailType = detailType;
73  break;
74  }
75  }
76 
77  detailsWidget.SetVisible(m_DetailType != null);
78  }
79 
80  //--- Get entity info (or if player without entity)
81  if (info)
82  {
83  //--- Entity name
84  TextWidget nameWidget = TextWidget.Cast(widget.FindAnyWidget(m_sNameWidgetName));
85  if (nameWidget)
86  {
87  if (playerID > 0)
88  {
89  nameWidget.SetText(GetGame().GetPlayerManager().GetPlayerName(playerID));
90 
91  Widget colorBar = widget.FindAnyWidget(m_sColorBarName);
92  if (colorBar)
93  colorBar.SetColor(m_cPlayerColor);
94  }
95  else
96  {
97  if (!info.SetNameTo(nameWidget))
98  nameWidget.SetText(string.Format("ERROR: Unknown %1", typename.EnumToString(EEditableEntityType, entityType)));
99  }
100  }
101 
102  SCR_CallsignBaseComponent callsignComponent = SCR_CallsignBaseComponent.Cast(entity.GetOwner().FindComponent(SCR_CallsignBaseComponent));;
103  if (callsignComponent)
104  {
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);
108 
109  if (callsignWidget && setCallsign)
110  {
111  callsignWidget.SetTextFormat(format, company, platoon, squad, character);
112  callsignWidget.SetVisible(true);
113  }
114  }
115 
116  //--- Get faction color
117  Color factionColor = Color.FromInt(Color.WHITE);
118  Faction faction = entity.GetFaction();
119  if (faction)
120  {
121  factionColor = faction.GetFactionColor();
122  }
123  else if (playerID > 0)
124  {
125  SCR_FactionManager factionManager = SCR_FactionManager.Cast(GetGame().GetFactionManager());
126 
127  if (factionManager)
128  faction = factionManager.GetPlayerFaction(playerID);
129 
130  if (faction)
131  factionColor = faction.GetFactionColor();
132  }
133 
134  //--- Widget colored by faction
135  ImageWidget factionWidget = ImageWidget.Cast(widget.FindAnyWidget(m_sFactionWidgetName));
136  if (factionWidget)
137  {
138  factionWidget.SetColor(factionColor);
139  factionWidget.SetOpacity(0.6);
140  }
141 
142  //--- Entity icon
143 
144 // ImageWidget imageWidget = ImageWidget.Cast(widget.FindAnyWidget(m_sIconWidgetName));
145 // if (imageWidget && !info.GetIconPath().IsEmpty())
146 // {
147 // imageWidget.LoadImageTexture(0, info.GetIconPath());
148 // imageWidget.SetColor(factionColor);
149 // }
150 
151  Widget slotWidget = widget.FindAnyWidget(m_sIconWidgetName);
152  if (slotWidget)
153  {
156  if (slotManager && slot)
157  {
158  //slotManager.InitSlotManager(entity);
159  slotManager.InsertSlotExternal(entity, slot);
160  }
161  else
162  {
163  Print(string.Format("SCR_EditableEntityBaseSlotUIComponent and/or SCR_EditableEntitySlotManagerUIComponent is missing on tooltip widget '%1'!", widget.GetName()), LogLevel.WARNING);
164  }
165  }
166 
167  SCR_EditableEntityUIInfo editableEntityInfo = SCR_EditableEntityUIInfo.Cast(info);
168  if (editableEntityInfo && showImage)
169  {
170  ImageWidget imageWidget = ImageWidget.Cast(widget.FindAnyWidget(m_sImageWidgetName));
171  if (imageWidget && editableEntityInfo.GetImage())
172  {
173  bool foundImage = imageWidget.LoadImageTexture(0, editableEntityInfo.GetImage());
174  imageWidget.SetVisible(foundImage);
175 
176  Widget imageOverlay = widget.FindAnyWidget(m_sImageOverlayWidgetName);
177  if (!imageOverlay)
178  imageOverlay = imageWidget;
179 
180  imageOverlay.SetVisible(foundImage);
181  }
182  }
183  }
184 
185  //--- Asset card (experimental)
186 
187 // Widget assetCardWidget = widget.FindAnyWidget(m_sAssetCardWidgetName);
188 // if (assetCardWidget)
189 // {
190 // SCR_AssetCardFrontUIComponent assetCard = SCR_AssetCardFrontUIComponent.Cast(assetCardWidget.FindHandler(SCR_AssetCardFrontUIComponent));
191 // if (assetCard)
192 // {
193 // assetCard.InitCard(info, true);
194 // }
195 // }
196 
197  return true;
198  }
199 }
200 
202 class SCR_EntityTooltipDetailType
203 {
204  [Attribute("0", UIWidgets.ComboBox, "", enums: ParamEnumArray.FromEnum(EEditableEntityType))]
205  protected EEditableEntityType m_EntityType;
206 
207  [Attribute(params: "layout")]
208  protected ResourceName m_DetailLayout;
209 
210  [Attribute("1")]
211  protected bool m_bEnabled;
212 
213  [Attribute("1")]
214  protected bool m_bShowImage;
215 
216  [Attribute()]
217  protected string m_sDetailLayoutName;
218 
219  [Attribute()]
220  protected string m_sDetailLayoutFrame;
221 
222  [Attribute()]
223  protected ref array<ref SCR_EntityTooltipDetail> m_aDetails;
224 
225  //------------------------------------------------------------------------------------------------
228  void UpdateDetailType(SCR_EditableEntityComponent entity)
229  {
230  foreach (SCR_EntityTooltipDetail detail: m_aDetails)
231  {
232  if (detail.NeedUpdate())
233  detail.UpdateDetail(entity);
234  }
235  }
236 
237  //------------------------------------------------------------------------------------------------
244  bool CreateDetailType(EEditableEntityType type, Widget parent, SCR_EditableEntityComponent entity, out bool showImage = true)
245  {
246  if (type != m_EntityType || !m_bEnabled)
247  return false;
248 
249  showImage = m_bShowImage;
250  bool showDetails = false;
251  WorkspaceWidget workspace = parent.GetWorkspace();
252  foreach (SCR_EntityTooltipDetail detail: m_aDetails)
253  {
254  Widget detailWidget;
255  Widget detailFrame;
256  TextWidget detailName = null;
257 
258  //With label
259  if (detail.GetShowLabel())
260  {
261  detailWidget = workspace.CreateWidgets(m_DetailLayout, parent);;
262  detailFrame = detailWidget.FindAnyWidget(m_sDetailLayoutFrame);
263  detailName = TextWidget.Cast(detailWidget.FindAnyWidget(m_sDetailLayoutName));
264  }
265  //No label
266  else
267  {
268  detailFrame = parent;
269  }
270 
271  if (detail.CreateDetail(entity, detailFrame, detailName, detail.GetShowLabel()))
272  {
273  showDetails = true;
274  detail.UpdateDetail(entity);
275  }
276  else if (detailWidget)
277  {
278  detailWidget.RemoveFromHierarchy();
279  }
280  }
281 
282  return showDetails;
283  }
284 }
SCR_BaseTooltipEditorUIComponent
Definition: SCR_BaseTooltipEditorUIComponent.c:3
SCR_EntityTooltipEditorUIComponent
Definition: SCR_EntityTooltipEditorUIComponent.c:3
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_EditableEntityUIInfo
Definition: SCR_EditableEntityUIInfo.c:2
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_EditableEntityBaseSlotUIComponent
Definition: SCR_EditableEntityBaseSlotUIComponent.c:6
SCR_CallsignBaseComponent
Component of assigning and storing squad names.
Definition: SCR_CallsignBaseComponent.c:11
m_EntityTooltipConfig
protected ref SCR_EntityTooltipConfig m_EntityTooltipConfig
Definition: SCR_EntityTooltipEditorUIComponent.c:27
SCR_EntityTooltipConfig
Definition: SCR_EntityTooltipConfig.c:2
SCR_EditableEntitySlotManagerUIComponent
Definition: SCR_EditableEntitySlotManagerUIComponent.c:1
Attribute
typedef Attribute
Post-process effect of scripted camera.
EEditableEntityType
EEditableEntityType
Defines type of SCR_EditableEntityComponent. Assigned automatically based on IEntity inheritance.
Definition: EEditableEntityType.c:5
SCR_BaseContainerCustomTitleEnum
SCR_EntityTooltipEditorUIComponent SCR_BaseTooltipEditorUIComponent SCR_BaseContainerCustomTitleEnum(EEditableEntityType, "m_EntityType")
Definition: SCR_EntityTooltipEditorUIComponent.c:201
SCR_UIInfo
Definition: SCR_UIInfo.c:7
SCR_EntityTooltipDetail
Definition: SCR_EntityTooltipDetail.c:2
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
Faction
Definition: Faction.c:12
m_DetailType
protected SCR_EntityTooltipDetailType m_DetailType
Definition: SCR_EntityTooltipEditorUIComponent.c:29
type
EDamageType type
Definition: SCR_DestructibleTreeV2.c:32
m_bEnabled
private bool m_bEnabled
Definition: SCR_BaseManualCameraComponent.c:3
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
SCR_FactionManager
void SCR_FactionManager(IEntitySource src, IEntity parent)
Definition: SCR_FactionManager.c:461
GetWidget
protected Widget GetWidget()
Definition: SCR_VonDisplay.c:155
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468