3 protected const int SERVERS_VISIBLE_COUNT = 24;
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);
156 #ifdef DIAG_DEVELOPER
163 #ifdef DIAG_DEVELOPER
164 if (m_DummyServersEnabled)
172 for (
int i = 0; i < entriesSortedCount; ++i )
246 int totalVisibleEntries = 0;
247 foreach(
string serverID, ServerBrowserEntry entry:
m_EntryWidgets)
249 if (entry.GetRoot().IsVisible())
250 totalVisibleEntries++;
259 #ifdef DIAG_DEVELOPER
260 if (m_DummyServersEnabled)
266 int count = result_list.
m_Results.Count();
269 for (
int i = 0; i < count; i++)
303 if (response ==
"thelastone")
323 super.OnClick(w,
x,
y, button);
521 for (
int i = 0; i <
m_BtnPages.Count(); ++i )
574 super.SetSort( type, order);
576 #ifdef PLATFORM_WINDOWS
577 m_Root.FindAnyWidget(
"host_sort" ).Show(
false );
578 m_Root.FindAnyWidget(
"population_sort" ).Show(
false );
579 m_Root.FindAnyWidget(
"slots_sort" ).Show(
false );
581 m_Root.FindAnyWidget(
"time_sort" ).Show(
false );
582 m_Root.FindAnyWidget(
"ping_sort" ).Show(
false );
583 m_Root.FindAnyWidget(
"map_sort" ).Show(
false );
586 root =
TextWidget.Cast(
m_Root.FindAnyWidget(
"server_list_content_header_host_label" ) );
587 root.SetColor(
ARGBF( 1, 1, 1, 1 ) );
588 root =
TextWidget.Cast(
m_Root.FindAnyWidget(
"server_list_content_header_population_label" ) );
589 root.SetColor(
ARGBF( 1, 1, 1, 1 ) );
590 root =
TextWidget.Cast(
m_Root.FindAnyWidget(
"server_list_content_header_slots_label" ) );
591 root.SetColor(
ARGBF( 1, 1, 1, 1 ) );
593 root =
TextWidget.Cast(
m_Root.FindAnyWidget(
"server_list_content_header_ping_label" ) );
594 root.SetColor(
ARGBF( 1, 1, 1, 1 ) );
595 root =
TextWidget.Cast(
m_Root.FindAnyWidget(
"server_list_content_header_time_label" ) );
596 root.SetColor(
ARGBF( 1, 1, 1, 1 ) );
605 r_name =
"server_list_content_header_host_label";
606 w_name =
"host_sort";
611 r_name =
"server_list_content_header_time_label";
612 w_name =
"time_sort";
617 r_name =
"server_list_content_header_population_label";
618 w_name =
"population_sort";
623 r_name =
"server_list_content_header_slots_label";
624 w_name =
"slots_sort";
629 r_name =
"server_list_content_header_ping_label";
630 w_name =
"ping_sort";
635 r_name =
"server_list_content_header_map_label";
642 root.SetColor(
ARGBF( 1, 1, 0, 0 ) );
644 m_Root.FindAnyWidget( w_name ).Show(
true );
726 int indexMax = list.Count() - 1;
728 int targetIndex =
Math.
Floor( indexMax / 2 );
729 int comparisonMultiplier = 1;
732 if (isDescending ==
true)
734 comparisonMultiplier = -1;
737 if ( indexMax == -1 )
739 list.Insert( entry );
745 int comparisonResult = comparisonMultiplier * entry.
CompareTo(list[targetIndex], sortType);
747 if ((indexMax - indexMin) <= 1)
749 for (
int i = indexMin; i <= indexMax; i++ )
751 comparisonResult = comparisonMultiplier * entry.
CompareTo(list[i], sortType);
753 if ( comparisonResult > 0 )
755 list.InsertAt( entry, i );
761 targetIndex =
Math.
Min(indexMax + 1, list.Count());
762 list.InsertAt(entry, targetIndex);
766 if (comparisonResult == 0)
768 list.InsertAt(entry, targetIndex);
772 if (comparisonResult > 0)
774 indexMax = targetIndex;
777 else if (comparisonResult < 0)
779 indexMin = targetIndex;
782 targetIndex = indexMin +
Math.
Floor((indexMax - indexMin) / 2);
795 int index_max = list.Count() - 1;
796 int target_index =
Math.
Floor( index_max / 2 );
798 if ( index_max == -1 )
800 list.Insert( entry );
810 string target_value_str = list[target_index].GetValueStr(
ESortType.HOST);
812 if ( entry_value_str == target_value_str || ((index_max - index_min) <= 1) )
814 for ( i = index_min; i <= index_max; i++ )
816 if ( entry_value_str <= list[i].GetValueStr(
ESortType.HOST) )
818 list.InsertAt( entry, i );
824 list.InsertAt( entry, index_max );
827 else if ( entry_value_str < target_value_str )
829 index_max = target_index;
830 target_index =
Math.
Floor( target_index / 2 );
832 else if ( entry_value_str > target_value_str )
834 index_min = target_index;
835 target_index +=
Math.
Floor( (index_max - index_min) / 2 );
841 int entry_value_int = entry.
GetValueInt( sort_type );
845 int target_value_int = list[target_index].GetValueInt( sort_type );
847 if ( entry_value_int == target_value_int || ((index_max - index_min) <= 1) )
849 for ( i = index_min; i <= index_max; i++ )
851 if ( entry_value_int <= list[i].GetValueInt( sort_type ) )
853 list.InsertAt( entry, i );
859 list.InsertAt( entry, index_max );
862 else if ( entry_value_int < target_value_int )
864 index_max = target_index;
865 target_index =
Math.
Floor( target_index / 2 );
867 else if ( entry_value_int > target_value_int )
869 index_min = target_index;
870 target_index +=
Math.
Floor( (index_max - index_min) / 2 );
902 int page_index = (i - 1);
903 m_BtnPages[page_index].Show( is_page_button_enable );
904 m_BtnPages[page_index].SetText( i.ToString() );
951 selected_btn_index = btn_index_center;
959 m_BtnPages[i].SetState( ( i == selected_btn_index ) );
1019 int lastFilledIndexOnPage = 0;
1022 ServerBrowserEntry entry;
1043 entry.SetIsOnline(
true);
1044 entry.FillInfo(server_info);
1046 entry.UpdateEntry();
1048 lastFilledIndexOnPage++;
1074 m_LoadingText.SetText(
string.Format(
"#dayz_game_loading %1", serversFound) );
1080 super.OnLoadServerModsAsync( server_id, mods );
1090 ref ServerBrowserEntry entry;
1100 entry =
new ServerBrowserEntry( null, index,
this );
1121 if ( super.IsFocusable( w ) )
1149 btn.SetText(
"#menu_cancel" );
1155 btn.SetText(
"#STR_server_browser_tab_root_filters_root_filters_content_refresh_list_button0" );
1183 super.ShowServerDetails();
1192#ifdef DIAG_DEVELOPER
1193 protected void RefreshDummyList()
1200 m_ServerListEntries.Clear();
1214 m_TotalServersCount = 0;
1215 m_ServersEstimateCount = 0;
1219 m_Menu.DeselectCurrentServer();
1223 if (!m_DummyServers || !m_DummyServers.m_Results)
1229 UpdatePageButtons();
1234 int count = m_DummyServers.m_Results.Count();
1235 for (
int j = 0; j < count; ++j)
1237 GetServersResultRow result = m_DummyServers.m_Results[j];
1248 if (PassLocalFilters(result))
1252 m_TotalServersCount = m_DummyServers.m_NumServers;
1260 ButtonCancelToRefresh();
1266 UpdatePageButtons();
1278 override void OnDummyServersEnabledChanged()
1280 super.OnDummyServersEnabledChanged();
1285 override int GetServersVisibleCount()
1287 return SERVERS_VISIBLE_COUNT;
1299 int index_max = list.Count() - 1;
1300 int target_index =
Math.
Floor( index_max / 2 );
1302 if ( index_max == -1 )
1304 list.Insert( entry );
1314 string target_value_str = list[target_index].GetValueStr(
ESortType.HOST);
1316 if ( entry_value_str == target_value_str || ((index_max - index_min) <= 1) )
1318 for ( i = index_min; i <= index_max; i++ )
1320 if ( entry_value_str >= list[i].GetValueStr(
ESortType.HOST) )
1322 list.InsertAt( entry, i );
1328 list.InsertAt( entry, index_max );
1329 return target_index;
1331 else if ( entry_value_str > target_value_str )
1333 index_max = target_index;
1334 target_index =
Math.
Floor( target_index / 2 );
1336 else if ( entry_value_str < target_value_str )
1338 index_min = target_index;
1339 target_index +=
Math.
Floor( (index_max - index_min) / 2 );
1345 int entry_value_int = entry.
GetValueInt( sort_type );
1349 int target_value_int = list[target_index].GetValueInt( sort_type );
1351 if ( entry_value_int == target_value_int || ((index_max - index_min) <= 1) )
1353 for ( i = index_min; i <= index_max; i++ )
1355 if ( entry_value_int >= list[i].GetValueInt( sort_type ) )
1357 list.InsertAt( entry, i );
1363 list.InsertAt( entry, index_max );
1364 return target_index;
1366 else if ( entry_value_int > target_value_int )
1368 index_max = target_index;
1369 target_index =
Math.
Floor( target_index / 2 );
1371 else if ( entry_value_int < target_value_int )
1373 index_min = target_index;
1374 target_index +=
Math.
Floor( (index_max - index_min) / 2 );
1379 return target_index;
EBiosError
Possible Error codes for bios API.
GetServersResult the output structure of the GetServers operation.
ref GetServersResultRowArray m_Results
GetServersResultRow the output structure of the GetServers operation that represents one game server.
int GetValueInt(ESortType sort_type)
int CompareTo(GetServersResultRow other, ESortType sortType)
string GetValueStr(ESortType sort_type)
static ref ScriptInvoker m_ServersAsyncInvoker
proto bool Remove(func fn, int flags=EScriptInvokerRemoveFlags.ALL)
remove specific call from list
proto bool Insert(func fn, int flags=EScriptInvokerInsertFlags.IMMEDIATE)
insert method to list
override bool IsFocusable(Widget w)
int m_ServersEstimateCount
ServerBrowserEntry GetServerEntryByIndex(int index, string server_id)
override void OnFilterChanged()
void ButtonRefreshToCancel()
override void RefreshList()
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
override void UpdateServerList()
const int PAGES_BUTTONS_COUNT
void LoadingServersStop()
int SortedInsertEx(GetServersResultRow entry, ESortType sortType, bool isDescending)
void SetPageIndex(int page_index)
int SortedInsertAsc(GetServersResultRow entry, ESortType sort_type)
override void SetSort(ESortType type, ESortOrder order)
void ToggleSort(ESortType type)
override void OnLoadServersAsyncPC(GetServersResult result_list, EBiosError error, string response)
bool OnClickPage(Widget w)
void OnLoadServersAsyncPCFinished()
override int AddSorted(GetServersResultRow entry)
ServerBrowserEntry GetServerEntryByIndex(int index)
TextWidget m_PnlPagesLoadingText
override void SwitchToFilters(bool focus=true)
override void ApplyFilters()
const int SERVERS_VISIBLE_COUNT
override void OnLoadServerModsAsync(string server_id, array< string > mods)
ref array< ref ServerBrowserEntry > m_ServerListEntries
Widget m_FilterPanelAccTime
override void ShowServerDetails()
int SortedInsertDesc(GetServersResultRow entry, ESortType sort_type)
ref TStringArray m_TempTime
ref array< ButtonWidget > m_BtnPages
int SortedInsert(GetServersResultRow entry, ESortType sort_type)
Widget m_FilterSearchIPBox
override void SwitchToDetails(bool focus=true)
override bool OnMouseEnter(Widget w, int x, int y)
ButtonWidget m_BtnPagesFirst
void ButtonCancelToRefresh()
ButtonWidget m_BtnPagesLast
int GetTimeOfDayEnum(string time_of_day)
override void Construct(Widget parent, ServerBrowserMenuNew menu, TabType type)
override bool OnClick(Widget w, int x, int y, int button)
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
override void ResetFilters()
override void LoadExtraEntries(int index)
override void RefreshList()
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
void Error(string err)
Messagebox with error message.
array< string > TStringArray
void Obsolete(string msg="")
static proto float Round(float f)
Returns mathematical round of value.
static proto float Min(float x, float y)
Returns smaller of two given values.
static proto float Floor(float f)
Returns floor of value.
void Split(string sample, out array< string > output)
Splits string into array of strings separated by 'sample'.
proto native int ToInt()
Converts string to integer.
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)
ref GetServersInput m_CurrentFilterInput
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
ref set< string > m_OnlineFavServers
ButtonWidget m_BtnShowDetails
int AddSorted(GetServersResultRow entry)