Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ServerBrowserDialogManager.c
Go to the documentation of this file.
1
5
6//------------------------------------------------------------------------------------------------
8{
9 // Resources
10 const ResourceName CONFIG_DIALOGS = "{471EFCF445C3E9C6}Configs/ServerBrowser/JoiningDialogs.conf";
11 protected const string OFFICIAL_SERVER_SCOPE = "officialServer";
12
13 // Dialog tags references
14 protected const string TAG_SEARCHING_SERVER = "SEARCHING_SERVER";
15 protected const string TAG_JOIN = "JOIN";
16 protected const string TAG_REJOIN = "REJOIN";
17 protected const string TAG_SERVER_NOT_FOUND = "SERVER_NOT_FOUND";
18 protected const string TAG_VERSION_MISMATCH = "VERSION_MISMATCH";
19 protected const string TAG_CHECKING_CONTENT = "CHECKING_CONTENT";
20 protected const string TAG_MOD_UGC_PRIVILEGE_MISSING = "MOD_UGC_PRIVILEGE_MISSING";
21 protected const string TAG_MODS_DOWNLOADING = "MODS_DOWNLOADING";
22 protected const string TAG_SERVER_FULL = "SERVER_FULL";
23 protected const string TAG_PASSWORD_REQUIRED = "PASSWORD_REQUIRED";
24 protected const string TAG_BACKEND_TIMEOUT = "BACKEND_TIMEOUT";
25 protected const string TAG_BANNED = "JOIN_FAILED_BAN";
26 protected const string TAG_HIGH_PING_SERVER = "HIGH_PING_SERVER";
27 protected const string TAG_UNRELATED_DOWNLOADS_CANCELING = "UNRELATED_DOWNLOADS_CANCELING";
28
29 protected const string STR_LIGHT_BAN = "#AR-LightBan";
30 protected const string STR_HEAVY_BAN = "#AR-HeavyBan";
31
32 // References
33 protected Room m_JoinRoom;
36
37 // States
38 protected EJoinDialogState m_iDisplayState;
40
41 const string ERROR_TAG_DEFAULT = "JOIN_FAILED";
42
43 // Invokers
47
50
51 //------------------------------------------------------------------------------------------------
52 // Public functions
53 //------------------------------------------------------------------------------------------------
54
55 //------------------------------------------------------------------------------------------------
57 void DisplayDialog(EJoinDialogState state)
58 {
59 // Set
60 m_iDisplayState = state;
61
63 m_CurrentDialog.Close();
64
65 // Visual set
66 switch (state)
67 {
68 // Searching server
69 case EJoinDialogState.SEARCHING_SERVER:
70 {
72 break;
73 }
74
75 // Joining
76 case EJoinDialogState.JOIN:
77 {
79 break;
80 }
81
82 // Joining
83 case EJoinDialogState.REJOIN:
84 {
86 break;
87 }
88
89 // Server by given parameters wasn't found
90 case EJoinDialogState.SERVER_NOT_FOUND:
91 {
93 break;
94 }
95
96 // Wrong version restriction
97 case EJoinDialogState.VERSION_MISMATCH:
98 {
100
101 // Display version difference text
102 string clientV = GetGame().GetBuildVersion();
103 string RoomV = m_JoinRoom.GameVersion();
104
105 string msg = string.Format("%1: %2 \n%3: %4", "#AR-ServerBrowser_Server", RoomV, "#AR-Editor_AttributeCategory_GameSettings_Name", clientV);
106 m_CurrentDialog.SetMessage(msg);
107 break;
108 }
109
110 // Checking mod content
111 case EJoinDialogState.CHECKING_CONTENT:
112 {
114 break;
115 }
116
117 // Client can't access user generated content
118 case EJoinDialogState.MOD_UGC_PRIVILEGE_MISSING:
119 {
121 break;
122 }
123
124 // Password input dialog
125 case EJoinDialogState.PASSWORD_REQUIRED:
126 {
128 break;
129 }
130
131 // Password input dialog
132 case EJoinDialogState.BACKEND_TIMEOUT:
133 {
135 break;
136 }
137
138 // High ping
139 case EJoinDialogState.HIGH_PING_SERVER:
140 {
142 break;
143 }
144
145 // Unrelated Downloads canceling filler dialog
146 case EJoinDialogState.UNRELATED_DOWNLOADS_CANCELING:
147 {
149 break;
150 }
151 }
152 }
153
154 //------------------------------------------------------------------------------------------------
155 void SetDialogMessage(string msg)
156 {
157 if (!m_CurrentDialog)
158 return;
159
160 m_CurrentDialog.SetMessage(msg);
161 }
162
163 //------------------------------------------------------------------------------------------------
165 {
166 if (m_CurrentDialog)
167 m_CurrentDialog.Close();
168 }
169
170 //------------------------------------------------------------------------------------------------
172 protected void SetDialogByTag(string tag, SCR_ConfigurableDialogUi dialog = null)
173 {
174 // Check dialog resource
175 if (CONFIG_DIALOGS.IsEmpty())
176 return;
177
178 // Remove invokers actions from old dialog
179 if (m_CurrentDialog)
180 m_CurrentDialog.m_OnConfirm.Remove(OnDialogConfirm);
181
182 // Create dialog
183 m_CurrentDialog = SCR_ConfigurableDialogUi.CreateFromPreset(CONFIG_DIALOGS, tag, dialog);
184
185 // Add invoker actions to current dialog
186 m_CurrentDialog.m_OnConfirm.Insert(OnDialogConfirm);
187 m_CurrentDialog.m_OnCancel.Insert(OnDialogCancel);
188 }
189
190 //------------------------------------------------------------------------------------------------
191 protected void OnDialogConfirm()
192 {
193 if (m_OnConfirm)
194 m_OnConfirm.Invoke();
195 }
196
197 //------------------------------------------------------------------------------------------------
198 protected void OnDialogCancel()
199 {
200 if (m_OnCancel)
201 m_OnCancel.Invoke();
202
203 // Separate invoker for final cleanup (the other OnCancel might be used for specific functionalities still)
205 m_OnJoinProcessCancel.Invoke();
206 }
207
208 //------------------------------------------------------------------------------------------------
209 // Spefic dialog handling
210 //------------------------------------------------------------------------------------------------
211 //------------------------------------------------------------------------------------------------
214 {
216
217 string errorTag = ERROR_TAG_DEFAULT;
218
219 // TODO@wernerjak - setup dialogs
220
221 switch (apiError)
222 {
223 case EApiCode.EACODE_ERROR_P2P_USER_JOIN_BAN: errorTag = TAG_BANNED; break;
224 case EApiCode.EACODE_ERROR_DS_USER_JOIN_BAN: errorTag = TAG_BANNED; break;
225 case EApiCode.EACODE_ERROR_USER_IS_BANNED_FROM_SHARED_GAME: errorTag = TAG_BANNED; break;
226 case EApiCode.EACODE_ERROR_PLAYER_IS_BANNED: errorTag = TAG_BANNED; break;
227 //case EApiCode.EACODE_ERROR_MAINTENANCE_IN_PROGRESS: errorTag = "JOIN_FAILED_MAITANANCE"; break;
228 //case EApiCode.EACODE_ERROR_MP_ROOM_IS_NOT_JOINABLE: errorTag = "JOIN_FAILED_NOT_JOINABLE"; break;
229 }
230
231 SetDialogByTag(errorTag);
232
233 // Show additional message
234 if (m_CurrentDialog)
235 {
236 SCR_ErrorDialog errorDialog = SCR_ErrorDialog.Cast(m_CurrentDialog.GetRootWidget().FindHandler(SCR_ErrorDialog));
237 if (errorDialog)
238 {
239 string strApiError = typename.EnumToString(EApiCode, apiError);
240 errorDialog.SetErrorDetail("#AR-Workshop_Error: " + strApiError);
241 }
242 }
243 }
244
245 //------------------------------------------------------------------------------------------------
246 void DisplayJoinBan(RoomJoinData data)
247 {
249
251
252 if (!m_CurrentDialog)
253 return;
254
255 if (data.expiresAt < 0)
256 return;
257
258 int time = data.expiresAt - System.GetUnixTime();
259
260 // Show message with time
261 if (time <= 0)
262 return;
263
264 string message = STR_LIGHT_BAN;
265
266 // Is ban for official servers
267 if (data.scope.Contains(OFFICIAL_SERVER_SCOPE))
268 message = STR_HEAVY_BAN;
269
270 int timeMinutes = time / 60; // show minutes
271 m_CurrentDialog.SetMessage(WidgetManager.Translate(message, timeMinutes.ToString()));
272 }
273
274 //------------------------------------------------------------------------------------------------
277 {
279 }
280
281 //------------------------------------------------------------------------------------------------
282 // Display a dialog asking for downloads cancel confirmation
283 void DisplayJoinDownloadsWarning(array<ref SCR_WorkshopItemActionDownload> downloads, SCR_EJoinDownloadsConfirmationDialogType type)
284 {
285 // Remove invokers actions from old dialog
286 if (m_CurrentDialog)
287 m_CurrentDialog.m_OnConfirm.Remove(OnDialogConfirm);
288
290
291 // Add invoker actions to current dialog
292 m_CurrentDialog.m_OnConfirm.Insert(OnDialogConfirm);
293 m_CurrentDialog.m_OnCancel.Insert(OnDialogCancel);
294
297 }
298
299 //------------------------------------------------------------------------------------------------
300 protected void OnDownloadingDone()
301 {
302 // Check if any of required addon is not failed
303 array<ref SCR_WorkshopItem> required = m_ModManager.GetRoomItemsScripted();
304
305 foreach (SCR_WorkshopItem item : required)
306 {
307 if (!item.GetOffline())
308 return;
309 }
310
312
315 }
316
317 //------------------------------------------------------------------------------------------------
319 protected void DisplayPasswordRequired()
320 {
321 SCR_EditboxDialogUi editboxDialog = new SCR_EditboxDialogUi();
323
324 editboxDialog.m_OnWriteModeLeave.Insert(OnPasswordEditboxChanged);
325 editboxDialog.FindButton(SCR_ConfigurableDialogUi.BUTTON_CONFIRM).SetEnabled(false);
326 }
327
328 //------------------------------------------------------------------------------------------------
330 protected void OnPasswordEditboxChanged(string text)
331 {
333 return;
334
336 if (navButton)
337 navButton.SetEnabled(!text.IsEmpty());
338
340 if (navButton)
341 navButton.SetEnabled(true);
342 }
343
345 //------------------------------------------------------------------------------------------------
347 {
348 MultiplayerDialogUI multiplayerDialogUI = new MultiplayerDialogUI();
349 MultiplayerDialogUI dialog = MultiplayerDialogUI.Cast(SCR_ConfigurableDialogUi.CreateFromPreset(CONFIG_DIALOGS, "MANUAL_CONNECT", multiplayerDialogUI));
350 m_CurrentDialog = dialog;
351
352 return dialog;
353 }
354
355 // Server details
356 //------------------------------------------------------------------------------------------------
357 SCR_ServerDetailsDialog CreateServerDetailsDialog(Room room, array<ref SCR_WorkshopItem> items, ScriptInvokerVoid onFavoritesResponse = null)
358 {
359 SCR_ServerDetailsDialog dialog = SCR_ServerDetailsDialog.CreateServerDetailsDialog(room, items, "SERVER_DETAILS", CONFIG_DIALOGS, onFavoritesResponse);
360 m_CurrentDialog = dialog;
361 m_CurrentDialog.m_OnCancel.Insert(OnDialogCancel);
362
363 return dialog;
364 }
365
366 //------------------------------------------------------------------------------------------------
367 void FillRoomDetailsMods(array<ref SCR_WorkshopItem> items, SCR_RoomModsManager modsManager = null)
368 {
370 dialog.FillModList(items, modsManager);
371 }
372
373 //------------------------------------------------------------------------------------------------
375 {
377 if (dialog)
378 dialog.SetScenarioImage(scenario);
379 }
380
381 // Server Full
382 //------------------------------------------------------------------------------------------------
384 {
387
388 m_CurrentDialog = dialog;
389
390 if (m_CurrentDialog)
391 m_CurrentDialog.m_OnCancel.Insert(OnDialogCancel);
392
393 return dialog;
394 }
395
396 //------------------------------------------------------------------------------------------------
398 {
400 if (dialog)
401 dialog.SetScenarioImage(scenario);
402 }
403
404 //------------------------------------------------------------------------------------------------
405 // Update wating queue with actual player count
407 {
409 if (dialog)
410 dialog.UpdateInfo();
411 }
412
413 //------------------------------------------------------------------------------------------------
414 void CreateBlockedPlayersWarningDialog(array<BlockedRoomPlayer> blockedPlayers)
415 {
417
418 m_CurrentDialog = dialog;
419
420 m_CurrentDialog.m_OnCancel.Insert(OnDialogCancel);
421 m_CurrentDialog.m_OnConfirm.Insert(OnDialogConfirm);
422 }
423
424 //------------------------------------------------------------------------------------------------
425 // Get & Set API
426 //------------------------------------------------------------------------------------------------
427
428 // Invokers
429 //------------------------------------------------------------------------------------------------
431 {
432 if (!m_OnConfirm)
434
435 return m_OnConfirm;
436 }
437
438 //------------------------------------------------------------------------------------------------
440 {
441 if (!m_OnCancel)
443
444 return m_OnCancel;
445 }
446
447 //------------------------------------------------------------------------------------------------
455
456 //------------------------------------------------------------------------------------------------
464
465 //------------------------------------------------------------------------------------------------
473
474 // Helpers
475 //------------------------------------------------------------------------------------------------
476 EJoinDialogState GetDisplayState()
477 {
478 return m_iDisplayState;
479 }
480
481 //------------------------------------------------------------------------------------------------
486
487 //------------------------------------------------------------------------------------------------
489 {
490 return GetCurrentDialog();
491 }
492
493 //------------------------------------------------------------------------------------------------
494 void SetJoinRoom(Room room)
495 {
496 m_JoinRoom = room;
497 }
498
499 //------------------------------------------------------------------------------------------------
501 {
502 m_ModManager = modManager;
503 }
504}
505
506//------------------------------------------------------------------------------------------------
508enum EJoinDialogState
509{
510 // Basic states
511 SEARCHING_SERVER, // Basic msg dialog with loading
512 JOIN, // Basic msg dialog with loading
513 REJOIN, // Rejoin dialog if client is kicked
514
515 // Basic issues states
516 SERVER_NOT_FOUND, // Basic error msg dialog
517 VERSION_MISMATCH, // Basic error msg dialog
519
520 // Content states
521 CHECKING_CONTENT, // Basic msg dialog with loading
522 MODS_DOWNLOADING, // Progress bar dialog
523 MOD_RESTRICTED, // Basic error msg dialog
524 MOD_UGC_PRIVILEGE_MISSING, // Client can't use user generated content
525
526 // Additional actions states
527 PASSWORD_REQUIRED, // Editbox dialog
528
529 // Issues
530 SERVICE_DOWN, // Backend service is not available
531 SERVER_DOWN, // Joined server is not running
533
534 // Warnings
536
537 // Fillers
538 UNRELATED_DOWNLOADS_CANCELING // Waiting for all downloads to cancel
540
541//------------------------------------------------------------------------------------------------
ArmaReforgerScripted GetGame()
Definition game.c:1398
EDamageType type
Get all prefabs that have the spawner data
ScriptInvokerBase< ScriptInvokerVoidMethod > ScriptInvokerVoid
class SCR_ServerBrowserDialogManager MOD_RESTRICTED
class SCR_ServerBrowserDialogManager CHECKING_CONTENT
class SCR_ServerBrowserDialogManager REJOIN
class SCR_ServerBrowserDialogManager PASSWORD_REQUIRED
class SCR_ServerBrowserDialogManager JOIN_FAILED
SCR_EJoinDownloadsConfirmationDialogType
Enum for confirmation dialogs that guide the player through the download processes required to join t...
class SCR_ServerBrowserDialogManager SEARCHING_SERVER
Enum for tracking current state of joining process.
class SCR_ServerBrowserDialogManager BACKEND_TIMEOUT
class SCR_ServerBrowserDialogManager SERVICE_DOWN
class SCR_ServerBrowserDialogManager UNRELATED_DOWNLOADS_CANCELING
class SCR_ServerBrowserDialogManager SERVER_DOWN
class SCR_ServerBrowserDialogManager SERVER_NOT_FOUND
class SCR_ServerBrowserDialogManager HIGH_PING_SERVER
class SCR_ServerBrowserDialogManager MODS_DOWNLOADING
class SCR_ServerBrowserDialogManager JOIN
class SCR_ServerBrowserDialogManager MOD_UGC_PRIVILEGE_MISSING
@ VERSION_MISMATCH
ScriptInvokerBase< ScriptInvokerRoomMethod > ScriptInvokerRoom
Definition Room.c:13
static SCR_ConfigurableDialogUi CreateFromPreset(ResourceName presetsResourceName, string tag, SCR_ConfigurableDialogUi customDialogObj=null)
Creates a dialog from preset.
static SCR_DownloadManager GetInstance()
ScriptInvokerVoid GetOnDownloadQueueCompleted()
Configurable editbox dialog base.
ref ScriptInvokerString m_OnWriteModeLeave
void SetErrorDetail(string strDetail)
override void SetEnabled(bool enabled, bool animate=true)
Show list of reported mods and provide option to cancel reports.
void UpdateRoomDetailsScenarioImage(MissionWorkshopItem scenario)
void SetModManager(SCR_RoomModsManager modManager)
void DisplayJoinDownloadsWarning(array< ref SCR_WorkshopItemActionDownload > downloads, SCR_EJoinDownloadsConfirmationDialogType type)
void DisplayJoinFail(EApiCode apiError)
Show join fail message in dialog.
void OnPasswordEditboxChanged(string text)
Call this whenever password dialog editbox is being edited.
void DisplayDialog(EJoinDialogState state)
Display dialog by state and setup current state.
SCR_ServerDetailsDialog CreateServerDetailsDialog(Room room, array< ref SCR_WorkshopItem > items, ScriptInvokerVoid onFavoritesResponse=null)
void SetDialogByTag(string tag, SCR_ConfigurableDialogUi dialog=null)
Quick short code to open dialog by tag and cache it.
void FillRoomDetailsMods(array< ref SCR_WorkshopItem > items, SCR_RoomModsManager modsManager=null)
void UpdateServerFullScenarioImage(MissionWorkshopItem scenario)
void OnAllReportsCanceled(SCR_ReportedAddonsDialog dialog)
Call this when all reports from dialog are cancled to clear invoker actions and display download dial...
MultiplayerDialogUI CreateManualJoinDialog()
DECOUPLED DIALOGS.
void CreateBlockedPlayersWarningDialog(array< BlockedRoomPlayer > blockedPlayers)
void DisplayPasswordRequired()
Display dialog for password insert whenever password is required.
void FillModList(array< ref SCR_WorkshopItem > items, SCR_RoomModsManager modsManager)
static SCR_ServerDetailsDialog CreateServerDetailsDialog(Room room, array< ref SCR_WorkshopItem > items, string preset, ResourceName dialogsConfig="", ScriptInvokerVoid onFavoritesResponse=null)
void SetScenarioImage(MissionWorkshopItem scenario)
void SetScenarioImage(MissionWorkshopItem scenario)
Dialog to cancel downloads during to server joining.
static SCR_ServerJoinDownloadsConfirmationDialog Create(array< ref SCR_WorkshopItemActionDownload > actions, SCR_EJoinDownloadsConfirmationDialogType type)
@ ALL
Everything except general switch.
Definition EntityEvent.c:37
EApiCode
Definition EApiCode.c:13