Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_WelcomeScreenMenu.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
4 {
5  protected SCR_BaseGameMode m_GameMode;
6  protected PlayerManager m_PlayerManager;
7  protected RichTextWidget m_wPlayerCount;
8  protected RichTextWidget m_wScenarioTimeElapsed;
9  protected ref MapConfiguration m_MapConfig = new MapConfiguration();
10  protected string m_sTimeElapsed;
11  protected float m_fTimeSlice;
12  protected int m_iMaxPlayerCount;
13 
14  //------------------------------------------------------------------------------------------------
16  override void OnMenuOpen()
17  {
18  super.OnMenuOpen();
19 
21  m_PlayerManager = PlayerManager.Cast(GetGame().GetPlayerManager());
22  m_MapEntity = SCR_MapEntity.GetMapInstance();
23 
24  SCR_WelcomeScreenComponent welcomeScreen = SCR_WelcomeScreenComponent.Cast(m_GameMode.FindComponent(SCR_WelcomeScreenComponent));
25  if (!welcomeScreen)
26  {
27  Close();
28  return;
29  }
30 
31  /*RichTextWidget scenarioTitle = RichTextWidget.Cast(GetRootWidget().FindAnyWidget("DeploySetup"));
32  if (scenarioTitle)
33  scenarioTitle.SetText(welcomeScreen.GetHeaderTitle());
34 
35  RichTextWidget scenarioSubtitle = RichTextWidget.Cast(GetRootWidget().FindAnyWidget("HeaderSubtitle"));
36  if (scenarioSubtitle)
37  scenarioSubtitle.SetText(welcomeScreen.GetHeaderSubtitle());*/
38 
39  SCR_MissionHeader header = SCR_MissionHeader.Cast(GetGame().GetMissionHeader());
40  if (header)
41  m_iMaxPlayerCount = header.m_iPlayerCount;
42 
43  m_wPlayerCount = RichTextWidget.Cast(GetRootWidget().FindAnyWidget("PlayerCount"));
44  UpdatePlayerCount(0);
45 
46  m_wScenarioTimeElapsed = RichTextWidget.Cast(GetRootWidget().FindAnyWidget("TimeElapsed"));
47 
48  Widget continueBtn = GetRootWidget().FindAnyWidget("CloseButton");
49  if (continueBtn)
50  {
51  SCR_InputButtonComponent continueButton = SCR_InputButtonComponent.Cast(continueBtn.FindHandler(SCR_InputButtonComponent));
52  if (continueButton)
53  continueButton.m_OnActivated.Insert(CloseWelcomeScreenMenu);
54  }
55 
56  Widget pauseMenuBtn = GetRootWidget().FindAnyWidget("PauseButton");
57  if (pauseMenuBtn)
58  {
59  SCR_InputButtonComponent pauseMenuButton = SCR_InputButtonComponent.Cast(pauseMenuBtn.FindHandler(SCR_InputButtonComponent));
60  if (pauseMenuButton)
61  pauseMenuButton.m_OnActivated.Insert(OpenPauseMenu);
62  }
63 
64  Widget chat = GetRootWidget().FindAnyWidget("ChatPanel");
65  if (chat)
66  m_ChatPanel = SCR_ChatPanel.Cast(chat.FindHandler(SCR_ChatPanel));
67 
68  m_ChatButton = SCR_InputButtonComponent.GetInputButtonComponent("ChatButton", GetRootWidget());
69  if (m_ChatButton)
70  m_ChatButton.m_OnActivated.Insert(OnChatToggle);
71 
72  UpdateElapsedTime();
73  SCR_DeployMenuBaseScreenLayout baseLayout = welcomeScreen.GetBaseLayout();
74  if (!baseLayout)
75  return;
76 
77  baseLayout.InitContent(this);
78 
79  InitMap();
80  }
81 
82  //------------------------------------------------------------------------------------------------
84  override void OnMenuOpened()
85  {
86  // Mute sounds
87  // If menu is opened before loading screen is closed, wait for closing
88  if (ArmaReforgerLoadingAnim.IsOpen())
89  ArmaReforgerLoadingAnim.m_onExitLoadingScreen.Insert(MuteSounds);
90  else
91  MuteSounds();
92  }
93 
94  //------------------------------------------------------------------------------------------------
96  protected void InitMap()
97  {
98  if (!m_MapEntity)
99  return;
100  ResourceName conf = "{A786DD4868598F15}Configs/Map/MapPlain.conf";
101  m_MapEntity.OpenMap(m_MapEntity.SetupMapConfig(EMapEntityMode.PLAIN, conf, GetRootWidget()));
102  }
103 
104  //------------------------------------------------------------------------------------------------
106  override void OnMenuFocusGained()
107  {
108  SCR_EditorManagerEntity editorManager = SCR_EditorManagerEntity.GetInstance();
109  if (editorManager)
110  editorManager.AutoInit();
111 
112  GetGame().GetInputManager().AddActionListener("ShowScoreboard", EActionTrigger.DOWN, OpenPlayerList);
113 
114  super.OnMenuFocusGained();
115  }
116 
117  //------------------------------------------------------------------------------------------------
119  override void OnMenuFocusLost()
120  {
121  GetGame().GetInputManager().RemoveActionListener("ShowScoreboard", EActionTrigger.DOWN, OpenPlayerList);
122 
123  super.OnMenuFocusLost();
124  }
125 
126  //------------------------------------------------------------------------------------------------
128  protected void OpenPauseMenu()
129  {
130  GetGame().OpenPauseMenu(false, true);
131  }
132 
133  //------------------------------------------------------------------------------------------------
135  void OpenWelcomeScreenMenu()
136  {
137  GetGame().GetMenuManager().OpenMenu(ChimeraMenuPreset.WelcomeScreenMenu);
138  }
139 
140  //------------------------------------------------------------------------------------------------
142  void CloseWelcomeScreenMenu()
143  {
144  GetGame().GetMenuManager().CloseMenuByPreset(ChimeraMenuPreset.WelcomeScreenMenu);
145 
146  PlayerController playerController = GetGame().GetPlayerController();
147  SCR_PlayerDeployMenuHandlerComponent deployMenu = SCR_PlayerDeployMenuHandlerComponent.Cast(playerController.FindComponent(SCR_PlayerDeployMenuHandlerComponent));
148  if (deployMenu)
149  deployMenu.SetWelcomeClosed();
150  }
151 
152  //------------------------------------------------------------------------------------------------
154  override void OnMenuUpdate(float tDelta)
155  {
156  super.OnMenuUpdate(tDelta);
157 
158  GetGame().GetInputManager().ActivateContext("DeployMenuContext");
159  GetGame().GetInputManager().ActivateContext("MenuWithEditorContext");
160 
161  if (m_ChatPanel)
162  m_ChatPanel.OnUpdateChat(tDelta);
163 
164  m_fTimeSlice += tDelta;
165  if (m_fTimeSlice > 1)
166  UpdateElapsedTime();
167  }
168 
169  //------------------------------------------------------------------------------------------------
171  protected void OnChatToggle()
172  {
173  if (!m_ChatPanel)
174  {
175  Widget chat = GetRootWidget().FindAnyWidget("ChatPanel");
176  if (chat)
177  m_ChatPanel = SCR_ChatPanel.Cast(chat.FindHandler(SCR_ChatPanel));
178  }
179 
180  if (!m_ChatPanel || m_ChatPanel.IsOpen())
181  return;
182 
183  SCR_ChatPanelManager chatPanelManager = SCR_ChatPanelManager.GetInstance();
184 
185  if (!chatPanelManager)
186  return;
187 
188  SCR_ChatPanelManager.GetInstance().ToggleChatPanel(m_ChatPanel);
189  }
190 
191  //------------------------------------------------------------------------------------------------
193  protected void UpdateElapsedTime()
194  {
195  m_fTimeSlice = 0;
196  m_sTimeElapsed = SCR_FormatHelper.FormatTime(m_GameMode.GetElapsedTime());
197  m_wScenarioTimeElapsed.SetText(m_sTimeElapsed);
198  UpdatePlayerCount(0);
199  }
200 
201  //------------------------------------------------------------------------------------------------
203  protected void UpdatePlayerCount(int playerID)
204  {
205  if (m_iMaxPlayerCount > 0)
206  m_wPlayerCount.SetTextFormat("%1/%2", m_PlayerManager.GetPlayerCount().ToString(), m_iMaxPlayerCount);
207  else
208  m_wPlayerCount.SetText(m_PlayerManager.GetPlayerCount().ToString());
209  }
210 };
SCR_BaseGameMode
Definition: SCR_BaseGameMode.c:137
m_MapEntity
protected SCR_MapEntity m_MapEntity
Definition: SCR_MapGadgetComponent.c:14
SCR_DeployMenuBaseScreenLayout
Base class for Deploy menu layouts.
Definition: SCR_DeployMenuBaseScreenComponent.c:43
SCR_FormatHelper
Definition: SCR_FormatHelper.c:1
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_ChatPanelManager
Definition: SCR_ChatPanelManager.c:12
conf
Configs ServerBrowser KickDialogs conf
Definition: SCR_NotificationSenderComponent.c:23
GetRootWidget
Widget GetRootWidget()
Definition: SCR_UITaskManagerComponent.c:160
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition: SCR_BaseGameModeComponent.c:15
SCR_ChatPanel
Definition: SCR_ChatPanel.c:6
SCR_DeployMenuBase
Base deploy menu class.
Definition: SCR_DeployMenuBase.c:3
m_GameMode
protected SCR_BaseGameMode m_GameMode
Definition: SCR_DeployMenuBase.c:111
SCR_MapEntity
Map entity.
Definition: SCR_MapEntity.c:20
m_PlayerManager
protected PlayerManager m_PlayerManager
Definition: SCR_PlayerTeleportedFeedbackComponent.c:9
SCR_WelcomeScreenMenu
Class that handles Welcome screen menu.
Definition: SCR_WelcomeScreenMenu.c:3
ChimeraMenuPreset
ChimeraMenuPreset
Menu presets.
Definition: ChimeraMenuBase.c:3
EMapEntityMode
EMapEntityMode
Mode of the map.
Definition: SCR_MapConstants.c:28
PlayerManager
Definition: PlayerManager.c:12
SCR_MissionHeader
Definition: SCR_MissionHeader.c:1
SCR_InputButtonComponent
Definition: SCR_InputButtonComponent.c:1
ArmaReforgerLoadingAnim
Definition: LoadingScreen.c:3
SCR_EditorManagerEntity
Definition: SCR_EditorManagerEntity.c:26