Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_MenuLoadingComponent.c
Go to the documentation of this file.
1// Used to handle custom inits of Configurable dialogs
7
8class 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() || (GetGame().m_bIsMainMenuOpen && lastMenu.ToInt() == ChimeraMenuPreset.MainMenu))
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}
ChimeraMenuPreset
Menu presets.
@ SERVER_HOSTING
ArmaReforgerScripted GetGame()
Definition game.c:1398
bool m_bIsMainMenuOpen
Definition game.c:57
enum SCR_EMenuLoadingAdditionalDialog SAVE_LAST_MENU
const string SAVE_ADDITIONAL_DIALOG
SCR_EMenuLoadingAdditionalDialog
const string SAVE_ADDITIONAL_MENU
GameSessionStorage is used to store data for whole lifetime of game executable run....
void JoinProcess_Init(Room roomToJoin)
Initialize joining process to specific room.
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134