Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_RoleSelectionMenu.c
Go to the documentation of this file.
1
3{
5
9
13
17
21
26
27 protected int m_iMaxPlayerCount;
28 protected float m_fTimer = 0;
29
31
32 //------------------------------------------------------------------------------------------------
33 override void OnMenuOpen()
34 {
35 super.OnMenuOpen();
36
38 m_FactionManager = SCR_FactionManager.Cast(GetGame().GetFactionManager());
41
42 m_wPersistentFaction = GetRootWidget().FindAnyWidget("PermanentFaction");
44 m_wPersistentFaction.SetVisible(!SCR_RespawnSystemComponent.GetInstance().IsFactionChangeAllowed());
45
46 m_wScenarioTimeElapsed = TextWidget.Cast(GetRootWidget().FindAnyWidget("TimeElapsed"));
47 m_wServerName = TextWidget.Cast(GetRootWidget().FindAnyWidget("ServerName"));
48 if (m_wServerName)
49 {
50 SCR_MissionHeader header = SCR_MissionHeader.Cast(GetGame().GetMissionHeader());
51 if (header)
52 m_wServerName.SetText(header.m_sName);
53 }
54
55 ServerInfo serverInfo = GetGame().GetServerInfo();
56 if (serverInfo)
57 m_iMaxPlayerCount = serverInfo.GetPlayerLimit();
58
59 if (!m_MenuHandler)
60 {
61 Print("SCR_DeployMenuHandler is missing on root widget of " + this, LogLevel.ERROR);
62 return;
63 }
64
65 PlayerController pc = GetGame().GetPlayerController();
68 {
69 Print("Cannot find player faction affiliation component!", LogLevel.ERROR);
70 }
71
74 {
75 Print("Cannot find player loadout component!", LogLevel.ERROR);
76 }
77
78 m_wPlayerCount = TextWidget.Cast(GetRootWidget().FindAnyWidget("PlayerCount"));
79 m_FactionPlayerList = m_MenuHandler.GetFactionPlayerList();
80
83
85 HookEvents();
86
89 {
90 m_ContinueButton.m_OnActivated.Insert(Close);
91 m_ContinueButton.SetEnabled(CanContinue());
92 }
93
96 {
97 m_GroupOpenButton.m_OnActivated.Insert(OpenGroupMenu);
99 }
100
103 {
105 m_ViewProfileButton.m_OnActivated.Insert(OnViewProfile);
106 }
107
108 Widget chat = GetRootWidget().FindAnyWidget("ChatPanel");
109 if (chat)
110 m_ChatPanel = SCR_ChatPanel.Cast(chat.FindHandler(SCR_ChatPanel));
111
113 if (m_ChatButton)
114 m_ChatButton.m_OnActivated.Insert(OnChatToggle);
115
117 if (m_PauseButton)
118 m_PauseButton.m_OnActivated.Insert(OnPauseMenu);
119 InitMapPlain();
120
122 gameMode.PauseGame(true, SCR_EPauseReason.MENU);
123 }
124
125 //------------------------------------------------------------------------------------------------
126 override void OnMenuOpened()
127 {
128 super.OnMenuOpened();
129
131 {
132 SCR_FactionButton btn = m_FactionRequestUIHandler.GetFirstValidFactionButton();
133 if (btn)
134 btn.SetFocused();
135 else
136 ShowFactionPlayerList(show: false);
137 }
138 }
139
140 //------------------------------------------------------------------------------------------------
141 override void OnMenuUpdate(float tDelta)
142 {
143 super.OnMenuUpdate(tDelta);
144
145 GetGame().GetInputManager().ActivateContext("DeployMenuContext");
146
147 if (m_ChatPanel)
148 m_ChatPanel.OnUpdateChat(tDelta);
149
150 m_fTimer -= tDelta;
151 if (m_fTimer < 0)
153 }
154
155 //------------------------------------------------------------------------------------------------
156 override void OnMenuFocusGained()
157 {
158 SCR_EditorManagerEntity editorManager = SCR_EditorManagerEntity.GetInstance();
159 if (editorManager)
160 editorManager.AutoInit();
161
162 GetGame().GetInputManager().AddActionListener("ShowScoreboard", EActionTrigger.DOWN, OpenPlayerList);
163
164 super.OnMenuFocusGained();
165 }
166
167 //------------------------------------------------------------------------------------------------
168 override void OnMenuFocusLost()
169 {
170 GetGame().GetInputManager().RemoveActionListener("ShowScoreboard", EActionTrigger.DOWN, OpenPlayerList);
171
172 super.OnMenuFocusLost();
173 }
174
175 //------------------------------------------------------------------------------------------------
177 protected void FindRequestHandlers()
178 {
179 m_FactionRequestUIHandler = m_MenuHandler.GetFactionRequestHandler();
180 m_LoadoutRequestUIHandler = m_MenuHandler.GetLoadoutRequestHandler();
181 m_GroupRequestUIHandler = m_MenuHandler.GetGroupRequestHandler();
182 }
183
184 //------------------------------------------------------------------------------------------------
186 protected void HookEvents()
187 {
188 m_PlyFactionAffilComp.GetOnPlayerFactionRequestInvoker_O().Insert(OnPlayerFactionRequest);
189 m_PlyFactionAffilComp.GetOnPlayerFactionResponseInvoker_O().Insert(OnPlayerFactionResponse);
190
191 m_PlyLoadoutComp.GetOnPlayerLoadoutRequestInvoker_O().Insert(OnPlayerLoadoutRequest);
192 m_PlyLoadoutComp.GetOnPlayerLoadoutResponseInvoker_O().Insert(OnPlayerLoadoutResponse);
193
194 m_FactionRequestUIHandler.GetOnButtonFocused().Insert(ShowFactionPlayerList);
195 m_FactionRequestUIHandler.GetOnFactionRequested().Insert(OnPlayerFactionResponse);
196
197 m_LoadoutRequestUIHandler.GetOnButtonFocused().Insert(ShowLoadoutList);
198 m_LoadoutRequestUIHandler.GetOnMouseLeft().Insert(OnMouseLeft);
199 m_LoadoutRequestUIHandler.GetOnPlayerEntryFocused().Insert(OnPlayerEntryFocused);
200 m_LoadoutRequestUIHandler.GetOnPlayerEntryFocusLost().Insert(OnPlayerEntryFocusLost);
201
202 m_GroupRequestUIHandler.GetOnMouseLeft().Insert(OnMouseLeft);
203 m_GroupRequestUIHandler.GetOnButtonFocused().Insert(ShowLoadoutList);
204
205 m_GroupRequestUIHandler.GetOnPlayerGroupJoined().Insert(OnPlayerGroupJoined);
206 m_GroupRequestUIHandler.GetOnLocalPlayerGroupJoined().Insert(OnLocalGroupJoined);
207 }
208
209 //------------------------------------------------------------------------------------------------
211 protected void UpdateElapsedTime()
212 {
213 m_fTimer = 1;
214 string timeElapsed = SCR_FormatHelper.FormatTime(m_GameMode.GetElapsedTime());
215
217 m_wScenarioTimeElapsed.SetText(timeElapsed);
218
220 }
221
222 //------------------------------------------------------------------------------------------------
224 protected void InitMapPlain()
225 {
226 const ResourceName conf = "{A786DD4868598F15}Configs/Map/MapPlain.conf"; // TODO: check for good const usage
227 m_MapEntity.OpenMap(m_MapEntity.SetupMapConfig(EMapEntityMode.PLAIN, conf, GetRootWidget()));
228 }
229
230 //------------------------------------------------------------------------------------------------
233 protected void OnMouseLeft()
234 {
235 bool hasFaction = (m_PlyFactionAffilComp.GetAffiliatedFaction() != null);
236 bool hasGroup = true;
237
238 if (!hasFaction)
239 {
240 SCR_FactionButton btn = m_FactionRequestUIHandler.GetFirstValidFactionButton();
242 return;
243 }
244
246 }
247
248 //------------------------------------------------------------------------------------------------
252 protected void ShowFactionPlayerList(Faction faction = null, bool show = true)
253 {
255 {
256 m_FactionPlayerList.SetFaction(faction);
257 m_FactionPlayerList.ShowPlayerList(show && faction != null);
258 }
259
260 m_LoadoutRequestUIHandler.ShowLoadoutSelector(false);
261 }
262
263 //------------------------------------------------------------------------------------------------
265 protected void ShowLoadoutList()
266 {
267 SCR_PlayerControllerGroupComponent plyGroupComp = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
268 if (!plyGroupComp)
269 return;
270
271 // can show after the player is added to the group
272 if (plyGroupComp.GetGroupID() < 0)
273 return;
274
276 m_FactionPlayerList.ShowPlayerList(false);
277
278 m_LoadoutRequestUIHandler.ShowLoadoutSelector(true);
279 }
280
281 //------------------------------------------------------------------------------------------------
283 protected void ShowGroupPlayerList()
284 {
286 m_FactionPlayerList.ShowPlayerList(false);
287
288 m_LoadoutRequestUIHandler.ShowLoadoutSelector(false);
289 }
290
291 //------------------------------------------------------------------------------------------------
293 protected void UpdatePlayerCount()
294 {
295 if (m_iMaxPlayerCount > 0)
296 m_wPlayerCount.SetTextFormat("%1/%2", GetGame().GetPlayerManager().GetPlayerCount().ToString(), m_iMaxPlayerCount);
297 else
298 m_wPlayerCount.SetText(GetGame().GetPlayerManager().GetPlayerCount().ToString());
299 }
300
301 //------------------------------------------------------------------------------------------------
303 protected bool CanContinue()
304 {
306 return false;
307
308 bool canContinue = m_PlyFactionAffilComp.GetAffiliatedFaction() && m_PlyLoadoutComp.GetLoadout();
310 {
311 canContinue = canContinue && (m_GroupRequestUIHandler.GetPlayerGroup() != null);
312 }
313
314 return canContinue;
315 }
316
317 //------------------------------------------------------------------------------------------------
319 protected bool CanOpenGroupMenu()
320 {
321 return m_PlyFactionAffilComp && m_PlyFactionAffilComp.GetAffiliatedFaction();
322 }
323
324 //------------------------------------------------------------------------------------------------
325 protected void OpenGroupMenu()
326 {
327 SCR_GroupsManagerComponent groupManager = SCR_GroupsManagerComponent.GetInstance();
328 if (!groupManager || !groupManager.IsGroupMenuAllowed())
329 return;
330
331 GetGame().GetMenuManager().OpenDialog(ChimeraMenuPreset.GroupMenu);
332 }
333
334 //------------------------------------------------------------------------------------------------
335 protected void OnPlayerFactionRequest(SCR_PlayerFactionAffiliationComponent component, int factionIndex)
336 {
337 }
338
339 //------------------------------------------------------------------------------------------------
341 protected void OnPlayerFactionResponse(SCR_PlayerFactionAffiliationComponent component, int factionIndex, bool response)
342 {
343 if (response)
344 {
345 m_FactionRequestUIHandler.OnPlayerFactionAssigned(component.GetAffiliatedFaction());
346 if (factionIndex == -1)
347 {
348 m_GroupRequestUIHandler.SetExpanded(false);
349 m_FactionRequestUIHandler.SetExpanded(false);
350 }
351 else
352 {
353 // If groups are enabled, update them first, otherwise just show players assigned to the faction
355 {
356 Widget list = m_FactionRequestUIHandler.GetFactionButton(factionIndex).GetList();
357 m_GroupRequestUIHandler.SetListWidget(list);
358 m_GroupRequestUIHandler.ShowAvailableGroups(component.GetAffiliatedFaction());
359 m_LoadoutRequestUIHandler.ShowAvailableLoadouts(component.GetAffiliatedFaction());
360 }
361 else
362 {
363 Widget list = m_FactionRequestUIHandler.GetFactionButton(factionIndex).GetGridList();
364 m_LoadoutRequestUIHandler.SetListWidget(list);
365 m_LoadoutRequestUIHandler.ShowAvailableLoadouts(component.GetAffiliatedFaction());
366
367 array<int> players = {};
368 GetGame().GetPlayerManager().GetPlayers(players);
369 foreach (int pid : players)
370 {
371 if (SCR_Faction.Cast(SCR_FactionManager.SGetPlayerFaction(pid)) != component.GetAffiliatedFaction())
372 players.RemoveItem(pid);
373 }
374
375 m_LoadoutRequestUIHandler.ShowPlayerLoadouts(players);
376 }
377 }
378
380 m_ContinueButton.SetEnabled(CanContinue());
382 m_wPersistentFaction.SetVisible(false);
383 }
384
386 }
387
388 //------------------------------------------------------------------------------------------------
390 protected void OnPlayerGroupJoined(SCR_AIGroup group, int pid = -1)
391 {
392 if (!group || group.GetGroupID() != m_GroupRequestUIHandler.GetShownGroupId())
393 return;
394
395 SCR_GroupButton groupBtn = m_GroupRequestUIHandler.GetGroupButton(group);
396 if (!groupBtn)
397 return;
398
399 Widget list = m_GroupRequestUIHandler.GetGroupButton(group).GetList();
400 array<int> players = group.GetPlayerIDs();
401
402 m_LoadoutRequestUIHandler.SetListWidget(list);
403 m_LoadoutRequestUIHandler.ShowPlayerLoadouts(players, group);
404 }
405
406 //------------------------------------------------------------------------------------------------
408 protected void OnLocalGroupJoined(SCR_AIGroup group)
409 {
410 if (!group)
411 {
412 m_LoadoutRequestUIHandler.SetListVisible(false);
413 return;
414 }
415
416 OnPlayerGroupJoined(group);
417
418 m_ContinueButton.SetEnabled(CanContinue());
419
420 m_LoadoutRequestUIHandler.ShowAvailableLoadouts(group.GetFaction());
421
423 }
424
425 //------------------------------------------------------------------------------------------------
426 protected void OnPlayerLoadoutRequest(SCR_PlayerLoadoutComponent component, int loadoutIndex)
427 {
428 }
429
430 //------------------------------------------------------------------------------------------------
432 protected void OnPlayerLoadoutResponse(SCR_PlayerLoadoutComponent component, int loadoutIndex, bool response)
433 {
434 if (response)
435 {
436 m_LoadoutRequestUIHandler.OnPlayerLoadoutAssigned(component);
437 m_LoadoutRequestUIHandler.SetSelected(component);
438 m_LoadoutRequestUIHandler.RefreshLoadoutPreview();
439 }
440
441 m_ContinueButton.SetEnabled(CanContinue());
443 }
444
445 //------------------------------------------------------------------------------------------------
446 protected void OnChatToggle()
447 {
448 if (!m_ChatPanel)
449 {
450 Widget chat = GetRootWidget().FindAnyWidget("ChatPanel");
451 if (chat)
452 m_ChatPanel = SCR_ChatPanel.Cast(chat.FindHandler(SCR_ChatPanel));
453 }
454
455 if (!m_ChatPanel || m_ChatPanel.IsOpen())
456 return;
457
459 }
460
461 //------------------------------------------------------------------------------------------------
462 protected void OnPauseMenu()
463 {
465
466 MenuBase menu = GetGame().GetMenuManager().OpenMenu(ChimeraMenuPreset.PauseMenu, 0, true, false);
467
468 PauseMenuUI pauseMenu = PauseMenuUI.Cast(menu);
469 if (pauseMenu)
470 {
471 pauseMenu.FadeBackground(true, true);
472 pauseMenu.DisableSettings();
473 }
474 }
475
476 //------------------------------------------------------------------------------------------------
477 override void OnMenuClose()
478 {
479 super.OnMenuClose();
480
481 if (m_MapEntity && m_MapEntity.IsOpen())
482 m_MapEntity.CloseMap();
483
485 if (gameMode)
486 gameMode.PauseGame(false, SCR_EPauseReason.MENU);
487 }
488
489 //------------------------------------------------------------------------------------------------
490 protected void OnPlayerEntryFocused(int id)
491 {
494 }
495
496 //------------------------------------------------------------------------------------------------
498 {
500 }
501
502 //------------------------------------------------------------------------------------------------
503 protected void OnViewProfile()
504 {
505 GetGame().GetPlayerManager().ShowUserProfile(m_iLastFocusedEntryPlayerId);
506 }
507
508 //------------------------------------------------------------------------------------------------
509 protected void UpdateViewProfileButton(bool forceHidden = false)
510 {
512 return;
513
514 m_ViewProfileButton.SetVisible(!forceHidden && GetGame().GetPlayerManager().IsUserProfileAvailable(m_iLastFocusedEntryPlayerId), false);
515 }
516
517 //------------------------------------------------------------------------------------------------
523 {
525 GetGame().GetMenuManager().OpenMenu(ChimeraMenuPreset.RoleSelectionDialog);
526
527 return GetRoleSelectionMenu();
528 }
529
530 //------------------------------------------------------------------------------------------------
533 {
534 GetGame().GetMenuManager().CloseMenuByPreset(ChimeraMenuPreset.RoleSelectionDialog);
535 }
536
537 //------------------------------------------------------------------------------------------------
543 {
544 return SCR_RoleSelectionMenu.Cast(GetGame().GetMenuManager().FindMenuByPreset(ChimeraMenuPreset.RoleSelectionDialog));
545 }
546};
AddonBuildInfoTool id
ChimeraMenuPreset
Menu presets.
SCR_EPauseReason
Definition EPauseReason.c:2
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_BaseGameMode GetGameMode()
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
int GetPlayerCount()
void SCR_FactionManager(IEntitySource src, IEntity parent)
void SCR_GroupsManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
EMapEntityMode
Mode of the map.
Widget GetRootWidget()
Configs ServerBrowser KickDialogs conf
array< int > GetPlayerIDs()
int GetGroupID()
Faction GetFaction()
bool PauseGame(bool pause, SCR_EPauseReason reason=SCR_EPauseReason.SYSTEM)
static SCR_ChatPanelManager GetInstance()
Returns SCR_ChatPanelManager instance.
void ToggleChatPanel(notnull SCR_ChatPanel panel)
Toggles the chat panel: opens if it's closed, closes if it's open.
Base deploy menu class.
SCR_InputButtonComponent m_ChatButton
SCR_InputButtonComponent m_PauseButton
SCR_MapEntity m_MapEntity
SCR_ChatPanel m_ChatPanel
SCR_Faction GetFaction()
Get this button's faction.
Component attached to the group button.
Component responsible for handling group requests and visualization in deploy menu.
static SCR_InputButtonComponent GetInputButtonComponent(string name, notnull Widget parent, bool searchAllChildren=true)
Component responsible for requesting and visualization of available loadouts in deploy menu.
static SCR_MapEntity GetMapInstance()
Get map entity instance.
Role selection menu for setting up player faction, group and loadout.
SCR_InputButtonComponent m_ViewProfileButton
SCR_FactionPlayerList m_FactionPlayerList
void UpdatePlayerCount()
Updates the session's player count.
SCR_LoadoutRequestUIComponent m_LoadoutRequestUIHandler
SCR_GroupRequestUIComponent m_GroupRequestUIHandler
void UpdateElapsedTime()
Update elapsed time.
SCR_DeployMenuHandler m_MenuHandler
void ShowGroupPlayerList()
Shows the Player List selector on the right side of role selection screen.
SCR_FactionManager m_FactionManager
SCR_PlayerLoadoutComponent m_PlyLoadoutComp
bool CanOpenGroupMenu()
Check if group menu can be opened.
SCR_InputButtonComponent m_ContinueButton
static void CloseRoleSelectionMenu()
Close role selection menu.
static SCR_RoleSelectionMenu GetRoleSelectionMenu()
SCR_InputButtonComponent m_GroupOpenButton
void OnPlayerLoadoutRequest(SCR_PlayerLoadoutComponent component, int loadoutIndex)
void OnPlayerGroupJoined(SCR_AIGroup group, int pid=-1)
Callback when a player joins a group.
void OnPlayerEntryFocusLost(Widget w)
void HookEvents()
Initialize event listeners.
void OnPlayerLoadoutResponse(SCR_PlayerLoadoutComponent component, int loadoutIndex, bool response)
Callback when local player receives a response to a loadout request.
SCR_FactionRequestUIComponent m_FactionRequestUIHandler
void ShowLoadoutList()
Shows the loadout selector on the right side of role selection screen.
void OnPlayerFactionResponse(SCR_PlayerFactionAffiliationComponent component, int factionIndex, bool response)
Callback when player receives a response to afaction request.
void ShowFactionPlayerList(Faction faction=null, bool show=true)
static SCR_RoleSelectionMenu OpenRoleSelectionMenu()
void InitMapPlain()
Initialize empty map in the background.
void OnLocalGroupJoined(SCR_AIGroup group)
Callback when local player joins a group.
override void OnMenuUpdate(float tDelta)
void FindRequestHandlers()
Find request handlers based on the layout configuration.
void UpdateViewProfileButton(bool forceHidden=false)
SCR_PlayerFactionAffiliationComponent m_PlyFactionAffilComp
void OnPlayerFactionRequest(SCR_PlayerFactionAffiliationComponent component, int factionIndex)
SCR_GroupPlayerList m_GroupPlayerList
bool CanContinue()
Check if role selection screen can be closed.
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
EActionTrigger
proto external string ToString()
Plain C++ pointer, no weak pointers, no memory management.