Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_KickDialogs.c
Go to the documentation of this file.
2{
3 protected const ResourceName KICK_DIALOGS_CONFIG = "{D3BFEE28E7D5B6A1}Configs/ServerBrowser/KickDialogs.conf";
4 protected const ResourceName HOSTING_ERROR_DIALOG_CONFIG = "{F96212757F65C4A3}Configs/ServerBrowser/ServerHosting/Dialogs/ServerHostingErrors.conf";
5
6 protected const string TAG_KICK_DEFAULT = "DEFAULT_ERROR";
7 protected const int MAX_AUTO_REJOINS = 3;
8
10
11 protected static string s_sErrorMessage;
12 protected static string s_sErrorMessageGroup;
13 protected static string s_sErrorMessageDetail;
14
15 protected static bool m_bReconnectEnabled;
16
18 protected static ref ScriptInvokerVoid s_OnCancel;
19 protected static ref ScriptInvokerVoid s_OnReconnect;
20
22
23 //------------------------------------------------------------------------------------------------
25 static void CreateKickErrorDialog(string msg, string group, string details = "")
26 {
27 s_sErrorMessage = msg;
29 s_sErrorMessageDetail = details;
30
32 s_OnErrorMessageSet.Invoke();
33
35 }
36
37 //------------------------------------------------------------------------------------------------
40 {
41 if (s_sErrorMessage.IsEmpty())
42 return;
43
44 // --- Setup Kick dialog ---
46 if (dialogUi && s_sErrorMessage == "PLATFORM_USER_SIGNED_OUT")
47 {
48 dialogUi.m_OnCancel.Insert(ForceMainMenu);
49 }
50
51 // Use group as fallback if no dialog found
52 if (!dialogUi)
54
55
56 // Show default error if tag is not found
57 if (!dialogUi)
59
60 if (!dialogUi)
61 {
62 Clear();
63 return;
64 }
65
66 s_CurrentKickDialog = dialogUi;
67 dialogUi.m_OnClose.Insert(OnDialogClose);
68
69 // Set error details
71 if (errorDialogComp)
72 errorDialogComp.SetErrorDetail(s_sErrorMessageDetail);
73
74 // Check reconnect
76 bool reconnect = m_bReconnectEnabled && kickPreset && kickPreset.m_bCanBeReconnected;
77
79 if (confirmButton)
80 confirmButton.SetVisible(reconnect);
81
82 // --- Setup reconnect ---
83 if (!reconnect)
84 {
85 Clear();
86 return;
87 }
88
89 string errorStr = kickPreset.m_sMessage;
90 errorDialogComp.SetErrorMessage(errorStr);
91
92 // Check rejoin attempt
93 string strAttempt = GameSessionStorage.s_Data["m_iRejoinAttempt"];
94 int attempt = strAttempt.ToInt();
95
96 if (attempt <= MAX_AUTO_REJOINS)
97 {
98 errorStr += "\n" + "#AR-ServerBrowser_JoinMessageDefault";
99 errorDialogComp.SetErrorMessage(errorStr);
100
101 dialogUi.SetMessage(errorStr + " " + errorDialogComp.GetTimer());
102
103 // Setup timer
104 errorDialogComp.GetEventOnTimerChanged().Insert(OnDialogTimerChange);
105
106 errorDialogComp.ShowLoading(true);
107 errorDialogComp.SetTimer(kickPreset.m_iAutomaticReconnectTime);
108 errorDialogComp.RunTimer(true);
109 }
110 else
111 {
112 dialogUi.SetMessage(errorStr);
113
114 // Block rejoin
115 errorDialogComp.ShowLoading(false);
116 if (confirmButton)
117 confirmButton.SetEnabled(false);
118 }
119
120 // Reconnect button
121 dialogUi.m_OnConfirm.Insert(OnReconnect);
122 dialogUi.m_OnCancel.Insert(OnCancel);
123
124 Clear();
125 }
126
127 //------------------------------------------------------------------------------------------------
130 {
131 // Check for hosting errors
133 GetGame().GetBackendApi().GetClientLobby().ProcessLastHostError(m_ProcessLastHostCallback);
134 }
135
136 //------------------------------------------------------------------------------------------------
137 protected static void OnProcessLastHostError(BackendCallback callback)
138 {
139 int apiCode = callback.GetApiCode();
140
141 string apiStr = typename.EnumToString(EApiCode, apiCode);
142
143 switch (apiCode)
144 {
145 case EApiCode.EACODE_ERROR_ASSET_NOT_FOUND:
146 {
148 return;
149 }
150 default:
151 {
153 return;
154 }
155 }
156 }
157
158 //------------------------------------------------------------------------------------------------
159 static void SetReconnectEnabled(bool enabled)
160 {
161 m_bReconnectEnabled = enabled;
162 }
163
164 //------------------------------------------------------------------------------------------------
165 static void Clear()
166 {
167 s_sErrorMessage = string.Empty;
168 s_sErrorMessageGroup = string.Empty;
169 s_sErrorMessageDetail = string.Empty;
170 }
171
172 // Getters
173 //------------------------------------------------------------------------------------------------
178
179 //------------------------------------------------------------------------------------------------
181 {
182 if (!s_OnCancel)
184
185 return s_OnCancel;
186 }
187
188 //------------------------------------------------------------------------------------------------
190 {
191 if (!s_OnReconnect)
193
194 return s_OnReconnect;
195 }
196
197 // Internal
198 //------------------------------------------------------------------------------------------------
199 protected static void OnDialogTimerChange(SCR_RejoinDialog dialog, int time)
200 {
202 return;
203
204 s_CurrentKickDialog.SetMessage(dialog.GetErrorMessage() + " " + time);
205
206 if (time == 0)
207 {
208 OnReconnect();
209 s_CurrentKickDialog.Close();
210 }
211 }
212
213 //------------------------------------------------------------------------------------------------
214 protected static void OnDialogClose()
215 {
216 s_CurrentKickDialog = null;
217 Clear();
218 }
219
220 //------------------------------------------------------------------------------------------------
221 protected static void OnReconnect()
222 {
223 if (s_OnReconnect)
224 s_OnReconnect.Invoke();
225 }
226
227 //------------------------------------------------------------------------------------------------
228 protected static void OnCancel()
229 {
230 if (s_OnCancel)
231 s_OnCancel.Invoke();
232 }
233
234 //------------------------------------------------------------------------------------------------
235 static void ForceMainMenu()
236 {
237 GetGame().GetMenuManager().OpenMenu(ChimeraMenuPreset.MainMenu);
238 }
239}
ChimeraMenuPreset
Menu presets.
ArmaReforgerScripted GetGame()
Definition game.c:1398
ScriptInvokerBase< ScriptInvokerVoidMethod > ScriptInvokerVoid
GameSessionStorage is used to store data for whole lifetime of game executable run....
static SCR_ConfigurableDialogUi CreateFromPreset(ResourceName presetsResourceName, string tag, SCR_ConfigurableDialogUi customDialogObj=null)
Creates a dialog from preset.
SCR_InputButtonComponent FindButton(string tag)
Returns a button with given tag.
SCR_ConfigurableDialogUiPreset GetDialogPreset()
override void SetEnabled(bool enabled, bool animate=true)
Server kick message specific dialog.
static ref ScriptInvokerVoid s_OnReconnect
const int MAX_AUTO_REJOINS
static void OnDialogTimerChange(SCR_RejoinDialog dialog, int time)
static SCR_ConfigurableDialogUi GetCurrentKickDialog()
static void SetReconnectEnabled(bool enabled)
static void CreateKickErrorDialog(string msg, string group, string details="")
Set message for error dialog and create it.
static ScriptInvokerVoid GetOnCancel()
static ScriptInvokerVoid GetOnReconnect()
static void DisplayKickErrorDialog()
Create and setup error dialog.
static SCR_ConfigurableDialogUi s_CurrentKickDialog
static string s_sErrorMessageGroup
static void OnDialogClose()
static bool m_bReconnectEnabled
static ref ScriptInvokerVoid s_OnCancel
static void OnProcessLastHostError(BackendCallback callback)
static void CheckLastServerHost()
Check last server hosting to find out if there was a bug.
static ref BackendCallback m_ProcessLastHostCallback
static void ForceMainMenu()
const string TAG_KICK_DEFAULT
static string s_sErrorMessage
static void OnReconnect()
static ref ScriptInvokerVoid s_OnErrorMessageSet
static string s_sErrorMessageDetail
const ResourceName HOSTING_ERROR_DIALOG_CONFIG
static void OnCancel()
static void Clear()
const ResourceName KICK_DIALOGS_CONFIG
void RunTimer(bool run)
ScriptInvoker GetEventOnTimerChanged()
void ShowLoading(bool show)
static SCR_RejoinDialog FindRejoinComponent(notnull Widget w)
void SetTimer(int time)
EApiCode
Definition EApiCode.c:13