Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
ScriptedMainMenuEntity.c
Go to the documentation of this file.
1 //#define DEBUG_WARNING_SCREEN
2 
3 //------------------------------------------------------------------------------------------------
5 [EntityEditorProps(category: "GameScripted/Menu", description:"When put into a level will make sure that the main menu is open.")]
6 class SCR_MainMenuEntityClass: GenericEntityClass
7 {
8 };
9 
10 //------------------------------------------------------------------------------------------------
12 {
13  [Attribute("ChimeraMenuPreset.MainMenu", UIWidgets.SearchComboBox, "Menu to launch at start of the world", "", ParamEnumArray.FromEnum(ChimeraMenuPreset) )]
14  ChimeraMenuPreset m_eMenu;
15 
16  [Attribute("{1C71B463B3B66BAB}UI/layouts/Menus/MainMenu/IntroSplashScreen.layout")]
17  private ResourceName m_sSplashScreenLayout;
18 
19  protected static SCR_MainMenuEntity m_Instamce;
20 
21  //------------------------------------------------------------------------------------------------
22  void SCR_MainMenuEntity(IEntitySource src, IEntity parent)
23  {
24  m_Instamce = this;
25 
26  // Enable
27  SetEventMask(EntityEvent.FRAME);
28  SetFlags(EntityFlags.NO_TREE | EntityFlags.NO_LINK);
29  }
30 
31  //------------------------------------------------------------------------------------------------
32  void ~SCR_MainMenuEntity()
33  {
34  if (m_eMenu == ChimeraMenuPreset.MainMenu)
35  GetGame().m_bIsMainMenuOpen = false;
36  }
37 
38  // Wait until first update - all systems, like MenuManager should be initialized
39  //------------------------------------------------------------------------------------------------
40  override void EOnFrame(IEntity owner, float timeSlice)
41  {
42  bool isDevVersion = Game.IsDev();
43  bool showWarningScreen = SplashScreen.GetGameReloads() == 0 && SplashScreen.s_iSplashShown == 1;
44 
45  #ifdef DEBUG_WARNING_SCREEN
46  isDevVersion = false;
47  #endif
48 
49  if (showWarningScreen && !isDevVersion)
50  ShowWarningScreen();
51  else
52  ShowMainMenu();
53 
54  // Reset scenario loading time
55  SCR_BaseLoadingScreenComponent.ResetLoadingTime();
56 
57  // Disable all events
58  ClearEventMask(EntityEvent.ALL);
59  }
60 
61  //------------------------------------------------------------------------------------------------
62  private void ShowWarningScreen()
63  {
64  Widget w = GetGame().GetWorkspace().CreateWidgets(m_sSplashScreenLayout, GetGame().GetWorkspace());
65 
67  w.AddHandler(comp);
68 
69  if (!comp)
70  return;
71 
72  // If splash screen was skipped (due to CLI for example) make sure, we have it flagged and do not run ShowWarningScreen again
73  if (SplashScreen.s_iSplashShown == 0)
74  SplashScreen.s_iSplashShown++;
75 
76  comp.m_OnFinished.Insert(ShowMainMenu);
77  }
78 
79  //------------------------------------------------------------------------------------------------
80  private void ShowMainMenu()
81  {
82  GetGame().GetMenuManager().OpenMenu(m_eMenu);
83  if (m_eMenu == ChimeraMenuPreset.MainMenu)
84  GetGame().m_bIsMainMenuOpen = true;
85 
86  // Check hosting fail
87  SCR_KickDialogs.CheckLastServerHost();
88  }
89 
90  //------------------------------------------------------------------------------------------------
91  static SCR_MainMenuEntity GetInstance()
92  {
93  return m_Instamce;
94  }
95 };
SCR_IntroSplashScreen2Component
Definition: SCR_IntroSplashScreen2Component.c:3
SCR_MainMenuEntityClass
Main menu entity.
Definition: ScriptedMainMenuEntity.c:6
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
SCR_KickDialogs
Definition: SCR_KickDialogs.c:1
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
GenericEntity
SCR_GenericBoxEntityClass GenericEntity
Attribute
typedef Attribute
Post-process effect of scripted camera.
ChimeraMenuPreset
ChimeraMenuPreset
Menu presets.
Definition: ChimeraMenuBase.c:3
SCR_MainMenuEntity
Definition: ScriptedMainMenuEntity.c:11
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180