13 const string TAG_DETAILS_FALLBACK_SEACHING =
"Searching";
14 const string TAG_DETAILS_FALLBACK_EMPTY =
"Empty";
15 const string TAG_MESSAGE_SEARCHING =
"SEARCHING";
16 const string TAG_MESSAGE_CONNECTING =
"CONNECTING";
18 const int SERVER_LIST_VIEW_SIZE = 32;
19 const int ROOM_CONTENT_LOAD_DELAY = 500;
20 const int ROOM_REFRESH_RATE = 10 * 1000;
24 static const int HIGH_PING_SERVER_THRESHOLD = 200;
26 protected bool m_bWaitForRefresh;
27 protected bool m_bHostedServers;
45 protected Widget m_wFirstServerEntry;
46 protected SCR_EListMenuWidgetFocus m_iFocusedWidgetState = SCR_EListMenuWidgetFocus.LIST;
49 protected bool m_bQuickJoin =
true;
52 protected Room m_RoomToJoin;
53 protected ref array<Room> m_aRooms = {};
54 protected ref array<Room> m_aDirectFoundRooms = {};
56 protected WorkshopApi m_WorkshopApi;
57 protected ClientLobbyApi m_Lobby;
68 protected ref OnDirectJoinCallback m_CallbackSearchTarget =
new OnDirectJoinCallback();
72 protected bool m_bFirstRoomLoad =
true;
73 protected bool m_bForceUnfilteredRequest;
74 protected int m_iTotalNumberOfRooms;
80 protected ref RoomJoinData m_JoinData =
new RoomJoinData();
89 protected ref array<ref SCR_WorkshopItem> m_aRequiredMods = {};
90 protected ref array<ref SCR_WorkshopItemActionDownload> m_aUnrelatedDownloads = {};
94 protected MissionWorkshopItem m_RoomScenario;
100 protected bool m_bIsWaitingForBackend =
true;
104 protected ref SCR_GetRoomsIds m_SearchIds =
new SCR_GetRoomsIds();
105 protected Room m_RejoinRoom;
107 protected ref array<ref SCR_FilterEntry> m_aFiltersToSelect = {};
108 protected bool m_bIsCheckingSpecificfilter;
111 ref ScriptInvoker m_OnAutoRefresh =
new ScriptInvoker();
112 ref ScriptInvoker m_OnScenarioLoad =
new ScriptInvoker();
117 protected EInputDeviceType m_eLastInputType;
118 protected bool m_bWasEntrySelected;
127 override void OnMenuOpen()
131 m_Lobby =
GetGame().GetBackendApi().GetClientLobby();
143 m_CallbackAutoRefresh.m_OnSuccess.Insert(OnRoomAutoRefresh);
145 SetupParams(m_Lobby);
149 Messages_ShowMessage(TAG_MESSAGE_SEARCHING);
151 Messages_ShowMessage(TAG_MESSAGE_CONNECTING,
true);
153 if (m_ScrollableList)
154 m_ScrollableList.ShowEmptyRooms();
158 if (m_ActionsComponent)
159 m_ActionsComponent.GetOnAction().Insert(OnActionTriggered);
161 UpdateNavigationButtons();
163 SwitchFocus(SCR_EListMenuWidgetFocus.SORTING);
169 override void OnMenuOpened()
176 super.OnMenuOpened();
182 override void OnMenuFocusGained()
185 if (m_bHostedServers)
186 GetGame().GetCallqueue().CallLater(FocusWidget, 0,
false,
m_Widgets.m_wHostNewServerButton);
188 SwitchFocus(SCR_EListMenuWidgetFocus.LIST,
true);
190 super.OnMenuFocusGained();
192 if (m_ActionsComponent)
193 m_ActionsComponent.ActivateActions();
198 override void OnMenuClose()
205 ClearScenarioFilters();
209 m_TabView.GetOnChanged().Remove(OnTabViewSwitch);
212 m_Lobby.StoreParams();
215 m_Lobby.SetRefreshCallback(
null);
217 m_ScrollableList.GetOnSetPage().Remove(CallOnServerListSetPage);
218 m_CallbackAutoRefresh.m_OnSuccess.Clear();
220 ClearConnectionTimeoutWaiting();
223 m_FilterPanel.Save();
230 override protected void OnMenuUpdate(
float tDelta)
232 super.OnMenuUpdate(tDelta);
235 if (m_bIsWaitingForBackend)
236 WaitingForRunningBackend();
239 if (m_ScrollableList)
240 m_ScrollableList.UpdateScroll();
243 EInputDeviceType inputDeviceType =
GetGame().GetInputManager().GetLastUsedInputDevice();
244 bool isEntrySelected = GetSelectedEntry();
245 bool shouldUpdateButtons = inputDeviceType != m_eLastInputType || isEntrySelected != m_bWasEntrySelected;
247 if (shouldUpdateButtons)
248 UpdateNavigationButtons();
250 m_eLastInputType = inputDeviceType;
251 m_bWasEntrySelected = isEntrySelected;
255 override void OnMenuShow()
259 if (m_ActionsComponent)
260 m_ActionsComponent.ActivateActions();
267 protected void UpdateNavigationButtons()
273 bool versionMismatch, unjoinable;
274 bool enabled = entry && entry.GetIsEnabled(versionMismatch, unjoinable);
275 bool visible = entry &&
GetGame().GetInputManager().GetLastUsedInputDevice() != EInputDeviceType.MOUSE;
278 m_Widgets.m_JoinButton.SetVisible(visible && !unjoinable,
false);
281 m_Widgets.m_DetailsButton.SetVisible(visible && !unjoinable,
false);
284 m_Widgets.m_FavoritesButton.SetVisible(visible && enabled,
false);
286 if (!enabled || !visible)
289 Room room = entry.GetRoomInfo();
294 m_Widgets.m_FavoritesButton.SetLabel(GetFavoriteLabel(room.IsFavorite()));
298 protected void OnActionTriggered(
string action,
float multiplier)
308 case "MenuSelectDouble": OnServerEntryClickInteraction(multiplier);
break;
309 case "MenuServerDetails": OnActionDetails();
break;
310 case "MenuFavourite": OnActionFavorite();
break;
316 [MenuBindAttribute()]
317 void OnActionRefresh()
319 m_bForceUnfilteredRequest =
true;
326 PrintDebug(
"m_RejoinRoom: " + m_RejoinRoom,
"OnActionRefresh");
329 if (!
GetGame().GetPlatformService().GetPrivilege(UserPrivilege.MULTIPLAYER_GAMEPLAY))
331 Messages_ShowMessage(
"MISSING_PRIVILEGE_MP");
333 NegotiatePrivilegeAsync(UserPrivilege.MULTIPLAYER_GAMEPLAY);
339 m_CallbackScroll.GetEventOnResponse().Remove(OnScrollResponse);
342 if (m_ScrollableList)
344 m_ScrollableList.MoveToTop();
345 m_ScrollableList.ShowEmptyRooms();
346 m_ScrollableList.ShowScrollbar(
false);
352 m_Lobby.SetRefreshCallback(
null);
355 if (m_bFirstRoomLoad)
358 GetGame().GetCallqueue().CallLater(SearchRooms, ROOM_CONTENT_LOAD_DELAY,
false);
361 Messages_ShowMessage(TAG_MESSAGE_SEARCHING);
363 Messages_ShowMessage(TAG_MESSAGE_CONNECTING,
true);
365 if (m_ServerScenarioDetails)
366 m_ServerScenarioDetails.SetDefaultScenario(TAG_DETAILS_FALLBACK_SEACHING);
371 [MenuBindAttribute()]
372 void OnActionManualConnect()
376 if (!multiplayerDialog)
380 multiplayerDialog.m_OnConfirm.Clear();
381 multiplayerDialog.m_OnConfirm.Insert(JoinActions_DirectJoin);
384 multiplayerDialog.m_OnCancel.Clear();
385 multiplayerDialog.m_OnCancel.Insert(OnDirectJoinCancel);
390 [MenuBindAttribute()]
391 void OnActionFilter()
396 SCR_EListMenuWidgetFocus focus = SCR_EListMenuWidgetFocus.FILTERING;
397 if (m_FilterPanel.GetFilterListBoxShown())
398 focus = SCR_EListMenuWidgetFocus.LIST;
401 m_FilterPanel.ShowFilterListBox(focus == SCR_EListMenuWidgetFocus.FILTERING);
407 [MenuBindAttribute()]
415 void OnActionFavorite()
419 Debug.Error(
"No entry selected.");
422 m_ServerEntry.SetFavorite(!m_ServerEntry.IsFavorite());
427 void OnActionDetails()
433 m_bQuickJoin =
false;
436 Room room = entry.GetRoomInfo();
437 if (room && room.Joinable())
442 protected void OnServerEntryClickInteraction(
float multiplier)
447 if (!entry || !GetEntryUnderCursor())
450 switch (Math.Floor(multiplier))
452 case 1: OnServerEntryClick(entry);
break;
453 case 2: OnServerEntryDoubleClick(entry);
break;
456 m_ClickedEntry =
null;
463 if (entry != m_ServerEntry)
464 OnServerEntryFocusEnter(entry);
469 if (entry && entry.GetRoomInfo() && entry.GetRoomInfo().Joinable())
474 protected void OnEntryMouseButton(
string tag)
476 OnServerEntryDoubleClick(GetSelectedEntry());
480 protected void OnJoinButton()
482 OnServerEntryClick(GetSelectedEntry());
491 if (entry != m_ServerEntry)
492 OnServerEntryFocusEnter(entry);
494 m_RoomToJoin = entry.GetRoomInfo();
497 m_bQuickJoin =
GetGame().GetInputManager().GetLastUsedInputDevice() != EInputDeviceType.MOUSE;
500 if (entry.GetRoomInfo() && entry.GetRoomInfo().Joinable())
511 protected void WaitingForRunningBackend()
513 if (!IsBackendReady())
517 string lastId = m_Lobby.GetPreviousRoomId();
519 if (!m_Lobby.IsPingAvailable())
522 ClearConnectionTimeoutWaiting();
529 m_bIsWaitingForBackend =
false;
533 protected bool IsBackendReady()
535 auto ba =
GetGame().GetBackendApi();
536 return ba.IsActive() && ba.IsAuthenticated();
540 protected void CheckBackendState()
542 if (!IsBackendReady())
544 m_bIsWaitingForBackend =
true;
545 GetGame().GetCallqueue().Remove(ConnectionTimeout);
551 protected void ShowTimeoutDialog()
553 Messages_ShowMessage(
"NO_CONNECTION");
557 m_Dialogs.GetOnConfirm().Clear();
558 m_Dialogs.GetOnConfirm().Insert(OnConnectionTimeoutDialogConfirm);
563 protected void ConnectionTimeout()
565 if (!IsBackendReady())
569 ClearConnectionTimeoutWaiting();
571 m_bIsWaitingForBackend =
false;
575 protected void OnConnectionTimeoutDialogConfirm()
577 m_Dialogs.GetOnConfirm().Remove(OnConnectionTimeoutDialogConfirm);
580 Messages_ShowMessage(TAG_MESSAGE_SEARCHING);
582 Messages_ShowMessage(TAG_MESSAGE_CONNECTING,
true);
586 protected void ClearConnectionTimeoutWaiting()
588 GetGame().GetCallqueue().Remove(ConnectionTimeout);
594 protected void OnRoomsFound(array<Room> rooms =
null)
597 ClientLobbyApi lobby =
GetGame().GetBackendApi().GetClientLobby();
607 lobby.Rooms(m_aRooms);
610 if (m_aRooms.IsEmpty())
612 PrintDebug(
"No room found",
"OnRoomsFound");
617 lobby.SetRefreshCallback(m_CallbackAutoRefresh);
618 lobby.SetRefreshRate(ROOM_REFRESH_RATE);
620 DisplayRooms(m_aRooms);
623 if (m_ScrollableList)
625 if (m_ScrollableList.IsListFocused() || m_bFirstRoomLoad)
627 m_ScrollableList.FocusFirstAvailableEntry();
631 if (m_bFirstRoomLoad)
633 m_ScrollableList.SetIsListFocused(
true);
634 m_bFirstRoomLoad =
false;
637 m_ScrollableList.ShowScrollbar(
true);
639 int currentRoomsCount = m_Lobby.TotalRoomCount();
640 if (currentRoomsCount > m_iTotalNumberOfRooms)
641 m_iTotalNumberOfRooms = currentRoomsCount;
645 m_FilterPanel.SetItemsFoundMessage(m_Lobby.TotalRoomCount(), m_iTotalNumberOfRooms, m_Lobby.TotalRoomCount() != m_iTotalNumberOfRooms);
649 protected void DisplayRooms(array<Room> rooms =
null)
652 if (!
GetGame().GetPlatformService().GetPrivilege(UserPrivilege.MULTIPLAYER_GAMEPLAY))
658 if (!m_ScrollableList || !m_ServerScenarioDetails)
660 PrintDebug(
"Missing important component references!",
"DisplayRooms");
669 PrintDebug(
"Could not find addon mngr to verify ugc privilege",
"DisplayRooms");
674 if (m_ParamsFilter.IsModdedFilterSelected() && !addonMgr.GetUgcPrivilege())
676 Messages_ShowMessage(
"MISSING_PRIVILEGE_UGC");
679 addonMgr.m_OnUgcPrivilegeResult.Insert(Platform_OnUgcPrivilegeResult);
680 addonMgr.NegotiateUgcPrivilegeAsync();
682 SwitchFocus(SCR_EListMenuWidgetFocus.LIST);
684 m_FilterPanel.ShowFilterListBox(
false);
689 int roomCount = m_Lobby.TotalRoomCount();
695 m_ScrollableList.SetRooms(rooms, 0,
true);
696 m_ScrollableList.ShowEmptyRooms();
698 if (m_ServerScenarioDetails)
699 m_ServerScenarioDetails.SetDefaultScenario(TAG_DETAILS_FALLBACK_EMPTY);
702 if (!m_FilterPanel.GetFilterListBoxShown())
703 SwitchFocus(SCR_EListMenuWidgetFocus.FILTERING);
705 m_FilterPanel.ShowFilterListBox(
true);
708 Messages_ShowMessage(
"NO_FILTERED_SERVERS");
715 m_ScrollableList.SetRooms(m_aRooms, m_Lobby.TotalRoomCount(),
true);
720 if (m_FilterPanel && !m_FilterPanel.GetFilterListBoxShown())
721 SwitchFocus(SCR_EListMenuWidgetFocus.LIST);
731 m_Lobby.SetRefreshRate(ROOM_REFRESH_RATE);
732 DisplayRooms(m_aRooms);
734 m_bWaitForRefresh =
false;
736 m_OnAutoRefresh.Invoke();
742 protected void SearchRooms()
747 m_ServerEntry =
null;
751 m_Lobby.SetRefreshCallback(
null);
753 if (!m_bFirstRoomLoad && !m_bForceUnfilteredRequest)
755 SearchRoomsFiltered();
763 searchCallback.m_OnSuccess.Insert(OnSearchAllRoomsSuccess);
764 searchCallback.m_OnFail.Insert(OnSearchAllRoomsFail);
765 searchCallback.m_OnTimeOut.Insert(OnSearchAllRoomsTimeOut);
767 m_CallbackLastSearch = searchCallback;
770 m_Lobby.SearchRooms(
params, searchCallback);
786 protected void OnSearchAllRoomsTimeOut()
792 protected void OnSearchAllRooms()
794 m_CallbackLastSearch =
null;
797 m_iTotalNumberOfRooms = m_Lobby.TotalRoomCount();
799 SearchRoomsFiltered();
804 protected void SearchRoomsFiltered()
806 if (m_ScrollableList)
807 m_Lobby.SetViewSize(m_ScrollableList.GetPageEntriesCount() * 2);
809 m_Lobby.SetViewSize(SERVER_LIST_VIEW_SIZE);
815 searchCallback.m_OnSuccess.Insert(OnSearchRoomsSuccess);
816 searchCallback.m_OnFail.Insert(OnSearchRoomsFail);
817 searchCallback.m_OnTimeOut.Insert(OnSearchRoomsTimeOut);
819 m_CallbackLastSearch = searchCallback;
821 m_Lobby.SearchRooms(m_ParamsFilter, searchCallback);
827 PrintDebug(
string.Format(
"Success - servers found: %1", m_Lobby.TotalRoomCount()),
"OnSearchRoomsSuccess");
831 m_CallbackLastSearch =
null;
833 PrintDebug(
"AFTER - m_RejoinRoom: " + m_RejoinRoom,
"OnSearchRoomsSuccess");
839 PrintDebug(
string.Format(
"Room search fail - code: %1 | restCode: %2 | apiCode: %3", code, restCode, apiCode),
"OnSearchRoomsFail");
840 m_CallbackLastSearch =
null;
843 if (m_bFirstRoomLoad && m_ParamsFilter.GetSortOrder() == m_ParamsFilter.SORT_PING)
849 Messages_ShowMessage(
"BACKEND_SERVICE_FAIL");
853 protected void OnSearchRoomsTimeOut()
856 PrintDebug(
"time out!",
"OnSearchRoomsTimeOut");
861 protected void SetupParams(ClientLobbyApi lobby)
867 string strParams = lobby.GetStrParams();
868 if (!strParams.IsEmpty())
870 m_ParamsFilter.ExpandFromRAW(strParams);
881 m_ParamsFilter.SetSearch(
string.Empty);
883 SetupFilteringUI(m_ParamsFilter);
894 m_TabView.ShowTab(m_ParamsFilter.GetSelectedTab());
899 bool show = m_FilterPanel.AnyFilterButtonsVisible();
900 m_FilterPanel.ShowFilterListBox(show, show);
906 protected void SetupCallbacks()
909 SCR_MenuLoadingComponent.m_OnMenuOpening.Insert(OnOpeningByLoadComponent);
912 m_ScrollableList.GetOnSetPage().Insert(CallOnServerListSetPage);
927 Room room = serverEntry.GetRoomInfo();
930 m_ServerEntry =
null;
934 DisplayFavoriteAction(room.IsFavorite());
935 UpdateNavigationButtons();
936 serverEntry.m_OnClick.Insert(OnEntryMouseClick);
938 if (m_ServerEntry == serverEntry)
941 m_ServerEntry = serverEntry;
947 ReceiveRoomContent(m_RoomToJoin,
true);
955 serverEntry.m_OnClick.Remove(OnEntryMouseClick);
965 protected void ReceiveRoomContent(notnull Room room,
bool receiveMods)
967 GetGame().GetCallqueue().Remove(ReceiveRoomContent_Mods);
969 if (m_ServerScenarioDetails)
970 m_ServerScenarioDetails.DisplayRoomData(room, receiveMods);
973 if (!room.IsAuthorized())
979 array<Dependency> roomMod = {};
980 room.GetItems(roomMod);
983 if (!roomMod.IsEmpty() && m_ServerScenarioDetails)
984 m_ServerScenarioDetails.DisplayModsCount(roomMod.Count());
987 if (room.IsDownloadListLoaded())
989 ReceiveRoomContent_Mods(room);
995 GetGame().GetCallqueue().CallLater(ReceiveRoomContent_Mods, ROOM_CONTENT_LOAD_DELAY,
false, room);
1002 protected void ReceiveRoomContent_Scenario()
1012 protected void ReceiveRoomContent_Mods(Room room)
1017 m_ModsManager.GetOnGetAllDependencies().Insert(OnLoadingDependencyList);
1025 protected void SetupHandlers()
1031 m_TabView.GetOnChanged().Insert(OnTabViewSwitch);
1032 OnTabViewSwitch(
null,
null,
m_TabView.GetShownTab());
1035 m_TabView.AddTab(
"",
"#AR-Workshop_ButtonHost");
1043 m_FilterPanel.GetOnFilterPanelToggled().Insert(OnFilterPanelToggle);
1044 m_FilterPanel.GetOnFilterChanged().Insert(OnChangeFilter);
1047 m_FilterPanel.TryLoad();
1048 m_ParamsFilter.SetFilters(m_FilterPanel.GetFilter());
1050 FilterCrossplayCheck();
1058 m_SortBar.m_OnChanged.Insert(OnChangeSort);
1062 m_SortBar.SetCurrentSortElement(3,
ESortOrder.DESCENDING);
1070 if (m_SearchEditBox)
1071 m_SearchEditBox.m_OnConfirm.Insert(OnSearchEditBoxConfirm);
1079 array<SCR_ServerBrowserEntryComponent> entries = m_ScrollableList.GetRoomEntries();
1084 entry.GetOnFocus().Insert(OnServerEntryFocusEnter);
1085 entry.GetOnFocusLost().Insert(OnServerEntryFocusLeave);
1086 entry.GetOnFavorite().Insert(OnRoomEntrySetFavorite);
1087 entry.GetOnMouseInteractionButtonClicked().Insert(OnEntryMouseButton);
1096 if (m_ServerScenarioDetails)
1102 if (m_SimpleMessageList)
1103 m_SimpleMessageList.SetVisible(
false);
1107 m_Widgets.m_JoinButton.m_OnActivated.Insert(OnJoinButton);
1108 m_Widgets.m_DetailsButton.m_OnActivated.Insert(OnActionDetails);
1109 m_Widgets.m_FavoritesButton.m_OnActivated.Insert(OnActionFavorite);
1117 protected void FilterCrossplayCheck()
1122 bool hasCrossplay =
GetGame().GetPlatformService().GetPrivilege(UserPrivilege.CROSS_PLAY);
1138 enabled.SetSelected(
false);
1139 m_FilterPanel.SelectFilter(enabled,
false,
false);
1145 disabled.SetSelected(
true);
1146 m_FilterPanel.SelectFilter(disabled,
true,
false);
1155 protected void SwitchFocus(SCR_EListMenuWidgetFocus focus,
bool force =
false)
1157 if (m_iFocusedWidgetState == focus && !force)
1164 case SCR_EListMenuWidgetFocus.LIST:
1166 if (m_ServerEntry && m_ServerEntry.IsVisible())
1167 focusTarget = m_ServerEntry.GetRootWidget();
1168 else if (m_ScrollableList)
1169 focusTarget = m_ScrollableList.FirstAvailableEntry();
1174 case SCR_EListMenuWidgetFocus.FILTERING:
1176 focusTarget = m_FilterPanel.GetWidgets().m_FilterButton;
1180 case SCR_EListMenuWidgetFocus.SORTING:
1182 focusTarget =
m_Widgets.m_wSortSessionFavorite;
1187 m_iFocusedWidgetState = focus;
1189 if (!focusTarget || !focusTarget.IsVisible())
1192 focusTarget =
m_Widgets.m_wSortSessionFavorite;
1193 m_iFocusedWidgetState = SCR_EListMenuWidgetFocus.SORTING;
1196 GetGame().GetWorkspace().SetFocusedWidget(focusTarget);
1202 void ActivateFilter(
string filterName,
bool enabled,
bool processFilters =
true)
1206 filter.m_sInternalName = filterName;
1207 filter.SetSelected(
true);
1210 m_aFiltersToSelect.Insert(filter);
1214 ActivateFiltersFromList();
1218 protected void ActivateFiltersFromList()
1221 if (!m_aFiltersToSelect || m_aFiltersToSelect.IsEmpty())
1225 if (!m_FilterPanel || !m_ParamsFilter)
1240 SCR_FilterEntry targetFilter = filterSet.FindFilter(filter.m_sInternalName);
1243 if (targetFilter && targetFilter.GetSelected() != filter.GetSelected())
1245 targetFilter.SetSelected(filter.GetSelected());
1246 m_FilterPanel.SelectFilter(targetFilter, filter.GetSelected());
1251 m_aFiltersToSelect.Clear();
1254 m_ParamsFilter.SetFilters(filterSet);
1260 protected void FocusWidget(Widget w)
1262 GetGame().GetWorkspace().SetFocusedWidget(w);
1266 protected void CallOnServerListSetPage(
int page)
1268 GetGame().GetCallqueue().Remove(OnServerListSetPage);
1269 GetGame().GetCallqueue().CallLater(OnServerListSetPage, ROOM_CONTENT_LOAD_DELAY,
false, page);
1275 protected void Messages_ShowMessage(
string messageTag,
bool showWrap =
false)
1278 if (!
m_Widgets.m_wPanelEmpty || !m_SimpleMessageWrap || !m_SimpleMessageList)
1280 string msg =
string.Format(
"Missing ref - WrapLayout: %1 Wrap: %2, List: %3",
m_Widgets.m_wPanelEmpty, m_SimpleMessageWrap, m_SimpleMessageList);
1281 PrintDebug(msg,
"Messages_ShowMessage");
1287 m_Widgets.m_wContent.SetVisible(!showWrap);
1289 m_Widgets.m_wPanelEmpty.SetVisible(showWrap);
1292 m_SimpleMessageWrap.SetVisible(showWrap);
1293 m_SimpleMessageList.SetVisible(!showWrap);
1296 m_SimpleMessageWrap.SetContentFromPreset(messageTag);
1297 m_SimpleMessageList.SetContentFromPreset(messageTag);
1301 m_Widgets.m_RefreshButton.SetVisible(!showWrap,
false);
1304 m_Widgets.m_DirectJoinButton.SetVisible(!showWrap,
false);
1307 m_Widgets.m_FilterButton.SetVisible(!showWrap,
false);
1312 protected void Messages_Hide()
1314 Widget wrapLayout =
m_Widgets.m_wPanelEmpty;
1317 if (!wrapLayout || !m_SimpleMessageWrap || !m_SimpleMessageList)
1319 string msg =
string.Format(
"Missing ref - WrapLayout: %1 Wrap: %2, List: %3", wrapLayout, m_SimpleMessageWrap, m_SimpleMessageList);
1320 PrintDebug(msg,
"Messages_Hide");
1325 m_SimpleMessageWrap.SetVisible(
false);
1326 m_SimpleMessageList.SetVisible(
false);
1328 wrapLayout.SetVisible(
false);
1336 protected void DisplayFavoriteAction(
bool favorited)
1338 string label = GetFavoriteLabel(favorited);
1341 m_Widgets.m_FavoritesButton.SetLabel(label);
1349 protected void OnOpeningByLoadComponent(
int menuPreset)
1360 if (!m_ParamsFilter)
1364 bool sortAscending = sortHeader.GetSortOrderAscending();
1365 string sortElementName = sortHeader.GetSortElementName();
1366 m_ParamsFilter.SetSorting(sortElementName, sortAscending);
1368 if (!m_bFirstRoomLoad)
1377 m_ParamsFilter.SetFavoriteFilter(
false);
1378 m_ParamsFilter.SetRecentlyPlayedFilter(
false);
1379 m_ParamsFilter.SetOwnedOnly(
false);
1380 m_bHostedServers =
false;
1382 m_Widgets.m_wHostNewServerButton.SetVisible(
false);
1389 m_ParamsFilter.SetOfficialFilter(
false,
false);
1396 m_ParamsFilter.SetOfficialFilter(
true,
false);
1403 m_ParamsFilter.SetOfficialFilter(
true,
true);
1410 m_ParamsFilter.SetFavoriteFilter(
true);
1411 m_ParamsFilter.SetOfficialFilter(
false,
false);
1418 m_ParamsFilter.SetRecentlyPlayedFilter(
true);
1419 m_ParamsFilter.SetOfficialFilter(
false,
false);
1427 GetGame().GetCallqueue().CallLater(FocusWidget, 0,
false,
m_Widgets.m_wHostNewServerButton);
1430 m_ParamsFilter.SetOfficialFilter(
false,
false);
1431 m_ParamsFilter.SetOwnedOnly(
true);
1432 m_bHostedServers =
true;
1439 m_Widgets.m_wHostNewServerButton.SetVisible(m_bHostedServers);
1440 m_Widgets.m_wHostNewServerButton.SetEnabled(m_bHostedServers);
1444 m_ParamsFilter.SetSelectedTab(
id);
1446 if (!m_bFirstRoomLoad)
1449 Widget focus =
GetGame().GetWorkspace().GetFocusedWidget();
1450 if (!m_FilterPanel || !m_FilterPanel.GetFilterListBoxShown() || !focus || !focus.IsVisible())
1451 SwitchFocus(SCR_EListMenuWidgetFocus.LIST,
true);
1455 protected void OnFilterPanelToggle(
bool show)
1461 if (show || m_Lobby.TotalRoomCount() == 0)
1463 SwitchFocus(SCR_EListMenuWidgetFocus.FILTERING);
1468 SwitchFocus(SCR_EListMenuWidgetFocus.LIST);
1477 m_ParamsFilter.SetFilters(m_FilterPanel.GetFilter());
1481 bool hasCrossplay =
GetGame().GetPlatformService().GetPrivilege(UserPrivilege.CROSS_PLAY);
1487 if (filter.GetCategory().m_sInternalName ==
"Crossplay")
1489 if (!m_CallbackGetPrivilege)
1492 m_CallbackGetPrivilege.m_OnResult.Insert(OnCrossPlayPrivilegeResultFilter);
1493 NegotiatePrivilegeAsync(UserPrivilege.CROSS_PLAY);
1498 protected void OnCrossPlayPrivilegeResultFilter(UserPrivilege privilege, UserPrivilegeResult result)
1500 if (privilege == UserPrivilege.CROSS_PLAY)
1502 if (result != UserPrivilegeResult.ALLOWED)
1504 FilterCrossplayCheck();
1509 m_CallbackGetPrivilege.m_OnResult.Remove(OnCrossPlayPrivilegeResultFilter);
1514 protected void OnServerListSetPage(
int page)
1517 if (!m_ScrollableList)
1521 int entriesC = m_ScrollableList.GetPageEntriesCount();
1522 int pos = entriesC * page;
1526 m_CallbackScroll.GetEventOnResponse().Insert(OnScrollResponse);
1528 array<Room> rooms = {};
1529 m_Lobby.Rooms(rooms);
1530 m_Lobby.Scroll(pos, m_CallbackScroll);
1537 switch (
callback.GetResponseType())
1547 PrintDebug(
"Scroll error!",
"OnScrollResponse");
1553 PrintDebug(
"Scroll timeout!",
"OnScrollResponse");
1563 bool loadedRoomFocused =
false;
1564 if (m_ServerEntry && !m_ScrollableList.IsRoomLoaded(m_ServerEntry))
1565 loadedRoomFocused =
true;
1568 m_Lobby.Rooms(m_aRooms);
1570 if (m_aRooms.IsEmpty())
1572 PrintDebug(
"No room found",
"OnScrollSuccess");
1574 if (m_Lobby.TotalRoomCount() > 0)
1576 if (m_ScrollableList)
1577 CallOnServerListSetPage(m_ScrollableList.GetCurrentPage());
1583 m_ScrollableList.UpdateLoadedPage();
1585 DisplayRooms(m_aRooms);
1588 if (loadedRoomFocused)
1589 ReceiveRoomContent(m_ServerEntry.GetRoomInfo(),
true);
1596 m_ParamsFilter.SetSearch(sInput);
1608 Room roomClicked = serverEntry.GetRoomInfo();
1612 int roomId = m_aRooms.Find(roomClicked);
1617 m_CallbackFavorite.SetRoom(roomClicked);
1618 m_CallbackFavorite.GetEventOnResponse().Insert(OnRoomSetFavoriteResponse);
1620 m_aRooms[roomId].SetFavorite(favorite, m_CallbackFavorite);
1626 switch (
callback.GetResponseType())
1632 DisplayFavoriteAction(
callback.GetRoom().IsFavorite());
1633 m_OnFavoritesResponse.Invoke();
1643 m_CallbackFavorite.SetRoom(
null);
1644 m_CallbackFavorite.GetEventOnResponse().Remove(OnRoomSetFavoriteResponse);
1650 protected void OnLoadingDependencyList()
1653 m_ModsManager.GetOnGetAllDependencies().Remove(OnLoadingDependencyList);
1655 array<ref SCR_WorkshopItem> updated =
m_ModsManager.GetRoomItemsUpdated();
1656 array<ref SCR_WorkshopItem> outdated =
m_ModsManager.GetRoomItemsToUpdate();
1659 bool modsUpdated = outdated.IsEmpty();
1661 if (m_ServerScenarioDetails)
1662 m_ServerScenarioDetails.DisplayMods();
1664 ReceiveRoomContent_Scenario();
1670 protected void OnModListFail(Room room)
1672 if (m_ModListFailDialog)
1676 m_ModListFailDialog.m_OnClose.Insert(OnModListFailDialogClose);
1682 m_ModListFailDialog =
null;
1688 protected void OnLoadingScenario(Dependency scenario)
1694 Room roomInfo =
null;
1697 roomInfo = m_ServerEntry.GetRoomInfo();
1702 MissionWorkshopItem scenarioItem = roomInfo.HostScenario();
1706 Dependency scenarioMod = roomInfo.HostScenarioMod();
1707 bool hideScenario = scenarioMod && !mgr.GetUgcPrivilege();
1710 if (m_ServerScenarioDetails)
1713 m_ServerScenarioDetails.SetHideScenarioImg(hideScenario);
1717 m_ServerScenarioDetails.SetScenario(scenarioItem);
1720 m_ServerScenarioDetails.DisplayDefaultScenarioImage();
1725 m_Dialogs.UpdateRoomDetailsScenarioImage(scenarioItem);
1727 m_RoomScenario = scenarioItem;
1729 m_OnScenarioLoad.Invoke(m_RoomScenario);
1734 protected void OnRejoinCancel()
1742 protected void OnDirectJoinCancel()
1750 protected MissionWorkshopItem MissionFromMod(Dependency scenario)
1755 WorkshopItem item = scenario.GetCachedItem();
1759 Revision rev = item.GetActiveRevision();
1763 array<MissionWorkshopItem> scenarios = {};
1764 rev.GetScenarios(scenarios);
1765 if (scenarios.IsEmpty())
1768 for (
int i = 0, count = scenarios.Count(); i < count; i++)
1770 if (scenarios[i].
GetOwner() == item)
1771 return scenarios[i];
1780 protected bool CanJoinRoom(Room room)
1784 PrintDebug(
"No room found for can join room check",
"CanJoinRoom");
1789 bool versionMatch = ClientRoomVersionMatch(room);
1793 return versionMatch && !
m_ModsManager.HasBlockedMods() && room.Joinable();
1797 protected bool ClientRoomVersionMatch(Room room)
1802 string clientV =
GetGame().GetBuildVersion();
1803 string roomV = room.GameVersion();
1806 return (clientV == roomV);
1810 protected string GetFavoriteLabel(
bool isFavorite)
1821 Widget w = WidgetManager.GetWidgetUnderCursor();
1833 Widget wfocused =
GetGame().GetWorkspace().GetFocusedWidget();
1838 EInputDeviceType inputDevice =
GetGame().GetInputManager().GetLastUsedInputDevice();
1839 bool isCursorOnInnerButton = m_ServerEntry && m_ServerEntry.IsInnerButtonInteraction();
1841 if (inputDevice == EInputDeviceType.MOUSE && (GetEntryUnderCursor() || isCursorOnInnerButton))
1842 return m_ServerEntry;
1848 protected void ClearScenarioFilters()
1850 if (!m_ParamsFilter)
1853 m_ParamsFilter.SetScenarioId(
"");
1854 m_ParamsFilter.SetHostedScenarioModId(
"");
1858 protected void SetMenuHeader(
string header)
1861 m_MenuHeader.SetTitle(header);
1868 void FilterScenarioId(
string scenarioId)
1871 m_ParamsFilter.SetScenarioId(scenarioId);
1875 void FilterHostedScenarioModId(
string scenarioModId)
1878 m_ParamsFilter.SetHostedScenarioModId(scenarioModId);
1882 void SetFilteredScenario(MissionWorkshopItem scenario)
1885 m_Widgets.m_HostButton.SetScenario(scenario);
1890 static void OpenWithScenarioFilter(MissionWorkshopItem mission)
1897 string scenarioId = mission.Id();
1898 sb.FilterScenarioId(scenarioId);
1902 WorkshopItem owner = mission.GetOwner();
1906 if (modId !=
string.Empty)
1907 sb.FilterHostedScenarioModId(modId);
1909 sb.SetMenuHeader(mission.Name());
1910 sb.SetFilteredScenario(mission);
1915 static bool IsServerPingAboveThreshold(Room room)
1918 return room && room.GetPing() >= HIGH_PING_SERVER_THRESHOLD;
1926 protected void JoinActions_Join()
1931 PrintDebug(
"Quick join is not possible because there is no selected server",
"JoinActions_Join");
1936 Room roomToJoin = m_ServerEntry.GetRoomInfo();
1938 JoinProcess_Init(roomToJoin);
1940 GameSessionStorage.s_Data[
"m_iRejoinAttempt"] =
"0";
1947 JoinProcess_FindRoom(
params, format, publicNetwork);
1948 GameSessionStorage.s_Data[
"m_iRejoinAttempt"] =
"0";
1953 protected void OnLastRoomReconnectConfirm()
1959 string lastId = m_Lobby.GetPreviousRoomId();
1960 JoinProcess_FindRoomById(lastId, m_CallbackSearchPreviousRoom);
1975 m_DirectJoinParams.SetHostAddress(
params);
1982 m_DirectJoinParams.SetJoinCode(
params);
1989 PrintDebug(
"Invalid format of direct join",
"JoinProcess_FindRoom");
1995 m_DirectJoinParams.SetUsePlayerLimit(
false);
1996 m_Lobby.SearchTarget(m_DirectJoinParams, m_CallbackSearchTarget);
2004 m_CallbackSearchTarget.m_OnSuccess.Insert(JoinProcess_OnFindRoomSuccess);
2005 m_CallbackSearchTarget.m_OnFail.Insert(JoinProcess_OnFindRoomFail);
2006 m_CallbackSearchTarget.m_OnTimeOut.Insert(JoinProcess_OnFindRoomTimeout);
2013 m_aDirectFoundRooms = m_CallbackSearchTarget.GetFoundRooms();
2014 if (m_aDirectFoundRooms.IsEmpty())
2016 PrintDebug(
"No room found through direct join!",
"JoinProcess_OnFindRoomSuccess");
2021 if (!m_aDirectFoundRooms || m_aDirectFoundRooms.Count() < 1)
2029 if (m_aDirectFoundRooms.Count() == 1)
2034 m_RoomToJoin = m_aDirectFoundRooms[0];
2035 JoinProcess_Init(m_RoomToJoin);
2040 OnRoomsFound(m_aDirectFoundRooms);
2044 JoinProcess_CleanFindCallback();
2054 JoinProcess_CleanFindCallback();
2064 JoinProcess_CleanFindCallback();
2068 protected void JoinProcess_CleanFindCallback()
2070 m_CallbackSearchTarget.m_OnSuccess.Remove(JoinProcess_OnFindRoomSuccess);
2071 m_CallbackSearchTarget.m_OnFail.Remove(JoinProcess_OnFindRoomFail);
2072 m_CallbackSearchTarget.m_OnTimeOut.Remove(JoinProcess_OnFindRoomTimeout);
2080 m_SearchIds.ClearIds();
2081 m_SearchIds.RegisterId(
id);
2084 m_Lobby.GetRoomsByIds(m_SearchIds,
callback);
2085 callback.event_OnResponse.Insert(JoinProcess_OnFindRoomByIdResponse);
2102 m_Lobby.Rooms(m_aDirectFoundRooms);
2105 if (m_aDirectFoundRooms.IsEmpty())
2107 JoinProcess_OnFindRoomFail(
null, -1, -1, -1);
2112 m_RoomToJoin = m_aDirectFoundRooms[0];
2113 m_RejoinRoom = m_RoomToJoin;
2114 JoinProcess_Init(m_RoomToJoin);
2121 JoinProcess_OnFindRoomFail(
null, -1, -1, -1);
2128 JoinProcess_OnFindRoomFail(
null, -1, -1, -1);
2134 callback.event_OnResponse.Remove(JoinProcess_OnFindRoomByIdResponse);
2139 void JoinProcess_Init(Room roomToJoin)
2141 if (!m_DownloadManager)
2146 m_bWaitForRefresh =
true;
2152 m_RoomToJoin = roomToJoin;
2155 bool hasPrivilege =
GetGame().GetPlatformService().GetPrivilege(UserPrivilege.CROSS_PLAY);
2157 if (roomToJoin.IsCrossPlatform() && !hasPrivilege)
2162 if (!m_CallbackGetPrivilege)
2165 m_CallbackGetPrivilege.m_OnResult.Insert(OnCrossPlayPrivilegeResultJoin);
2166 NegotiatePrivilegeAsync(UserPrivilege.CROSS_PLAY);
2172 JoinProcess_CheckVersion(m_RoomToJoin);
2175 JoinProcess_CheckRoomPasswordProtected(m_RoomToJoin);
2179 protected void OnCrossPlayPrivilegeResultJoin(UserPrivilege privilege, UserPrivilegeResult result)
2181 if (privilege == UserPrivilege.CROSS_PLAY)
2183 if (result == UserPrivilegeResult.ALLOWED)
2184 JoinProcess_CheckVersion(m_RoomToJoin);
2187 m_CallbackGetPrivilege.m_OnResult.Remove(OnCrossPlayPrivilegeResultJoin);
2193 protected void JoinProcess_CheckVersion(Room roomToJoin)
2196 bool versionsMatch = ClientRoomVersionMatch(roomToJoin);
2203 m_Dialogs.SetJoinRoom(roomToJoin);
2210 JoinProcess_CheckHighPing(roomToJoin);
2215 protected void JoinProcess_CheckHighPing(Room roomToJoin)
2217 if (IsServerPingAboveThreshold(roomToJoin))
2219 m_Dialogs.SetJoinRoom(roomToJoin);
2221 m_Dialogs.GetOnConfirm().Insert(OnHighPingServerWarningDialogConfirm);
2226 JoinProcess_CheckRoomPasswordProtected(roomToJoin);
2230 protected void OnHighPingServerWarningDialogConfirm()
2232 m_Dialogs.GetOnConfirm().Remove(OnHighPingServerWarningDialogConfirm);
2233 JoinProcess_CheckRoomPasswordProtected(m_Dialogs.GetJoinRoom());
2238 protected void JoinProcess_CheckRoomPasswordProtected(Room roomToJoin)
2243 if (m_Lobby.GetInviteRoom() == m_RoomToJoin || m_RejoinRoom)
2244 skipPassword = m_RoomToJoin.IsAuthorized();
2247 if (!m_RoomToJoin.PasswordProtected() || skipPassword)
2249 JoinProcess_ShowJoinDetailsDialog(roomToJoin);
2253 m_PasswordVerification.GetOnVerified().Insert(OnPasswordVerified);
2254 m_PasswordVerification.GetOnFailVerification().Clear();
2255 m_PasswordVerification.GetOnFailVerification().Insert(OnRejoinAuthorizationFailed);
2256 m_PasswordVerification.CheckRejoinAuthorization(roomToJoin);
2260 protected void OnRejoinAuthorizationFailed(
string message)
2262 m_PasswordVerification.GetOnFailVerification().Remove(OnRejoinAuthorizationFailed);
2264 m_Dialogs.CloseCurrentDialog();
2265 JoinProcess_PasswordClearInvokers();
2266 GetGame().GetCallqueue().CallLater(JoinProcess_PasswordDialogOpen);
2270 protected void JoinProcess_PasswordDialogOpen()
2273 m_Dialogs.GetOnCancel().Insert(JoinProcess_PasswordClearInvokers);
2275 m_PasswordVerification.SetupDialog(m_Dialogs.GetCurrentDialog(), m_RoomToJoin);
2276 m_PasswordVerification.GetOnVerified().Insert(OnPasswordVerified);
2277 m_PasswordVerification.GetOnFailVerification().Insert(OnPasswordFailVerification);
2282 protected void OnPasswordVerified(Room room)
2284 JoinProcess_PasswordClearInvokers();
2289 Print(
"ServerBrowserMenuUI - OnPasswordVerified() - NULL ROOM");
2295 m_RoomToJoin = room;
2296 JoinProcess_ShowJoinDetailsDialog(m_RoomToJoin);
2298 ReceiveRoomContent(m_RoomToJoin,
true);
2303 protected void OnPasswordFailVerification(
string message)
2306 m_PasswordVerification.SetupDialog(m_Dialogs.GetCurrentDialog(), m_RoomToJoin, message);
2310 protected void JoinProcess_PasswordClearInvokers()
2312 m_PasswordVerification.GetOnVerified().Remove(OnPasswordVerified);
2313 m_PasswordVerification.GetOnFailVerification().Remove(OnPasswordFailVerification);
2314 m_Dialogs.GetOnCancel().Remove(JoinProcess_PasswordClearInvokers);
2318 protected void JoinProcess_ShowJoinDetailsDialog(Room roomToJoin)
2323 JoinProcess_LoadModContent();
2327 CreateServerDetailsDialog(roomToJoin);
2331 protected void CreateServerDetailsDialog(Room roomToJoin)
2337 array<ref SCR_WorkshopItem> items = {};
2338 array<Dependency> dependencies = {};
2339 roomToJoin.GetItems(dependencies);
2341 if (
m_ModsManager.GetRoomItemsScripted().Count() == dependencies.Count())
2344 SCR_ServerDetailsDialog serverDetails = m_Dialogs.CreateServerDetailsDialog(roomToJoin, items, m_OnFavoritesResponse);
2345 serverDetails.SetCanJoin(CanJoinRoom(roomToJoin));
2346 serverDetails.m_OnFavorites.Insert(OnActionFavorite);
2348 bool loaded = roomToJoin.IsDownloadListLoaded();
2350 if (!dependencies.IsEmpty())
2353 if (!roomToJoin.IsDownloadListLoaded())
2354 m_ModsManager.GetOnGetAllDependencies().Insert(OnServerDetailModsLoaded);
2356 OnServerDetailModsLoaded();
2361 m_Dialogs.FillRoomDetailsMods({});
2364 m_Dialogs.GetCurrentDialog().m_OnConfirm.Insert(JoinProcess_LoadModContent);
2365 m_Dialogs.GetCurrentDialog().m_OnClose.Insert(OnServerDetailsClosed);
2370 protected void OnServerDetailModsLoaded()
2373 m_ModsManager.GetOnGetAllDependencies().Remove(OnServerDetailModsLoaded);
2379 m_ModsManager.GetOnGetAllDependencies().Remove(OnServerDetailModsLoaded);
2385 protected void JoinProcess_LoadModContent()
2393 array<Dependency> deps = {};
2395 m_RoomToJoin.GetItems(deps);
2397 if (!mgr.GetUgcPrivilege() && !deps.IsEmpty())
2402 mgr.m_OnUgcPrivilegeResult.Insert(Platform_OnUgcPrivilegeResult);
2403 mgr.NegotiateUgcPrivilegeAsync();
2408 JoinProcess_LoadModContentVisualize();
2412 protected void Platform_OnUgcPrivilegeResult(
bool result)
2415 mgr.m_OnUgcPrivilegeResult.Remove(Platform_OnUgcPrivilegeResult);
2417 JoinProcess_LoadModContentVisualize();
2421 protected void JoinProcess_LoadModContentVisualize()
2424 if (m_RoomToJoin.IsDownloadListLoaded())
2427 JoinProcess_CheckModContent();
2436 m_ModsManager.GetOnGetAllDependencies().Insert(JoinProcess_CheckModContent);
2437 m_ModsManager.GetOnModsFail().Insert(JoinProcess_OnModCheckFailed);
2438 m_ModsManager.GetOnDependenciesLoadingPrevented().Insert(OnDependenciesLoadingPrevented);
2444 protected void JoinProcess_OnModCheckFailed(Room room)
2446 m_Dialogs.CloseCurrentDialog();
2447 OnModListFail(room);
2449 m_ModsManager.GetOnGetAllDependencies().Remove(JoinProcess_CheckModContent);
2450 m_ModsManager.GetOnModsFail().Remove(JoinProcess_OnModCheckFailed);
2451 m_ModsManager.GetOnDependenciesLoadingPrevented().Remove(OnDependenciesLoadingPrevented);
2455 protected void OnDependenciesLoadingPrevented(Room room, array<ref SCR_WorkshopItem> dependencies)
2457 m_Dialogs.CloseCurrentDialog();
2459 if (room != m_RoomToJoin)
2462 JoinProcess_CheckModContent();
2469 protected void JoinProcess_CheckModContent()
2471 m_Dialogs.CloseCurrentDialog();
2472 m_Dialogs.SetJoinRoom(m_RoomToJoin);
2475 m_ModsManager.GetOnGetAllDependencies().Remove(JoinProcess_CheckModContent);
2476 m_ModsManager.GetOnModsFail().Remove(JoinProcess_OnModCheckFailed);
2477 m_ModsManager.GetOnDependenciesLoadingPrevented().Remove(OnDependenciesLoadingPrevented);
2480 array<ref SCR_WorkshopItem> items =
m_ModsManager.GetRoomItemsScripted();
2483 bool restricted = restricedMods.Count() > 0;
2489 dialog.GetOnAllReportsCanceled().Insert(JoinProcess_LoadModContentVisualize);
2497 if (!m_aRequiredMods.IsEmpty())
2499 m_aUnrelatedDownloads = m_DownloadManager.GetUnrelatedDownloads(items);
2501 if (!m_aUnrelatedDownloads.IsEmpty())
2502 JoinProcess_DisplayUnrelatedDownloadsWarning();
2504 JoinProcess_DownloadRequiredMods();
2509 JoinProcess_CheckRunningDownloads();
2514 protected void JoinProcess_DisplayUnrelatedDownloadsWarning()
2517 m_Dialogs.GetOnConfirm().Insert(JoinProcess_StopDownloadingUnrelatedMods);
2522 protected void JoinProcess_StopDownloadingUnrelatedMods()
2524 m_Dialogs.GetOnConfirm().Remove(JoinProcess_StopDownloadingUnrelatedMods);
2526 if (!m_DownloadManager || m_DownloadManager.GetDownloadQueue().IsEmpty())
2528 OnAllUnrelatedDownloadsStopped();
2533 m_DownloadManager.GetOnAllDownloadsStopped().Insert(OnAllUnrelatedDownloadsStopped);
2548 protected void OnAllUnrelatedDownloadsStopped()
2550 if (m_DownloadManager)
2551 m_DownloadManager.GetOnAllDownloadsStopped().Remove(OnAllUnrelatedDownloadsStopped);
2554 GetGame().GetCallqueue().CallLater(JoinProcess_CloseUnrelatedDownloadsCancelingDialog);
2558 protected void JoinProcess_CloseUnrelatedDownloadsCancelingDialog()
2560 m_Dialogs.GetCurrentDialog().Close();
2561 JoinProcess_DownloadRequiredMods();
2566 protected void JoinProcess_DownloadRequiredMods()
2568 if (m_DownloadManager)
2569 m_DownloadManager.DownloadItems(m_aRequiredMods);
2574 m_Dialogs.GetOnDownloadComplete().Insert(JoinProcess_OnJoinRoomDemand);
2575 m_Dialogs.GetOnCancel().Insert(OnDownloadRequiredModsCancel);
2579 protected void OnDownloadRequiredModsCancel()
2581 m_Dialogs.GetOnCancel().Remove(OnDownloadRequiredModsCancel);
2583 if (m_DownloadManager)
2585 m_DownloadManager.EndAllDownloads();
2586 m_DownloadManager.ClearFailedDownloads();
2591 protected void JoinProcess_OnJoinRoomDemand(Room roomToJoin)
2593 m_Dialogs.GetOnDownloadComplete().Remove(JoinProcess_OnJoinRoomDemand);
2595 m_RoomToJoin = roomToJoin;
2596 JoinProcess_CheckRunningDownloads();
2601 protected void JoinProcess_CheckRunningDownloads()
2603 int nCompleted, nTotal;
2606 if (m_DownloadManager)
2607 m_DownloadManager.GetDownloadQueueState(nCompleted, nTotal);
2616 m_Dialogs.GetOnConfirm().Insert(OnInterruptDownloadConfirm);
2621 protected void OnInterruptDownloadConfirm()
2625 PrintDebug(
"Missing m_RoomToJoin!",
"OnInteruptDownloadConfirm");
2633 mgr.EndAllDownloads();
2640 protected void JoinProcess_Join()
2643 if (!m_CallbackJoin)
2645 m_CallbackJoin.m_OnSuccess.Insert(JoinProcess_OnJoinSuccess);
2646 m_CallbackJoin.m_OnFail.Insert(JoinProcess_OnJoinFail);
2647 m_CallbackJoin.m_OnTimeOut.Insert(JoinProcess_OnJoinTimeout);
2650 m_RoomToJoin.Join(m_CallbackJoin, m_JoinData);
2669 m_RoomToJoin =
null;
2670 GetGame().GetMenuManager().CloseAllMenus();
2671 GetGame().GetBackendApi().GetWorkshop().Cleanup();
2673 JoinProcess_Clear();
2679 JoinProcess_Clear();
2685 if (apiCode == EApiCode.EACODE_ERROR_MP_ROOM_IS_FULL)
2687 m_Dialogs.SetJoinRoom(m_RoomToJoin);
2688 m_Dialogs.GetOnJoinRoomDemand().Insert(JoinProcess_OnJoinRoomDemand);
2691 GetGame().GetBackendApi().GetClientLobby().SetRefreshCallback(m_CallbackAutoRefresh);
2697 if (!m_JoinData.scope.IsEmpty())
2698 m_Dialogs.DisplayJoinBan(m_JoinData);
2701 m_Dialogs.DisplayJoinFail(apiCode);
2708 JoinProcess_Clear();
2709 m_Dialogs.CloseCurrentDialog();
2715 protected void JoinProcess_Clear()
2717 m_CallbackJoin =
null;
2719 ClientLobbyApi lobby =
GetGame().GetBackendApi().GetClientLobby();
2720 lobby.ClearInviteRoom();
2729 m_Dialogs.GetOnConfirm().Clear();
2730 m_Dialogs.GetOnCancel().Clear();
2731 m_Dialogs.GetOnDialogClose().Clear();
2732 m_Dialogs.GetOnDownloadComplete().Clear();
2733 m_Dialogs.GetOnDownloadCancelDialogClose().Clear();
2734 m_Dialogs.GetOnJoinRoomDemand().Clear();
2741 protected void SetupJoinDialogs()
2748 m_Dialogs.SetServerBrowser(
this);
2752 m_Dialogs.GetOnDownloadComplete().Clear();
2753 m_Dialogs.GetOnCancel().Insert(JoinProcess_Clear);
2755 m_CallbackLastSearch =
null;
2763 protected void NegotiateMPPrivilegeAsync()
2765 if (!m_CallbackGetPrivilege)
2768 m_CallbackGetPrivilege.m_OnResult.Insert(OnMPPrivilegeResult);
2771 GetGame().GetPlatformService().GetPrivilegeAsync(UserPrivilege.MULTIPLAYER_GAMEPLAY, m_CallbackGetPrivilege);
2776 protected void NegotiatePrivilegeAsync(UserPrivilege privilege)
2778 if (!m_CallbackGetPrivilege)
2783 case UserPrivilege.MULTIPLAYER_GAMEPLAY:
2785 m_CallbackGetPrivilege.m_OnResult.Insert(OnMPPrivilegeResult);
2789 case UserPrivilege.CROSS_PLAY:
2791 m_CallbackGetPrivilege.m_OnResult.Insert(OnCrossPlayPrivilegeResult);
2796 GetGame().GetPlatformService().GetPrivilegeAsync(privilege, m_CallbackGetPrivilege);
2800 protected void OnMPPrivilegeResult(UserPrivilege privilege, UserPrivilegeResult result)
2803 if (privilege == UserPrivilege.MULTIPLAYER_GAMEPLAY && result == UserPrivilegeResult.ALLOWED)
2806 m_CallbackGetPrivilege.m_OnResult.Remove(OnMPPrivilegeResult);
2810 protected void OnCrossPlayPrivilegeResult(UserPrivilege privilege, UserPrivilegeResult result)
2813 if (privilege == UserPrivilege.CROSS_PLAY && result == UserPrivilegeResult.ALLOWED)
2816 m_CallbackGetPrivilege.m_OnResult.Remove(OnCrossPlayPrivilegeResult);
2824 protected void PrintDebug(
string msg,
string functionName =
string.Empty)
2828 string fncStr =
string.Empty;
2829 if (functionName !=
string.Empty)
2830 fncStr =
string.Format(
" Fnc: %1()", functionName);
2833 PrintFormat(
"[ServerBrowserMenuUI]%1 -- Msg: %2", fncStr, msg);
2840 class SCR_GetRoomsIds
extends GetRoomsIds
2842 protected ref array<string>
roomIds = {};