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_MapCommandPostUI.c
Go to the documentation of this file.
1
class
SCR_MapCommandPostUI
:
ScriptedWidgetComponent
2
{
3
[
Attribute
(
"{3262679C50EF4F01}UI/Textures/Icons/icons_wrapperUI.imageset"
,
UIWidgets
.ResourceNamePicker,
"Imageset Wrapper UI with mode icons"
,
"imageset"
,
category
:
"Frontend"
)]
4
ResourceName
m_sWrapperImageset;
5
6
protected
ButtonWidget
m_wCloseButtonWidget
;
7
protected
SCR_InputButtonComponent
m_InputButton
;
8
9
protected
SCR_CampaignMilitaryBaseComponent
m_ActiveBase
;
10
11
protected
bool
m_bCommanderRoleEnabled
;
12
13
protected
string
m_sModeName
;
14
protected
string
m_sIconName
;
15
protected
Color
m_ModeColor
;
16
17
protected
RichTextWidget
m_wCommanderName
;
18
protected
Widget
m_wPlatformLayout
;
19
protected
ImageWidget
m_wPlatformIcon
;
20
protected
TextWidget
m_wModeText
;
21
protected
ImageWidget
m_wModeTopBar
;
22
protected
ImageWidget
m_wModeIcon
;
23
24
protected
BaseContainer
m_GameplaySettings
;
25
26
protected
const
string
CURRENT_COMMANDER_AI_TEXT
=
"#AR-FactionCommander_CurrentCommander_AI"
;
27
protected
const
string
CURRENT_COMMANDER_PLAYER_TEXT
=
"#AR-FactionCommander_CurrentCommander"
;
28
protected
const
string
LOGISTICS_LABEL_TEXT
=
"#AR-FactionCommander_UserAction_LogisticsStation"
;
29
protected
const
string
COMBAT_SUPPORT_LABEL_TEXT
=
"#AR-FactionCommander_UserAction_RadioStation"
;
30
protected
const
string
OPERATIONS_LABEL_TEXT
=
"#AR-FactionCommander_UserAction_EngineeringStation"
;
31
protected
const
string
LOGISTICS_ICON
=
"veh_trunk"
;
32
protected
const
string
COMBAT_SUPPORT_ICON
=
"characters"
;
33
protected
const
string
OPERATIONS_ICON
=
"scenarios"
;
34
35
//------------------------------------------------------------------------------------------------
36
override
void
HandlerAttached
(
Widget
w)
37
{
38
if
(
SCR_Global
.
IsEditMode
())
39
return
;
40
41
SetActiveBase
();
42
SCR_CampaignMilitaryBaseManager
.
GetOnBaseDisassembled
().Insert(
OnBaseDisassembled
);
43
SCR_CampaignMilitaryBaseComponent
.
GetOnFactionChangedExtended
().Insert(
OnBaseFactionChanged
);
44
45
m_GameplaySettings
=
GetGame
().GetGameUserSettings().GetModule(
"SCR_GameplaySettings"
);
46
47
m_wCloseButtonWidget
=
ButtonWidget
.Cast(w.FindAnyWidget(
"Toolbar_PlayButton_CloseMap"
));
48
if
(!
m_wCloseButtonWidget
)
49
return
;
50
51
m_InputButton
=
SCR_InputButtonComponent
.Cast(
SCR_WidgetTools
.FindHandlerInChildren(
m_wCloseButtonWidget
,
SCR_InputButtonComponent
));
52
if
(!
m_InputButton
)
53
return
;
54
55
m_InputButton
.m_OnClicked.Insert(
OnCloseButtonClicked
);
56
57
SCR_CampaignLogisticMapUIBase
.
GetOnBaseSelected
().Insert(
OnBaseClicked
);
58
59
if
(SCR_FactionCommanderHandlerComponent.GetInstance())
60
SCR_FactionCommanderHandlerComponent.GetInstance().GetOnFactionCommanderChanged().Insert(
OnFactionCommanderChanged
);
61
62
SetCommanderNameWidget
(w);
63
SetModeType
(w);
64
}
65
66
//------------------------------------------------------------------------------------------------
67
override
void
HandlerDeattached
(
Widget
w)
68
{
69
SCR_CampaignLogisticMapUIBase
.
GetOnBaseSelected
().Remove(
OnBaseClicked
);
70
71
SCR_CampaignMilitaryBaseManager
.
GetOnBaseDisassembled
().Remove(
OnBaseDisassembled
);
72
SCR_CampaignMilitaryBaseComponent
.
GetOnFactionChangedExtended
().Remove(
OnBaseFactionChanged
);
73
74
if
(
m_InputButton
)
75
m_InputButton
.m_OnClicked.Remove(
OnCloseButtonClicked
);
76
77
if
(SCR_FactionCommanderHandlerComponent.GetInstance())
78
SCR_FactionCommanderHandlerComponent.GetInstance().GetOnFactionCommanderChanged().Remove(
OnFactionCommanderChanged
);
79
}
80
81
//------------------------------------------------------------------------------------------------
82
protected
void
OnCloseButtonClicked
()
83
{
84
CloseMenu
();
85
}
86
87
//------------------------------------------------------------------------------------------------
88
protected
void
OnBaseClicked
(
bool
selected)
89
{
90
if
(!
m_wCloseButtonWidget
|| !
m_InputButton
)
91
return
;
92
93
bool
isEnabled = !selected;
94
m_wCloseButtonWidget
.SetEnabled(isEnabled);
95
m_InputButton
.SetEnabled(isEnabled);
96
}
97
98
//------------------------------------------------------------------------------------------------
100
protected
void
OnFactionCommanderChanged
(
SCR_Faction
faction,
int
commanderPlayerId)
101
{
102
int
playerId =
SCR_PlayerController
.
GetLocalPlayerId
();
103
SCR_Faction
playerFaction =
SCR_Faction
.Cast(
SCR_PlayerController
.
GetLocalMainEntityFaction
());
104
105
// Skip closing if another faction commander changed or local player is a new commander
106
if
(!playerFaction || playerFaction != faction || commanderPlayerId == playerId)
107
return
;
108
109
CloseMenu
();
110
}
111
112
//------------------------------------------------------------------------------------------------
114
protected
void
OnBaseDisassembled
(
SCR_CampaignMilitaryBaseComponent
base
,
Faction
faction)
115
{
116
if
(!
m_ActiveBase
||
base
!=
m_ActiveBase
)
117
return
;
118
119
CloseMenu
();
120
}
121
122
//------------------------------------------------------------------------------------------------
124
protected
void
OnBaseFactionChanged
(
SCR_CampaignMilitaryBaseComponent
base
,
Faction
defendingFaction,
Faction
attackingFaction)
125
{
126
if
(!
m_ActiveBase
||
base
!=
m_ActiveBase
)
127
return
;
128
129
Faction
playerFaction =
SCR_PlayerController
.
GetLocalMainEntityFaction
();
130
if
(attackingFaction == playerFaction)
131
return
;
132
133
CloseMenu
();
134
}
135
136
//------------------------------------------------------------------------------------------------
137
protected
void
CloseMenu
()
138
{
139
MenuManager
menuManager =
GetGame
().GetMenuManager();
140
menuManager.
CloseMenuByPreset
(
ChimeraMenuPreset
.CommandPostMapMenu);
141
}
142
143
//------------------------------------------------------------------------------------------------
144
protected
void
SetCommanderNameWidget
(
Widget
w)
145
{
146
m_wCommanderName
=
RichTextWidget
.Cast(w.FindAnyWidget(
"CurrentCommander"
));
147
if
(!
m_wCommanderName
)
148
return
;
149
150
m_wPlatformLayout
= w.FindAnyWidget(
"PlatformLayout"
);
151
if
(!
m_wPlatformLayout
)
152
return
;
153
154
m_wPlatformIcon
=
ImageWidget
.Cast(w.FindAnyWidget(
"PlatformIcon"
));
155
if
(!
m_wPlatformIcon
)
156
return
;
157
158
SCR_Faction
faction =
SCR_Faction
.Cast(
SCR_FactionManager
.SGetLocalPlayerFaction());
159
if
(!faction)
160
return
;
161
162
int
commanderId = faction.
GetCommanderId
();
163
if
(!commanderId)
164
return
;
165
166
string
name =
CURRENT_COMMANDER_AI_TEXT
;
167
168
if
(!faction.
IsAICommander
())
169
name =
SCR_PlayerNamesFilterCache
.GetInstance().GetPlayerDisplayName(commanderId);
170
171
m_wCommanderName
.SetTextFormat(
CURRENT_COMMANDER_PLAYER_TEXT
, name);
172
173
bool
showOnPC;
174
if
(
m_GameplaySettings
)
175
m_GameplaySettings
.Get(
"m_bPlatformIconNametag"
, showOnPC);
176
177
SCR_PlayerController
playerController =
SCR_PlayerController
.Cast(
GetGame
().
GetPlayerController
());
178
if
(playerController)
179
{
180
bool
res = playerController.SetPlatformImageTo(commanderId,
m_wPlatformIcon
, showOnPC: showOnPC);
181
m_wPlatformLayout
.SetVisible(res);
182
}
183
}
184
185
//------------------------------------------------------------------------------------------------
186
protected
void
SetModeType
(
Widget
w)
187
{
188
m_wModeText
=
TextWidget
.Cast(w.FindAnyWidget(
"ModeText"
));
189
m_wModeTopBar
=
ImageWidget
.Cast(w.FindAnyWidget(
"TopBadgeLine"
));
190
m_wModeIcon
=
ImageWidget
.Cast(w.FindAnyWidget(
"ModeIcon"
));
191
192
BaseGameMode gameMode =
GetGame
().GetGameMode();
193
if
(!gameMode)
194
return
;
195
196
SCR_MapConfigComponent configComp = SCR_MapConfigComponent.Cast(gameMode.FindComponent(SCR_MapConfigComponent));
197
if
(!configComp)
198
return
;
199
200
EMapEntityMode
currentMapEntityMode = configComp.GetCommandPostMapEntityMode();
201
202
switch
(currentMapEntityMode)
203
{
204
case
EMapEntityMode
.LOGISTICS_STATION:
205
{
206
m_sModeName
=
LOGISTICS_LABEL_TEXT
;
207
m_sIconName
=
LOGISTICS_ICON
;
208
m_ModeColor
=
UIColors
.EDITOR_MODE_GM_MODE;
209
break
;
210
}
211
case
EMapEntityMode
.COMBAT_SUPPORT_STATION:
212
{
213
m_sModeName
=
COMBAT_SUPPORT_LABEL_TEXT
;
214
m_sIconName
=
COMBAT_SUPPORT_ICON
;
215
m_ModeColor
=
UIColors
.EDITOR_MODE_ADMIN_MODE;
216
break
;
217
}
218
case
EMapEntityMode
.OPERATIONS_STATION:
219
{
220
m_sModeName
=
OPERATIONS_LABEL_TEXT
;
221
m_sIconName
=
OPERATIONS_ICON
;
222
m_ModeColor
=
UIColors
.EDITOR_MODE_ARMAVISION;
223
break
;
224
}
225
}
226
227
m_wModeText
.SetText(
m_sModeName
);
228
m_wModeTopBar
.SetColor(
m_ModeColor
);
229
m_wModeIcon
.SetColor(
m_ModeColor
);
230
m_wModeIcon
.LoadImageFromSet(0, m_sWrapperImageset,
m_sIconName
);
231
}
232
233
//------------------------------------------------------------------------------------------------
234
protected
void
SetActiveBase
()
235
{
236
IEntity
playerEntity =
SCR_PlayerController
.
GetLocalMainEntity
();
237
if
(!playerEntity)
238
return
;
239
240
SCR_GameModeCampaign
campaign =
SCR_GameModeCampaign
.GetInstance();
241
if
(!campaign)
242
return
;
243
244
SCR_CampaignMilitaryBaseManager
baseManager = campaign.GetBaseManager();
245
if
(!baseManager)
246
return
;
247
248
m_ActiveBase
= baseManager.
FindClosestBase
(playerEntity.
GetOrigin
());
249
}
250
}
ChimeraMenuPreset
ChimeraMenuPreset
Menu presets.
Definition
ChimeraMenuBase.c:4
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
SCR_FactionManager
void SCR_FactionManager(IEntitySource src, IEntity parent)
Definition
SCR_FactionManager.c:498
SCR_GameModeCampaign
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
Definition
SCR_GameModeCampaign.c:1812
base
around base
Definition
SCR_HoldCampaignMilitaryBaseTaskEntity.c:9
EMapEntityMode
EMapEntityMode
Mode of the map.
Definition
SCR_MapConstants.c:29
category
params category
Definition
SCR_VehicleDamageManagerComponent.c:302
BaseContainer
Definition
BaseContainer.c:13
ButtonWidget
Definition
ButtonWidget.c:16
Color
Definition
Color.c:13
Faction
Definition
Faction.c:13
IEntity
Definition
IEntity.c:13
IEntity::GetOrigin
proto external vector GetOrigin()
ImageWidget
Definition
ImageWidget.c:13
MenuManager
Definition
MenuManager.c:13
MenuManager::CloseMenuByPreset
proto external bool CloseMenuByPreset(ScriptMenuPresetEnum preset)
Put menu with given iPresetId into queue for closing (which is processed during next MenuManeger upda...
ResourceName
Definition
ResourceName.c:13
RichTextWidget
Definition
RichTextWidget.c:13
SCR_CampaignLogisticMapUIBase
Definition
SCR_CampaignLogisticMapUIBase.c:2
SCR_CampaignLogisticMapUIBase::GetOnBaseSelected
static ScriptInvokerBool GetOnBaseSelected()
Definition
SCR_CampaignLogisticMapUIBase.c:59
SCR_CampaignMilitaryBaseComponent
Definition
SCR_CampaignMilitaryBaseComponent.c:38
SCR_CampaignMilitaryBaseComponent::GetOnFactionChangedExtended
static OnBaseStateChangedInvoker GetOnFactionChangedExtended()
Definition
SCR_CampaignMilitaryBaseComponent.c:1065
SCR_CampaignMilitaryBaseManager
Created in SCR_GameModeCampaign.
Definition
SCR_CampaignMilitaryBaseManager.c:25
SCR_CampaignMilitaryBaseManager::FindClosestBase
SCR_CampaignMilitaryBaseComponent FindClosestBase(vector position, SCR_ECampaignBaseType searchedType=-1)
Definition
SCR_CampaignMilitaryBaseManager.c:888
SCR_CampaignMilitaryBaseManager::GetOnBaseDisassembled
static OnBaseBuiltInvoker GetOnBaseDisassembled()
Definition
SCR_CampaignMilitaryBaseManager.c:172
SCR_Faction
Definition
SCR_Faction.c:6
SCR_Faction::IsAICommander
bool IsAICommander()
Definition
SCR_Faction.c:887
SCR_Faction::GetCommanderId
int GetCommanderId()
Definition
SCR_Faction.c:899
SCR_Global
Definition
Functions.c:7
SCR_Global::IsEditMode
static bool IsEditMode()
Definition
Functions.c:1566
SCR_InputButtonComponent
Definition
SCR_InputButtonComponent.c:2
SCR_MapCommandPostUI
Definition
SCR_MapCommandPostUI.c:2
SCR_MapCommandPostUI::OPERATIONS_LABEL_TEXT
const string OPERATIONS_LABEL_TEXT
Definition
SCR_MapCommandPostUI.c:30
SCR_MapCommandPostUI::m_bCommanderRoleEnabled
bool m_bCommanderRoleEnabled
Definition
SCR_MapCommandPostUI.c:11
SCR_MapCommandPostUI::m_wPlatformIcon
ImageWidget m_wPlatformIcon
Definition
SCR_MapCommandPostUI.c:19
SCR_MapCommandPostUI::HandlerDeattached
override void HandlerDeattached(Widget w)
Definition
SCR_MapCommandPostUI.c:67
SCR_MapCommandPostUI::COMBAT_SUPPORT_LABEL_TEXT
const string COMBAT_SUPPORT_LABEL_TEXT
Definition
SCR_MapCommandPostUI.c:29
SCR_MapCommandPostUI::m_wModeTopBar
ImageWidget m_wModeTopBar
Definition
SCR_MapCommandPostUI.c:21
SCR_MapCommandPostUI::LOGISTICS_ICON
const string LOGISTICS_ICON
Definition
SCR_MapCommandPostUI.c:31
SCR_MapCommandPostUI::m_sIconName
string m_sIconName
Definition
SCR_MapCommandPostUI.c:14
SCR_MapCommandPostUI::OnCloseButtonClicked
void OnCloseButtonClicked()
Definition
SCR_MapCommandPostUI.c:82
SCR_MapCommandPostUI::OPERATIONS_ICON
const string OPERATIONS_ICON
Definition
SCR_MapCommandPostUI.c:33
SCR_MapCommandPostUI::CURRENT_COMMANDER_PLAYER_TEXT
const string CURRENT_COMMANDER_PLAYER_TEXT
Definition
SCR_MapCommandPostUI.c:27
SCR_MapCommandPostUI::OnBaseDisassembled
void OnBaseDisassembled(SCR_CampaignMilitaryBaseComponent base, Faction faction)
Closes the Command Post Menu when base where commander is using Command Post is disassembled.
Definition
SCR_MapCommandPostUI.c:114
SCR_MapCommandPostUI::COMBAT_SUPPORT_ICON
const string COMBAT_SUPPORT_ICON
Definition
SCR_MapCommandPostUI.c:32
SCR_MapCommandPostUI::m_wCloseButtonWidget
ButtonWidget m_wCloseButtonWidget
Definition
SCR_MapCommandPostUI.c:6
SCR_MapCommandPostUI::m_InputButton
SCR_InputButtonComponent m_InputButton
Definition
SCR_MapCommandPostUI.c:7
SCR_MapCommandPostUI::m_wModeText
TextWidget m_wModeText
Definition
SCR_MapCommandPostUI.c:20
SCR_MapCommandPostUI::m_sModeName
string m_sModeName
Definition
SCR_MapCommandPostUI.c:13
SCR_MapCommandPostUI::m_wModeIcon
ImageWidget m_wModeIcon
Definition
SCR_MapCommandPostUI.c:22
SCR_MapCommandPostUI::LOGISTICS_LABEL_TEXT
const string LOGISTICS_LABEL_TEXT
Definition
SCR_MapCommandPostUI.c:28
SCR_MapCommandPostUI::m_wCommanderName
RichTextWidget m_wCommanderName
Definition
SCR_MapCommandPostUI.c:17
SCR_MapCommandPostUI::SetCommanderNameWidget
void SetCommanderNameWidget(Widget w)
Definition
SCR_MapCommandPostUI.c:144
SCR_MapCommandPostUI::OnBaseFactionChanged
void OnBaseFactionChanged(SCR_CampaignMilitaryBaseComponent base, Faction defendingFaction, Faction attackingFaction)
Closes the Command Post Menu when base where commander is using Command Post is captured by other fac...
Definition
SCR_MapCommandPostUI.c:124
SCR_MapCommandPostUI::m_ActiveBase
SCR_CampaignMilitaryBaseComponent m_ActiveBase
Definition
SCR_MapCommandPostUI.c:9
SCR_MapCommandPostUI::m_ModeColor
Color m_ModeColor
Definition
SCR_MapCommandPostUI.c:15
SCR_MapCommandPostUI::OnBaseClicked
void OnBaseClicked(bool selected)
Definition
SCR_MapCommandPostUI.c:88
SCR_MapCommandPostUI::CloseMenu
void CloseMenu()
Definition
SCR_MapCommandPostUI.c:137
SCR_MapCommandPostUI::m_GameplaySettings
BaseContainer m_GameplaySettings
Definition
SCR_MapCommandPostUI.c:24
SCR_MapCommandPostUI::CURRENT_COMMANDER_AI_TEXT
const string CURRENT_COMMANDER_AI_TEXT
Definition
SCR_MapCommandPostUI.c:26
SCR_MapCommandPostUI::OnFactionCommanderChanged
void OnFactionCommanderChanged(SCR_Faction faction, int commanderPlayerId)
Closes the Command Post Menu when local player loses commander role.
Definition
SCR_MapCommandPostUI.c:100
SCR_MapCommandPostUI::HandlerAttached
override void HandlerAttached(Widget w)
Definition
SCR_MapCommandPostUI.c:36
SCR_MapCommandPostUI::m_wPlatformLayout
Widget m_wPlatformLayout
Definition
SCR_MapCommandPostUI.c:18
SCR_MapCommandPostUI::SetActiveBase
void SetActiveBase()
Definition
SCR_MapCommandPostUI.c:234
SCR_MapCommandPostUI::SetModeType
void SetModeType(Widget w)
Definition
SCR_MapCommandPostUI.c:186
SCR_PlayerController
Definition
SCR_PlayerController.c:31
SCR_PlayerController::GetLocalPlayerId
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
Definition
SCR_PlayerController.c:481
SCR_PlayerController::GetLocalMainEntityFaction
static Faction GetLocalMainEntityFaction()
Definition
SCR_PlayerController.c:551
SCR_PlayerController::GetLocalMainEntity
static IEntity GetLocalMainEntity()
Definition
SCR_PlayerController.c:511
SCR_PlayerNamesFilterCache
Definition
SCR_PlayerNamesFilterCache.c:3
SCR_WidgetTools
Definition
SCR_WidgetTools.c:2
ScriptedWidgetComponent
Definition
ScriptedWidgetComponent.c:13
TextWidget
Definition
TextWidget.c:16
UIColors
Definition
Constants.c:17
UIWidgets
Definition
attributes.c:40
Widget
Definition
Widget.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
GetPlayerController
proto external PlayerController GetPlayerController()
Definition
SCR_PlayerDeployMenuHandlerComponent.c:307
scripts
Game
Map
ComponentsUI
SCR_MapCommandPostUI.c
Generated by
1.17.0