28 protected override void Construct(Widget parent, ServerBrowserMenuNew menu,
TabType type)
30 #ifdef PLATFORM_CONSOLE
31 m_Root =
g_Game.GetWorkspace().CreateWidgets(
"gui/layouts/new_ui/server_browser/xbox/server_browser_tab.layout", parent);
33 #ifdef PLATFORM_WINDOWS
34 m_Root =
g_Game.GetWorkspace().CreateWidgets(
"gui/layouts/new_ui/server_browser/pc/server_browser_tab_pages.layout", parent);
91 m_Filters =
new ServerBrowserFilterContainer(
m_Root.FindAnyWidget(
"filters_content"),
this);
99 int page_button_num = 1;
100 ButtonWidget page_button = ButtonWidget.Cast(
m_Root.FindAnyWidget(
"servers_navigation_page" + page_button_num));
102 if (PAGES_BUTTONS_COUNT < 3 || PAGES_BUTTONS_COUNT > 10)
104 Error(
"ServerBrowserTabPage->PAGES_BUTTONS_COUNT must be in range 3 - 10!");
110 page_button.Show(
false);
118 page_button = ButtonWidget.Cast(
m_Root.FindAnyWidget(
"servers_navigation_page"+ page_button_num));
133 m_Details =
new ServerBrowserDetailsContainer(
m_Root.FindAnyWidget(
"details_content"),
this);
137 m_Root.FindAnyWidget(
"filters_content").Show(
false);
138 m_Root.FindAnyWidget(
"reset_filter_button").Show(
false);
140 m_Root.FindAnyWidget(
"spacer").Show(
false);
141 m_Root.FindAnyWidget(
"spacer1").Show(
false);
142 m_Root.FindAnyWidget(
"spacer5").Show(
false);
237 int totalVisibleEntries = 0;
238 foreach(
string serverID, ServerBrowserEntry entry:
m_EntryWidgets)
240 if (entry.GetRoot().IsVisible())
241 totalVisibleEntries++;
252 int count = result_list.m_Results.Count();
255 for (
int i = 0; i < count; i++)
260 result.m_SortName = result.m_Name.ToInt();
289 if (response ==
"thelastone")
307 override bool OnClick(Widget w,
int x,
int y,
int button)
309 super.OnClick(w,
x,
y, button);
507 for (
int i = 0; i <
m_BtnPages.Count(); ++i )
560 super.SetSort( type, order);
562 #ifdef PLATFORM_WINDOWS
563 m_Root.FindAnyWidget(
"host_sort" ).Show(
false );
564 m_Root.FindAnyWidget(
"population_sort" ).Show(
false );
565 m_Root.FindAnyWidget(
"slots_sort" ).Show(
false );
567 m_Root.FindAnyWidget(
"time_sort" ).Show(
false );
568 m_Root.FindAnyWidget(
"ping_sort" ).Show(
false );
569 m_Root.FindAnyWidget(
"map_sort" ).Show(
false );
572 root = TextWidget.Cast(
m_Root.FindAnyWidget(
"server_list_content_header_host_label" ) );
573 root.SetColor(
ARGBF( 1, 1, 1, 1 ) );
574 root = TextWidget.Cast(
m_Root.FindAnyWidget(
"server_list_content_header_population_label" ) );
575 root.SetColor(
ARGBF( 1, 1, 1, 1 ) );
576 root = TextWidget.Cast(
m_Root.FindAnyWidget(
"server_list_content_header_slots_label" ) );
577 root.SetColor(
ARGBF( 1, 1, 1, 1 ) );
579 root = TextWidget.Cast(
m_Root.FindAnyWidget(
"server_list_content_header_ping_label" ) );
580 root.SetColor(
ARGBF( 1, 1, 1, 1 ) );
581 root = TextWidget.Cast(
m_Root.FindAnyWidget(
"server_list_content_header_time_label" ) );
582 root.SetColor(
ARGBF( 1, 1, 1, 1 ) );
591 r_name =
"server_list_content_header_host_label";
592 w_name =
"host_sort";
597 r_name =
"server_list_content_header_time_label";
598 w_name =
"time_sort";
603 r_name =
"server_list_content_header_population_label";
604 w_name =
"population_sort";
609 r_name =
"server_list_content_header_slots_label";
610 w_name =
"slots_sort";
615 r_name =
"server_list_content_header_ping_label";
616 w_name =
"ping_sort";
621 r_name =
"server_list_content_header_map_label";
627 root = TextWidget.Cast(
m_Root.FindAnyWidget( r_name ) );
628 root.SetColor(
ARGBF( 1, 1, 0, 0 ) );
630 m_Root.FindAnyWidget( w_name ).Show(
true );
706 return SortedInsertEx(entry, sort_type,
m_SortInverted[sort_type]);
712 int indexMax = list.Count() - 1;
714 int targetIndex =
Math.Floor( indexMax / 2 );
715 int comparisonMultiplier = 1;
718 if (isDescending ==
true)
720 comparisonMultiplier = -1;
723 if ( indexMax == -1 )
725 list.Insert( entry );
731 int comparisonResult = comparisonMultiplier * entry.CompareTo(list[targetIndex], sortType);
733 if ((indexMax - indexMin) <= 1)
735 for (
int i = indexMin; i <= indexMax; i++ )
737 comparisonResult = comparisonMultiplier * entry.CompareTo(list[i], sortType);
739 if ( comparisonResult > 0 )
741 list.InsertAt( entry, i );
747 targetIndex = Math.Min(indexMax + 1, list.Count());
748 list.InsertAt(entry, targetIndex);
752 if (comparisonResult == 0)
754 list.InsertAt(entry, targetIndex);
758 if (comparisonResult > 0)
760 indexMax = targetIndex;
763 else if (comparisonResult < 0)
765 indexMin = targetIndex;
768 targetIndex = indexMin + Math.Floor((indexMax - indexMin) / 2);
775 int SortedInsertAsc( GetServersResultRow entry,
ESortType sort_type )
781 int index_max = list.Count() - 1;
782 int target_index = Math.Floor( index_max / 2 );
784 if ( index_max == -1 )
786 list.Insert( entry );
792 string entry_value_str = entry.GetValueStr(
ESortType.HOST);
796 string target_value_str = list[target_index].GetValueStr(
ESortType.HOST);
798 if ( entry_value_str == target_value_str || ((index_max - index_min) <= 1) )
800 for ( i = index_min; i <= index_max; i++ )
802 if ( entry_value_str <= list[i].GetValueStr(
ESortType.HOST) )
804 list.InsertAt( entry, i );
810 list.InsertAt( entry, index_max );
813 else if ( entry_value_str < target_value_str )
815 index_max = target_index;
816 target_index = Math.Floor( target_index / 2 );
818 else if ( entry_value_str > target_value_str )
820 index_min = target_index;
821 target_index += Math.Floor( (index_max - index_min) / 2 );
827 int entry_value_int = entry.GetValueInt( sort_type );
831 int target_value_int = list[target_index].GetValueInt( sort_type );
833 if ( entry_value_int == target_value_int || ((index_max - index_min) <= 1) )
835 for ( i = index_min; i <= index_max; i++ )
837 if ( entry_value_int <= list[i].GetValueInt( sort_type ) )
839 list.InsertAt( entry, i );
845 list.InsertAt( entry, index_max );
848 else if ( entry_value_int < target_value_int )
850 index_max = target_index;
851 target_index = Math.Floor( target_index / 2 );
853 else if ( entry_value_int > target_value_int )
855 index_min = target_index;
856 target_index += Math.Floor( (index_max - index_min) / 2 );
865 int SortedInsertDesc( GetServersResultRow entry,
ESortType sort_type )
871 int index_max = list.Count() - 1;
872 int target_index = Math.Floor( index_max / 2 );
874 if ( index_max == -1 )
876 list.Insert( entry );
882 string entry_value_str = entry.GetValueStr(
ESortType.HOST);
886 string target_value_str = list[target_index].GetValueStr(
ESortType.HOST);
888 if ( entry_value_str == target_value_str || ((index_max - index_min) <= 1) )
890 for ( i = index_min; i <= index_max; i++ )
892 if ( entry_value_str >= list[i].GetValueStr(
ESortType.HOST) )
894 list.InsertAt( entry, i );
900 list.InsertAt( entry, index_max );
903 else if ( entry_value_str > target_value_str )
905 index_max = target_index;
906 target_index = Math.Floor( target_index / 2 );
908 else if ( entry_value_str < target_value_str )
910 index_min = target_index;
911 target_index += Math.Floor( (index_max - index_min) / 2 );
917 int entry_value_int = entry.GetValueInt( sort_type );
921 int target_value_int = list[target_index].GetValueInt( sort_type );
923 if ( entry_value_int == target_value_int || ((index_max - index_min) <= 1) )
925 for ( i = index_min; i <= index_max; i++ )
927 if ( entry_value_int >= list[i].GetValueInt( sort_type ) )
929 list.InsertAt( entry, i );
935 list.InsertAt( entry, index_max );
938 else if ( entry_value_int > target_value_int )
940 index_max = target_index;
941 target_index = Math.Floor( target_index / 2 );
943 else if ( entry_value_int < target_value_int )
945 index_min = target_index;
946 target_index += Math.Floor( (index_max - index_min) / 2 );
954 void UpdatePageButtons()
957 if ( m_PagesCount > 1 )
959 m_PnlPagesPanel.Show(
true );
962 int btn_index_center = Math.Round( PAGES_BUTTONS_COUNT / 2) - 1;
964 m_PageEndNum = PAGES_BUTTONS_COUNT;
966 if ( m_PagesCount <= PAGES_BUTTONS_COUNT )
968 m_PageEndNum = m_PagesCount;
971 for ( i = 1; i <= m_BtnPages.Count(); ++i )
973 bool is_page_button_enable = ( i <= m_PagesCount );
975 int page_index = (i - 1);
976 m_BtnPages[page_index].Show( is_page_button_enable );
977 m_BtnPages[page_index].SetText( i.ToString() );
981 m_BtnPages[page_index].SetState(
true );
985 m_BtnPages[page_index].SetState(
false );
1000 m_PageStartNum =
m_PageIndex - btn_index_center + 1;
1001 m_PageEndNum =
m_PageIndex + (PAGES_BUTTONS_COUNT - btn_index_center);
1003 if ( m_PageEndNum > m_PagesCount )
1006 m_PageStartNum -= m_PageEndNum - m_PagesCount;
1007 m_PageEndNum -= m_PageEndNum - m_PagesCount;
1016 if ( m_PageEndNum == m_PagesCount )
1019 selected_btn_index = PAGES_BUTTONS_COUNT - (m_PagesCount -
m_PageIndex);
1024 selected_btn_index = btn_index_center;
1029 for ( i = 0; i < m_BtnPages.Count(); ++i )
1031 m_BtnPages[i].SetText( (m_PageStartNum + i).
ToString() );
1032 m_BtnPages[i].SetState( ( i == selected_btn_index ) );
1061 if ( m_PageStartNum == 1 )
1063 m_BtnPagesFirst.SetText(
"" );
1064 m_BtnPagesFirst.Enable(
false );
1068 m_BtnPagesFirst.SetText(
"<<" );
1069 m_BtnPagesFirst.Enable(
true );
1073 if ( m_PageEndNum == m_PagesCount )
1075 m_BtnPagesLast.SetText(
"" );
1076 m_BtnPagesLast.Enable(
false );
1080 m_BtnPagesLast.SetText(
">>" );
1081 m_BtnPagesLast.Enable(
true );
1086 m_PnlPagesPanel.Show(
false);
1092 int lastFilledIndexOnPage = 0;
1095 ServerBrowserEntry entry;
1099 for (
int i = 0; i < SERVERS_VISIBLE_COUNT; ++i)
1101 int serverIndex = i + (SERVERS_VISIBLE_COUNT *
m_PageIndex);
1107 if (server_info.m_Favorite)
1114 entry = GetServerEntryByIndex(i, server_info.GetIpPort());
1116 entry.SetIsOnline(
true);
1117 entry.FillInfo(server_info);
1119 entry.UpdateEntry();
1121 lastFilledIndexOnPage++;
1125 entry = GetServerEntryByIndex(i,
"-1");
1138 void UpdateStatusBar()
1147 m_LoadingText.SetText(
string.Format(
"#dayz_game_loading %1", serversFound) );
1153 super.OnLoadServerModsAsync( server_id, mods );
1163 ref ServerBrowserEntry entry;
1173 entry =
new ServerBrowserEntry( null, index,
this );
1194 if ( super.IsFocusable( w ) )
1222 btn.SetText(
"#menu_cancel" );
1228 btn.SetText(
"#STR_server_browser_tab_root_filters_root_filters_content_refresh_list_button0" );
1256 super.ShowServerDetails();
EBiosError
Possible Error codes for bios API. This is the list of errors that can be returned from bios API....
GetServersResult the output structure of the GetServers operation.
GetServersResultRow the output structure of the GetServers operation that represents one game server.
ref TStringArray m_TempTime
int GetTimeOfDayEnum(string time_of_day)
override bool IsFocusable(Widget w)
override void ShowServerDetails()
override void ApplyFilters()
override bool OnClick(Widget w, int x, int y, int button)
void ToggleSort(ESortType type)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
void LoadingServersStop()
override void SwitchToDetails(bool focus=true)
override void SetSort(ESortType type, ESortOrder order)
TextWidget m_PnlPagesLoadingText
override void SwitchToFilters(bool focus=true)
void SetPageIndex(int page_index)
override int AddSorted(GetServersResultRow entry)
void ButtonCancelToRefresh()
ref array< ButtonWidget > m_BtnPages
ref array< ref ServerBrowserEntry > m_ServerListEntries
override void ResetFilters()
Widget m_FilterPanelAccTime
int m_ServersEstimateCount
ButtonWidget m_BtnPagesFirst
override void RefreshList()
Widget m_FilterSearchIPBox
ServerBrowserEntry GetServerEntryByIndex(int index, string server_id)
override void OnFilterChanged()
override bool OnMouseEnter(Widget w, int x, int y)
int SortedInsert(GetServersResultRow entry, ESortType sort_type)
void ~ServerBrowserTabPc()
override void Construct(Widget parent, ServerBrowserMenuNew menu, TabType type)
const int PAGES_BUTTONS_COUNT
ButtonWidget m_BtnPagesLast
void OnLoadServersAsyncPCFinished()
override void OnLoadServersAsyncPC(GetServersResult result_list, EBiosError error, string response)
const int SERVERS_VISIBLE_COUNT
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
void ButtonRefreshToCancel()
bool OnClickPage(Widget w)
override void RefreshList()
override void LoadExtraEntries(int index)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
void Error(string err)
Messagebox with error message.
array< string > TStringArray
void ColorNormal(Widget w)
void ColorHighlight(Widget w)
int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.
ref ServerBrowserFilterContainer m_Filters
ref map< ESortType, ref array< ref GetServersResultRow > > m_EntriesSorted
Widget m_FilterSearchText
TextWidget m_RightAreaHeaderText
ServerBrowserEntry m_SelectedServer
void ButtonDisable(Widget w)
ButtonWidget m_BtnPageNext
ref map< ESortType, ESortOrder > m_SortInverted
ButtonWidget m_BtnShowFilters
ref map< string, ref ServerBrowserEntry > m_EntryWidgets
void SwitchToDetails(bool focus=true)
ScrollWidget m_ServerListScroller
bool PassFilter(GetServersResultRow result)
string m_CurrentSelectedServer
ServerBrowserMenuNew m_Menu
void SwitchToFilters(bool focus=true)
ref map< string, ref array< string > > m_EntryMods
ButtonWidget m_BtnPagePrev
void ButtonEnable(Widget w)
SpacerBaseWidget m_ServerList
Widget m_FilterSearchTextBox
bool IsFocusable(Widget w)
ref ServerBrowserDetailsContainer m_Details
void OnLoadServerModsAsync(string server_id, array< string > mods)
ref set< string > m_OnlineFavServers
ButtonWidget m_BtnShowDetails
int AddSorted(GetServersResultRow entry)