Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_MapUISpawnPoint.c
Go to the documentation of this file.
2 {
3  [Attribute("Select")]
4  protected string m_sSelection;
5  [Attribute("Base_Main")]
6  protected string m_sSpawnPoint;
7 
8  protected SCR_SpawnPoint m_SpawnPoint;
9  protected RplId m_SpawnPointId;
10  protected string m_sFactionKey;
11  protected TextWidget m_wSpawnPointName;
12  protected Widget m_wImageOverlay;
13  protected OverlayWidget m_wSymbolOverlay;
14  protected SCR_MilitarySymbolUIComponent m_MilitarySymbolComponent;
15  protected ButtonWidget m_wButton;
16  protected SizeLayoutWidget m_wSizeLayout;
17  protected Widget m_wSupplies;
18  protected RichTextWidget m_wSuppliesText
19 
20  protected SCR_ResourceComponent m_ResourceComponent;
21  protected SCR_ResourceConsumer m_ResourceConsumer;
22  protected ref SCR_ResourceSystemSubscriptionHandleBase m_ResourceSubscriptionHandleConsumer;
23  protected RplId m_ResourceInventoryPlayerComponentRplId;
24 
25  //------------------------------------------------------------------------------
26  void Init(notnull SCR_SpawnPoint spawnPoint)
27  {
28  m_SpawnPoint = spawnPoint;
29  m_SpawnPointId = spawnPoint.GetRplId();
30  m_sFactionKey = spawnPoint.GetFactionKey();
31  // TODO@AS: Api?
32  m_wSpawnPointName.SetText(spawnPoint.GetSpawnPointName());
33  UpdateIcon();
34 
35  if (!m_wSuppliesText)
36  return;
37 
38  m_ResourceComponent = SCR_ResourceComponent.FindResourceComponent(spawnPoint);
39 
41  return;
42 
44 
45  if (!m_ResourceConsumer)
46  return;
47 
48  m_ResourceInventoryPlayerComponentRplId = Replication.FindId(SCR_ResourcePlayerControllerInventoryComponent.Cast(GetGame().GetPlayerController().FindComponent(SCR_ResourcePlayerControllerInventoryComponent)));
49  m_ResourceSubscriptionHandleConsumer = GetGame().GetResourceSystemSubscriptionManager().RequestSubscriptionListenerHandle(m_ResourceConsumer, m_ResourceInventoryPlayerComponentRplId);
50 
51  m_ResourceComponent.TEMP_GetOnInteractorReplicated().Insert(UpdateResources);
52  UpdateResources();
53  }
54 
55  //------------------------------------------------------------------------------------------------
56  override void SetName(string name)
57  {
58  if (m_wSpawnPointName)
59  m_wSpawnPointName.SetText(name);
60  }
61 
62  //------------------------------------------------------------------------------------------------
63  override vector GetPos()
64  {
65  return m_SpawnPoint.GetOrigin();
66  }
67 
68  //------------------------------------------------------------------------------------------------
69  protected void UpdateResources()
70  {
72  return;
73 
74  m_wSuppliesText.SetText(string.ToString(m_ResourceConsumer.GetAggregatedResourceValue()));
75  }
76 
77  //------------------------------------------------------------------------------
78  void UpdateIcon()
79  {
81 
83  if (!core)
84  return;
85 
86  SCR_Faction faction = SCR_Faction.Cast(GetGame().GetFactionManager().GetFactionByKey(m_sFactionKey));
87  if (faction)
88  {
89  SCR_MilitarySymbolRuleSet ruleSet = core.GetSymbolRuleSet();
90  ruleSet.UpdateSymbol(symbol, faction);
91  }
92  else
93  {
94  symbol.SetIdentity(EMilitarySymbolIdentity.UNKNOWN);
95  }
96 
97  //Selection visuals
98  string selection;
99  string highlight;
100  switch (symbol.GetIdentity())
101  {
102  case EMilitarySymbolIdentity.INDFOR:
103  {
104  selection = "Neutral_Select";
105  highlight = "Neutral_Focus";
106  break;
107  }
108  case EMilitarySymbolIdentity.OPFOR:
109  {
110  selection = "Hostile_Select";
111  highlight = "Hostile_Focus";
112  break;
113  }
114  case EMilitarySymbolIdentity.BLUFOR:
115  {
116  selection = "Friend_Select";
117  highlight = "Friend_Focus";
118  break;
119  }
120  case EMilitarySymbolIdentity.UNKNOWN:
121  {
122  selection = "Unknown_Select";
123  highlight = "Unknown_Focus";
124  break;
125  }
126  }
127  m_bVisible = true;
128 
129  m_wHighlightImg.LoadImageFromSet(0, m_sImageSetARO, highlight);
130  m_wSelectImg.LoadImageFromSet(0, m_sImageSetARO, selection);
131 
132  if (SCR_PlayerSpawnPoint.Cast(m_SpawnPoint))
133  symbol.SetIcons(EMilitarySymbolIcon.RELAY);
134  else
135  symbol.SetIcons(EMilitarySymbolIcon.RESPAWN);
136 
137  m_wSymbolOverlay.SetColor(GetColorForFaction(m_sFactionKey));
138  if (m_wGradient)
139  m_wGradient.SetColor(GetColorForFaction(m_sFactionKey));
140 
141  if (faction)
142  m_MilitarySymbolComponent.Update(symbol);
143  }
144 
145  //------------------------------------------------------------------------------
146  override void HandlerAttached(Widget w)
147  {
148  super.HandlerAttached(w);
149 
150  m_wImageOverlay = w.FindAnyWidget("IconOverlay");
151  m_wSizeLayout = SizeLayoutWidget.Cast(w.FindAnyWidget("SizeLayout"));
152  m_wSpawnPointName = TextWidget.Cast(w.FindAnyWidget("Name"));
153  m_wSymbolOverlay = OverlayWidget.Cast(m_wImageOverlay.FindWidget("Symbol"));
154 
155  if (!m_wSymbolOverlay)
156  return;
157 
158  m_MilitarySymbolComponent = SCR_MilitarySymbolUIComponent.Cast(m_wSymbolOverlay.FindHandler(SCR_MilitarySymbolUIComponent));
159 
160  m_wButton = ButtonWidget.Cast(w.FindAnyWidget("Button"));
161 
162  if (m_wButton)
163  m_wButton.SetEnabled(false);
164 
165  m_wSupplies = w.FindAnyWidget("w_Supplies");
166 
167  if (m_wSupplies)
168  m_wSuppliesText = RichTextWidget.Cast(m_wSupplies.FindAnyWidget("SuppliesText"));
169  }
170 
171  //------------------------------------------------------------------------------------------------
172  override void HandlerDeattached(Widget w)
173  {
174  super.HandlerDeattached(w);
175 
177  m_ResourceComponent.TEMP_GetOnInteractorReplicated().Remove(UpdateResources);
178 
180  }
181 
182  //------------------------------------------------------------------------------
183  override void SelectIcon(bool invoke = true)
184  {
185  if (!m_wSelectImg)
186  return;
187 
188  if (s_SelectedElement && s_SelectedElement != this)
189  s_SelectedElement.Select(false);
190 
191  Select();
192 
193  m_wSelectImg.SetVisible(true);
194  if (m_wGradient)
195  m_wGradient.SetVisible(true);
196 
197  if (m_bIsSelected && invoke)
198  m_Parent.OnSpawnPointSelected(m_SpawnPointId);
199  }
200 
201  // todo@lk: plug this somewhere later
202  // protected void OnSelected(SCR_SpawnPoint sp)
203  // {
204  // if (!sp)
205  // return;
206  // if (sp == m_SpawnPoint)
207  // {
208  // AnimExpand();
209  // m_wRoot.SetZOrder(1);
210  // m_wSelectImg.SetVisible(true);
211  // if (m_wGradient)
212  // m_wGradient.SetVisible(true);
213  // }
214  // else
215  // {
216  // AnimCollapse();
217  // m_wRoot.SetZOrder(0);
218  // m_wSelectImg.SetVisible(false);
219  // if (m_wGradient)
220  // m_wGradient.SetVisible(false);
221  // }
222  // }
223 
224  //------------------------------------------------------------------------------
225  override bool OnMouseEnter(Widget w, int x, int y)
226  {
227  if (m_wSizeLayout && w == m_wSizeLayout && m_wButton)
228  m_wButton.SetEnabled(true);
229 
230  GetGame().GetWorkspace().SetFocusedWidget(w);
231  super.OnMouseEnter(w, x, y);
232  m_wRoot.SetZOrder(1);
233  m_wHighlightImg.SetVisible(true);
234 
235  if (m_wGradient)
236  m_wGradient.SetVisible(true);
237 
238  if (!m_bIsSelected)
239  AnimExpand();
240 
241  if (m_ResourceConsumer)
242  m_wSupplies.SetVisible(true);
243 
244  return false;
245  }
246 
247  //------------------------------------------------------------------------------
248  override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
249  {
250  super.OnMouseLeave(w, enterW, x, y);
251  m_wRoot.SetZOrder(0);
252  m_wHighlightImg.SetVisible(false);
253  if (!m_bIsSelected && m_wGradient)
254  m_wGradient.SetVisible(false);
255  if (!m_bIsSelected)
256  {
257  AnimCollapse();
258  }
259 
260  if (RenderTargetWidget.Cast(enterW) && m_wButton.IsEnabled())
261  m_wButton.SetEnabled(false);
262 
263  if (m_ResourceConsumer)
264  m_wSupplies.SetVisible(false);
265 
266  return false;
267  }
268 
269  override RplId GetSpawnPointId()
270  {
271  return m_SpawnPointId;
272  }
273 };
m_ResourceConsumer
protected SCR_ResourceConsumer m_ResourceConsumer
Definition: SCR_BaseSupportStationComponent.c:114
SCR_MilitarySymbol
Definition: SCR_MilitarySymbol.c:2
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
SCR_GroupIdentityCore
Definition: SCR_GroupIdentityCore.c:2
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_SpawnPoint
Spawn point entity defines positions on which players can possibly spawn.
Definition: SCR_SpawnPoint.c:27
GetFactionByKey
FactionManagerClass GenericEntityClass GetFactionByKey(FactionKey factionKey)
m_sFactionKey
protected FactionKey m_sFactionKey
Definition: SCR_ScenarioFrameworkLayerBase.c:25
GetPlayerController
proto external PlayerController GetPlayerController()
Definition: SCR_PlayerDeployMenuHandlerComponent.c:307
SCR_MilitarySymbolRuleSet
Definition: SCR_MilitarySymbolRuleSet.c:2
EMilitarySymbolIdentity
EMilitarySymbolIdentity
Definition: EMilitarySymbol.c:1
m_ResourceSubscriptionHandleConsumer
protected SCR_ResourceSystemSubscriptionHandleBase m_ResourceSubscriptionHandleConsumer
Definition: SCR_BaseSupportStationComponent.c:125
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_MapUISpawnPoint
Definition: SCR_MapUISpawnPoint.c:1
EResourceType
EResourceType
Definition: SCR_ResourceContainer.c:1
m_ResourceComponent
protected SCR_ResourceComponent m_ResourceComponent
Definition: SCR_CampaignBuildingProviderComponent.c:51
m_SpawnPoint
protected SCR_SpawnPoint m_SpawnPoint
Definition: SCR_CampaignMobileAssemblyComponent.c:28
Select
void Select(bool select)
Definition: SCR_InventoryHitZonePointUI.c:508
SCR_MapUIElement
Definition: SCR_MapUIElement.c:12
SCR_ResourcePlayerControllerInventoryComponent
Definition: SCR_ResourcePlayerControllerInventoryComponent.c:20
SCR_ResourceSystemSubscriptionHandleBase
Definition: SCR_ResourceSystemSubscriptionHandleBase.c:1
m_bVisible
protected bool m_bVisible
Definition: SCR_UITaskManagerComponent.c:28
SCR_MilitarySymbolUIComponent
Definition: SCR_MilitarySymbolUIComponent.c:1
SCR_Faction
Definition: SCR_Faction.c:6
EMilitarySymbolIcon
EMilitarySymbolIcon
Definition: EMilitarySymbol.c:29
m_wButton
protected ButtonWidget m_wButton
Definition: SCR_InventoryHitZonePointUI.c:393
EResourceGeneratorID
EResourceGeneratorID
Definition: SCR_ResourceGenerator.c:1