9 protected const string WIDGET_SCROLL =
"ScrollSize";
10 protected const string WIDGET_ADDON_LIST =
"AddonList";
11 protected const string WIDGET_LOADING =
"Loading";
12 protected const string WIDGET_TITLEFRAME =
"TitleFrame";
14 protected const string WIDGET_IPADDRESS_TEXT =
"IPAddressText";
15 protected const string WIDGET_DISCORD_TEXT =
"DiscordText";
16 protected const string WIDGET_MODS_NUMBER_TEXT =
"ModsNumberText";
17 protected const string WIDGET_MODS_SIZE_TEXT =
"ModsSizeAmount";
18 protected const string WIDGET_ALERT_TEXT =
"AlertText";
19 protected const string WIDGET_ALERT_WRAPPER =
"AlertOverlay";
20 protected const string WIDGET_MODS_SIZE_TO_DOWNLOAD_TEXT =
"ModsSizeToDownload";
22 protected const string WIDGET_MODS_SIZE_LAYOUT =
"ModsSizeLayout";
23 protected const string WIDGET_DETAIL_ICONS_LAYOUT =
"DetailIconsLayout";
24 protected const string WIDGET_MODS_SIZE_TO_DOWNLOAD_LAYOUT =
"ModsSizeToDownloadLayout";
26 protected const string IMG_WRONG_VERSION =
"DetailIcon_WrongVersion";
27 protected const string IMG_PASSWORD_PROTECTED =
"Detailicon_PasswordProtected";
28 protected const string IMG_CROSS_PLATFORM =
"DetailIcon_CrossPlatform";
29 protected const string IMG_MODDED =
"DetailIcon_Modded";
30 protected const string IMG_VERSION_ALERT =
"VersionAlertIconButton";
32 protected const string BTN_CONFIRM =
"Confirm";
33 protected const string BTN_FAVORITES =
"favorites";
34 protected const string BTN_FAVORITES_STAR =
"FavoriteButton";
35 protected const string BTN_COPY_IPADDRESS =
"IPAddressButton";
36 protected const string BTN_DISCORD =
"DiscordButton";
38 protected Widget m_wScroll;
39 protected Widget m_wAddonList;
40 protected Widget m_wLoading;
41 protected Widget m_wModsSizeLayout;
42 protected Widget m_wDetailIconsLayout;
43 protected Widget m_wVersionAlertIcon;
44 protected Widget m_wModsSizeToDownloadLayout;
45 protected Widget m_wAlertWrapper;
47 protected RichTextWidget m_wIPAddressText;
48 protected RichTextWidget m_wDiscordText;
49 protected RichTextWidget m_wModsNumberText;
50 protected RichTextWidget m_wModsSizeText;
51 protected RichTextWidget m_wAlertText;
52 protected RichTextWidget m_wModsSizeToDownloadText;
57 protected SCR_ModularButtonComponent m_BtnFavorites;
61 protected SCR_ScenarioBackendImageComponent m_BackendImageComp;
62 protected Widget m_wBackgroundImageBackend;
64 ref ScriptInvoker m_OnFavorites =
new ScriptInvoker();
68 protected float m_fVersionAlertIconPaddingLeft;
70 protected const ResourceName ADDON_LINE_LAYOUT_SERVER_BROWSER =
"{3BC78F295971FD3D}UI/layouts/Menus/ContentBrowser/DownloadManager/DownloadManager_AddonDownloadLineConfirmation_ServerBrowser.layout";
71 protected const string STR_VERSION_MISMATCH =
"#AR-ServerBrowser_JoinModVersionMissmatch";
72 protected const string ICON_VERSION_MISMATCH =
"warning";
74 protected const string STR_HIGH_PING =
"#AR-ServerBrowser_HighPingWarning_Title";
75 protected const string STR_HIGH_PING_ICON =
"ping-low";
76 protected const string STR_HIGH_PING_ICON_SCALE =
"1.75";
79 protected const int MAX_TITLE_LENGTH = 55;
86 override protected void InitWidgets()
90 m_wScroll =
m_wRoot.FindAnyWidget(WIDGET_SCROLL);
91 m_wAddonList =
m_wRoot.FindAnyWidget(WIDGET_ADDON_LIST);
93 m_wModsSizeLayout =
m_wRoot.FindAnyWidget(WIDGET_MODS_SIZE_LAYOUT);
94 m_wDetailIconsLayout =
m_wRoot.FindAnyWidget(WIDGET_DETAIL_ICONS_LAYOUT);
95 m_wModsSizeToDownloadLayout =
m_wRoot.FindAnyWidget(WIDGET_MODS_SIZE_TO_DOWNLOAD_LAYOUT);
96 m_wAlertWrapper =
m_wRoot.FindAnyWidget(WIDGET_ALERT_WRAPPER);
98 m_wIPAddressText = RichTextWidget.Cast(
m_wRoot.FindAnyWidget(WIDGET_IPADDRESS_TEXT));
99 m_wDiscordText = RichTextWidget.Cast(
m_wRoot.FindAnyWidget(WIDGET_DISCORD_TEXT));
100 m_wModsNumberText = RichTextWidget.Cast(
m_wRoot.FindAnyWidget(WIDGET_MODS_NUMBER_TEXT));
101 m_wModsSizeText = RichTextWidget.Cast(
m_wRoot.FindAnyWidget(WIDGET_MODS_SIZE_TEXT));
102 m_wAlertText = RichTextWidget.Cast(
m_wRoot.FindAnyWidget(WIDGET_ALERT_TEXT));
103 m_wModsSizeToDownloadText = RichTextWidget.Cast(
m_wRoot.FindAnyWidget(WIDGET_MODS_SIZE_TO_DOWNLOAD_TEXT));
109 super.Init(root, preset, proxyMenu);
113 BindButtonConfirm(m_NavConfirm);
117 m_BtnFavorites = SCR_ModularButtonComponent.FindComponent(root.FindAnyWidget(BTN_FAVORITES_STAR));
120 m_NavFavorites.m_OnActivated.Insert(OnFavorites);
123 m_BtnFavorites.m_OnClicked.Insert(OnFavorites);
127 if (m_BtnCopyIPAddress)
128 m_BtnCopyIPAddress.m_OnClicked.Insert(OnCopyIPAddress);
133 m_BtnDiscord.m_OnClicked.Insert(OnDiscord);
135 m_wBackgroundImageBackend =
GetRootWidget().FindAnyWidget(
"BackgroundImageBackend");
136 if (m_wBackgroundImageBackend)
137 m_BackendImageComp = SCR_ScenarioBackendImageComponent.Cast(m_wBackgroundImageBackend.FindHandler(SCR_ScenarioBackendImageComponent));
144 m_wScroll.SetVisible(
false);
147 m_wModsSizeLayout.SetVisible(
false);
148 m_wModsSizeToDownloadLayout.SetVisible(
false);
154 SetScenarioImage(s_Room.HostScenario());
158 override void SetTitle(
string text)
160 super.SetTitle(text);
162 Widget titleFrame =
m_wRoot.FindAnyWidget(WIDGET_TITLEFRAME);
171 scrollComp.AnimationStop();
173 scrollComp.AnimationStart();
181 static SCR_ServerDetailsDialog CreateServerDetailsDialog(Room room, array<ref SCR_WorkshopItem> items,
string preset, ResourceName dialogsConfig =
"",
ScriptInvokerVoid onFavoritesResponse =
null)
183 if (dialogsConfig ==
"")
191 dialog.SetTitle(room.Name());
192 dialog.SetIPAddressText(
"#AR-ServerBrowser_IP: " + room.HostAddress());
196 if (onFavoritesResponse)
197 onFavoritesResponse.Insert(dialog.OnRoomSetFavoriteResponseDialog);
199 dialog.DisplayFavoriteAction(s_Room.IsFavorite());
200 dialog.UpdateDetailIcons();
201 dialog.UpdateAlertMessage();
214 if (m_aItems.IsEmpty())
219 array<SCR_WorkshopItem> itemsSorted = {};
221 array<SCR_WorkshopItem> itemsToUpdate = {};
222 array<SCR_WorkshopItem> itemsToDownload = {};
223 array<SCR_WorkshopItem> itemsDownloaded = {};
224 array<SCR_WorkshopItem> itemsOrdered = {};
228 itemsSorted.Insert(item);
231 SCR_Sorting<SCR_WorkshopItem, SCR_CompareWorkshopItemTargetSize>.HeapSort(itemsSorted,
true);
234 Revision versionFrom;
238 versionFrom = item.GetCurrentLocalRevision();
239 versionTo = item.GetItemTargetRevision();
241 if (!item.GetOffline())
242 itemsToDownload.Insert(item);
244 else if (versionFrom && !Revision.AreEqual(versionFrom, versionTo))
245 itemsToUpdate.Insert(item);
248 itemsDownloaded.Insert(item);
252 itemsOrdered.InsertAll(itemsToDownload);
253 itemsOrdered.InsertAll(itemsToUpdate);
254 itemsOrdered.InsertAll(itemsDownloaded);
260 Widget w =
GetGame().GetWorkspace().CreateWidgets(ADDON_LINE_LAYOUT_SERVER_BROWSER, m_wAddonList);
262 if (item == itemsOrdered[itemsOrdered.Count() - 1])
263 AlignableSlot.SetPadding(w, 0, 0, 0, 0);
266 comp.InitForServerBrowser(item, item.GetItemTargetRevision(),
true);
268 m_aDownloadLines.Insert(comp);
271 m_wScroll.SetVisible(
true);
272 UpdateModsAmountMessages(modsManager);
276 void SetScenarioImage(MissionWorkshopItem scenario)
278 if (!m_BackendImageComp)
282 m_BackendImageComp.SetScenarioAndImage(scenario, scenario.Thumbnail());
284 m_BackendImageComp.SetScenarioAndImage(
null,
null);
288 void SetCanJoin(
bool canJoin)
293 m_NavConfirm.SetEnabled(canJoin,
false);
297 protected void OnFavorites()
299 m_OnFavorites.Invoke();
303 protected void DisplayFavoriteAction(
bool isFavorite)
308 m_NavFavorites.SetLabel(
UIConstants.FAVORITE_LABEL_REMOVE);
310 m_NavFavorites.SetLabel(
UIConstants.FAVORITE_LABEL_ADD);
315 m_BtnFavorites.SetToggled(isFavorite,
false);
319 protected void OnRoomSetFavoriteResponseDialog()
321 DisplayFavoriteAction(s_Room.IsFavorite());
325 protected void OnCopyIPAddress()
327 System.ExportToClipboard(s_Room.HostAddress());
331 protected void OnDiscord()
337 protected void SetIPAddressText(
string text)
339 if (m_wIPAddressText)
340 m_wIPAddressText.SetText(text);
344 protected void SetDiscordText(
string text)
347 m_wDiscordText.SetText(text);
353 if (m_aItems.IsEmpty())
356 m_wModsSizeLayout.SetVisible(
true);
361 totalSize += item.GetSizeBytes();
364 if (m_wModsNumberText)
365 m_wModsNumberText.SetTextFormat(m_aItems.Count().ToString());
368 m_wModsSizeText.SetText(
SCR_ByteFormat.GetReadableSize(totalSize));
374 array<ref SCR_WorkshopItem> toUpdateMods = modsManager.GetRoomItemsToUpdate();
377 if (m_wModsSizeToDownloadLayout)
378 m_wModsSizeToDownloadLayout.SetVisible(!toUpdateMods.IsEmpty());
380 if (m_wModsSizeToDownloadText)
382 string toUpdateSize = modsManager.GetModListPatchSizeString(toUpdateMods);
383 m_wModsSizeToDownloadText.SetText(toUpdateSize);
388 protected void UpdateDetailIcons()
390 if (!s_Room || !m_wDetailIconsLayout)
393 bool isModded = s_Room.IsModded();
396 bool wrongVersion = s_Room.GameVersion() !=
GetGame().GetBuildVersion();
397 bool restrictedUGC = isModded && !
SCR_AddonManager.GetInstance().GetUgcPrivilege();
400 m_wDetailIconsLayout.FindWidget(IMG_WRONG_VERSION).SetVisible(
false);
403 m_wDetailIconsLayout.FindWidget(IMG_PASSWORD_PROTECTED).SetVisible(s_Room.PasswordProtected());
406 m_wDetailIconsLayout.FindWidget(IMG_CROSS_PLATFORM).SetVisible(s_Room.IsCrossPlatform());
410 m_wDetailIconsLayout.FindWidget(IMG_MODDED).SetVisible(
false);
415 protected void UpdateAlertMessage()
417 if (!s_Room || !m_wAlertText || !m_wAlertWrapper || !m_NavConfirm)
420 bool versionMismatch = s_Room.GameVersion() !=
GetGame().GetBuildVersion();
422 bool showMessage = versionMismatch || highPing;
424 m_wAlertWrapper.SetVisible(showMessage);
425 m_NavConfirm.ResetTexture();
432 m_wAlertText.SetText(s_Room.GameVersion() +
" - " + STR_VERSION_MISMATCH);
433 m_NavConfirm.SetTexture(
UIConstants.ICONS_IMAGE_SET, ICON_VERSION_MISMATCH, Color.FromInt(
UIColors.WARNING.PackToInt()));
437 string icon =
string.Format(
"<image set='%1' name='%2' scale='%3'/>",
UIConstants.ICONS_IMAGE_SET, STR_HIGH_PING_ICON, STR_HIGH_PING_ICON_SCALE);
438 m_wAlertText.SetText(icon +
" " + STR_HIGH_PING +
" ");