1class ServerBrowserEntry
extends ScriptedWidgetEventHandler
4 protected Widget m_Favorite;
7 protected TextWidget m_ServerName;
8 protected TextWidget m_ServerPopulation;
9 protected TextWidget m_ServerSlots;
10 protected TextWidget m_ServerPing;
11 protected ImageWidget m_ServerTime;
12 protected ImageWidget m_ServerLock;
13 protected ImageWidget m_ServerModIcon;
14 protected ImageWidget m_ServerMaKIcon;
17 protected TextWidget m_ServerShard;
18 protected TextWidget m_ServerCharacterAlive;
19 protected TextWidget m_ServerFriends;
20 protected TextWidget m_ServerMode;
21 protected TextWidget m_ServerBattleye;
22 protected TextWidget m_ServerIP;
23 protected TextWidget m_ServerAcceleration;
24 protected TextWidget m_ServerMap;
25 protected TextWidget m_ServerMods;
26 protected ButtonWidget m_ServerModsExpand;
29 protected Widget m_DetailedInfo;
30 protected bool m_IsExpanded;
31 protected bool m_IsFavorited;
32 protected bool m_IsOnline;
35 protected int m_Index;
37 protected bool m_Selected;
38 protected bool m_FirstExpand =
true;
42 #ifdef PLATFORM_CONSOLE
43 m_Root =
GetGame().GetWorkspace().CreateWidgets(
"gui/layouts/new_ui/server_browser/xbox/server_browser_list_entry.layout", parent);
45 m_Root =
GetGame().GetWorkspace().CreateWidgets(
"gui/layouts/new_ui/server_browser/pc/server_browser_list_entry_pages.layout", parent);
49 m_Favorite =
m_Root.FindAnyWidget(
"favorite_button");
50 m_ServerName = TextWidget.Cast(
m_Root.FindAnyWidget(
"server_name"));
51 m_ServerPopulation = TextWidget.Cast(
m_Root.FindAnyWidget(
"server_population"));
52 m_ServerSlots = TextWidget.Cast(
m_Root.FindAnyWidget(
"server_slots"));
53 m_ServerPing = TextWidget.Cast(
m_Root.FindAnyWidget(
"server_ping"));
54 m_ServerTime = ImageWidget.Cast(
m_Root.FindAnyWidget(
"server_time"));
55 m_ServerLock = ImageWidget.Cast(
m_Root.FindAnyWidget(
"lock_icon"));
56 m_ServerModIcon = ImageWidget.Cast(
m_Root.FindAnyWidget(
"modded_icon"));
57 m_ServerMaKIcon = ImageWidget.Cast(
m_Root.FindAnyWidget(
"mandk_icon"));
59 m_ServerShard = TextWidget.Cast(
m_Root.FindAnyWidget(
"shard_text"));
60 m_ServerCharacterAlive = TextWidget.Cast(
m_Root.FindAnyWidget(
"character_alive_text"));
61 m_ServerFriends = TextWidget.Cast(
m_Root.FindAnyWidget(
"steam_friends_text"));
62 m_ServerMode = TextWidget.Cast(
m_Root.FindAnyWidget(
"mode_text"));
63 m_ServerBattleye = TextWidget.Cast(
m_Root.FindAnyWidget(
"battlleye_text"));
64 m_ServerIP = TextWidget.Cast(
m_Root.FindAnyWidget(
"ip_text"));
65 m_ServerAcceleration = TextWidget.Cast(
m_Root.FindAnyWidget(
"server_acceleration_text"));
66 m_ServerMap = TextWidget.Cast(
m_Root.FindAnyWidget(
"server_map"));
67 m_ServerMods = TextWidget.Cast(
m_Root.FindAnyWidget(
"mods_text"));
68 m_ServerModsExpand = ButtonWidget.Cast(
m_Root.FindAnyWidget(
"mods_expand"));
70 m_DetailedInfo =
m_Root.FindAnyWidget(
"detailed_info");
72 m_Root.FindAnyWidget(
"basic_info").Show(
true);
73 m_Root.FindAnyWidget(
"favorite_image").Update();
74 m_Root.FindAnyWidget(
"unfavorite_image").Update();
80 m_ServerTime.LoadImageFile(0,
"set:dayz_gui image:icon_sun");
81 m_ServerTime.LoadImageFile(1,
"set:dayz_gui image:icon_sun_accel");
82 m_ServerTime.LoadImageFile(2,
"set:dayz_gui image:icon_moon");
83 m_ServerTime.LoadImageFile(3,
"set:dayz_gui image:icon_moon_accel");
88 void ~ServerBrowserEntry()
104 override bool OnClick(Widget w,
int x,
int y,
int button)
106 if (!IsOnline() || w == null)
113 #ifdef PLATFORM_CONSOLE
120 case m_ServerModsExpand:
126 for (
int i = 1; i <
m_Mods.Count(); i++)
128 mods_text +=
"\n" +
m_Mods[i];
132 GetGame().GetUIManager().ShowDialog(
"#main_menu_mods", mods_text, 0, 0, 0, 0,
GetGame().GetUIManager().GetMenu());
182 m_Tab.SetServerDetails(m_ServerData, m_IsOnline);
200 Lighten(w, enterW,
x,
y);
214 m_Tab.ServerListFocus(focus, m_IsFavorited);
217 override bool OnFocus(Widget w,
int x,
int y)
224 #ifdef PLATFORM_CONSOLE
229 m_Tab.SetServerDetails(m_ServerData, m_IsOnline);
240 #ifdef PLATFORM_CONSOLE
250 Lighten(w, null,
x,
y);
265 return (w ==
m_Root || w == m_Favorite || w == m_ServerModsExpand);
272 m_ServerData = server_info;
273 m_FirstExpand =
true;
275 #ifndef PLATFORM_CONSOLE
276 m_DetailedInfo.Show(server_info.m_IsExpanded);
279 SetName(server_info.m_Name);
280 SetPasswordLocked(server_info.m_IsPasswordProtected);
281 SetPopulationEx(server_info);
282 SetSlots(server_info.m_MaxPlayers);
283 SetPing(server_info.m_Ping);
284 SetFavorite(server_info.m_Favorite);
285 SetModded(server_info.m_Modded);
289 #ifdef PLATFORM_CONSOLE
290 SetMouseAndKeyboard(server_info.m_MouseAndKeyboardEnabled);
293#ifdef PLATFORM_WINDOWS
294 #ifndef PLATFORM_CONSOLE
295 SetExpand(server_info.m_IsExpanded);
298 if (server_info.m_ShardId.Length() == 3 && server_info.m_ShardId.ToInt() < 200)
304 SetCharacterAlive(server_info.m_CharactersAlive);
305 SetFriends(server_info.m_SteamFriends);
306 SetMode(server_info.m_Disable3rdPerson);
307 SetBattleye(server_info.m_AntiCheat);
308 SetIP(server_info.m_Id);
309 SetAcceleration(server_info.m_EnvironmentTimeMul);
316 if (m_ServerData.m_IsSelected)
324 Lighten(
m_Root, null, 0, 0);
329 void SetName(
string name)
331 m_ServerName.SetText(
name);
334 void SetPasswordLocked(
bool locked)
336 m_ServerLock.Show(locked);
342 int population = serverInfo.m_CurrentNumberPlayers;
343 int maxPlayers = serverInfo.m_MaxPlayers;
344 int playersInQueue = serverInfo.m_PlayersInQueue;
350 if (playersInQueue > 0 && population == maxPlayers)
352 popText = population.ToString() +
"+" + playersInQueue.ToString() +
"/" + maxPlayers.ToString();
356 popText = population.ToString() +
"/" + maxPlayers.ToString();
365 m_ServerPopulation.SetText(popText);
368 void SetSlots(
int slots)
372 m_ServerSlots.SetText(slots.ToString());
376 m_ServerSlots.SetText(
"-");
380 void SetPing(
int ping)
386 color =
ARGBF(1, 0, 1, 0);
388 color =
ARGBF(1, 0.8, 0.8, 0);
389 else if( ping < 200 )
390 color =
ARGBF(1, 1, 0.5, 0);
392 color =
ARGBF(1, 1, 0, 0);
396 displayValue = ping.ToString();
404 m_ServerPing.SetColor(color);
405 m_ServerPing.SetText(displayValue);
408 void SetTime(
string time,
float multiplier)
414 time.Split(
":", arr);
416 if (arr.Count() == 2)
418 int hour = arr.Get(0).ToInt();
419 int minute = arr.Get(1).ToInt();
421 if (hour >= 19 || hour <= 5)
424 m_ServerTime.SetImage(3);
426 m_ServerTime.SetImage(2);
431 m_ServerTime.SetImage(1);
433 m_ServerTime.SetImage(0);
439 void SetShard(
int shard)
446 text =
"#server_browser_entry_private";
451 text =
"#server_browser_entry_official";
455 m_ServerShard.SetText(text);
458 void RefreshDLCIcon()
460 if (m_ServerData.m_IsDLC)
462 bool own =
GetGame().VerifyWorldOwnership(GetMapToRun());
463 m_ServerModIcon.Show(
true);
464 m_ServerModIcon.FindWidget(
"Owned").Show(own);
465 m_ServerModIcon.FindWidget(
"Unowned").Show(!own);
469 m_ServerModIcon.FindWidget(
"Owned").Show(
false);
470 m_ServerModIcon.FindWidget(
"Unowned").Show(
false);
474 void SetCharacterAlive(
string char_alive)
476 if (char_alive ==
"")
477 m_ServerCharacterAlive.SetText(
"#STR_server_browser_char_not_alive");
479 m_ServerCharacterAlive.SetText(char_alive);
482 void SetFriends(
string friends_text)
484 m_ServerFriends.SetText(friends_text);
487 void SetMode(
int mode)
494 text =
"#server_browser_entry_person_both";
499 text =
"#server_browser_entry_person_first";
503 m_ServerMode.SetText(text);
506 void SetBattleye(
bool battleye)
510 m_ServerBattleye.SetText(
"#server_browser_entry_enabled");
511 m_ServerBattleye.SetColor(
ARGBF(1, 0, 1, 0));
515 m_ServerBattleye.SetText(
"#server_browser_entry_disabled");
516 m_ServerBattleye.SetColor(
ARGBF(1, 1, 0, 0));
520 void SetIP(
string ip)
522 m_ServerIP.SetText(ip);
527 return m_ServerData.GetIP();
532 return m_ServerData.m_HostPort;
535 int GetSteamQueryPort()
537 return m_ServerData.m_SteamQueryPort;
542 return m_ServerData.m_Id;
547 return m_ServerData.m_MapNameToRun;
550 void SetFavorite(
bool favorite)
552 m_IsFavorited = favorite;
553 m_Root.FindAnyWidget(
"favorite_image").Show(favorite);
554 m_Root.FindAnyWidget(
"unfavorite_image").Show(!favorite);
557 void SetAcceleration(
float mult)
561 m_ServerAcceleration.Show(
true);
562 m_ServerAcceleration.SetText(mult.ToString() +
"x");
566 m_ServerAcceleration.Show(
false);
570 void SetModded(
bool is_modded)
572 m_ServerModIcon.Show(is_modded);
575 void SetServerMapName()
577 string displayValue =
"-";
584 m_ServerMap.SetText(displayValue);
591 if (mods && mods.Count() > 0)
593 string mods_text = mods[0];
594 for (
int i = 1; i < mods.Count(); i++)
595 mods_text +=
", " + mods[i];
597 m_ServerMods.SetText(mods_text);
600 #ifdef PLATFORM_WINDOWS
601 m_ServerModsExpand.Show((mods && mods.Count() > 0));
605 void SetMouseAndKeyboard(
bool is_mkenabled)
607 m_ServerMaKIcon.Show(is_mkenabled);
610 void SetIsOnline(
bool isOnline)
612 m_IsOnline = isOnline;
615 bool ToggleFavorite()
617 m_IsFavorited = !m_IsFavorited;
618 string ip = m_ServerData.GetIP();
619#ifdef PLATFORM_WINDOWS
621 m_Tab.GetRootMenu().AddFavorite(ip, m_ServerData.m_SteamQueryPort, m_IsFavorited);
623 #ifdef PLATFORM_CONSOLE
630 m_IsFavorited = m_Tab.GetRootMenu().SetFavoriteConsoles(ip, m_ServerData.m_HostPort, m_IsFavorited);
632 ServerBrowserFavoritesTabConsolePages sbf = ServerBrowserFavoritesTabConsolePages.Cast(m_Tab);
633 if (!m_IsFavorited && sbf)
635 sbf.SetFavoriteChanged(
true);
636 sbf.RefreshServerList();
640 m_Root.FindAnyWidget(
"unfavorite_image").Show(!m_IsFavorited);
641 m_Root.FindAnyWidget(
"favorite_image").Show(m_IsFavorited);
643 return m_IsFavorited;
648 return SetExpand(!m_IsExpanded);
651 bool SetExpand(
bool expand)
653 m_IsExpanded = expand;
654 m_Root.FindAnyWidget(
"collapse_image").Show(m_IsExpanded);
655 m_Root.FindAnyWidget(
"expand_image").Show(!m_IsExpanded);
656 m_DetailedInfo.Show(m_IsExpanded);
660 m_ServerData.m_IsExpanded = m_IsExpanded;
663 if (expand && m_FirstExpand)
665 if (m_ServerData.m_Modded)
670 m_FirstExpand =
false;
676 void Select(
bool notify =
true)
682 m_Tab.SelectServer(
this);
685 m_ServerData.m_IsSelected =
true;
694 m_ServerData.m_IsSelected =
false;
697 Lighten(
m_Root, null, 0, 0);
704 int maxPlayers = m_ServerData.m_MaxPlayers;
705 int whiteColor =
ARGBF(1, 1, 1, 1);
706 int populationColor = whiteColor;
707 int populationOutline = 1;
713 int population = m_ServerData.m_CurrentNumberPlayers;
714 float pop_percentage = population / maxPlayers;
716 if (pop_percentage >= 1)
718 populationColor =
ARGBF(1, 1, 0, 0);
720 else if (pop_percentage >= 0.8)
722 populationColor =
ARGBF(1, 1, 0.5, 0);
729 populationOutline = 0;
731 m_ServerPing.SetColor(whiteColor);
734 m_ServerTime.Show(IsOnline());
735 m_ServerName.SetColor(whiteColor);
736 m_ServerName.SetAlpha(alpha);
737 m_ServerPopulation.SetBold(IsOnline());
738 m_ServerPopulation.SetColor(populationColor);
739 m_ServerPopulation.SetOutline(populationOutline);
740 m_ServerPopulation.SetAlpha(alpha);
741 m_ServerSlots.SetAlpha(alpha);
742 m_ServerPing.SetAlpha(alpha);
747 void Preview(Widget w,
int x,
int y)
761 m_ServerName.SetColor(
ARGB(255, 255, 0, 0));
764 m_ServerName.SetAlpha(0.5);
772 void Darken(Widget w,
int x,
int y)
783 SetPopulationEx(m_ServerData);
790 void Lighten(Widget w, Widget enterW,
int x,
int y)
794 if (GetFocus() == w || m_Selected)
799 if (w ==
m_Root && (m_Favorite && enterW == m_Favorite))
805 SetPopulationEx(m_ServerData);
825 void SetMapName(
string mapName);
828 void SetPopulation(
int population,
int slots);
override bool OnMouseEnter(Widget w, int x, int y)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
GetServersResultRow the output structure of the GetServers operation that represents one game server.
static void GetServerModList(string server_id)
static void SetServerFavorited(string ipAddress, int port, int steamQueryPort, bool is_favorited)
static string GetMapDisplayName(string mapName)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
override bool OnClick(Widget w, int x, int y, int button)
buttons clicks
proto native CGame GetGame()
array< string > TStringArray
override bool OnDoubleClick(Widget w, int x, int y, int button)
void SetTime(float time)
DEPRECATED.
int ARGB(int a, int r, int g, int b)
int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.
void ServerListFocus(bool focus, bool favorite)
override bool OnFocusLost(Widget w, int x, int y)
bool IsFocusable(Widget w)
override bool OnFocus(Widget w, int x, int y)