3 protected const int SERVERS_VISIBLE_COUNT = 24;
4 protected const int PAGES_BUTTONS_COUNT = 10;
6 protected int m_TotalServersCount;
8 protected int m_PageStartNum;
9 protected int m_PageEndNum;
10 protected int m_PagesCount;
11 protected int m_ServersEstimateCount;
13 protected Widget m_PnlPagesPanel;
30 #ifdef PLATFORM_CONSOLE
33 #ifdef PLATFORM_WINDOWS
70 m_FilterSearchIP =
m_Root.FindAnyWidget(
"search_ip_setting" );
71 m_FilterSearchIPBox =
m_Root.FindAnyWidget(
"search_ip_setting_option" );
73 m_FilterPanelAccTime =
m_Root.FindAnyWidget(
"accelerated_time_setting" );
74 m_FilterPanelPing =
m_Root.FindAnyWidget(
"ping_setting" );
86 m_Filters =
new ServerBrowserFilterContainer(
m_Root.FindAnyWidget(
"filters_content" ),
this );
94 int page_button_num = 1;
95 ButtonWidget page_button = ButtonWidget.Cast(
m_Root.FindAnyWidget(
"servers_navigation_page"+ page_button_num ) );
97 if ( PAGES_BUTTONS_COUNT < 3 || PAGES_BUTTONS_COUNT > 10 )
99 Error(
"ServerBrowserTabPage->PAGES_BUTTONS_COUNT must be in range 3 - 10!");
103 while ( page_button )
105 page_button.Show(
false);
107 if ( page_button_num <= PAGES_BUTTONS_COUNT )
109 m_BtnPages.Insert( page_button );
113 page_button = ButtonWidget.Cast(
m_Root.FindAnyWidget(
"servers_navigation_page"+ page_button_num ) );
118 m_PnlPagesPanel =
m_Root.FindAnyWidget(
"servers_navigation_spacer" );
121 m_BtnPagesFirst = ButtonWidget.Cast(
m_Root.FindAnyWidget(
"servers_navigation_page_first" ) ) ;
122 m_BtnPagesLast = ButtonWidget.Cast(
m_Root.FindAnyWidget(
"servers_navigation_page_last" ) ) ;
124 m_PnlPagesPanel.Show(
true );
136 m_Root.FindAnyWidget(
"filters_content" ).Show(
false );
137 m_Root.FindAnyWidget(
"spacer" ).Show(
false );
138 m_Root.FindAnyWidget(
"spacer2" ).Show(
false );
139 m_Root.FindAnyWidget(
"reset_filter_button" ).Show(
false );
155 m_TotalServersCount = 0;
157 m_ServersEstimateCount = 0;
163 ButtonRefreshToCancel();
197 ButtonCancelToRefresh();
207 int count = result_list.m_Results.Count();
210 for (
int i = 0; i < count; i++ )
212 GetServersResultRow result = result_list.m_Results[i];
213 m_TotalServersCount++;
215 result.m_SortName = result.m_Name.ToInt();
216 result.m_SortTime = GetTimeOfDayEnum( result.m_TimeOfDay );
221 if ( sorted_index < (
m_PageIndex * SERVERS_VISIBLE_COUNT + SERVERS_VISIBLE_COUNT) )
245 if ( response ==
"thelastone" )
247 OnLoadServersAsyncPCFinished();
251 m_ServersEstimateCount = result_list.m_NumServers;
260 LoadingServersStop();
265 super.OnClick( w,
x,
y, button );
282 LoadingServersStop();
301 else if ( w == m_BtnPagesLast )
306 else if ( w == m_BtnPagesFirst )
313 bool click = OnClickPage( w );
337 else if ( w == m_FilterSearchIP )
424 SetPageIndex( m_PagesCount - 1 );
442 SetPageIndex( m_PagesCount - 1 );
452 for (
int i = 0; i < m_BtnPages.Count(); ++i )
454 if ( m_BtnPages[i] == w )
456 SetPageIndex( m_PageStartNum + i - 1 );
504 super.SetSort( type, order);
506 #ifdef PLATFORM_WINDOWS
507 m_Root.FindAnyWidget(
"host_sort" ).Show(
false );
508 m_Root.FindAnyWidget(
"population_sort" ).Show(
false );
509 m_Root.FindAnyWidget(
"slots_sort" ).Show(
false );
511 m_Root.FindAnyWidget(
"time_sort" ).Show(
false );
512 m_Root.FindAnyWidget(
"ping_sort" ).Show(
false );
515 root =
TextWidget.Cast(
m_Root.FindAnyWidget(
"server_list_content_header_host_label" ) );
516 root.SetColor(
ARGBF( 1, 1, 1, 1 ) );
517 root =
TextWidget.Cast(
m_Root.FindAnyWidget(
"server_list_content_header_population_label" ) );
518 root.SetColor(
ARGBF( 1, 1, 1, 1 ) );
519 root =
TextWidget.Cast(
m_Root.FindAnyWidget(
"server_list_content_header_slots_label" ) );
520 root.SetColor(
ARGBF( 1, 1, 1, 1 ) );
522 root =
TextWidget.Cast(
m_Root.FindAnyWidget(
"server_list_content_header_ping_label" ) );
523 root.SetColor(
ARGBF( 1, 1, 1, 1 ) );
524 root =
TextWidget.Cast(
m_Root.FindAnyWidget(
"server_list_content_header_time_label" ) );
525 root.SetColor(
ARGBF( 1, 1, 1, 1 ) );
534 r_name =
"server_list_content_header_host_label";
535 w_name =
"host_sort";
540 r_name =
"server_list_content_header_time_label";
541 w_name =
"time_sort";
546 r_name =
"server_list_content_header_population_label";
547 w_name =
"population_sort";
552 r_name =
"server_list_content_header_slots_label";
553 w_name =
"slots_sort";
558 r_name =
"server_list_content_header_ping_label";
559 w_name =
"ping_sort";
565 root.SetColor(
ARGBF( 1, 1, 0, 0 ) );
567 m_Root.FindAnyWidget( w_name ).Show(
true );
577 time_of_day.
Split(
":", m_TempTime );
581 if ( m_TempTime.Count() > 0 )
583 int h = m_TempTime[0].ToInt();
597 if ( m_TempTime.Count() > 1 )
599 int m = m_TempTime[0].ToInt();
609 int index_host = SortedInsert( entry,
ESortType.HOST );
610 int index_time = SortedInsert( entry,
ESortType.TIME );
611 int index_popu = SortedInsert( entry,
ESortType.POPULATION );
612 int index_slot = SortedInsert( entry,
ESortType.SLOTS );
613 int index_ping = SortedInsert( entry,
ESortType.PING );
614 int index_favo = SortedInsert( entry,
ESortType.FAVORITE );
615 int index_pass = SortedInsert( entry,
ESortType.PASSWORDED );
640 super.SelectServer( server );
642 #ifdef PLATFORM_CONSOLE
651 m_Menu.SelectServer( server );
658 return SortedInsertDesc(entry, sort_type);
661 return SortedInsertAsc(entry, sort_type);
670 int index_max = list.Count() - 1;
671 int target_index =
Math.
Floor( index_max / 2 );
673 if ( index_max == -1 )
675 list.Insert( entry );
681 string entry_value_str = entry.GetValueStr(
ESortType.HOST);
685 string target_value_str = list[target_index].GetValueStr(
ESortType.HOST);
687 if ( entry_value_str == target_value_str || ((index_max - index_min) <= 1) )
689 for ( i = index_min; i <= index_max; i++ )
693 list.InsertAt( entry, i );
699 list.InsertAt( entry, index_max );
702 else if ( entry_value_str < target_value_str )
704 index_max = target_index;
705 target_index =
Math.
Floor( target_index / 2 );
707 else if ( entry_value_str > target_value_str )
709 index_min = target_index;
710 target_index +=
Math.
Floor( (index_max - index_min) / 2 );
716 int entry_value_int = entry.GetValueInt( sort_type );
720 int target_value_int = list[target_index].GetValueInt( sort_type );
722 if ( entry_value_int == target_value_int || ((index_max - index_min) <= 1) )
724 for ( i = index_min; i <= index_max; i++ )
726 if ( entry_value_int <= list[i].
GetValueInt( sort_type ) )
728 list.InsertAt( entry, i );
734 list.InsertAt( entry, index_max );
737 else if ( entry_value_int < target_value_int )
739 index_max = target_index;
740 target_index =
Math.
Floor( target_index / 2 );
742 else if ( entry_value_int > target_value_int )
744 index_min = target_index;
745 target_index +=
Math.
Floor( (index_max - index_min) / 2 );
759 int index_max = list.Count() - 1;
760 int target_index =
Math.
Floor( index_max / 2 );
762 if ( index_max == -1 )
764 list.Insert( entry );
770 string entry_value_str = entry.GetValueStr(
ESortType.HOST);
774 string target_value_str = list[target_index].GetValueStr(
ESortType.HOST);
776 if ( entry_value_str == target_value_str || ((index_max - index_min) <= 1) )
778 for ( i = index_min; i <= index_max; i++ )
782 list.InsertAt( entry, i );
788 list.InsertAt( entry, index_max );
791 else if ( entry_value_str > target_value_str )
793 index_max = target_index;
794 target_index =
Math.
Floor( target_index / 2 );
796 else if ( entry_value_str < target_value_str )
798 index_min = target_index;
799 target_index +=
Math.
Floor( (index_max - index_min) / 2 );
805 int entry_value_int = entry.GetValueInt( sort_type );
809 int target_value_int = list[target_index].GetValueInt( sort_type );
811 if ( entry_value_int == target_value_int || ((index_max - index_min) <= 1) )
813 for ( i = index_min; i <= index_max; i++ )
815 if ( entry_value_int >= list[i].
GetValueInt( sort_type ) )
817 list.InsertAt( entry, i );
823 list.InsertAt( entry, index_max );
826 else if ( entry_value_int > target_value_int )
828 index_max = target_index;
829 target_index =
Math.
Floor( target_index / 2 );
831 else if ( entry_value_int < target_value_int )
833 index_min = target_index;
834 target_index +=
Math.
Floor( (index_max - index_min) / 2 );
845 if ( m_PagesCount > 1 )
847 m_PnlPagesPanel.Show(
true );
850 int btn_index_center =
Math.
Round( PAGES_BUTTONS_COUNT / 2) - 1;
852 m_PageEndNum = PAGES_BUTTONS_COUNT;
854 if ( m_PagesCount <= PAGES_BUTTONS_COUNT )
856 m_PageEndNum = m_PagesCount;
859 for ( i = 1; i <= m_BtnPages.Count(); ++i )
861 bool is_page_button_enable = ( i <= m_PagesCount );
863 int page_index = (i - 1);
864 m_BtnPages[page_index].Show( is_page_button_enable );
865 m_BtnPages[page_index].SetText( i.ToString() );
869 m_BtnPages[page_index].SetState(
true );
873 m_BtnPages[page_index].SetState(
false );
888 m_PageStartNum =
m_PageIndex - btn_index_center + 1;
889 m_PageEndNum =
m_PageIndex + (PAGES_BUTTONS_COUNT - btn_index_center);
891 if ( m_PageEndNum > m_PagesCount )
894 m_PageStartNum -= m_PageEndNum - m_PagesCount;
895 m_PageEndNum -= m_PageEndNum - m_PagesCount;
904 if ( m_PageEndNum == m_PagesCount )
907 selected_btn_index = PAGES_BUTTONS_COUNT - (m_PagesCount -
m_PageIndex);
912 selected_btn_index = btn_index_center;
917 for ( i = 0; i < m_BtnPages.Count(); ++i )
919 m_BtnPages[i].SetText( (m_PageStartNum + i).ToString() );
920 m_BtnPages[i].SetState( ( i == selected_btn_index ) );
949 if ( m_PageStartNum == 1 )
951 m_BtnPagesFirst.SetText(
"" );
952 m_BtnPagesFirst.Enable(
false );
956 m_BtnPagesFirst.SetText(
"<<" );
957 m_BtnPagesFirst.Enable(
true );
961 if ( m_PageEndNum == m_PagesCount )
963 m_BtnPagesLast.SetText(
"" );
964 m_BtnPagesLast.Enable(
false );
968 m_BtnPagesLast.SetText(
">>" );
969 m_BtnPagesLast.Enable(
true );
974 m_PnlPagesPanel.Show(
false);
980 int lastFilledIndexOnPage = 0;
982 ServerBrowserEntry entry;
986 for (
int i = 0; i < SERVERS_VISIBLE_COUNT; ++i )
988 int serverIndex = i + (SERVERS_VISIBLE_COUNT *
m_PageIndex);
994 if ( server_info.m_Favorite )
999 entry = GetServerEntryByIndex(i, server_info.m_Id);
1001 entry.SetIsOnline(
true );
1002 entry.FillInfo( server_info );
1003 entry.SetMods(
m_EntryMods.Get( server_info.m_Id ) );
1004 entry.UpdateEntry();
1008 entry.SetName(
"#dayz_game_loading");
1011 lastFilledIndexOnPage++;
1015 entry = GetServerEntryByIndex(i,
"-1");
1019 entry.Show(
false );
1037 m_LoadingText.SetText(
string.Format(
"#dayz_game_loading %1", serversFound) );
1043 super.OnLoadServerModsAsync( server_id, mods );
1053 ref ServerBrowserEntry entry;
1057 if ( index < m_ServerListEntries.Count() )
1059 entry = m_ServerListEntries[index];
1063 entry =
new ServerBrowserEntry( null, index,
this );
1066 m_ServerListEntries.Insert(entry);
1084 if ( super.IsFocusable( w ) )
1099 if ( w == m_FilterPanelAccTime || m_FilterPanelPing )
1112 btn.SetText(
"#menu_cancel" );
1118 btn.SetText(
"#STR_server_browser_tab_root_filters_root_filters_content_refresh_list_button0" );
EBiosError
Possible Error codes for bios API. This is the list of errors that can be returned from bios API....
int GetValueInt(ESortType sort_type)
string GetValueStr(ESortType sort_type)
protected Widget m_SlotsSort
protected Widget m_PopulationSort
protected ref ServerBrowserFilterContainer m_Filters
protected ServerBrowserMenuNew m_Menu
protected Widget m_ResetFilters
protected TextWidget m_LoadingText
void ButtonDisable(Widget w)
protected ref map< ESortType, ref array< ref GetServersResultRow > > m_EntriesSorted
void ScrollToEntry(ServerBrowserEntry entry)
protected ref map< string, ref ServerBrowserEntry > m_EntryWidgets
protected TabType m_TabType
bool PassFilter(GetServersResultRow result)
protected ref map< ESortType, ESortOrder > m_SortInverted
protected Widget m_ApplyFilter
protected ESortOrder m_SortOrder
protected Widget m_RefreshList
protected Widget m_TimeSort
protected bool m_LoadingFinished
protected Widget m_HostSort
protected ESortType m_SortType
void ColorNormal(Widget w)
protected int m_TotalLoadedServers
protected ref map< string, ref array< string > > m_EntryMods
void ButtonEnable(Widget w)
protected Widget m_FilterSearchText
protected SpacerBaseWidget m_ServerList
protected Widget m_FiltersChanged
protected ServerBrowserEntry m_SelectedServer
protected ButtonWidget m_BtnPagePrev
bool IsFocusable(Widget w)
protected Widget m_FilterSearchTextBox
void ColorHighlight(Widget w)
protected ButtonWidget m_BtnPageNext
protected ScrollWidget m_ServerListScroller
protected ref set< string > m_OnlineFavServers
protected Widget m_PingSort
int AddSorted(GetServersResultRow entry)
ServerBrowserMenuNew GetRootMenu()
protected int m_PageIndex
proto native WorkspaceWidget GetWorkspace()
GetServersResult the output structure of the GetServers operation.
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
protected Widget m_FilterPanelPing
override bool IsFocusable(Widget w)
protected ButtonWidget m_BtnPagesFirst
override void OnLoadServersAsyncPC(ref GetServersResult result_list, EBiosError error, string response)
protected ref array< ButtonWidget > m_BtnPages
protected int m_PageIndex
protected Widget m_FilterPanelAccTime
override void OnFilterChanged()
void ButtonRefreshToCancel()
protected Widget m_FilterSearchIP
override void RefreshList()
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
void LoadingServersStop()
void SetPageIndex(int page_index)
int SortedInsertAsc(GetServersResultRow entry, ESortType sort_type)
override void SetSort(ESortType type, ESortOrder order)
void ToggleSort(ESortType type)
protected ServerBrowserEntry GetServerEntryByIndex(int index, string server_id)
bool OnClickPage(Widget w)
void OnLoadServersAsyncPCFinished()
override int AddSorted(GetServersResultRow entry)
protected Widget m_FilterSearchIPBox
override void ApplyFilters()
void ~ServerBrowserTabPc()
override void OnLoadServerModsAsync(string server_id, array< string > mods)
protected ref array< ref ServerBrowserEntry > m_ServerListEntries
protected override void Construct(Widget parent, ServerBrowserMenuNew menu, TabType type)
int SortedInsertDesc(GetServersResultRow entry, ESortType sort_type)
int SortedInsert(GetServersResultRow entry, ESortType sort_type)
protected ButtonWidget m_BtnPagesLast
override bool OnMouseEnter(Widget w, int x, int y)
override void SelectServer(ServerBrowserEntry server)
void ButtonCancelToRefresh()
int GetTimeOfDayEnum(string time_of_day)
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 RefreshList()
protected override void LoadExtraEntries(int index)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.
array< string > TStringArray
static proto float Round(float f)
Returns mathematical round of value.
static proto float Ceil(float f)
Returns ceil of value.
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'.
int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.