4 [
Attribute(
"{E48F14D6D3C54BE5}UI/layouts/Campaign/BaseElement.layout",
params:
"layout")]
5 protected ResourceName m_sBaseElement;
7 [
Attribute(
"{94F1E2223D7E0588}UI/layouts/Campaign/ServiceHint.layout",
params:
"layout")]
8 protected ResourceName m_sServiceHint;
10 [
Attribute(
"{FD71287E68006A26}UI/layouts/Campaign/CampaignPlayerMapIndicator.layout",
params:
"layout")]
11 protected ResourceName m_sSpawnPositionHint;
13 protected Widget m_wMobileAssembly;
16 void InitMobileAssembly(
string factionKey,
bool deployed)
18 if (m_wMobileAssembly)
20 m_wMobileAssembly.SetVisible(deployed);
24 FactionManager fm =
GetGame().GetFactionManager();
33 if (faction != playerFaction)
36 SCR_CampaignMobileAssemblyStandaloneComponent assembly = faction.GetMobileAssembly();
40 Widget w =
GetGame().GetWorkspace().CreateWidgets(m_sBaseElement, m_wIconsContainer);
44 m_wMobileAssembly = w;
50 handler.SetParent(
this);
51 handler.InitMobile(assembly);
52 m_mIcons.Set(w, handler);
54 FrameSlot.SetSizeToContent(w,
true);
55 FrameSlot.SetAlignment(w, 0.5, 0.5);
59 protected void InitBases()
62 array<SCR_MilitaryBaseComponent> bases = {};
63 baseManager.GetBases(bases);
71 for (
int i = 0, count = bases.Count(); i < count; ++i)
75 if (!base || !base.IsInitialized())
78 if (base.IsHQ() && base.GetFaction() != faction)
81 Widget w =
GetGame().GetWorkspace().CreateWidgets(m_sBaseElement, m_wIconsContainer);
87 handler.SetParent(
this);
88 handler.InitBase(base);
89 m_mIcons.Set(w, handler);
90 base.SetBaseUI(handler);
92 FrameSlot.SetSizeToContent(w,
true);
93 FrameSlot.SetAlignment(w, 0.5, 0.5);
98 string factionKey = faction.GetFactionKey();
99 InitMobileAssembly(factionKey, faction.GetMobileAssembly() !=
null);
106 protected override void ShowSpawnPoint(notnull
SCR_SpawnPoint spawnPoint)
108 if (!m_bIsDeployMap && spawnPoint.GetVisibleInDeployMapOnly())
118 IEntity owner = spawnPoint.GetParent();
121 SCR_CampaignMobileAssemblyStandaloneComponent westMHQ = gameMode.GetFactionByEnum(
SCR_ECampaignFaction.BLUFOR).GetMobileAssembly();
122 SCR_CampaignMobileAssemblyStandaloneComponent eastMHQ = gameMode.GetFactionByEnum(
SCR_ECampaignFaction.OPFOR).GetMobileAssembly();
124 if ((westMHQ && westMHQ.GetOwner() == spawnPoint) || (eastMHQ && eastMHQ.GetOwner() == spawnPoint))
127 super.ShowSpawnPoint(spawnPoint);
136 Widget w =
GetGame().GetWorkspace().CreateWidgets(m_sSpawnPointElement, m_wIconsContainer);
141 handler.Init(spawnPoint);
142 handler.SetParent(
this);
143 m_mIcons.Set(w, handler);
145 FrameSlot.SetSizeToContent(w,
true);
146 FrameSlot.SetAlignment(w, 0.5, 0.5);
150 protected void CreatePlayerSpawnPositionHint()
152 SCR_CampaignFeedbackComponent comp = SCR_CampaignFeedbackComponent.GetInstance();
157 if (!comp.CanShowPlayerSpawn())
160 comp.SetMapCampaignUI(
this);
162 vector playerLocation = comp.GetPlayerSpawnPos();
164 Widget indicator =
GetGame().GetWorkspace().CreateWidgets(m_sSpawnPositionHint, m_wIconsContainer);
168 if (!highlightHandler)
171 m_mIcons.Insert(indicator, highlightHandler);
173 highlightHandler.SetParent(
this);
174 highlightHandler.SetPos(playerLocation);
176 FrameSlot.SetPosX(indicator, playerLocation[0]);
177 FrameSlot.SetPosY(indicator, playerLocation[1]);
178 FrameSlot.SetSizeToContent(indicator,
true);
179 FrameSlot.SetAlignment(indicator, 0.5, 0.5);
182 if (!comp.WasMapOpened())
184 m_MapEntity.ZoomPanSmooth(1.5,playerLocation[0],playerLocation[2]);
185 comp.SetMapOpened(
true);
189 ResourceName imageSet =
"{5E8F77F38C2B9B9F}UI/Imagesets/MilitarySymbol/ICO.imageset";
190 ImageWidget image = ImageWidget.Cast(indicator.FindAnyWidget(
"Image"));
193 image.LoadImageFromSet(0, imageSet,
"PlayerSpawnHint");
194 image.SetColor(Color.FromInt(Color.ORANGE));
198 RichTextWidget timeWidget = RichTextWidget.Cast(indicator.FindAnyWidget(
"TimeString"));
199 TimeContainer timeContainer = comp.GetSpawnTime();
202 string hours = timeContainer.m_iHours.ToString();
203 string minutes = timeContainer.m_iMinutes.ToString();
205 if (timeContainer.m_iHours < 10)
208 if (timeContainer.m_iMinutes < 10)
209 minutes =
"0" + minutes;
211 timeWidget.SetTextFormat(
"%1:%2",hours, minutes);
214 HideSpawnPositionHint(
m_MapEntity.GetLayerIndex());
215 m_MapEntity.GetOnLayerChanged().Insert(HideSpawnPositionHint);
220 void RemoveSpawnPositionHint()
228 w.RemoveFromHierarchy();
236 protected void HideSpawnPositionHint(
int layer)
255 protected override void OnSpawnPointFactionChange(
SCR_SpawnPoint spawnPoint)
269 void OnMapZoom(
float pixelPerUnit)
275 override void OnMapOpen(MapConfiguration config)
277 super.OnMapOpen(config);
279 Widget serviceHint =
GetGame().GetWorkspace().CreateWidgets(m_sServiceHint,
SCR_MapEntity.GetMapInstance().GetMapMenuRoot());
283 FrameSlot.SetSizeToContent(serviceHint,
true);
284 serviceHint.SetName(
"ServiceHintRoot");
285 serviceHint.SetVisible(
false);
288 SCR_CampaignFeedbackComponent comp = SCR_CampaignFeedbackComponent.GetInstance();
291 comp.SetMapCampaignUI(
this);
294 CreatePlayerSpawnPositionHint();
301 override void OnMapClose(MapConfiguration config)
303 super.OnMapClose(config);
308 delete m_wMobileAssembly;
312 w.RemoveFromHierarchy();
317 m_MapEntity.GetOnLayerChanged().Remove(HideSpawnPositionHint);
323 delete m_wMobileAssembly;