Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_GameOverScreenUIComponent.c
Go to the documentation of this file.
1 class SCR_GameOverScreenUIComponent: ScriptedWidgetComponent
2 {
3  [Attribute("TabView", desc: "Tab view will only be used if the widget in the layout is visible. This is because some changes that no longer required the tabview")]
4  protected string m_sTabViewName;
5 
6  [Attribute("Base_ContentHolder")]
7  protected string m_sContentHolderName;
8 
9  [Attribute("Base_Background")]
10  protected string m_sBackgroundName;
11 
12  [Attribute("Base_ColorOverlay")]
13  protected string m_sBackgroundColorOverlayName;
14 
15  [Attribute("#AR-PauseMenu_ReturnTitle", uiwidget: UIWidgets.LocaleEditBox)]
16  protected LocalizedString m_sMainMenuPopUpTitle;
17 
18  [Attribute("#AR-PauseMenu_ReturnText", uiwidget: UIWidgets.LocaleEditBox)]
19  protected LocalizedString m_sMainMenuPopUpMessage;
20 
21  [Attribute("{2EFEA2AF1F38E7F0}UI/Textures/Icons/icons_wrapperUI-64.imageset", params: "imageset")]
22  protected ResourceName m_sMainMenuPopUpImageSet;
23 
24  [Attribute("exit")]
25  protected string m_sMainMenuPopUpImage;
26 
27  [Attribute("Back")]
28  protected string m_sBackButtonName;
29 
30  [Attribute("ChatButton")]
31  protected string m_sChatButtonName;
32 
33  [Attribute("Debriefing")]
34  protected string m_sDebriefingButtonName;
35 
36  [Attribute("ButtonHolder")]
37  protected string m_sButtonHolderName;
38 
39  [Attribute("RestartTimeHolder")]
40  protected string m_sRestartTimerHolderName;
41 
42  [Attribute("0.05")]
43  protected float m_fBackgroundColorOverlayOpacity;
44 
45  [Attribute("2")]
46  protected float m_fContentFadeInSpeed;
47 
48  [Attribute("0", desc: "Which tab will show the end screen content eg: Victory, Defeat, etc.")]
49  protected float m_iContentTabIndex;
50 
51  protected Widget m_wRoot;
52  protected Widget m_wEndscreenContent;
53  protected SCR_TabViewComponent m_TabViewComponent;
54  protected SCR_FadeUIComponent m_OverlayBackgroundColorFadeUIComponent;
55  protected SCR_FadeUIComponent m_ContentFadeComponent;
56  protected SCR_FadeUIComponent m_TabViewFadeComponent;
57  protected SCR_FadeUIComponent m_ButtonHolderFadeComponent;
58  protected SCR_FadeUIComponent m_RestartTimerFadeComponent;
59  protected ref SCR_GameOverScreenUIContentData m_EndScreenUIContentInfo;
60 
61  //~ On tab changed
62  protected void OnTabChanged(SCR_TabViewComponent tabView, Widget w, int tabIndex)
63  {
64  OnEndScreenContentShow(tabIndex == m_iContentTabIndex);
65  }
66 
67  //~ On Tab created
68  protected void OnTabCreated(SCR_TabViewComponent tabView, Widget w, int index)
69  {
70  if (!w)
71  return;
72 
74  if (baseGameOverTab)
75  baseGameOverTab.GameOverTabInit(m_EndScreenUIContentInfo);
76  }
77 
78  //~ When tabview fade is done
79  protected void OnTabViewFadeDone()
80  {
81  if (m_TabViewComponent)
82  m_TabViewComponent.EnableAllTabs(true);
83  }
84 
85  //~ Show end screen content eg: Victory, defeat, etc.
86  protected void OnEndScreenContentShow(bool show)
87  {
88  if (m_wEndscreenContent)
89  m_wEndscreenContent.SetVisible(show);
90  }
91 
96  void InitGameOverScreen(SCR_GameOverScreenUIContentData endScreenUIContent)
97  {
98  //~ Already has end screen
99  if (m_wEndscreenContent)
100  return;
101 
102  m_EndScreenUIContentInfo = endScreenUIContent;
103 
104  Widget contentHolder = m_wRoot.FindAnyWidget(m_sContentHolderName);
105  if (!contentHolder)
106  return;
107 
108  //Spawn gameover layout content
109  if (!endScreenUIContent.m_sGameOverLayout.IsEmpty())
110  {
111  m_wEndscreenContent = GetGame().GetWorkspace().CreateWidgets(endScreenUIContent.m_sGameOverLayout, contentHolder);
112 
113  if (m_wEndscreenContent)
114  {
115  SCR_GameOverScreenContentUIComponent gameOverWidgetContent = SCR_GameOverScreenContentUIComponent.Cast(m_wEndscreenContent.FindHandler(SCR_GameOverScreenContentUIComponent));
116 
117  if (gameOverWidgetContent)
118  gameOverWidgetContent.InitContent(endScreenUIContent);
119  }
120  }
121 
122  if (endScreenUIContent.m_cVignetteColor)
123  {
124  ImageWidget colorOverlay = ImageWidget.Cast(m_wRoot.FindAnyWidget(m_sBackgroundColorOverlayName));
125  if (colorOverlay)
126  colorOverlay.SetColor(endScreenUIContent.m_cVignetteColor);
127  }
128 
129  if (m_ContentFadeComponent)
130  m_ContentFadeComponent.FadeIn();
131  if (m_TabViewFadeComponent)
132  m_TabViewFadeComponent.FadeIn();
133  if (m_ButtonHolderFadeComponent)
134  m_ButtonHolderFadeComponent.FadeIn();
135  if (m_OverlayBackgroundColorFadeUIComponent)
136  m_OverlayBackgroundColorFadeUIComponent.FadeIn();
137  if (m_RestartTimerFadeComponent)
138  m_RestartTimerFadeComponent.FadeIn();
139 
140  Widget returnToMenuBtn = m_wRoot.FindAnyWidget(m_sBackButtonName);
141  if (returnToMenuBtn)
142  {
143  SCR_InputButtonComponent returnToMenuButton = SCR_InputButtonComponent.Cast(returnToMenuBtn.FindHandler(SCR_InputButtonComponent));
144  if (returnToMenuButton)
145  returnToMenuButton.m_OnActivated.Insert(ReturnToMenu);
146  }
147 
148  Widget debriefingWidgetButton = m_wRoot.FindAnyWidget(m_sDebriefingButtonName);
149  if (debriefingWidgetButton)
150  {
151  BaseGameMode gameMode = GetGame().GetGameMode();
152  if (!gameMode)
153  {
154  debriefingWidgetButton.SetVisible(false);
155  }
156  else
157  {
158  SCR_DebriefingScreenComponent debriefingScreen = SCR_DebriefingScreenComponent.Cast(gameMode.FindComponent(SCR_DebriefingScreenComponent));
159  if (debriefingScreen)
160  {
161  SCR_InputButtonComponent debriefingButton = SCR_InputButtonComponent.Cast(debriefingWidgetButton.FindHandler(SCR_InputButtonComponent));
162  if (debriefingButton)
163  debriefingButton.m_OnActivated.Insert(OpenDebriefingScreenMenu);
164  }
165  else
166  {
167  debriefingWidgetButton.SetVisible(false);
168  }
169  }
170  }
171  }
172 
173  //------------------------------------------------------------------------------------------------
174  void OpenDebriefingScreenMenu()
175  {
176  GetGame().GetMenuManager().OpenMenu(ChimeraMenuPreset.DebriefingScreenMenu);
177  }
178 
179  //------------------------------------------------------------------------------------------------
180  void ReturnToMenu()
181  {
182  SCR_ConfigurableDialogUi dlg = SCR_CommonDialogs.CreateDialog("scenario_exit");
183  if (!dlg)
184  return;
185 
186  dlg.m_OnConfirm.Insert(BackToMainMenuPopupConfirm);
187  }
188 
189  //-----------------------------------------------------------------------------------------------
190  protected void BackToMainMenuPopupConfirm()
191  {
192  OnGameEnd();
193  GameStateTransitions.RequestGameplayEndTransition();
194  }
195 
200  void SetMainMenuPopUpTexts(DialogUI popup)
201  {
202  popup.SetMessage(m_sMainMenuPopUpMessage);
203  popup.SetTitle(m_sMainMenuPopUpTitle);
204  popup.SetTitleIcon(m_sMainMenuPopUpImageSet, m_sMainMenuPopUpImage);
205  }
206 
207  //~ Removes itself from hierargy on game end just in cause
208  protected void OnGameEnd()
209  {
210  m_wRoot.RemoveFromHierarchy();
211  }
212 
213  override void HandlerAttached(Widget w)
214  {
215  if (SCR_Global.IsEditMode())
216  return;
217 
218  m_wRoot = w;
219 
220  ImageWidget colorOverlay = ImageWidget.Cast(m_wRoot.FindAnyWidget(m_sBackgroundColorOverlayName));
221  if (colorOverlay)
222  {
223  colorOverlay.SetOpacity(m_fBackgroundColorOverlayOpacity);
224  m_OverlayBackgroundColorFadeUIComponent = SCR_FadeUIComponent.Cast(colorOverlay.FindHandler(SCR_FadeUIComponent));
225 
226  if (m_OverlayBackgroundColorFadeUIComponent)
227  {
228  m_OverlayBackgroundColorFadeUIComponent.SetFadeInSpeed(m_fContentFadeInSpeed);
229  colorOverlay.SetVisible(false);
230  }
231  }
232 
233  Widget contentHolder = w.FindAnyWidget(m_sContentHolderName);
234  if (contentHolder)
235  {
236  m_ContentFadeComponent = SCR_FadeUIComponent.Cast(contentHolder.FindHandler(SCR_FadeUIComponent));
237 
238  if (m_ContentFadeComponent)
239  {
240  m_ContentFadeComponent.SetFadeInSpeed(m_fContentFadeInSpeed);
241  contentHolder.SetVisible(false);
242  }
243  }
244 
245  Widget buttonHolder = w.FindAnyWidget(m_sButtonHolderName);
246  if (buttonHolder)
247  {
248  m_ButtonHolderFadeComponent = SCR_FadeUIComponent.Cast(buttonHolder.FindHandler(SCR_FadeUIComponent));
249  if (m_ButtonHolderFadeComponent)
250  {
251  m_ButtonHolderFadeComponent.SetFadeInSpeed(m_fContentFadeInSpeed);
252  buttonHolder.SetVisible(false);
253  }
254  }
255 
256  Widget restartTimerHolder = w.FindAnyWidget(m_sRestartTimerHolderName);
257  if (restartTimerHolder)
258  {
260 
261  if (restartTimer && restartTimer.IsValid())
262  {
263  m_RestartTimerFadeComponent = SCR_FadeUIComponent.Cast(restartTimerHolder.FindHandler(SCR_FadeUIComponent));
264  if (m_RestartTimerFadeComponent)
265  {
266  m_RestartTimerFadeComponent.SetFadeInSpeed(m_fContentFadeInSpeed);
267  restartTimerHolder.SetVisible(false);
268  }
269  }
270  }
271 
273  if (gameMode)
274  gameMode.GetOnGameEnd().Insert(OnGameEnd);
275 
276  Widget tabView = w.FindAnyWidget(m_sTabViewName);
277 
278  //~ Only use tabview if it is visible in the layout
279  if (tabView && tabView.IsVisible())
280  {
281  m_TabViewComponent = SCR_TabViewComponent.Cast(tabView.FindHandler(SCR_TabViewComponent));
282  m_TabViewFadeComponent = SCR_FadeUIComponent.Cast(tabView.FindHandler(SCR_FadeUIComponent));
283 
284  if (m_TabViewFadeComponent)
285  {
286  m_TabViewFadeComponent.SetFadeInSpeed(m_fContentFadeInSpeed);
287  tabView.SetVisible(false);
288  m_TabViewFadeComponent.GetOnFadeDone().Insert(OnTabViewFadeDone);
289  }
290  }
291 
292  if (m_TabViewComponent)
293  {
294  if (m_TabViewFadeComponent)
295  m_TabViewComponent.EnableAllTabs(false);
296 
297  m_TabViewComponent.GetOnChanged().Insert(OnTabChanged);
298  m_TabViewComponent.GetOnContentCreate().Insert(OnTabCreated);
299  }
300  }
301 
302  override void HandlerDeattached(Widget w)
303  {
305  if (gameMode)
306  gameMode.GetOnGameEnd().Remove(OnGameEnd);
307  }
308 };
309 
310 
311 
312 
313 
SCR_BaseGameMode
Definition: SCR_BaseGameMode.c:137
SCR_FadeUIComponent
Definition: SCR_FadeUIComponent.c:1
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_CommonDialogs
Definition: CommonDialogs.c:5
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_TabViewComponent
Definition: SCR_TabViewComponent.c:13
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition: SCR_BaseGameModeComponent.c:15
GameStateTransitions
Definition: GameStateTransitions.c:12
Attribute
typedef Attribute
Post-process effect of scripted camera.
DialogUI
Definition: DialogUI.c:1
SCR_ServerRestartTimerUIComponent
Definition: SCR_ServerRestartTimerUIComponent.c:1
SCR_BaseGameOverTabUIComponent
Definition: SCR_GameOverTabBaseUIComponent.c:1
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
SCR_Global
Definition: Functions.c:6
SCR_GameOverScreenUIContentData
Definition: SCR_GameOverScreenManagerComponent.c:497
ChimeraMenuPreset
ChimeraMenuPreset
Menu presets.
Definition: ChimeraMenuBase.c:3
SCR_GameOverScreenContentUIComponent
Definition: SCR_GameOverScreenContentUIComponent.c:1
SCR_ConfigurableDialogUi
Definition: SCR_ConfigurableDialogUI.c:13
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
SCR_GameOverScreenUIComponent
Definition: SCR_GameOverScreenUIComponent.c:1
LocalizedString
Definition: LocalizedString.c:21
SCR_InputButtonComponent
Definition: SCR_InputButtonComponent.c:1