Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CampaignMapUIService.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
3 {
4  protected SCR_CampaignMapUIBase m_ParentBase;
5 
6  protected SCR_EServicePointType m_eServiceType;
7 
8  protected bool m_bEnabled;
9  protected string m_sServiceName;
10  protected string m_sServiceIcon;
11  protected string m_sServiceText;
12 
13  //------------------------------------------------------------------------------
14  override bool OnMouseEnter(Widget w, int x, int y)
15  {
16  PlayHoverSound(m_sSoundService);
17 
18  ShowHint(true);
19  if (m_ParentBase)
20  m_ParentBase.m_bIsAnyElementHovered = true;
21 
22  return false;
23  }
24 
25  //------------------------------------------------------------------------------
26  override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
27  {
28  ShowHint(false);
29  if (m_ParentBase)
30  m_ParentBase.m_bIsAnyElementHovered = false;
31 
32  return false;
33  }
34 
35  //------------------------------------------------------------------------------
36  override bool OnClick(Widget w, int x, int y, int button)
37  {
38  SCR_MapEntity mapa = SCR_MapEntity.GetMapInstance();
39  if (m_MapItem && m_MapItem.IsVisible() && mapa)
40  {
41  vector pos = m_MapItem.GetPos();
42  mapa.ZoomPanSmooth(10, pos[0], pos[2]);
43  }
44 
45  return false;
46  }
47 
48  //------------------------------------------------------------------------------
49  override void AnimExpand()
50  {
51  }
52 
53  //------------------------------------------------------------------------------
54  override void AnimCollapse()
55  {
56  }
57 
58  //------------------------------------------------------------------------------
59  override void HandlerAttached(Widget w)
60  {
61  super.HandlerAttached(w);
62  m_eIconType = SCR_EIconType.SERVICE;
63  }
64 
65  //------------------------------------------------------------------------------
66  void ShowHint(bool show)
67  {
68  if (m_ParentBase)
69  {
71 
72  if (m_eServiceType == EEditableEntityLabel.SERVICE_SUPPLY_STORAGE && base)
73  {
74  Faction playerFaction = SCR_FactionManager.SGetLocalPlayerFaction();
75  if (base.GetFaction() == playerFaction)
76  {
77  int supplies = base.GetSupplies();
78  int suppliesMax = base.GetSuppliesMax();
79 
80  m_sServiceText = "#AR-Campaign_BaseSuppliesHintAmount";
81  m_ParentBase.ShowServiceHint(m_sServiceName, m_sServiceText, show, supplies, suppliesMax);
82  }
83  else
84  {
85  m_sServiceText = "#AR-Campaign_BaseSuppliesHintUnknown";
86  m_ParentBase.ShowServiceHint(m_sServiceName, m_sServiceText, show);
87  }
88  }
89  else
90  {
91  m_ParentBase.ShowServiceHint(m_sServiceName, m_sServiceText, show);
92  }
93  }
94  }
95 
96  //------------------------------------------------------------------------------
97  void SetServiceImage()
98  {
99  switch (m_eServiceType)
100  {
101  case SCR_EServicePointType.BARRACKS:
102  {
103  SetImage(m_sBarracks);
104  m_sServiceName = "#AR-Campaign_Building_Barracks";
105  } break;
106 
107  case SCR_EServicePointType.FIELD_HOSPITAL:
108  {
109  SetImage(m_sFieldHospital);
110  m_sServiceName = "#AR-Campaign_Building_FieldHospital";
111  } break;
112 
113  case SCR_EServicePointType.LIGHT_VEHICLE_DEPOT:
114  {
115  SetImage(m_sLightVehicleDepot);
116  m_sServiceName = "#AR-Comm_Variable_Miscellaneous_LightVehicleDepot";
117  } break;
118 
119  case SCR_EServicePointType.HEAVY_VEHICLE_DEPOT:
120  {
121  SetImage(m_sHeavyVehicleDepot);
122  m_sServiceName = "#AR-Comm_Variable_Miscellaneous_HeavyVehicleDepot";
123  } break;
124 
125  case SCR_EServicePointType.RADIO_ANTENNA:
126  {
127  SetImage(m_sRadioAntenna);
128  m_sServiceName = "#AR-Comm_Variable_Miscellaneous_RadioAntenna";
129  } break;
130 
131  case SCR_EServicePointType.SUPPLY_DEPOT:
132  {
133  SetImage(m_sSupplyDepot);
134  m_sServiceName = "#AR-Comm_Variable_Miscellaneous_Supplydepot_US";
135  } break;
136 
137  case SCR_EServicePointType.ARMORY:
138  {
139  SetImage(m_sArmory);
140  m_sServiceName = "#AR-Campaign_Building_Armory";
141  } break;
142 
143  case SCR_EServicePointType.FUEL_DEPOT:
144  {
145  SetImage(m_sFuelDepot);
146  m_sServiceName = "#AR-Comm_Variable_Miscellaneous_Fueldepot_US";
147  } break;
148 
149  case SCR_EServicePointType.HELIPAD:
150  {
151  SetImage(m_sHelipad);
152  m_sServiceName = "#AR-EditableEntity_Helipad_L_US_01_Name";
153  } break;
154 
155  /*case SCR_EServicePointType.VEHICLE_DEPOT:
156  {
157  SetImage(m_sVehicleDepot);
158  m_sServiceName = "#AR-Campaign_Building_MotorPool";
159  } break;*/
160  }
161  }
162 
163  //------------------------------------------------------------------------------
164  void SetParent(SCR_CampaignMapUIBase parent)
165  {
166  m_ParentBase = parent;
167  }
168 
169  //------------------------------------------------------------------------------
170  void SetService(EEditableEntityLabel type, SCR_ServicePointDelegateComponent service)
171  {
172  m_bEnabled = service != null;
173  m_eServiceType = type;
174  SetServiceImage();
175 
176  if (!service)
177  return;
178 
179  IEntity owner = service.GetOwner();
180 
181  if (!owner)
182  return;
183 
185 
186  if (!descr)
187  {
188  IEntity compositionParent = SCR_EntityHelper.GetMainParent(owner, true);
189  descr = SCR_ServicePointMapDescriptorComponent.Cast(compositionParent.FindComponent(SCR_ServicePointMapDescriptorComponent));
190  }
191 
192  if (descr)
193  m_MapItem = descr.Item();
194  }
195 
196  //------------------------------------------------------------------------------
197  override void SetImage(string image)
198  {
199  m_sServiceIcon = image;
200  string suffix = string.Empty;
201 
203  if (img)
204  {
205  img.SetImage(m_sImageSet, image + suffix);
206  img.SetEnabled(m_bEnabled);
207  }
208  }
209 };
SCR_CampaignMapUIService
Definition: SCR_CampaignMapUIService.c:2
EEditableEntityLabel
EEditableEntityLabel
Definition: EEditableEntityLabel.c:1
SCR_EntityHelper
Definition: SCR_EntityHelper.c:1
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
m_MapItem
protected MapItem m_MapItem
Definition: SCR_CampaignMobileAssemblyStandaloneComponent.c:14
SCR_EIconType
SCR_EIconType
Definition: SCR_MapUIElement.c:1
SCR_CampaignMapUIBase
Definition: SCR_CampaignMapUIBase.c:2
SCR_ServicePointMapDescriptorComponent
void SCR_ServicePointMapDescriptorComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_ServicePointMapDescriptorComponent.c:198
m_sImageSet
ResourceName m_sImageSet
Definition: SCR_MapToolMenuUI.c:8
SCR_MapEntity
Map entity.
Definition: SCR_MapEntity.c:20
SCR_CampaignMapUIElement
Definition: SCR_CampaignMapUIElement.c:2
Faction
Definition: Faction.c:12
type
EDamageType type
Definition: SCR_DestructibleTreeV2.c:32
m_ParentBase
protected SCR_MilitaryBaseComponent m_ParentBase
Definition: SCR_ServicePointDelegateComponent.c:14
m_bEnabled
private bool m_bEnabled
Definition: SCR_BaseManualCameraComponent.c:3
SCR_FactionManager
void SCR_FactionManager(IEntitySource src, IEntity parent)
Definition: SCR_FactionManager.c:461
SCR_ButtonImageComponent
Definition: SCR_ButtonImageComponent.c:2
SCR_EServicePointType
SCR_EServicePointType
Definition: SCR_ServicePointComponent.c:180
SCR_CampaignMilitaryBaseComponent
Definition: SCR_CampaignMilitaryBaseComponent.c:38