Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_MenuLoadingComponent.c
Go to the documentation of this file.
1 // Used to handle custom inits of Configurable dialogs
3 {
6 }
7 
8 class SCR_MenuLoadingComponent
9 {
10  // Static saving values
11  protected const string SAVE_LAST_MENU = "m_LastMenu";
12  protected const string SAVE_ADDITIONAL_MENU = "m_LastAdditionalMenu"; // Can be used for extra menu e.g. Mod details
13  protected const string SAVE_ADDITIONAL_DIALOG = "m_LastAdditionalDialog"; // Can be used for extra menu that is dialog e.g. Server hosting dialog
14 
15  // Variables
16  protected static DialogUI m_DialogToDisplay = null;
17 
18  // Invoker
19  static ref ScriptInvoker m_OnMenuOpening = new ScriptInvoker;
20 
21  //------------------------------------------------------------------------------------------------
23  static bool LoadLastMenu()
24  {
25  // Special cases
26  if (JoinInvite())
27  return false;
28 
29  // Open last menu
30  string lastMenu = GameSessionStorage.s_Data[SAVE_LAST_MENU];
31  if (lastMenu.IsEmpty())
32  return false;
33 
34  GetGame().GetMenuManager().OpenMenu(lastMenu.ToInt());
35 
36  // Additional menu
37  string lastAdditionalMenu = GameSessionStorage.s_Data[SAVE_ADDITIONAL_MENU];
38  if (!lastAdditionalMenu.IsEmpty())
39  GetGame().GetMenuManager().OpenMenu(lastAdditionalMenu.ToInt());
40 
41  // Addition dialog
42  string lastAdditionalDialog = GameSessionStorage.s_Data[SAVE_ADDITIONAL_DIALOG];
43  if (!lastAdditionalDialog.IsEmpty())
44  OpenAdditionalDialog(lastAdditionalDialog.ToInt());
45 
46  m_OnMenuOpening.Invoke(lastMenu.ToInt());
47  return true;
48  }
49 
50  //------------------------------------------------------------------------------------------------
51  static void SaveLastMenu(ChimeraMenuPreset menuPreset, ChimeraMenuPreset additionalMenu = -1, SCR_EMenuLoadingAdditionalDialog additionalDialog = -1)
52  {
53  GameSessionStorage.s_Data[SAVE_LAST_MENU] = menuPreset.ToString();
54 
55  if (additionalMenu != -1)
56  GameSessionStorage.s_Data[SAVE_ADDITIONAL_MENU] = additionalMenu.ToString();
57 
58  if (additionalDialog != -1)
59  GameSessionStorage.s_Data[SAVE_ADDITIONAL_DIALOG] = additionalDialog.ToString();
60  }
61 
62  //------------------------------------------------------------------------------------------------
63  static void ClearLastMenu()
64  {
65  GameSessionStorage.s_Data[SAVE_LAST_MENU] = string.Empty;
66  GameSessionStorage.s_Data[SAVE_ADDITIONAL_MENU] = string.Empty;
67  GameSessionStorage.s_Data[SAVE_ADDITIONAL_DIALOG] = string.Empty;
68  }
69 
70  //------------------------------------------------------------------------------------------------
72  protected static bool JoinInvite()
73  {
74  ClientLobbyApi lobby = GetGame().GetBackendApi().GetClientLobby();
75 
76  // Check invited rooom
77  Room invited = lobby.GetInviteRoom();
78  if (!invited)
79  return false;
80 
81  #ifdef SB_DEBUG
82  Print("[SCR_MenuLoadingComponent] Client is invited to room: " + invited + ", name: " + invited.Name());
83  #endif
84 
85  // Open server browser
86  ServerBrowserMenuUI serverBrowser = ServerBrowserMenuUI.Cast(GetGame().GetMenuManager().OpenMenu(ChimeraMenuPreset.ServerBrowserMenu));
87  if (serverBrowser)
88  {
89  serverBrowser.JoinProcess_Init(invited);
90  return true;
91  }
92 
93  return false;
94  }
95 
96  //------------------------------------------------------------------------------------------------
97  protected static void OpenAdditionalDialog(SCR_EMenuLoadingAdditionalDialog dialog)
98  {
99  switch (dialog)
100  {
101  case SCR_EMenuLoadingAdditionalDialog.SERVER_HOSTING: SCR_CommonDialogs.CreateServerHostingDialog(); break;
102  //TODO: add other cases as they become necessary
103  }
104  }
105 }
SCR_EMenuLoadingAdditionalDialog
SCR_EMenuLoadingAdditionalDialog
Definition: SCR_MenuLoadingComponent.c:2
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_CommonDialogs
Definition: CommonDialogs.c:5
SAVE_ADDITIONAL_DIALOG
const protected string SAVE_ADDITIONAL_DIALOG
Definition: SCR_MenuLoadingComponent.c:13
DialogUI
Definition: DialogUI.c:1
SAVE_LAST_MENU
enum SCR_EMenuLoadingAdditionalDialog SAVE_LAST_MENU
MOD_DETAILS
@ MOD_DETAILS
Definition: SCR_MenuLoadingComponent.c:5
ChimeraMenuPreset
ChimeraMenuPreset
Menu presets.
Definition: ChimeraMenuBase.c:3
SAVE_ADDITIONAL_MENU
const protected string SAVE_ADDITIONAL_MENU
Definition: SCR_MenuLoadingComponent.c:12
SERVER_HOSTING
@ SERVER_HOSTING
Definition: SCR_MenuLoadingComponent.c:4
ServerBrowserMenuUI
Definition: ServerBrowserMenuUI.c:10