3 [
Attribute(
"0", UIWidgets.EditBox,
desc:
"Adjust rotation for debug unit icons",
params:
"-180 180")]
4 protected float m_fUnitIconRotation;
6 [
Attribute(
"{BCD5479864D1A79A}UI/Textures/Map/topographicIcons/icons_topographic_map.imageset", UIWidgets.ResourceNamePicker,
"Imageset source for display icon")]
7 protected ResourceName m_sIconImageset;
9 protected bool m_bIsUnitVisible;
10 protected ref array<MapItem> m_aMapItems = {};
16 protected void ShowUnits()
18 m_bIsUnitVisible = !m_bIsUnitVisible;
22 SetPropsVisible(
true);
25 for (
int i = 0; i < count; i++)
31 IEntity ent = item.Entity();
40 if (contrComp && contrComp.IsDead())
42 item.SetVisible(
false);
47 array<string> nameParams = {};
48 GetUnitName(ent, name, nameParams);
49 item.SetInfoText(name, nameParams);
51 FactionAffiliationComponent factionComp = FactionAffiliationComponent.Cast(ent.FindComponent(FactionAffiliationComponent));
52 if (factionComp && factionComp.GetAffiliatedFaction())
54 string factionKey = factionComp.GetAffiliatedFaction().GetFactionKey();
55 if (factionKey ==
"USSR")
56 item.SetFactionIndex(EFactionMapID.EAST);
57 else if (factionKey ==
"US")
58 item.SetFactionIndex(EFactionMapID.WEST);
59 else if (factionKey ==
"FIA")
60 item.SetFactionIndex(EFactionMapID.FIA);
62 item.SetFactionIndex(EFactionMapID.UNKNOWN);
68 SetPropsVisible(
false);
75 void SetPropsVisible(
bool state)
77 for (
int i = 0; i < 6; i++)
89 props.SetVisible(state);
100 void GetUnitName(IEntity ent, out
string name, out notnull array<string> nameParams)
106 int id = playerMgr.GetPlayerIdFromControlledEntity(ent);
109 name = playerMgr.GetPlayerName(
id);
113 SCR_CharacterIdentityComponent scrCharIdentity = SCR_CharacterIdentityComponent.Cast(ent.FindComponent(SCR_CharacterIdentityComponent));
116 scrCharIdentity.GetFormattedFullName(name, nameParams);
120 CharacterIdentityComponent charIdentity = CharacterIdentityComponent.Cast(ent.FindComponent(CharacterIdentityComponent));
122 name = charIdentity.GetIdentity().GetName();
124 name =
"No identity";
132 protected void PanToPlayer()
138 float targetScreenX, targetScreenY;
139 vector playerPos = player.GetOrigin();
140 m_MapEntity.WorldToScreen(playerPos[0], playerPos[2], targetScreenX, targetScreenY);
141 m_MapEntity.PanSmooth(targetScreenX, targetScreenY);
146 protected void ZoomToPPU1()
153 protected void ZoomLayerUp()
159 if (layer.GetCeiling() <=
m_MapEntity.GetMinZoom())
168 protected void ZoomLayerDown()
181 protected void ToggleLight()
183 SCR_MapLightUI lightUI = SCR_MapLightUI.Cast(
SCR_MapEntity.GetMapInstance().GetMapUIComponent(SCR_MapLightUI));
185 lightUI.ToggleActive();
190 protected void UpdateUnits()
193 foreach (
MapItem item : m_aMapItems)
198 vector angles = ent.GetAngles();
199 item.SetAngle(angles[1] + m_fUnitIconRotation);
205 protected void OnRadialMenuOpen()
209 bool isDebugOn = DiagMenu.GetBool(
SCR_DebugMenuID.DEBUGUI_UI_MAP_DEBUG_OPTIONS,
false);
213 category.SetIcon(m_sIconImageset,
"view-point");
216 entry.GetOnPerform().Insert(
m_MapEntity.ShowScriptDebug);
217 entry.SetIcon(m_sIconImageset,
"culvet");
219 entry = radialUI.AddRadialEntry(
"Zoom to 1px == 1m",
category);
220 entry.GetOnPerform().Insert(ZoomToPPU1);
221 entry.SetIcon(m_sIconImageset,
"single-tree");
223 entry = radialUI.AddRadialEntry(
"Zoom up a layer",
category);
224 entry.GetOnPerform().Insert(ZoomLayerUp);
225 entry.SetIcon(m_sIconImageset,
"ancient-fortification");
227 entry = radialUI.AddRadialEntry(
"Zoom down a layer",
category);
228 entry.GetOnPerform().Insert(ZoomLayerDown);
229 entry.SetIcon(m_sIconImageset,
"hospital");
231 entry = radialUI.AddRadialEntry(
"Pan to player",
category);
232 entry.GetOnPerform().Insert(PanToPlayer);
233 entry.SetIcon(m_sIconImageset,
"hill-marker");
235 entry = radialUI.AddRadialEntry(
"Show units",
category);
236 entry.GetOnPerform().Insert(ShowUnits);
237 entry.SetIcon(m_sIconImageset,
"crane");
239 entry = radialUI.AddRadialEntry(
"Toggle Light",
category);
240 entry.GetOnPerform().Insert(ToggleLight);
241 entry.SetIcon(m_sIconImageset,
"smoke-stack");
246 override void Update(
float timeSlice)
248 if (m_bIsUnitVisible)
253 override void OnMapOpen(MapConfiguration config)
255 super.OnMapOpen(config);
256 m_DefaultsCfg = config.DescriptorDefsConfig;
258 if (m_bIsUnitVisible)
260 m_bIsUnitVisible =
false;
270 radialMenu.GetOnMenuInitInvoker().Insert(OnRadialMenuOpen);