Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ServicePointMapDescriptorComponent.c
Go to the documentation of this file.
2 {
3 }
4 
5 class SCR_ServicePointMapDescriptorComponent : SCR_MapDescriptorComponent
6 {
7  [Attribute("", desc: "Name of marker (service is active).")]
8  protected string m_sMarkerActive;
9 
10  [Attribute("", desc: "Name of marker (service is inctive).")]
11  protected string m_sMarkerInactive;
12 
13  [Attribute("Default Name", desc: "Name of service to be shown on hover.")]
14  protected string m_sMarkerName;
15 
16  [Attribute("Default Description", desc: "Description of service to be shown on hover.")]
17  protected string m_sMarkerDesc;
18 
19  [Attribute("{94F1E2223D7E0588}UI/layouts/Campaign/ServiceHint.layout")]
20  protected ResourceName m_sDescriptorServiceHint;
21 
22  protected string m_sMarkerSmall = "Slot_Small";
23 
24  protected Widget m_wDescriptorServiceHint;
25 
26  protected SCR_MilitaryBaseComponent m_Base;
27 
28  //------------------------------------------------------------------------------------------------
31  void SetParentBase(SCR_MilitaryBaseComponent base, bool duringInit = false)
32  {
33  m_Base = base;
34 
35  if (!m_Base || m_Base.GetFaction() != SCR_FactionManager.SGetLocalPlayerFaction() || duringInit)
36  SetServiceMarker(m_Base.GetFaction(), false);
37  }
38 
39  //------------------------------------------------------------------------------------------------
42  void SetServiceMarker(Faction faction = null, bool visible = true)
43  {
44  MapItem item = Item();
45 
46  if (!item)
47  return;
48 
49  if (visible)
50  {
51  item.SetVisible(true);
52  }
53  else
54  {
55  item.SetVisible(false);
56  return;
57  }
58 
59  if (!faction)
60  return;
61 
62  MapDescriptorProps props = item.GetProps();
63 
64  props.SetFrontColor(faction.GetFactionColor());
65  props.SetTextVisible(false);
66  props.Activate(true);
67 
68  SCR_MapEntity mapEntity = SCR_MapEntity.GetMapInstance();
69 
70  if (mapEntity)
71  SetVisible(mapEntity.GetLayerIndex());
72  }
73 
74  //------------------------------------------------------------------------------------------------
76  void SetServiceMarkerActive(bool active)
77  {
78  MapItem item = Item();
79 
80  if (!item)
81  return;
82 
83  string marker;
84 
85  if (active)
86  marker = m_sMarkerActive;
87  else
88  marker = m_sMarkerInactive;
89 
90  item.SetImageDef(marker);
91  }
92 
93  //------------------------------------------------------------------------------------------------
95  void SetVisible(int layer)
96  {
97  if (!m_Base)
98  return;
99 
100  MapItem item = Item();
101  MapDescriptorProps props = item.GetProps();
102 
103  if (layer == 0)
104  {
105  item.SetImageDef(m_sMarkerActive);
106  props.SetIconSize(32, 0.3, 0.3);
107  }
108  else
109  {
110  item.SetImageDef(m_sMarkerSmall);
111  props.SetIconSize(32, 0.1, 0.1);
112  }
113 
114  // TODO: Get rid of Campaign dependency once radio signal range is a sandbox feature
116 
117  if (!campaignBase)
118  return;
119 
120  Faction f = SCR_FactionManager.SGetLocalPlayerFaction();
121 
122  if (!f)
123  return;
124 
125  if (campaignBase.IsHQRadioTrafficPossible(f))
126  Item().GetProps().SetVisible(layer < 3);
127  }
128 
129  //------------------------------------------------------------------------------------------------
133  {
134  MapItem item = Item();
135  if (show != item)
136  return;
137 
138  int mx;
139  int my;
140  WidgetManager.GetMousePos(mx, my);
141 
142  mx = GetGame().GetWorkspace().DPIUnscale(mx);
143  my = GetGame().GetWorkspace().DPIUnscale(my);
144 
146  {
147  SCR_MapEntity entity = SCR_MapEntity.GetMapInstance();
148  m_wDescriptorServiceHint = entity.GetMapMenuRoot().FindAnyWidget("ServiceHintRoot");
149  }
150 
152  return;
153 
154  if (show)
155  {
156  FrameSlot.SetPos(m_wDescriptorServiceHint, mx, my);
157  TextWidget.Cast(m_wDescriptorServiceHint.FindAnyWidget("ServiceName")).SetTextFormat(m_sMarkerName);
158  Widget resupplyText = m_wDescriptorServiceHint.FindAnyWidget("ResupplyText");
159  if (resupplyText)
160  resupplyText.SetVisible(false);
161 
162  TextWidget serviceText = TextWidget.Cast(m_wDescriptorServiceHint.FindAnyWidget("ServiceText"));
163  if (serviceText)
164  {
165  if (m_sMarkerDesc != "Default Description")
166  {
167  serviceText.SetTextFormat(m_sMarkerDesc);
168  serviceText.SetVisible(true);
169  }
170  else
171  {
172  serviceText.SetVisible(false);
173  }
174  }
175  }
176 
177  m_wDescriptorServiceHint.SetVisible(true)
178  }
179 
180  //------------------------------------------------------------------------------------------------
184  {
185  MapItem item = Item();
186  if (show != item)
187  return;
188 
190  m_wDescriptorServiceHint.SetVisible(false);
191  }
192 
193  //------------------------------------------------------------------------------------------------
194  // constructor
198  void SCR_ServicePointMapDescriptorComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
199  {
200  SCR_MapEntity.GetOnLayerChanged().Insert(SetVisible);
201  SCR_MapEntity.GetOnHoverItem().Insert(ShowServiceHint);
202  SCR_MapEntity.GetOnHoverEnd().Insert(HideServiceHint);
203  }
204 
205  //------------------------------------------------------------------------------------------------
206  // destructor
208  {
209  SCR_MapEntity.GetOnLayerChanged().Remove(SetVisible);
210  SCR_MapEntity.GetOnHoverItem().Remove(ShowServiceHint);
211  SCR_MapEntity.GetOnHoverEnd().Remove(HideServiceHint);
212  }
213 }
~SCR_ServicePointMapDescriptorComponent
void ~SCR_ServicePointMapDescriptorComponent()
Definition: SCR_ServicePointMapDescriptorComponent.c:207
ShowServiceHint
void ShowServiceHint(MapItem show)
Definition: SCR_ServicePointMapDescriptorComponent.c:132
HideServiceHint
void HideServiceHint(MapItem show)
Definition: SCR_ServicePointMapDescriptorComponent.c:183
SCR_MapDescriptorComponentClass
Definition: SCR_MapDescriptorComponent.c:1
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_ServicePointMapDescriptorComponent
void SCR_ServicePointMapDescriptorComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_ServicePointMapDescriptorComponent.c:198
MapDescriptorProps
Definition: MapDescriptorProps.c:12
SetVisible
void SetVisible(int layer)
Definition: SCR_ServicePointMapDescriptorComponent.c:95
Item
proto external MapItem Item()
raist todo: this is temporary - before we fix script
m_wDescriptorServiceHint
protected Widget m_wDescriptorServiceHint
Definition: SCR_ServicePointMapDescriptorComponent.c:24
MapItem
Definition: MapItem.c:12
SetServiceMarkerActive
void SetServiceMarkerActive(bool active)
Definition: SCR_ServicePointMapDescriptorComponent.c:76
m_sMarkerSmall
protected string m_sMarkerSmall
Definition: SCR_ServicePointMapDescriptorComponent.c:22
SetParentBase
void SetParentBase(SCR_MilitaryBaseComponent base, bool duringInit=false)
Definition: SCR_ServicePointMapDescriptorComponent.c:31
SCR_MapEntity
Map entity.
Definition: SCR_MapEntity.c:20
SCR_ServicePointMapDescriptorComponentClass
Definition: SCR_ServicePointMapDescriptorComponent.c:1
Faction
Definition: Faction.c:12
m_Base
protected SCR_MilitaryBaseComponent m_Base
Definition: SCR_ServicePointMapDescriptorComponent.c:26
m_sDescriptorServiceHint
UI layouts Campaign ServiceHint layout protected ResourceName m_sDescriptorServiceHint
Definition: SCR_ServicePointMapDescriptorComponent.c:20
SetServiceMarker
void SetServiceMarker(Faction faction=null, bool visible=true)
Definition: SCR_ServicePointMapDescriptorComponent.c:42
SCR_FactionManager
void SCR_FactionManager(IEntitySource src, IEntity parent)
Definition: SCR_FactionManager.c:461
Attribute
SCR_ServicePointMapDescriptorComponentClass SCR_MapDescriptorComponentClass Attribute("", desc:"Name of marker (service is active).")
Definition: SCR_ServicePointMapDescriptorComponent.c:7
SCR_CampaignMilitaryBaseComponent
Definition: SCR_CampaignMilitaryBaseComponent.c:38