3 private bool m_IsFilterChanged;
4 private bool m_IsFilterFocused;
5 protected bool m_MouseKeyboardControlled
7 private Widget m_WidgetNavFilters;
8 private Widget m_WidgetNavServers;
10 protected Widget m_ButtonPageLeftImg;
11 protected Widget m_ButtonPageRightImg;
13 protected int m_PreviousPage;
14 protected int m_TotalServersCount;
15 protected int m_PageStartNum;
16 protected int m_PageEndNum;
17 protected int m_PagesCount;
18 protected int m_ServersEstimateCount;
19 protected int m_TimeLastServerRefresh;
20 protected int m_TimeLastServerRefreshHoldButton;
22 protected Widget m_PnlPagesPanel;
26 protected override void Construct(
Widget parent, ServerBrowserMenuNew menu,
TabType type )
28 m_Root =
GetGame().GetWorkspace().CreateWidgets(
"gui/layouts/new_ui/server_browser/xbox/server_browser_tab_console_pages.layout", parent );
56 m_WidgetNavFilters =
m_Root.FindAnyWidget(
"filters_root_nav_wrapper" );
57 m_WidgetNavServers =
m_Root.FindAnyWidget(
"server_list_root_nav_wrapper" );
63 m_ButtonPageLeftImg =
m_Root.FindAnyWidget(
"servers_navigation_page_prev_icon_ps4" );
64 m_ButtonPageRightImg =
m_Root.FindAnyWidget(
"servers_navigation_page_next_icon_ps4" );
65 m_Root.FindAnyWidget(
"servers_navigation_page_prev_icon_xbox" ).Show(
false );
66 m_Root.FindAnyWidget(
"servers_navigation_page_next_icon_xbox" ).Show(
false );
68 m_ButtonPageLeftImg =
m_Root.FindAnyWidget(
"servers_navigation_page_prev_icon_xbox" );
69 m_ButtonPageRightImg =
m_Root.FindAnyWidget(
"servers_navigation_page_next_icon_xbox" );
70 m_Root.FindAnyWidget(
"servers_navigation_page_prev_icon_ps4" ).Show(
false );
71 m_Root.FindAnyWidget(
"servers_navigation_page_next_icon_ps4" ).Show(
false );
74 ShowHideConsoleWidgets();
76 m_Filters =
new ServerBrowserFilterContainer(
m_Root.FindAnyWidget(
"filters_content" ),
this );
78 m_PnlPagesPanel =
m_Root.FindAnyWidget(
"servers_navigation_spacer" );
81 m_PnlPagesPanel.Show(
true );
96 void ShowHideConsoleWidgets()
104 m_Root.FindAnyWidget(
"filters_button_wrapper" ).Show(
GetGame().
GetInput().IsEnabledMouseAndKeyboard() );
106 m_Root.FindAnyWidget(
"filters_root_nav_img_lb_xbox" ).Show( is_xbox );
107 m_Root.FindAnyWidget(
"filters_root_nav_img_rb_xbox" ).Show( is_xbox );
108 m_Root.FindAnyWidget(
"server_list_root_nav_img_lb_xbox" ).Show( is_xbox );
109 m_Root.FindAnyWidget(
"server_list_root_nav_img_rb_xbox" ).Show( is_xbox );
111 m_Root.FindAnyWidget(
"filters_root_nav_img_l1_ps4" ).Show( !is_xbox );
112 m_Root.FindAnyWidget(
"filters_root_nav_img_r1_ps4" ).Show( !is_xbox );
113 m_Root.FindAnyWidget(
"server_list_root_nav_img_l1_ps4" ).Show( !is_xbox );
114 m_Root.FindAnyWidget(
"server_list_root_nav_img_r1_ps4" ).Show( !is_xbox );
119 switch (pInputDeviceType)
122 ShowHideConsoleWidgets();
124 m_WidgetNavFilters.Show(m_IsFilterFocused);
125 m_WidgetNavServers.Show(!m_IsFilterFocused);
126 m_MouseKeyboardControlled =
false;
132 m_WidgetNavFilters.Show(
false);
133 m_WidgetNavServers.Show(
false);
134 m_ButtonPageLeftImg.Show(
false);
135 m_ButtonPageRightImg.Show(
false);
136 m_MouseKeyboardControlled =
true;
153 m_PagesCount = result_list.m_Pages;
154 m_TotalServersCount = result_list.m_NumServers;
156 LoadEntries( result_list.m_Page, result_list.m_Results );
163 OnLoadServersAsyncFinished();
167 void OnLoadServersAsyncFinished()
172 msg =
"#server_browser_tab_unable_to_get_server";
183 ServerBrowserEntry entry;
197 if ( m_PagesCount && page_entries )
199 foreach ( GetServersResultRow result : page_entries )
201 if ( PassFilter( result ) )
203 string ipPort = result.GetIpPort();
204 bool isFavorited =
m_Menu.IsFavorited(ipPort);
206 entry = GetServerEntryByIndex( index );
207 entry.SetIsOnline(
true);
208 entry.FillInfo( result );
209 entry.SetFavorite(isFavorited);
230 LoadExtraEntries(index);
235 protected ServerBrowserEntry GetServerEntryByIndex(
int index )
237 ServerBrowserEntry entry;
241 if ( index < m_ServerListEntiers.Count() )
243 entry = m_ServerListEntiers[index];
247 entry =
new ServerBrowserEntry(
m_ServerList, index,
this );
248 m_ServerListEntiers.Insert(entry);
263 m_IsFilterChanged =
true;
266 bool CanRefreshServerList()
271 override void RefreshList()
273 for (
int i = 0; i < m_ServerListEntiers.Count(); i++ )
275 m_ServerListEntiers[i].Show(
false);
288 m_IsFilterChanged =
false;
300 super.ResetFilters();
302 m_IsFilterChanged =
false;
307 if ( m_IsFilterChanged )
312 m_IsFilterChanged =
false;
322 override void PressX()
326 m_TimeLastServerRefresh =
GetGame().GetTime();
328 if ( m_IsFilterChanged)
338 override void PressY()
342 case SelectedPanel.BROWSER:
350 case SelectedPanel.FILTERS:
363 if ( !m_IsFilterFocused )
366 m_PreviousPage = curr_page;
377 if ( !m_IsFilterFocused )
379 if ( (
GetGame().
GetTime() - m_TimeLastServerRefreshHoldButton) > 100 )
381 m_TimeLastServerRefreshHoldButton =
GetGame().GetTime();
395 override void Right()
397 if ( !m_IsFilterFocused )
400 m_PreviousPage = curr_page;
401 if ( curr_page < m_PagesCount )
411 if ( !m_IsFilterFocused )
413 if ( (
GetGame().
GetTime() - m_TimeLastServerRefreshHoldButton) > 100 )
415 m_TimeLastServerRefreshHoldButton =
GetGame().GetTime();
431 if ( m_IsFilterFocused )
443 if ( m_IsFilterFocused )
452 override void Focus()
461 if ( entries && entries.Count() > 0 )
468 void SetFocusFilters()
470 SetEnableFilters(
true);
471 SetEnableServers(
false);
474 if (!m_MouseKeyboardControlled)
476 m_WidgetNavFilters.Show(
true);
477 m_WidgetNavServers.Show(
false);
481 m_IsFilterFocused =
true;
486 void SetFocusServers()
488 SetEnableServers(
true);
489 SetEnableFilters(
false);
491 if (!m_MouseKeyboardControlled)
493 m_WidgetNavFilters.Show(
false);
494 m_WidgetNavServers.Show(
true);
498 if ( entries && entries.Count() > 0 )
507 m_IsFilterFocused =
false;
514 void SetEnableFilters(
bool enable)
516 Widget w_filters =
m_Root.FindAnyWidget(
"filters_content");
517 Widget w_content =
m_Root.FindAnyWidget(
"server_list_scroller");
518 w_content.Enable( !enable );
522 SetFocus( ButtonWidget.Cast(w_filters.FindWidget(
"sort_button")) );
526 void SetEnableServers(
bool enable)
528 Widget w_filters =
m_Root.FindAnyWidget(
"filters_content");
529 Widget w_content =
m_Root.FindAnyWidget(
"server_list_scroller");
530 w_content.Enable( enable );
533 void UpdatePageButtons()
539 if ( !m_IsFilterFocused && (m_PagesCount > 1) && !m_MouseKeyboardControlled )
542 m_ButtonPageLeftImg.Show( can_left );
546 m_ButtonPageRightImg.Show( can_right );
551 m_ButtonPageLeftImg.Show(
false );
553 m_ButtonPageRightImg.Show(
false );
560 super.OnClick( w,
x,
y, button );
608 w.SetColor(
ARGB( 255, 200, 0, 0) );
623 if ( w.IsInherited( ButtonWidget ) )
625 ButtonWidget button = ButtonWidget.Cast( w );
626 button.SetTextColor(
ARGB( 255, 255, 255, 255 ) );
630 w.SetColor(
ARGB( 0, 255, 255, 255 ) );
636 ImageWidget image = ImageWidget.Cast( w.FindAnyWidget( w.GetName() +
"_image" ) );
638 Widget option =
Widget.Cast( w.FindAnyWidget( w.GetName() +
"_option_wrapper" ) );
642 text1.SetColor(
ARGB( 255, 255, 255, 255 ) );
647 text2.SetColor(
ARGB( 255, 255, 255, 255 ) );
652 text3.SetColor(
ARGB( 255, 255, 255, 255 ) );
658 image.SetColor(
ARGB( 255, 255, 255, 255 ) );
663 option.SetColor(
ARGB( 150, 255, 255, 255 ) );
669 #ifdef PLATFORM_WINDOWS
673 ButtonWidget button = ButtonWidget.Cast( w );
676 button.SetTextColor(
ColorManager.COLOR_DISABLED_TEXT );