10 const ResourceName CONFIG_DIALOGS =
"{471EFCF445C3E9C6}Configs/ServerBrowser/JoiningDialogs.conf";
11 protected const string OFFICIAL_SERVER_SCOPE =
"officialServer";
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_QUEUE_WAITING =
"QUEUE_WAITING";
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";
29 protected const string STR_LIGHT_BAN =
"#AR-LightBan";
30 protected const string STR_HEAVY_BAN =
"#AR-HeavyBan";
33 protected Room m_JoinRoom;
38 protected bool m_bIsOpen =
false;
39 protected int m_iOpenDialogCount = 0;
44 const string WIDGET_IMAGE_ICON =
"ImgIcon";
45 const string WIDGET_TXT_SUBMSG =
"TxtSubMsg";
46 const string WIDGET_LOADING =
"LoadingCircle0";
48 const string WIDGET_PROGRESS =
"VProgress";
49 const string WIDGET_TXT_PROGRESS =
"TxtProgress";
50 const string WIDGET_PROGRESS_BAR =
"ProgressBar";
52 const string WIDGET_BUTTON_ADDITIONAL =
"Additional";
53 const string ERROR_TAG_DEFAULT =
"JOIN_FAILED";
55 protected int m_iDownloadedCount = 0;
56 protected ref array<ref SCR_WorkshopItemAction> m_JoinDownloadActions = {};
77 m_iDisplayState = state;
81 m_CurrentDialog.Close();
88 SetDialogByTag(TAG_SEARCHING_SERVER);
93 SetDialogByTag(TAG_JOIN);
99 SetDialogByTag(TAG_REJOIN);
105 SetDialogByTag(TAG_SERVER_NOT_FOUND);
111 SetDialogByTag(TAG_VERSION_MISMATCH);
114 string clientV =
GetGame().GetBuildVersion();
115 string RoomV = m_JoinRoom.GameVersion();
117 string msg =
string.Format(
"%1: %2 \n%3: %4",
"#AR-ServerBrowser_Server", RoomV,
"#AR-Editor_AttributeCategory_GameSettings_Name", clientV);
118 m_CurrentDialog.SetMessage(msg);
124 SetDialogByTag(TAG_CHECKING_CONTENT);
134 SetDialogByTag(TAG_MOD_UGC_PRIVILEGE_MISSING);
139 DisplayWaitingQueue();
145 DisplayPasswordRequired();
152 SetDialogByTag(TAG_BACKEND_TIMEOUT);
159 SetDialogByTag(TAG_HIGH_PING_SERVER);
166 SetDialogByTag(TAG_UNRELATED_DOWNLOADS_CANCELING);
173 void SetDialogMessage(
string msg)
175 if (!m_CurrentDialog)
178 m_CurrentDialog.SetMessage(msg);
182 void CloseCurrentDialog()
185 m_CurrentDialog.Close();
193 if (CONFIG_DIALOGS.IsEmpty())
198 m_CurrentDialog.m_OnConfirm.Remove(OnDialogConfirm);
202 m_iOpenDialogCount++;
206 m_CurrentDialog.m_OnConfirm.Insert(OnDialogConfirm);
207 m_CurrentDialog.m_OnCancel.Insert(OnDialogCancel);
208 m_CurrentDialog.m_OnClose.Insert(OnDialogClose);
212 protected void OnDialogConfirm()
215 m_OnConfirm.Invoke();
219 protected void OnDialogCancel()
226 protected void InvokeOnCloseAll()
228 if (!Event_OnCloseAll)
231 Event_OnCloseAll.Invoke();
238 m_OnDialogClose.Invoke();
240 if (m_CurrentDialog == dialog)
249 void DisplayJoinFail(EApiCode apiError)
251 CloseCurrentDialog();
253 string errorTag = ERROR_TAG_DEFAULT;
259 case EApiCode.EACODE_ERROR_P2P_USER_JOIN_BAN: errorTag = TAG_BANNED;
break;
260 case EApiCode.EACODE_ERROR_DS_USER_JOIN_BAN: errorTag = TAG_BANNED;
break;
261 case EApiCode.EACODE_ERROR_USER_IS_BANNED_FROM_SHARED_GAME: errorTag = TAG_BANNED;
break;
262 case EApiCode.EACODE_ERROR_PLAYER_IS_BANNED: errorTag = TAG_BANNED;
break;
267 SetDialogByTag(errorTag);
275 string strApiError =
typename.EnumToString(EApiCode, apiError);
276 errorDialog.SetErrorDetail(
"#AR-Workshop_Error: " + strApiError);
282 void DisplayJoinBan(RoomJoinData
data)
284 CloseCurrentDialog();
286 SetDialogByTag(TAG_BANNED);
288 if (!m_CurrentDialog)
291 if (
data.expiresAt < 0)
294 int time =
data.expiresAt - System.GetUnixTime();
300 string message = STR_LIGHT_BAN;
303 if (
data.scope.Contains(OFFICIAL_SERVER_SCOPE))
304 message = STR_HEAVY_BAN;
306 int timeMinutes = time / 60;
307 m_CurrentDialog.SetMessage(WidgetManager.Translate(message, timeMinutes.ToString()));
314 dialog.GetOnAllReportsCanceled().Remove(OnAllReportsCanceled);
323 m_CurrentDialog.m_OnConfirm.Remove(OnDialogConfirm);
328 m_CurrentDialog.m_OnConfirm.Insert(OnDialogConfirm);
329 m_CurrentDialog.m_OnCancel.Insert(OnDialogCancel);
330 m_CurrentDialog.m_OnClose.Insert(OnDialogClose);
340 protected void OnDownloadingDone()
343 array<ref SCR_WorkshopItem> required = m_ModManager.GetRoomItemsScripted();
345 for (
int i = 0, count = required.Count(); i < count; i++)
348 if (!required[i].GetOffline())
352 if (m_OnDownloadComplete)
353 m_OnDownloadComplete.Invoke(m_JoinRoom);
362 CloseCurrentDialog();
371 protected void DisplayWaitingQueue()
373 SetDialogByTag(TAG_QUEUE_WAITING);
374 UpdateWaitingQueue();
377 TextWidget txtStateTitle = TextWidget.Cast(m_CurrentDialog.GetRootWidget().FindAnyWidget(
"TxtStateTitle"));
379 txtStateTitle.SetText(
"#AR-PlayerList_Header");
382 m_CurrentDialog.m_OnConfirm.Insert(OnWaitingQueueConfirm);
385 Print(
"[SCR_ServerBrowserDialogManager] displaying queue waiting dialog");
392 protected void DisplayPasswordRequired()
395 SetDialogByTag(TAG_PASSWORD_REQUIRED, editboxDialog);
397 editboxDialog.m_OnWriteModeLeave.Insert(OnPasswordEditboxChanged);
398 editboxDialog.FindButton(
"confirm").SetEnabled(
false);
403 protected void OnPasswordEditboxChanged(
string text)
410 navButton.SetEnabled(!text.IsEmpty());
412 navButton = m_CurrentDialog.FindButton(
"cancel");
414 navButton.SetEnabled(
true);
419 protected void OnServerBrowserAutoRefresh()
422 UpdateWaitingQueue();
428 if (m_ServerBrowser && m_OnJoinRoomDemand)
429 m_OnJoinRoomDemand.Invoke(m_JoinRoom);
431 m_CurrentDialog.m_OnConfirm.Remove(OnWaitingQueueConfirm);
436 protected void UpdateWaitingQueue()
443 int count = m_JoinRoom.PlayerCount();
444 int limit = m_JoinRoom.PlayerLimit();
446 if (!m_CurrentDialog)
450 TextWidget txtState = TextWidget.Cast(m_CurrentDialog.GetRootWidget().FindAnyWidget(
"TxtState"));
452 txtState.SetText(count.ToString() +
"/" + limit.ToString());
458 bool enable = limit - count > 0;
459 btnConfirm.SetEnabled(enable);
469 m_CurrentDialog = dialog;
478 m_CurrentDialog = dialog;
484 void FillRoomDetailsMods(array<ref SCR_WorkshopItem> items,
SCR_RoomModsManager modsManager =
null)
487 dialog.FillModList(items, modsManager);
491 void UpdateRoomDetailsScenarioImage(MissionWorkshopItem scenario)
495 dialog.SetScenarioImage(scenario);
525 if (!m_OnDialogClose)
528 return m_OnDialogClose;
534 if (!Event_OnCloseAll)
537 return Event_OnCloseAll;
543 if (!m_OnDownloadComplete)
546 return m_OnDownloadComplete;
552 if (!m_OnDownloadCancelDialogClose)
555 return m_OnDownloadCancelDialogClose;
561 if (!m_OnJoinRoomDemand)
564 return m_OnJoinRoomDemand;
577 return m_iDisplayState;
583 return m_CurrentDialog;
589 return GetCurrentDialog();
599 void SetJoinRoom(Room room)
607 m_ServerBrowser = serverBrowser;
611 m_ServerBrowser.m_OnAutoRefresh.Remove(OnServerBrowserAutoRefresh);
612 m_ServerBrowser.m_OnAutoRefresh.Insert(OnServerBrowserAutoRefresh);
619 m_ModManager = modManager;