4 InputManager m_InputManager;
6 protected TextWidget m_wVersion;
7 protected Widget m_wRoot;
8 protected Widget m_wFade;
9 protected Widget m_wSystemTime;
10 protected bool m_bFocused =
true;
18 protected SCR_SaveLoadComponent m_SavingComponent;
20 const string EXIT_SAVE =
"#AR-PauseMenu_ReturnSaveTitle";
21 const string EXIT_NO_SAVE =
"#AR-PauseMenu_ReturnTitle";
23 const ResourceName ACTIONS_IMAGESET =
"{2EFEA2AF1F38E7F0}UI/Textures/Icons/icons_wrapperUI-64.imageset";
24 const string EXIT_MESSAGE =
"#AR-PauseMenu_ReturnText";
25 const string EXIT_TITLE =
"#AR-PauseMenu_ReturnTitle";
26 const string EXIT_IMAGE =
"exit";
28 const string RESTART_MESSAGE =
"#AR-PauseMenu_RestartText";
29 const string RESTART_TITLE =
"#AR-PauseMenu_Restart";
30 const string RESTART_IMAGE =
"restart";
32 const string LOAD_MESSAGE =
"#AR-PauseMenu_LoadText";
33 const string LOAD_TITLE =
"#AR-PauseMenu_Load";
34 const string LOAD_IMAGE =
"up";
36 static ref ScriptInvoker m_OnPauseMenuOpened =
new ScriptInvoker();
37 static ref ScriptInvoker m_OnPauseMenuClosed =
new ScriptInvoker();
43 static void MoveToTop()
51 GetGame().GetCallqueue().CallLater(OpenMenuOnTop);
58 static void OpenMenuOnTop()
60 GetGame().OpenPauseMenu(
false,
true);
64 override void OnMenuOpen()
68 m_SavingComponent = SCR_SaveLoadComponent.GetInstance();
71 m_wFade =
m_wRoot.FindAnyWidget(
"BackgroundFade");
72 m_wSystemTime =
m_wRoot.FindAnyWidget(
"SystemTime");
80 GetGame().GetWorkspace().SetFocusedWidget(comp.GetRootWidget());
81 comp.m_OnClicked.Insert(Close);
88 bool enabledRestart = !Replication.IsRunning();
89 comp.GetRootWidget().SetVisible(enabledRestart);
90 comp.m_OnClicked.Insert(OnRestart);
99 if (campaign && campaign.IsTutorial())
101 comp.SetVisible(
false)
106 BaseGameMode gameMode =
GetGame().GetGameMode();
109 RespawnSystemComponent respawn = RespawnSystemComponent.Cast(gameMode.FindComponent(RespawnSystemComponent));
110 canRespawn = (respawn !=
null);
113 comp.GetRootWidget().SetVisible(canRespawn);
114 comp.m_OnClicked.Insert(OnRespawn);
122 bool factionLeaveAllowed;
125 factionLeaveAllowed = gm.IsFactionChangeAllowed();
130 array<Faction> factions = {};
131 fm.GetFactionsList(factions);
132 int playableFactionCount = 0;
136 if (scriptedFaction && scriptedFaction.IsPlayable())
137 playableFactionCount++;
140 factionLeaveAllowed = factionLeaveAllowed && (playableFactionCount > 1);
143 comp.GetRootWidget().SetVisible(factionLeaveAllowed);
144 if (factionLeaveAllowed)
146 PlayerController pc =
GetGame().GetPlayerController();
150 comp.SetEnabled(factionComp.GetAffiliatedFaction() !=
null);
152 comp.m_OnClicked.Insert(OnLeaveFaction)
160 comp.m_OnClicked.Insert(OnExit);
161 if (IsSavingOnExit())
162 comp.SetText(EXIT_SAVE);
164 comp.SetText(EXIT_NO_SAVE);
171 SCR_RewindComponent rewindManager = SCR_RewindComponent.GetInstance();
172 comp.GetRootWidget().SetVisible(rewindManager !=
null);
173 comp.GetRootWidget().SetEnabled(rewindManager && rewindManager.HasRewindPoint());
175 comp.m_OnClicked.Insert(OnRewind);
183 comp.SetVisible(
false);
185 if (campaign.IsTutorial())
187 comp.SetVisible(
true);
188 comp.m_OnClicked.Insert(OnReturnToHub);
191 comp.SetVisible(
false);
197 comp.m_OnClicked.Insert(OnCamera);
198 comp.SetEnabled(editorManager && !editorManager.IsOpened());
199 comp.GetRootWidget().SetVisible(Game.IsDev());
205 comp.m_OnClicked.Insert(OnSettings);
211 comp.m_OnClicked.Insert(OnFieldManual);
218 comp.GetRootWidget().SetVisible(Replication.IsRunning());
219 comp.m_OnClicked.Insert(OnPlayers);
226 bool canInvite = Replication.IsRunning() &&
GetGame().GetPlayerManager().IsMultiplayerActivityInviteAvailable();
227 comp.GetRootWidget().SetVisible(canInvite);
230 comp.m_OnClicked.Insert(OnInviteFriends);
234 m_wVersion = TextWidget.Cast(
m_wRoot.FindAnyWidget(
"Version"));
236 m_wVersion.SetText(
GetGame().GetBuildVersion());
240 if (m_EditorUnlimitedOpenButton)
241 m_EditorUnlimitedOpenButton.m_OnClicked.Insert(OnEditorUnlimited);
244 if (m_EditorUnlimitedCloseButton)
245 m_EditorUnlimitedCloseButton.m_OnClicked.Insert(OnEditorUnlimited);
249 if (m_EditorPhotoOpenButton)
250 m_EditorPhotoOpenButton.m_OnClicked.Insert(OnEditorPhoto);
252 if (m_EditorPhotoCloseButton)
253 m_EditorPhotoCloseButton.m_OnClicked.Insert(OnEditorPhoto);
255 SetEditorUnlimitedButton(editorManager);
256 SetEditorPhotoButton(editorManager);
260 editorManager.GetOnModeAdd().Insert(OnEditorModeChanged);
261 editorManager.GetOnModeRemove().Insert(OnEditorModeChanged);
267 comp.m_OnClicked.Insert(OnFeedback);
272 m_OnPauseMenuOpened.Invoke();
278 override void OnMenuShow()
284 editorManager.GetOnOpened().Insert(Close);
285 editorManager.GetOnClosed().Insert(Close);
290 override void OnMenuHide()
295 editorManager.GetOnOpened().Insert(Close);
296 editorManager.GetOnClosed().Insert(Close);
300 m_wFade.SetVisible(
false);
304 override void OnMenuClose()
310 hud.SetVisible(
true);
312 m_OnPauseMenuClosed.Invoke();
318 override void OnMenuFocusLost()
321 m_InputManager.RemoveActionListener(
"MenuOpen", EActionTrigger.DOWN, Close);
322 m_InputManager.RemoveActionListener(
"MenuBack", EActionTrigger.DOWN, Close);
324 m_InputManager.RemoveActionListener(
"MenuOpenWB", EActionTrigger.DOWN, Close);
325 m_InputManager.RemoveActionListener(
"MenuBackWB", EActionTrigger.DOWN, Close);
330 override void OnMenuFocusGained()
333 m_InputManager.AddActionListener(
"MenuOpen", EActionTrigger.DOWN, Close);
334 m_InputManager.AddActionListener(
"MenuBack", EActionTrigger.DOWN, Close);
336 m_InputManager.AddActionListener(
"MenuOpenWB", EActionTrigger.DOWN, Close);
337 m_InputManager.AddActionListener(
"MenuBackWB", EActionTrigger.DOWN, Close);
342 void FadeBackground(
bool fade,
bool animate =
true)
347 m_wFade.SetVisible(fade);
348 m_wFade.SetOpacity(0);
350 AnimateWidget.Opacity(m_wFade, 1,
UIConstants.FADE_RATE_FAST,
true);
354 private void OnSettings()
360 private void OnFieldManual()
366 private void OnReturnToHub()
373 SCR_CampaignTutorialArlandComponent component = SCR_CampaignTutorialArlandComponent.Cast(campaign.FindComponent(SCR_CampaignTutorialArlandComponent));
375 component.SetActiveConfig(0);
377 GetGame().GetMenuManager().CloseAllMenus();
381 private void OnExit()
388 dialog.m_OnConfirm.Insert(OnExitConfirm);
393 private void OnRewind()
399 private void OnExitConfirm()
401 if (IsSavingOnExit())
404 GetGame().GetSaveManager().GetOnSaved().Insert(OnSaved);
418 GetGame().GetSaveManager().GetOnSaved().Remove(OnSaved);
424 private void OnEditorUnlimited()
429 if (!editorManager.IsOpened() || editorManager.GetCurrentModeEntity().IsLimited())
431 editorManager.SetCurrentMode(
false);
432 editorManager.Open();
436 editorManager.Close();
446 if (!m_EditorUnlimitedOpenButton || !m_EditorUnlimitedCloseButton)
return;
448 if (!editorManager || editorManager.IsLimited())
453 bool isUnlimitedEditorLegal;
456 isUnlimitedEditorLegal = settingsEntity.IsUnlimitedEditorLegal();
458 m_EditorUnlimitedOpenButton.GetRootWidget().SetVisible(isUnlimitedEditorLegal);
459 m_EditorUnlimitedOpenButton.SetEnabled(
false);
462 m_EditorUnlimitedCloseButton.GetRootWidget().SetVisible(
false);
465 m_wSystemTime.SetVisible(
false);
470 if (!editorManager.IsOpened() || editorManager.GetCurrentModeEntity().IsLimited())
473 m_EditorUnlimitedOpenButton.GetRootWidget().SetVisible(
true);
474 m_EditorUnlimitedCloseButton.GetRootWidget().SetVisible(
false);
479 m_EditorUnlimitedOpenButton.GetRootWidget().SetVisible(
false);
480 m_EditorUnlimitedCloseButton.GetRootWidget().SetVisible(
true);
481 m_EditorUnlimitedCloseButton.SetEnabled(editorManager.CanClose());
485 m_wSystemTime.SetVisible(
true);
494 SetEditorUnlimitedButton(editorManager);
495 SetEditorPhotoButton(editorManager);
499 private void OnEditorPhoto()
504 if (!editorManager.IsOpened() || editorManager.GetCurrentMode() !=
EEditorMode.PHOTO)
507 editorManager.Open();
511 editorManager.Close();
521 if (!m_EditorPhotoOpenButton || !m_EditorPhotoCloseButton)
return;
523 if (!editorManager || !editorManager.HasMode(
EEditorMode.PHOTO))
525 m_EditorPhotoOpenButton.GetRootWidget().SetVisible(
true);
526 m_EditorPhotoOpenButton.SetEnabled(
false);
527 m_EditorPhotoCloseButton.GetRootWidget().SetVisible(
false);
531 if (!editorManager.IsOpened() || editorManager.GetCurrentMode() !=
EEditorMode.PHOTO)
533 m_EditorPhotoOpenButton.GetRootWidget().SetVisible(
true);
534 m_EditorPhotoCloseButton.GetRootWidget().SetVisible(
false);
541 m_EditorPhotoOpenButton.GetRootWidget().SetVisible(
false);
542 m_EditorPhotoCloseButton.GetRootWidget().SetVisible(
true);
543 m_EditorPhotoCloseButton.SetEnabled(editorManager.CanClose());
549 private void OnFeedback()
555 private void OnRestart()
562 dialog.m_OnConfirm.Insert(OnRestartConfirm);
566 private void OnRestartConfirm()
568 GetGame().GetMenuManager().CloseAllMenus();
573 private void OnPlayers()
575 ArmaReforgerScripted.OpenPlayerList();
579 protected void OnInviteFriends()
581 GetGame().GetPlayerManager().ShowMultiplayerActivityInvite();
585 private void OnRespawn()
587 PlayerController playerController =
GetGame().GetPlayerController();
588 if (!playerController)
595 respawn.RequestPlayerSuicide();
600 private void OnLeaveFaction()
602 PlayerController pc =
GetGame().GetPlayerController();
614 factionComp.RequestFaction(
null);
615 rc.RequestPlayerSuicide();
621 private void OnCamera()
625 cameraCore.ToggleCamera();
630 override void HandlerDeattached(Widget w)
632 super.HandlerDeattached(w);
639 editorManager.GetOnModeAdd().Remove(OnEditorModeChanged);
640 editorManager.GetOnModeRemove().Remove(OnEditorModeChanged);
645 protected bool IsSavingOnExit()
647 return !Replication.IsRunning() &&
GetGame().GetSaveManager().CanSave(
ESaveType.AUTO) && m_SavingComponent && m_SavingComponent.CanSaveOnExit();