Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_MapCommandPostUI.c
Go to the documentation of this file.
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
8
10
12
13 protected string m_sModeName;
14 protected string m_sIconName;
15 protected Color m_ModeColor;
16
23
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 {
39 return;
40
44
45 m_GameplaySettings = GetGame().GetGameUserSettings().GetModule("SCR_GameplaySettings");
46
47 m_wCloseButtonWidget = ButtonWidget.Cast(w.FindAnyWidget("Toolbar_PlayButton_CloseMap"));
49 return;
50
52 if (!m_InputButton)
53 return;
54
55 m_InputButton.m_OnClicked.Insert(OnCloseButtonClicked);
56
58
59 if (SCR_FactionCommanderHandlerComponent.GetInstance())
60 SCR_FactionCommanderHandlerComponent.GetInstance().GetOnFactionCommanderChanged().Insert(OnFactionCommanderChanged);
61
63 SetModeType(w);
64 }
65
66 //------------------------------------------------------------------------------------------------
67 override void HandlerDeattached(Widget w)
68 {
70
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 {
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();
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 //------------------------------------------------------------------------------------------------
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
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 //------------------------------------------------------------------------------------------------
145 {
146 m_wCommanderName = RichTextWidget.Cast(w.FindAnyWidget("CurrentCommander"));
147 if (!m_wCommanderName)
148 return;
149
150 m_wPlatformLayout = w.FindAnyWidget("PlatformLayout");
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
172
173 bool showOnPC;
175 m_GameplaySettings.Get("m_bPlatformIconNametag", showOnPC);
176
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 {
208 m_ModeColor = UIColors.EDITOR_MODE_GM_MODE;
209 break;
210 }
211 case EMapEntityMode.COMBAT_SUPPORT_STATION:
212 {
215 m_ModeColor = UIColors.EDITOR_MODE_ADMIN_MODE;
216 break;
217 }
218 case EMapEntityMode.OPERATIONS_STATION:
219 {
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 {
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
Menu presets.
ArmaReforgerScripted GetGame()
Definition game.c:1398
void SCR_FactionManager(IEntitySource src, IEntity parent)
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
EMapEntityMode
Mode of the map.
Definition Color.c:13
proto external vector GetOrigin()
proto external bool CloseMenuByPreset(ScriptMenuPresetEnum preset)
Put menu with given iPresetId into queue for closing (which is processed during next MenuManeger upda...
static ScriptInvokerBool GetOnBaseSelected()
static OnBaseStateChangedInvoker GetOnFactionChangedExtended()
SCR_CampaignMilitaryBaseComponent FindClosestBase(vector position, SCR_ECampaignBaseType searchedType=-1)
bool IsAICommander()
int GetCommanderId()
static bool IsEditMode()
Definition Functions.c:1566
const string OPERATIONS_LABEL_TEXT
bool m_bCommanderRoleEnabled
ImageWidget m_wPlatformIcon
override void HandlerDeattached(Widget w)
const string COMBAT_SUPPORT_LABEL_TEXT
ImageWidget m_wModeTopBar
const string LOGISTICS_ICON
string m_sIconName
void OnCloseButtonClicked()
const string OPERATIONS_ICON
const string CURRENT_COMMANDER_PLAYER_TEXT
void OnBaseDisassembled(SCR_CampaignMilitaryBaseComponent base, Faction faction)
Closes the Command Post Menu when base where commander is using Command Post is disassembled.
const string COMBAT_SUPPORT_ICON
ButtonWidget m_wCloseButtonWidget
SCR_InputButtonComponent m_InputButton
TextWidget m_wModeText
string m_sModeName
ImageWidget m_wModeIcon
const string LOGISTICS_LABEL_TEXT
RichTextWidget m_wCommanderName
void SetCommanderNameWidget(Widget w)
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...
SCR_CampaignMilitaryBaseComponent m_ActiveBase
Color m_ModeColor
void OnBaseClicked(bool selected)
void CloseMenu()
BaseContainer m_GameplaySettings
const string CURRENT_COMMANDER_AI_TEXT
void OnFactionCommanderChanged(SCR_Faction faction, int commanderPlayerId)
Closes the Command Post Menu when local player loses commander role.
override void HandlerAttached(Widget w)
Widget m_wPlatformLayout
void SetActiveBase()
void SetModeType(Widget w)
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
static Faction GetLocalMainEntityFaction()
static IEntity GetLocalMainEntity()
SCR_FieldOfViewSettings Attribute
proto external PlayerController GetPlayerController()