4 protected string m_sIconsContainer;
6 protected Widget m_wIconsContainer;
8 [
Attribute(
"{E78DE3FD19654C1B}UI/layouts/Campaign/SpawnPointElement.layout",
params:
"layout")]
9 protected ResourceName m_sSpawnPointElement;
11 [
Attribute(
"{EAB5D9841F081D07}UI/layouts/Campaign/TaskElementNew.layout",
params:
"layout")]
12 protected ResourceName m_sTaskElement;
14 [
Attribute(
"{C013EB43E812F9C1}UI/layouts/Menus/DeployMenu/WarningHintTemp.layout")]
15 protected ResourceName m_sWarningWidget;
17 protected Widget m_wWarningWidget;
20 protected bool m_bShowSpawnPointsHint;
23 protected bool m_bShowSpawnPoints;
26 protected bool m_bShowTasks;
28 protected bool m_bIsEditor;
29 protected bool m_bIsDeployMap;
31 protected ref map<Widget, SCR_MapUIElement> m_mIcons =
new map<Widget, SCR_MapUIElement>();
34 protected SCR_PlayerControllerGroupComponent m_PlyGroupComp;
37 protected ref ScriptInvoker<SCR_MapUIElement> m_OnElementSelected;
38 protected ref ScriptInvoker<RplId> m_OnSpawnPointSelected;
54 if (playerFaction && playerFaction.GetFactionKey() == spawnPoint.GetFactionKey())
56 ShowSpawnPoint(spawnPoint);
64 RplId pointId = spawnPoint.GetRplId();
65 HideSpawnPoint(pointId);
70 protected void OnSpawnPointFactionChange(
SCR_SpawnPoint spawnPoint)
73 AddSpawnPoint(spawnPoint);
75 RemoveSpawnPoint(spawnPoint);
79 protected void UpdateSpawnPointName(RplId
id,
string name)
83 if (icon && icon.GetSpawnPointId() ==
id)
92 protected void HideSpawnPoint(RplId spawnPointId)
96 if (icon && icon.GetSpawnPointId() == spawnPointId)
99 w.RemoveFromHierarchy();
111 if (m_bShowSpawnPoints)
120 override void OnMapOpen(MapConfiguration config)
122 PlayerController pc =
GetGame().GetPlayerController();
129 m_PlyGroupComp = SCR_PlayerControllerGroupComponent.Cast(pc.FindComponent(SCR_PlayerControllerGroupComponent));
131 m_PlyGroupComp.GetOnGroupChanged().Insert(OnPlayerGroupChanged);
134 SCR_SpawnPoint.Event_SpawnPointFactionAssigned.Insert(OnSpawnPointFactionChange);
140 m_bIsDeployMap = (config.MapEntityMode ==
EMapEntityMode.SPAWNSCREEN);
142 m_wIconsContainer =
m_RootWidget.FindAnyWidget(m_sIconsContainer);
143 m_wIconsContainer.SetVisible(
true);
145 Widget child = m_wIconsContainer.GetChildren();
148 Widget sibling = child.GetSibling();
153 if (m_bShowSpawnPoints)
160 SCR_SpawnPoint.OnSpawnPointNameChanged.Insert(UpdateSpawnPointName);
164 override void OnMapClose(MapConfiguration config)
170 m_PlyGroupComp.GetOnGroupChanged().Remove(OnPlayerGroupChanged);
172 SCR_SpawnPoint.Event_SpawnPointFactionAssigned.Remove(OnSpawnPointFactionChange);
179 SCR_SpawnPoint.OnSpawnPointNameChanged.Remove(UpdateSpawnPointName);
185 w.RemoveFromHierarchy();
195 void OnMapPan(
float panX,
float panY,
bool adjustedPan)
201 protected void UpdateIcons()
205 if (!icon || !widget)
208 vector pos = icon.GetPos();
210 m_MapEntity.WorldToScreen(pos[0], pos[2], x, y,
true);
212 x =
GetGame().GetWorkspace().DPIUnscale(x);
213 y =
GetGame().GetWorkspace().DPIUnscale(y);
215 if (m_bShowSpawnPointsHint)
217 if (!m_wWarningWidget)
218 m_wWarningWidget =
GetGame().GetWorkspace().CreateWidgets(m_sWarningWidget, m_wIconsContainer);
221 float screenWidth =
GetGame().GetWorkspace().GetWidth();
222 float screenHeight =
GetGame().GetWorkspace().GetHeight();
223 float screenWUnscaled =
GetGame().GetWorkspace().DPIUnscale(screenWidth);
224 float screenHUnscaled =
GetGame().GetWorkspace().DPIUnscale(screenHeight);
225 float ctverecWidth, ctverecHeight;
226 m_wWarningWidget.GetScreenSize(ctverecWidth, ctverecHeight);
229 FrameSlot.SetPos(m_wWarningWidget, 0, y);
230 if (x > screenWUnscaled)
231 FrameSlot.SetPos(m_wWarningWidget, screenWUnscaled - ctverecWidth * 2, y);
234 FrameSlot.SetPos(m_wWarningWidget, x, 0);
235 if (y > screenHUnscaled)
236 FrameSlot.SetPos(m_wWarningWidget, x, screenHUnscaled - ctverecHeight * 2);
238 m_wWarningWidget.SetVisible(x < 0 || x > screenWUnscaled || y < 0 || y > screenHUnscaled);
241 FrameSlot.SetPos(widget, x, y);
245 protected void InitSpawnPoints()
247 array<SCR_SpawnPoint> infos = {};
254 infos =
SCR_SpawnPoint.GetSpawnPointsForFaction(playerFaction.GetFactionKey());
263 ShowSpawnPoint(info);
271 if (!m_bIsDeployMap && spawnPoint.GetVisibleInDeployMapOnly())
277 Widget w =
GetGame().GetWorkspace().CreateWidgets(m_sSpawnPointElement, m_wIconsContainer);
282 handler.Init(spawnPoint);
283 handler.SetParent(
this);
284 m_mIcons.Set(w, handler);
286 FrameSlot.SetSizeToContent(w,
true);
287 FrameSlot.SetAlignment(w, 0.5, 0.5);
291 protected void InitTaskMarkers()
298 array<SCR_BaseTask> availableTasks = {};
301 taskCount = taskManager.GetTasks(availableTasks);
305 taskCount = taskManager.GetFilteredTasks(availableTasks,
SCR_FactionManager.SGetLocalPlayerFaction());
308 for (
int i = 0; i < taskCount; ++i)
310 InitTaskIcon(availableTasks[i]);
321 Widget w =
GetGame().GetWorkspace().CreateWidgets(m_sTaskElement, m_wIconsContainer);
329 handler.SetParent(
this);
330 handler.InitTask(task);
331 m_mIcons.Set(w, handler);
333 FrameSlot.SetSizeToContent(w,
true);
334 FrameSlot.SetAlignment(w, 0.5, 0.5);
339 if (!m_bShowTasks || !task)
351 if (t.GetTask() == task)
359 protected void RemoveAllIcons()
361 Widget child = m_wIconsContainer.GetChildren();
364 Widget sibling = child.GetSibling();
377 delete m_mIcons.GetKeyByValue(icon);
384 if (icon && icon.GetSpawnPointId() ==
id)
393 void OnSpawnPointSelectedExt(RplId
id)
397 icon.SelectIcon(
false);
404 GetOnElementSelected().Invoke(element);
410 void OnSpawnPointSelected(RplId spId = RplId.Invalid())
412 GetOnSpawnPointSelected().Invoke(spId);
416 protected void OnPlayerGroupChanged(
SCR_AIGroup group)
429 if (!sp.IsSpawnPointVisibleForPlayer(pid))
430 RemoveSpawnPoint(sp);
457 if (sp.GetSpawnPointId() ==
id)
466 ScriptInvoker GetOnSpawnPointSelected()
468 if (!m_OnSpawnPointSelected)
469 m_OnSpawnPointSelected =
new ScriptInvoker();
471 return m_OnSpawnPointSelected;
476 ScriptInvoker GetOnElementSelected()
478 if (!m_OnElementSelected)
479 m_OnElementSelected =
new ScriptInvoker();
481 return m_OnElementSelected;