Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_CampaignMapInfoDisplay.c
Go to the documentation of this file.
2{
3 protected bool m_bMapOpen;
4 protected bool m_bCommanderRoleEnabled;
5 protected bool m_bIsPlayerCommander;
6
11
13
15
16 protected const string CURRENT_COMMANDER_AI_TEXT = "#AR-FactionCommander_CurrentCommander_AI";
17 protected const string CURRENT_COMMANDER_PLAYER_TEXT = "#AR-FactionCommander_CurrentCommander";
18
19 //------------------------------------------------------------------------------------------------
20 override bool DisplayStartDrawInit(IEntity owner)
21 {
22 super.DisplayStartDrawInit(owner);
23
24 m_GameplaySettings = GetGame().GetGameUserSettings().GetModule("SCR_GameplaySettings");
25
26 SCR_FactionCommanderHandlerComponent comp = SCR_FactionCommanderHandlerComponent.GetInstance();
27
28 if (!comp)
29 return true;
30
31 SCR_GameModeCampaign campaign = SCR_GameModeCampaign.GetInstance();
32 if (campaign)
33 m_bCommanderRoleEnabled = campaign.GetCommanderRoleEnabled();
34
35 comp.GetOnFactionCommanderChanged().Insert(OnFactionCommanderChanged);
36
37 return true;
38 }
39
40 //------------------------------------------------------------------------------------------------
41 override void DisplayStartDraw(IEntity owner)
42 {
43 super.DisplayStartDraw(owner);
44
45 m_wCommanderNameWrapper = m_wRoot.FindAnyWidget("CommanderNameWrapper");
46 m_wCommanderName = RichTextWidget.Cast(m_wRoot.FindAnyWidget("CurrentCommanderPlayers"));
47 m_wPlatformScale = m_wRoot.FindAnyWidget("ScalePlatform");
48 m_wPlatformIcon = ImageWidget.Cast(m_wRoot.FindAnyWidget("PlatformIcon"));
49
52 }
53
54 //------------------------------------------------------------------------------------------------
55 override void DisplayStopDraw(IEntity owner)
56 {
57 super.DisplayStopDraw(owner);
58
61
62 SCR_FactionCommanderHandlerComponent commanderHandler = SCR_FactionCommanderHandlerComponent.GetInstance();
63 if (!commanderHandler)
64 return;
65
66 commanderHandler.GetOnFactionCommanderChanged().Remove(OnFactionCommanderChanged);
67 }
68
69 //------------------------------------------------------------------------------------------------
70 override void UpdateHUD()
71 {
72 m_bPeriodicRefresh = false;
73
74 if (!m_wRoot || !m_bInitDone)
75 return;
76
77 if (m_Campaign.IsTutorial() || m_Campaign.GetIsMatchOver())
78 {
79 Show(false);
80 return;
81 }
82
83 if (m_bMapOpen)
84 Show(true);
85
87 }
88
89 //------------------------------------------------------------------------------------------------
90 override void UpdateHUDValues()
91 {
92 super.UpdateHUDValues();
93 string name;
94
95 SCR_Faction faction = SCR_Faction.Cast(SCR_FactionManager.SGetLocalPlayerFaction());
96 if (!faction)
97 return;
98
99 int commanderId = faction.GetCommanderId();
100
102 if (!playerController)
103 return;
104
106 return;
107
108 m_bIsPlayerCommander = playerController.GetLocalPlayerId() == commanderId;
109
110 bool isSupportStationMapMode;
111
112 if (m_MapConfig)
113 {
114 EMapEntityMode currentMapEntityMode = m_MapConfig.MapEntityMode;
115 isSupportStationMapMode = currentMapEntityMode == EMapEntityMode.LOGISTICS_STATION ||
116 currentMapEntityMode == EMapEntityMode.OPERATIONS_STATION ||
117 currentMapEntityMode == EMapEntityMode.COMBAT_SUPPORT_STATION;
118 }
119
120 if (!m_bCommanderRoleEnabled || isSupportStationMapMode || !faction.IsCommanderAvailable())
121 {
122 m_wCommanderNameWrapper.SetVisible(false);
123 return;
124 }
125
126 m_wCommanderNameWrapper.SetVisible(true);
127
128 if (!faction.IsAICommander())
129 name = SCR_PlayerNamesFilterCache.GetInstance().GetPlayerDisplayName(commanderId);
130 else
132
134
135 SetPlatformImage(!faction.IsAICommander(), commanderId, playerController);
136 }
137
138 //------------------------------------------------------------------------------------------------
140 {
141 m_MapConfig = config;
142
143 if (m_Campaign.IsTutorial())
144 return;
145
146 m_bMapOpen = true;
147
148 if (SCR_DeployMenuMain.GetDeployMenu() == null)
149 {
150 Show(true);
151 UpdateHUD();
152 }
153 else
154 {
155 Show(false);
156 }
157 }
158
159 //------------------------------------------------------------------------------------------------
161 {
162 m_MapConfig = null;
163
164 if (m_Campaign.IsTutorial())
165 return;
166
167 m_bMapOpen = false;
168 Show(false);
169 }
170
171 //------------------------------------------------------------------------------------------------
172 protected void SetPlatformImage(bool setVisible, int commanderId, notnull SCR_PlayerController playerController)
173 {
175 return;
176
177 if (!setVisible)
178 {
179 m_wPlatformScale.SetVisible(false);
180 return;
181 }
182
183 bool showOnPC;
185 m_GameplaySettings.Get("m_bPlatformIconNametag", showOnPC);
186
187 bool res = playerController.SetPlatformImageTo(commanderId, m_wPlatformIcon, showOnPC: showOnPC);
188 m_wPlatformScale.SetVisible(res);
189 }
190
191 //------------------------------------------------------------------------------------------------
192 protected void OnFactionCommanderChanged(SCR_Faction faction, int commanderPlayerId)
193 {
194 if (faction && faction == SCR_Faction.Cast(SCR_FactionManager.SGetLocalPlayerFaction()))
196 }
197}
ArmaReforgerScripted GetGame()
Definition game.c:1398
void SCR_FactionManager(IEntitySource src, IEntity parent)
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
Widget m_wRoot
EMapEntityMode
Mode of the map.
SCR_GameModeCampaign m_Campaign
void OnMapOpen(MapConfiguration config)
override bool DisplayStartDrawInit(IEntity owner)
void SetPlatformImage(bool setVisible, int commanderId, notnull SCR_PlayerController playerController)
void OnFactionCommanderChanged(SCR_Faction faction, int commanderPlayerId)
void OnMapClose(MapConfiguration config)
override void DisplayStartDraw(IEntity owner)
override void DisplayStopDraw(IEntity owner)
bool IsAICommander()
int GetCommanderId()
bool IsCommanderAvailable()
static ScriptInvokerBase< MapConfigurationInvoker > GetOnMapClose()
Get on map close invoker.
static ScriptInvokerBase< MapConfigurationInvoker > GetOnMapOpen()
Get on map open invoker.
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
override void Show()
Definition gameLib.c:262
proto external PlayerController GetPlayerController()