Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_MapDebugUI.c
Go to the documentation of this file.
1
class
SCR_MapDebugUI
:
SCR_MapUIBaseComponent
2
{
3
[
Attribute
(
"0"
,
UIWidgets
.EditBox,
desc
:
"Adjust rotation for debug unit icons"
,
params
:
"-180 180"
)]
4
protected
float
m_fUnitIconRotation
;
5
6
[
Attribute
(
"{BCD5479864D1A79A}UI/Textures/Map/topographicIcons/icons_topographic_map.imageset"
,
UIWidgets
.ResourceNamePicker,
"Imageset source for display icon"
)]
7
protected
ResourceName
m_sIconImageset
;
8
9
protected
bool
m_bIsUnitVisible
;
// units debug visible
10
protected
ref array<MapItem>
m_aMapItems
= {};
// cached map items
11
12
protected
SCR_MapDescriptorDefaults
m_DefaultsCfg
;
13
14
//------------------------------------------------------------------------------------------------
16
protected
void
ShowUnits
()
17
{
18
m_bIsUnitVisible
= !
m_bIsUnitVisible
;
19
20
if
(
m_bIsUnitVisible
)
21
{
22
SetPropsVisible
(
true
);
23
24
int
count =
m_MapEntity
.GetByType(
m_aMapItems
,
EMapDescriptorType
.MDT_UNIT);
25
for
(
int
i = 0; i < count; i++)
26
{
27
MapItem
item =
m_aMapItems
[i];
28
if
(!item)
29
continue
;
30
31
IEntity
ent = item.Entity();
32
if
(!ent)
33
{
34
item.Recycle();
35
count--;
36
continue
;
37
}
38
39
SCR_CharacterControllerComponent
contrComp =
SCR_CharacterControllerComponent
.Cast(ent.
FindComponent
(
SCR_CharacterControllerComponent
));
40
if
(contrComp && contrComp.IsDead())
41
{
42
item.SetVisible(
false
);
43
continue
;
44
}
45
46
string
name;
47
array<string> nameParams = {};
48
GetUnitName
(ent, name, nameParams);
49
item.SetInfoText(name, nameParams);
50
51
FactionAffiliationComponent factionComp = FactionAffiliationComponent.Cast(ent.
FindComponent
(FactionAffiliationComponent));
52
if
(factionComp && factionComp.GetAffiliatedFaction())
53
{
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);
61
else
62
item.SetFactionIndex(EFactionMapID.UNKNOWN);
63
}
64
}
65
}
66
else
67
{
68
SetPropsVisible
(
false
);
69
}
70
}
71
72
//------------------------------------------------------------------------------------------------
75
void
SetPropsVisible
(
bool
state)
76
{
77
for
(
int
i = 0; i < 6; i++)
// TODO unhardcode layers
78
{
79
MapLayer
layer
=
m_MapEntity
.GetLayer(i);
80
if
(!
layer
)
81
continue
;
82
83
MapDescriptorProps
props;
84
foreach
(
SCR_FactionColorDefaults
factionDefaults :
m_DefaultsCfg
.m_aFactionColors)
85
{
86
props =
layer
.GetPropsFor(factionDefaults.m_iFaction,
EMapDescriptorType
.MDT_UNIT);
87
if
(props)
88
{
89
props.SetVisible(state);
90
}
91
}
92
}
93
}
94
95
//------------------------------------------------------------------------------------------------
100
void
GetUnitName
(
IEntity
ent, out
string
name, out notnull array<string> nameParams)
101
{
102
PlayerManager
playerMgr =
GetGame
().GetPlayerManager();
103
if
(!playerMgr)
104
return
;
105
106
int
id
= playerMgr.GetPlayerIdFromControlledEntity(ent);
107
if
(
id
!= 0)
108
{
109
name = playerMgr.GetPlayerName(
id
);
110
}
111
else
112
{
113
SCR_CharacterIdentityComponent scrCharIdentity = SCR_CharacterIdentityComponent.Cast(ent.
FindComponent
(SCR_CharacterIdentityComponent));
114
if
(scrCharIdentity)
115
{
116
scrCharIdentity.GetFormattedFullName(name, nameParams);
117
}
118
else
119
{
120
CharacterIdentityComponent charIdentity = CharacterIdentityComponent.Cast(ent.
FindComponent
(CharacterIdentityComponent));
121
if
(charIdentity)
122
name = charIdentity.GetIdentity().GetName();
123
else
124
name =
"No identity"
;
125
}
126
127
}
128
}
129
130
//------------------------------------------------------------------------------------------------
132
protected
void
PanToPlayer
()
133
{
134
IEntity
player =
SCR_PlayerController
.
GetLocalControlledEntity
();
135
if
(!player)
136
return
;
137
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);
// zoom to PPU = 1 and pan to player
142
}
143
144
//------------------------------------------------------------------------------------------------
146
protected
void
ZoomToPPU1
()
147
{
148
m_MapEntity
.ZoomSmooth(1);
149
}
150
151
//------------------------------------------------------------------------------------------------
153
protected
void
ZoomLayerUp
()
154
{
155
int
index
=
m_MapEntity
.GetLayerIndex();
156
MapLayer
layer
=
m_MapEntity
.GetLayer(
index
);
157
if
(
layer
)
158
{
159
if
(
layer
.GetCeiling() <=
m_MapEntity
.GetMinZoom())
// max layer
160
return
;
161
162
m_MapEntity
.ZoomSmooth(
layer
.GetCeiling() - 0.1);
163
}
164
}
165
166
//------------------------------------------------------------------------------------------------
168
protected
void
ZoomLayerDown
()
169
{
170
int
index
=
m_MapEntity
.GetLayerIndex();
171
if
(
index
== 0)
// min layer
172
return
;
173
174
MapLayer
layer
=
m_MapEntity
.GetLayer(
index
-1);
175
if
(
layer
)
176
m_MapEntity
.ZoomSmooth(
layer
.GetCeiling());
177
}
178
179
//------------------------------------------------------------------------------------------------
181
protected
void
ToggleLight
()
182
{
183
SCR_MapLightUI lightUI = SCR_MapLightUI.Cast(
SCR_MapEntity
.
GetMapInstance
().
GetMapUIComponent
(SCR_MapLightUI));
184
if
(lightUI)
185
lightUI.ToggleActive();
186
}
187
188
//------------------------------------------------------------------------------------------------
190
protected
void
UpdateUnits
()
191
{
192
IEntity
ent;
193
foreach
(
MapItem
item :
m_aMapItems
)
194
{
195
ent = item.Entity();
196
if
(ent)
197
{
198
vector
angles
= ent.
GetAngles
();
199
item.SetAngle(
angles
[1] +
m_fUnitIconRotation
);
200
}
201
}
202
}
203
204
//------------------------------------------------------------------------------------------------
205
protected
void
OnRadialMenuOpen
()
206
{
207
SCR_MapRadialUI
radialUI =
SCR_MapRadialUI
.Cast(
m_MapEntity
.GetMapUIComponent(
SCR_MapRadialUI
));
208
209
bool
isDebugOn =
DiagMenu
.GetBool(
SCR_DebugMenuID
.DEBUGUI_UI_MAP_DEBUG_OPTIONS,
false
);
210
if
(isDebugOn)
211
{
212
SCR_SelectionMenuCategoryEntry
category
= radialUI.
AddRadialCategory
(
"Debug Options"
);
213
category
.SetIcon(
m_sIconImageset
,
"view-point"
);
214
215
SCR_SelectionMenuEntry
entry = radialUI.
AddRadialEntry
(
"Map variables dbg"
,
category
);
216
entry.
GetOnPerform
().Insert(
m_MapEntity
.ShowScriptDebug);
217
entry.
SetIcon
(
m_sIconImageset
,
"culvet"
);
218
219
entry = radialUI.
AddRadialEntry
(
"Zoom to 1px == 1m"
,
category
);
220
entry.
GetOnPerform
().Insert(
ZoomToPPU1
);
221
entry.
SetIcon
(
m_sIconImageset
,
"single-tree"
);
222
223
entry = radialUI.
AddRadialEntry
(
"Zoom up a layer"
,
category
);
224
entry.
GetOnPerform
().Insert(
ZoomLayerUp
);
225
entry.
SetIcon
(
m_sIconImageset
,
"ancient-fortification"
);
226
227
entry = radialUI.
AddRadialEntry
(
"Zoom down a layer"
,
category
);
228
entry.
GetOnPerform
().Insert(
ZoomLayerDown
);
229
entry.
SetIcon
(
m_sIconImageset
,
"hospital"
);
230
231
entry = radialUI.
AddRadialEntry
(
"Pan to player"
,
category
);
232
entry.
GetOnPerform
().Insert(
PanToPlayer
);
233
entry.
SetIcon
(
m_sIconImageset
,
"hill-marker"
);
234
235
entry = radialUI.
AddRadialEntry
(
"Show units"
,
category
);
236
entry.
GetOnPerform
().Insert(
ShowUnits
);
237
entry.
SetIcon
(
m_sIconImageset
,
"crane"
);
238
239
entry = radialUI.
AddRadialEntry
(
"Toggle Light"
,
category
);
240
entry.
GetOnPerform
().Insert(
ToggleLight
);
241
entry.
SetIcon
(
m_sIconImageset
,
"smoke-stack"
);
242
}
243
}
244
245
//------------------------------------------------------------------------------------------------
246
override
void
Update
(
float
timeSlice)
247
{
248
if
(
m_bIsUnitVisible
)
249
UpdateUnits
();
250
}
251
252
//------------------------------------------------------------------------------------------------
253
override
void
OnMapOpen
(
MapConfiguration
config)
254
{
255
super.OnMapOpen(config);
256
m_DefaultsCfg
= config.DescriptorDefsConfig;
257
258
if
(
m_bIsUnitVisible
)
259
{
260
m_bIsUnitVisible
=
false
;
261
ShowUnits
();
262
}
263
}
264
265
//------------------------------------------------------------------------------------------------
266
override
void
Init
()
267
{
268
SCR_MapRadialUI
radialMenu =
SCR_MapRadialUI
.Cast(
m_MapEntity
.GetMapUIComponent(
SCR_MapRadialUI
));
269
if
(radialMenu)
270
radialMenu.
GetOnMenuInitInvoker
().Insert(
OnRadialMenuOpen
);
271
}
272
}
SCR_DebugMenuID
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition
DebugMenuID.c:4
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
layer
LayerPresets layer
angles
ref array< string > angles
Definition
PrefabImporter.c:22
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition
SCR_DestructionSynchronizationComponent.c:17
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
params
category params
Definition
SCR_SpherePointGeneratorPreviewComponent.c:21
category
params category
Definition
SCR_VehicleDamageManagerComponent.c:302
DiagMenu
Diagnostic and developer menu system.
Definition
DiagMenu.c:18
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
IEntity::GetAngles
proto external vector GetAngles()
Same as GetYawPitchRoll(), but returns rotation vector around X, Y and Z axis.
IEntity::GetOrigin
proto external vector GetOrigin()
MapConfiguration
Definition
MapConfiguration.c:3
MapDescriptorProps
Definition
MapDescriptorProps.c:13
MapItem
Definition
MapItem.c:13
MapLayer
Definition
MapLayer.c:13
PlayerManager
Definition
PlayerManager.c:13
ResourceName
Definition
ResourceName.c:13
SCR_CharacterControllerComponent
Definition
SCR_CharacterControllerComponent.c:36
SCR_FactionColorDefaults
Configuration of descriptor defaults.
Definition
SCR_MapDescriptorDefaults.c:29
SCR_MapDebugUI
Definition
SCR_MapDebugUI.c:2
SCR_MapDebugUI::m_aMapItems
ref array< MapItem > m_aMapItems
Definition
SCR_MapDebugUI.c:10
SCR_MapDebugUI::OnMapOpen
override void OnMapOpen(MapConfiguration config)
Definition
SCR_MapDebugUI.c:253
SCR_MapDebugUI::m_DefaultsCfg
SCR_MapDescriptorDefaults m_DefaultsCfg
Definition
SCR_MapDebugUI.c:12
SCR_MapDebugUI::ShowUnits
void ShowUnits()
Show infantry units.
Definition
SCR_MapDebugUI.c:16
SCR_MapDebugUI::PanToPlayer
void PanToPlayer()
Context callback.
Definition
SCR_MapDebugUI.c:132
SCR_MapDebugUI::ToggleLight
void ToggleLight()
Toggle map light.
Definition
SCR_MapDebugUI.c:181
SCR_MapDebugUI::m_fUnitIconRotation
float m_fUnitIconRotation
Definition
SCR_MapDebugUI.c:4
SCR_MapDebugUI::ZoomLayerUp
void ZoomLayerUp()
Zooms to the beginning of higher layer.
Definition
SCR_MapDebugUI.c:153
SCR_MapDebugUI::Update
override void Update(float timeSlice)
Definition
SCR_MapDebugUI.c:246
SCR_MapDebugUI::GetUnitName
void GetUnitName(IEntity ent, out string name, out notnull array< string > nameParams)
Definition
SCR_MapDebugUI.c:100
SCR_MapDebugUI::Init
override void Init()
Definition
SCR_MapDebugUI.c:266
SCR_MapDebugUI::m_bIsUnitVisible
bool m_bIsUnitVisible
Definition
SCR_MapDebugUI.c:9
SCR_MapDebugUI::ZoomToPPU1
void ZoomToPPU1()
Zooms to current pixel per unit ratio == 1.
Definition
SCR_MapDebugUI.c:146
SCR_MapDebugUI::SetPropsVisible
void SetPropsVisible(bool state)
Definition
SCR_MapDebugUI.c:75
SCR_MapDebugUI::m_sIconImageset
ResourceName m_sIconImageset
Definition
SCR_MapDebugUI.c:7
SCR_MapDebugUI::UpdateUnits
void UpdateUnits()
Update unit map items.
Definition
SCR_MapDebugUI.c:190
SCR_MapDebugUI::OnRadialMenuOpen
void OnRadialMenuOpen()
Definition
SCR_MapDebugUI.c:205
SCR_MapDebugUI::ZoomLayerDown
void ZoomLayerDown()
Zooms to the ceiling of lower layer.
Definition
SCR_MapDebugUI.c:168
SCR_MapDescriptorDefaults
Config for default values set per descriptor type.
Definition
SCR_MapDescriptorDefaults.c:5
SCR_MapEntity
Definition
SCR_MapEntity.c:18
SCR_MapEntity::GetMapUIComponent
SCR_MapUIBaseComponent GetMapUIComponent(typename componentType)
Definition
SCR_MapEntity.c:261
SCR_MapEntity::GetMapInstance
static SCR_MapEntity GetMapInstance()
Get map entity instance.
Definition
SCR_MapEntity.c:112
SCR_MapRadialUI
2D map radial menu UI
Definition
SCR_MapRadialUI.c:14
SCR_MapRadialUI::GetOnMenuInitInvoker
ScriptInvokerVoid GetOnMenuInitInvoker()
Definition
SCR_MapRadialUI.c:35
SCR_MapRadialUI::AddRadialEntry
SCR_SelectionMenuEntry AddRadialEntry(string name, SCR_SelectionMenuCategoryEntry category=null)
Definition
SCR_MapRadialUI.c:252
SCR_MapRadialUI::AddRadialCategory
SCR_SelectionMenuCategoryEntry AddRadialCategory(string name, SCR_SelectionMenuCategoryEntry parent=null)
Definition
SCR_MapRadialUI.c:270
SCR_MapUIBaseComponent::SCR_MapUIBaseComponent
void SCR_MapUIBaseComponent()
Definition
SCR_MapUIBaseComponent.c:94
SCR_MapUIBaseComponent::m_MapEntity
SCR_MapEntity m_MapEntity
Definition
SCR_MapUIBaseComponent.c:13
SCR_PlayerController
Definition
SCR_PlayerController.c:31
SCR_PlayerController::GetLocalControlledEntity
static IEntity GetLocalControlledEntity()
Definition
SCR_PlayerController.c:495
SCR_SelectionMenuCategoryEntry
Definition
SCR_SelectionMenuCategory.c:7
SCR_SelectionMenuEntry
Definition
SCR_SelectionMenuEntry.c:8
SCR_SelectionMenuEntry::GetOnPerform
ScriptInvoker GetOnPerform()
Definition
SCR_SelectionMenuEntry.c:36
SCR_SelectionMenuEntry::SetIcon
void SetIcon(ResourceName iconPath, string imageSetName="")
Set icon and invoke change.
Definition
SCR_SelectionMenuEntry.c:157
UIWidgets
Definition
attributes.c:40
vector
Definition
vector.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
EMapDescriptorType
EMapDescriptorType
Definition
EMapDescriptorType.c:16
scripts
Game
Map
ComponentsUI
SCR_MapDebugUI.c
Generated by
1.17.0