12 protected ImageWidget m_ServerTime;
13 protected ImageWidget m_ServerLock;
14 protected ImageWidget m_ServerModIcon;
15 protected ImageWidget m_ServerMaKIcon;
27 protected ButtonWidget m_ServerModsExpand;
31 protected bool m_IsFavorited;
32 protected bool m_IsOnline;
34 protected ref GetServersResultRow m_ServerData;
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 );
50 m_Expand =
m_Root.FindAnyWidget(
"expand_button" );
52 m_ServerPopulation =
TextWidget.Cast(
m_Root.FindAnyWidget(
"server_population" ) );
55 m_ServerTime = ImageWidget.Cast(
m_Root.FindAnyWidget(
"server_time" ) );
56 m_ServerLock = ImageWidget.Cast(
m_Root.FindAnyWidget(
"lock_icon" ) );
57 m_ServerModIcon = ImageWidget.Cast(
m_Root.FindAnyWidget(
"modded_icon" ) );
58 m_ServerMaKIcon = ImageWidget.Cast(
m_Root.FindAnyWidget(
"mandk_icon" ) );
61 m_ServerCharacterAlive =
TextWidget.Cast(
m_Root.FindAnyWidget(
"character_alive_text" ) );
62 m_ServerFriends =
TextWidget.Cast(
m_Root.FindAnyWidget(
"steam_friends_text" ) );
64 m_ServerBattleye =
TextWidget.Cast(
m_Root.FindAnyWidget(
"battlleye_text" ) );
66 m_ServerAcceleration =
TextWidget.Cast(
m_Root.FindAnyWidget(
"server_acceleration_text" ) );
69 m_ServerModsExpand = ButtonWidget.Cast(
m_Root.FindAnyWidget(
"mods_expand" ) );
71 m_Root.FindAnyWidget(
"basic_info" ).Show(
true );
72 m_Root.FindAnyWidget(
"favorite_image" ).Update();
73 m_Root.FindAnyWidget(
"unfavorite_image" ).Update();
79 m_ServerTime.LoadImageFile( 0,
"set:dayz_gui image:icon_sun" );
80 m_ServerTime.LoadImageFile( 1,
"set:dayz_gui image:icon_sun_accel" );
81 m_ServerTime.LoadImageFile( 2,
"set:dayz_gui image:icon_moon" );
82 m_ServerTime.LoadImageFile( 3,
"set:dayz_gui image:icon_moon_accel" );
87 void ~ServerBrowserEntry()
109 #ifdef PLATFORM_CONSOLE
112 m_Tab.Connect(
this );
117 if ( w == m_ServerModsExpand )
120 if ( m_Mods && m_Mods.Count() > 0 )
122 mods_text = m_Mods[0];
123 for (
int i = 1; i < m_Mods.Count(); i++ )
125 mods_text +=
"\n" + m_Mods[i];
129 GetGame().GetUIManager().ShowDialog(
"#main_menu_mods", mods_text, 0, 0, 0, 0,
GetGame().GetUIManager().GetMenu() );
146 m_Tab.Connect(
this );
163 else if ( w == m_Expand )
194 Lighten( w, enterW,
x,
y );
208 m_Tab.ServerListFocus( focus, m_IsFavorited );
218 #ifdef PLATFORM_CONSOLE
233 #ifdef PLATFORM_CONSOLE
244 Lighten( w,
null,
x,
y );
259 return ( w ==
m_Root || w ==
m_Favorite || w == m_Expand || w == m_ServerModsExpand );
264 void FillInfo( GetServersResultRow server_info )
266 m_ServerData = server_info;
267 m_FirstExpand =
true;
269 #ifndef PLATFORM_CONSOLE
270 m_Root.FindAnyWidget(
"detailed_info" ).Show( server_info.m_IsExpanded );
274 SetPasswordLocked( server_info.m_IsPasswordProtected );
275 SetPopulationEx( server_info );
276 SetSlots( server_info.m_MaxPlayers );
277 SetPing( server_info.m_Ping );
278 SetTime( server_info.m_TimeOfDay, server_info.m_EnvironmentTimeMul );
279 SetFavorite( server_info.m_Favorite );
280 SetModded( server_info.m_Modded );
281 SetMapName( server_info.m_MapNameToRun );
283 #ifdef PLATFORM_CONSOLE
284 SetMouseAndKeyboard( server_info.m_MouseAndKeyboardEnabled );
287 #ifdef PLATFORM_WINDOWS
288 #ifndef PLATFORM_CONSOLE
289 SetExpand( server_info.m_IsExpanded );
292 if ( server_info.m_ShardId.Length() == 3 && server_info.m_ShardId.ToInt() < 200 )
298 SetCharacterAlive( server_info.m_CharactersAlive );
299 SetFriends( server_info.m_SteamFriends );
300 SetMode( server_info.m_Disable3rdPerson );
301 SetBattleye( server_info.m_AntiCheat );
302 SetIP( server_info.m_Id );
303 SetAcceleration( server_info.m_EnvironmentTimeMul );
311 if (m_ServerData.m_IsSelected)
319 Lighten(
m_Root,
null, 0, 0);
325 m_ServerName.SetText(
name );
328 void SetPasswordLocked(
bool locked )
330 m_ServerLock.Show( locked );
334 void SetPopulation(
int population,
int slots )
336 int color =
ARGBF(1, 1, 1, 1);
337 string pop_text = population.ToString() +
"/" + slots.ToString();
341 float pop_percentage = population / slots;
343 if (pop_percentage >= 1)
344 color =
ARGBF( 1, 1, 0, 0 );
345 else if ( pop_percentage >= 0.8 )
346 color =
ARGBF( 1, 1, 0.5, 0 );
349 m_ServerPopulation.SetText(pop_text);
350 m_ServerPopulation.SetColor(color);
351 m_ServerPopulation.SetBold(
true);
352 m_ServerPopulation.SetOutline(1);
356 private void SetPopulationEx(GetServersResultRow serverInfo)
359 int population = serverInfo.m_CurrentNumberPlayers;
360 int maxPlayers = serverInfo.m_MaxPlayers;
361 int playersInQueue = serverInfo.m_PlayersInQueue;
367 if (playersInQueue > 0 && population == maxPlayers)
369 popText = population.ToString() +
"+" + playersInQueue.ToString() +
"/" + maxPlayers.ToString();
373 popText = population.ToString() +
"/" + maxPlayers.ToString();
382 m_ServerPopulation.SetText(popText);
385 void SetSlots(
int slots )
389 m_ServerSlots.SetText( slots.ToString() );
393 m_ServerSlots.SetText(
"-");
397 void SetPing(
int ping )
403 color =
ARGBF( 1, 0, 1, 0 );
404 else if( ping < 100 )
405 color =
ARGBF( 1, 0.8, 0.8, 0 );
406 else if( ping < 200 )
407 color =
ARGBF( 1, 1, 0.5, 0 );
409 color =
ARGBF( 1, 1, 0, 0 );
413 displayValue = ping.ToString();
421 m_ServerPing.SetColor( color );
422 m_ServerPing.SetText( displayValue );
425 void SetTime(
string time,
float multiplier )
431 time.Split(
":", arr );
433 if ( arr.Count() == 2 )
435 int hour = arr.Get( 0 ).ToInt();
436 int minute = arr.Get( 1 ).ToInt();
438 if ( hour >= 19 || hour <= 5 )
440 if ( multiplier > 1 )
441 m_ServerTime.SetImage( 3 );
443 m_ServerTime.SetImage( 2 );
447 if ( multiplier > 1 )
448 m_ServerTime.SetImage( 1 );
450 m_ServerTime.SetImage( 0 );
456 void SetShard(
int shard )
463 text =
"#server_browser_entry_private";
468 text =
"#server_browser_entry_official";
472 m_ServerShard.SetText( text );
475 void SetMapName(
string mapName )
480 void RefreshDLCIcon()
482 if ( m_ServerData.m_IsDLC )
484 bool own =
GetGame().VerifyWorldOwnership( GetMapToRun() );
485 m_ServerModIcon.Show(
true );
486 m_ServerModIcon.FindWidget(
"Owned" ).Show( own );
487 m_ServerModIcon.FindWidget(
"Unowned" ).Show( !own );
491 m_ServerModIcon.FindWidget(
"Owned" ).Show(
false );
492 m_ServerModIcon.FindWidget(
"Unowned" ).Show(
false );
496 void SetCharacterAlive(
string char_alive )
498 if ( char_alive ==
"")
499 m_ServerCharacterAlive.SetText(
"#STR_server_browser_char_not_alive" );
501 m_ServerCharacterAlive.SetText( char_alive );
504 void SetFriends(
string friends_text )
506 m_ServerFriends.SetText( friends_text );
509 void SetMode(
int mode )
516 text =
"#server_browser_entry_person_both";
521 text =
"#server_browser_entry_person_first";
525 m_ServerMode.SetText( text );
528 void SetBattleye(
bool battleye )
532 m_ServerBattleye.SetText(
"#server_browser_entry_enabled" );
533 m_ServerBattleye.SetColor(
ARGBF( 1, 0, 1, 0 ) );
537 m_ServerBattleye.SetText(
"#server_browser_entry_disabled" );
538 m_ServerBattleye.SetColor(
ARGBF( 1, 1, 0, 0 ) );
542 void SetIP(
string ip )
544 m_ServerIP.SetText( ip );
549 return m_ServerData.GetIP();
554 return m_ServerData.m_HostPort;
559 return m_ServerData.m_Id;
564 return m_ServerData.m_MapNameToRun;
569 string map_name = m_ServerData.m_MapNameToRun;
572 if ( map_name ==
"enoch" )
574 if ( map_name ==
"chernarusplus" )
577 return m_ServerData.m_MapNameToRun;
580 void SetFavorite(
bool favorite )
582 m_IsFavorited = favorite;
583 m_Root.FindAnyWidget(
"favorite_image" ).Show( favorite );
584 m_Root.FindAnyWidget(
"unfavorite_image" ).Show( !favorite );
587 void SetAcceleration(
float mult )
591 m_ServerAcceleration.Show(
true );
592 m_ServerAcceleration.SetText( mult.ToString() +
"x" );
596 m_ServerAcceleration.Show(
false );
600 void SetModded(
bool is_modded )
602 m_ServerModIcon.Show( is_modded );
605 void SetServerMapName()
607 m_ServerMap.SetText( GetMapName() );
615 if ( mods && mods.Count() > 0 )
617 string mods_text = mods[0];
618 for (
int i = 1; i < mods.Count(); i++ )
619 mods_text +=
", " + mods[i];
621 m_ServerMods.SetText( mods_text );
624 #ifdef PLATFORM_WINDOWS
625 m_ServerModsExpand.Show( ( mods && mods.Count() > 0 ) );
629 void SetMouseAndKeyboard(
bool is_mkenabled )
631 m_ServerMaKIcon.Show( is_mkenabled );
634 void SetIsOnline(
bool isOnline)
636 m_IsOnline = isOnline;
639 bool ToggleFavorite()
641 m_IsFavorited = !m_IsFavorited;
642 string ip = m_ServerData.GetIP();
643 #ifdef PLATFORM_WINDOWS
645 m_Tab.GetRootMenu().AddFavorite(ip, m_ServerData.m_SteamQueryPort, m_IsFavorited);
647 #ifdef PLATFORM_CONSOLE
648 OnlineServices.SetServerFavorited(ip, 0, m_ServerData.m_SteamQueryPort, m_IsFavorited);
650 OnlineServices.SetServerFavorited(ip, m_ServerData.m_HostPort, m_ServerData.m_SteamQueryPort, m_IsFavorited);
654 m_IsFavorited = m_Tab.GetRootMenu().SetFavoriteConsoles(ip, m_ServerData.m_HostPort, m_IsFavorited);
657 m_Root.FindAnyWidget(
"unfavorite_image" ).Show( !m_IsFavorited );
658 m_Root.FindAnyWidget(
"favorite_image" ).Show( m_IsFavorited );
660 return m_IsFavorited;
668 bool SetExpand(
bool expand)
680 if ( expand && m_FirstExpand )
682 if ( m_ServerData.m_Modded )
689 m_FirstExpand =
false;
695 void Select(
bool notify =
true )
701 m_Tab.SelectServer(
this );
704 m_ServerData.m_IsSelected =
true;
717 m_ServerData.m_IsSelected =
false;
720 Lighten(
m_Root,
null, 0, 0 );
727 int maxPlayers = m_ServerData.m_MaxPlayers;
728 int whiteColor =
ARGBF(1, 1, 1, 1);
729 int populationColor = whiteColor;
730 int populationOutline = 1;
734 if ( maxPlayers > 0 )
736 int population = m_ServerData.m_CurrentNumberPlayers;
737 float pop_percentage = population / maxPlayers;
739 if (pop_percentage >= 1)
741 populationColor =
ARGBF( 1, 1, 0, 0 );
743 else if ( pop_percentage >= 0.8 )
745 populationColor =
ARGBF( 1, 1, 0.5, 0 );
753 populationOutline = 0;
755 m_ServerPing.SetColor(whiteColor);
758 m_ServerTime.Show(IsOnline());
759 m_ServerName.SetColor(whiteColor);
760 m_ServerName.SetAlpha(alpha);
761 m_ServerPopulation.SetBold(IsOnline());
762 m_ServerPopulation.SetColor(populationColor);
763 m_ServerPopulation.SetOutline(populationOutline);
764 m_ServerPopulation.SetAlpha(alpha);
765 m_ServerSlots.SetAlpha(alpha);
766 m_ServerPing.SetAlpha(alpha);
769 #ifndef PLATFORM_CONSOLE
770 m_Expand.Show(IsOnline());
775 void Preview(
Widget w,
int x,
int y )
786 m_ServerName.SetColor(
ARGB( 255, 255, 0, 0 ) );
789 m_ServerName.SetAlpha(0.5);
795 void Darken(
Widget w,
int x,
int y )
803 SetPopulationEx(m_ServerData);
812 if (
GetFocus() == w || m_Selected )
823 SetPopulationEx(m_ServerData);