6 protected int m_iPingLimit;
9 protected string m_sTooltipDownloadIcon;
12 protected float m_fTooltipDownloadIconScale;
15 protected static const string LAYOUT_CONTENT =
"HorizontalLayout";
16 protected static const string LAYOUT_LOADING =
"Loading";
18 protected static const string BUTTON_FAVORITE =
"FavButton";
19 protected static const string BUTTON_JOIN =
"JoinButton";
20 protected static const string BUTTON_PASSWORD =
"PasswordButton";
22 protected static const string ICON_WARNING =
"VersionWarningIcon";
23 protected static const string ICON_UNJOINABLE =
"JoinWarningIcon";
24 protected static const string ICON_MODDED =
"ImageModded";
25 protected static const string ICON_PING =
"ImgPing";
27 protected static const string FRAME_NAME =
"FrameName";
28 protected static const string FRAME_SCENARIO =
"FrameScenario";
30 protected static const string TEXT_CELL =
"Content";
33 protected Room m_RoomInfo;
38 protected ref array<ref ServerBrowserEntryProperty> m_aPingStates;
41 protected Widget m_wHorizontalContent;
42 protected Widget m_wLoading;
45 protected Widget m_wUnjoinableIcon;
47 protected ImageWidget m_wImgPing;
48 protected int m_iHighestPing = 0;
50 protected Widget m_wImageModded;
51 protected Widget m_wJoinButton;
52 protected Widget m_wPasswordButton;
55 protected string m_sPatchSize;
56 protected bool m_bIsPatchSizeLoaded;
58 protected Widget m_wVersionWarningIcon;
65 override void HandlerAttached(Widget w)
77 Widget favoriteButton = w.FindAnyWidget(BUTTON_FAVORITE);
80 m_FavComponent = SCR_ModularButtonComponent.Cast(favoriteButton.FindHandler(SCR_ModularButtonComponent));
93 m_aMouseButtons.Insert(m_FavComponent);
95 SCR_ModularButtonComponent buttonComp = SCR_ModularButtonComponent.FindComponent(
m_wJoinButton);
98 buttonComp.m_OnClicked.Insert(OnJoinInteractionButtonClicked);
99 m_aMouseButtons.Insert(buttonComp);
105 buttonComp.m_OnClicked.Insert(OnJoinInteractionButtonClicked);
106 m_aMouseButtons.Insert(buttonComp);
110 m_wImgPing = ImageWidget.Cast(w.FindAnyWidget(ICON_PING));
114 Widget frameName =
m_wRoot.FindAnyWidget(FRAME_NAME);
119 m_aScrollAnimations.Insert(scrollComp);
123 Widget frameScenario =
m_wRoot.FindAnyWidget(FRAME_SCENARIO);
128 m_aScrollAnimations.Insert(scrollComp);
135 foreach (ServerBrowserEntryProperty pingState :
m_aPingStates)
137 int ping = pingState.m_sValue.ToInt();
142 super.HandlerAttached(w);
146 override void OnTooltipShow(
SCR_ScriptedWidgetTooltip tooltipClass, Widget tooltipWidget, Widget hoverWidget, SCR_ScriptedWidgetTooltipPreset preset,
string tag)
148 super.OnTooltipShow(tooltipClass, tooltipWidget, hoverWidget, preset, tag);
150 string message = tooltipClass.GetDefaultMessage();
154 case "VersionMismatch":
157 comp.SetWrongVersionMessage(
m_RoomInfo.GameVersion());
162 message =
string.Format(message, GetDownloadSizeMessage());
164 tooltipClass.SetMessage(message);
170 override void UpdateModularButtons()
176 super.UpdateModularButtons();
180 override bool OnFocusLost(Widget w,
int x,
int y)
184 m_ModsManager.GetOnGetAllDependencies().Remove(OnServerDetailModsLoaded);
188 return super.OnFocusLost(w, x, y);
196 protected void OnJoinInteractionButtonClicked()
198 if (m_OnMouseInteractionButtonClicked)
199 m_OnMouseInteractionButtonClicked.Invoke(
"");
206 protected void SetCellText(
string cellName,
string str)
208 Widget wCell =
m_wRoot.FindAnyWidget(cellName);
212 TextWidget wText = TextWidget.Cast(wCell.FindAnyWidget(TEXT_CELL));
220 protected void DisplayPing(
int ping)
225 ServerBrowserEntryProperty displayState;
237 foreach (ServerBrowserEntryProperty pingState : m_aPingStates)
239 float pingFromStr = pingState.m_sValue.ToFloat();
242 if (ping < pingFromStr && pingFromStr < lastHighest)
244 displayState = pingState;
245 lastHighest = pingFromStr;
250 string strPing = Math.Floor(ping).ToString();
253 if (ping > m_iHighestPing || ping < 0)
256 if (ping > m_iPingLimit)
257 strPing =
m_iPingLimit.ToString() +
"#ENF-ComboModifier";
259 SetCellText(
"Ping", strPing);
262 if (displayState && m_wImgPing)
272 protected void CheckRoomProperties()
280 if (wrongVersion || restrictedUGC)
305 protected void DisplayServerProperties()
321 m_FavComponent.SetEnabled(!versionMismatch && !unjoinable);
326 m_bDisabled = versionMismatch || unjoinable;
327 UpdateModularButtons();
331 protected string GetDownloadSizeMessage()
343 protected void OnServerDetailModsLoaded()
348 array<ref SCR_WorkshopItem> toUpdateMods =
m_ModsManager.GetRoomItemsToUpdate();
349 if (!toUpdateMods.IsEmpty())
355 UpdateTooltipJoinDownloadSizeMessage();
359 protected void UpdateTooltipJoinDownloadSizeMessage()
361 if (!m_CurrentTooltip || !m_CurrentTooltip.IsVisible())
364 switch (m_CurrentTooltip.GetTag())
367 string message = m_CurrentTooltip.GetDefaultMessage();
368 message =
string.Format(message, GetDownloadSizeMessage());
369 m_CurrentTooltip.SetMessage(message);
381 void SetRoomInfo(Room room)
390 CheckRoomProperties();
391 DisplayServerProperties();
397 SetCellText(
"Scenario",
m_RoomInfo.ScenarioName());
400 string playerCount =
m_RoomInfo.PlayerCount().ToString();
401 string playerCountMax =
m_RoomInfo.PlayerLimit().ToString();
403 SetCellText(
"Players", playerCount +
"/" + playerCountMax);
410 DisplayPing(room.GetPing());
416 void EmptyVisuals(
bool enable)
430 m_ModsManager.GetOnGetAllDependencies().Insert(OnServerDetailModsLoaded);
453 bool GetIsEnabled(out
bool versionMismatch, out
bool unjoinable)
457 return !versionMismatch && !unjoinable;
462 class ServerBrowserEntryProperty
467 [
Attribute(
"", UIWidgets.EditBox,
desc:
"Image name to load")]
470 [
Attribute(
"", UIWidgets.EditBox,
desc:
"String value of property")]
473 [
Attribute(
"1 1 1 1", UIWidgets.ColorPicker)]