Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
serverbrowsertabconsole.c
Go to the documentation of this file.
1 class ServerBrowserTabConsole extends ServerBrowserTab
2 {
3  private bool m_IsFilterChanged;
4  private bool m_IsFilterFocused;
5 
6  private Widget m_WidgetNavFilters;
7  private Widget m_WidgetNavServers;
8 
9  protected override void Construct( Widget parent, ServerBrowserMenuNew menu, TabType type )
10  {
11  m_Root = GetGame().GetWorkspace().CreateWidgets( "gui/layouts/new_ui/server_browser/xbox/server_browser_tab.layout", parent );
12 
13  m_ServerListScroller = ScrollWidget.Cast( m_Root.FindAnyWidget( "server_list_scroller" ) );
14  m_ServerList = SpacerBaseWidget.Cast( m_ServerListScroller.FindAnyWidget( "server_list_content" ) );
15  m_ServerListScroller.VScrollToPos01( 0 );
16 
19 
22 
23  m_Menu = menu;
24  m_TabType = type;
25 
26  m_ApplyFilter = m_Root.FindAnyWidget( "apply_filter_button" );
27  m_RefreshList = m_Root.FindAnyWidget( "refresh_list_button" );
28  m_FiltersChanged = m_Root.FindAnyWidget( "unapplied_filters_notify" );
29  m_HostSort = m_Root.FindAnyWidget( "server_list_content_header_host" );
30  m_TimeSort = m_Root.FindAnyWidget( "server_list_content_header_time" );
31  m_PopulationSort = m_Root.FindAnyWidget( "server_list_content_header_population" );
32  m_SlotsSort = m_Root.FindAnyWidget( "server_list_content_header_slots" );
33  m_PingSort = m_Root.FindAnyWidget( "server_list_content_header_ping" );
34  m_LoadingText = TextWidget.Cast( m_Root.FindAnyWidget( "loading_servers_info" ) );
35  m_WidgetNavFilters = m_Root.FindAnyWidget( "filters_root_nav_wrapper" );
36  m_WidgetNavServers = m_Root.FindAnyWidget( "server_list_root_nav_wrapper" );
37 
38  ShowHideConsoleWidgets();
39 
40  m_Filters = new ServerBrowserFilterContainer( m_Root.FindAnyWidget( "filters_content" ), this );
41 
42  SetSort( ESortType.HOST, ESortOrder.ASCENDING );
43  SetFocusFilters();
44 
45  m_Root.SetHandler( this );
46  }
47 
48  void ShowHideConsoleWidgets()
49  {
50 #ifdef PLATFORM_PS4
51  bool is_xbox = false;
52 #else
53  bool is_xbox = true;
54 #endif
55 
56  m_Root.FindAnyWidget( "filters_root_nav_img_lb_xbox" ).Show( is_xbox );
57  m_Root.FindAnyWidget( "filters_root_nav_img_rb_xbox" ).Show( is_xbox );
58  m_Root.FindAnyWidget( "server_list_root_nav_img_lb_xbox" ).Show( is_xbox );
59  m_Root.FindAnyWidget( "server_list_root_nav_img_rb_xbox" ).Show( is_xbox );
60 
61  m_Root.FindAnyWidget( "filters_root_nav_img_l1_ps4" ).Show( !is_xbox );
62  m_Root.FindAnyWidget( "filters_root_nav_img_r1_ps4" ).Show( !is_xbox );
63  m_Root.FindAnyWidget( "server_list_root_nav_img_l1_ps4" ).Show( !is_xbox );
64  m_Root.FindAnyWidget( "server_list_root_nav_img_r1_ps4" ).Show( !is_xbox );
65  }
66 
67  override void OnLoadServersAsyncConsole( GetServersResult result_list, EBiosError error, string response )
68  {
69  //Print("m_NumServers: "+ result_list.m_NumServers +" m_Pages: "+ result_list.m_Pages + " m_Page: "+ result_list.m_Page);
70  //string smg = "m_NumServers: "+ result_list.m_NumServers +" m_Pages: "+ result_list.m_Pages + " m_Page: "+ result_list.m_Page +" response: "+ response +" error: "+ error;
71  //m_LoadingText.SetText( smg );
72 
73  if ( error != EBiosError.OK || !result_list )
74  {
75  m_LoadingText.SetText( string.Format("Error: %1", ErrorModuleHandler.GetClientMessage(ErrorCategory.BIOSError, error)) );
76  return;
77  }
78 
79  if ( result_list.m_Page == 1 )
80  {
81  m_TotalPages = result_list.m_Pages;
82  m_TotalServers = result_list.m_NumServers;
83 
84  if ( m_Menu.GetServersLoadingTab() != m_TabType || !result_list || ( !result_list.m_Results || result_list.m_Results.Count() == 0 ) )
85  {
86  m_Menu.SetServersLoadingTab( TabType.NONE );
87  m_LoadingText.SetText("#server_browser_tab_unable_to_get_server #server_browser_tab_no_servers_with_filter");
88  return;
89  }
90  }
91 
92  m_LastLoadedPage = result_list.m_Page;
93 
94  if ( m_TotalPages > 0 )
95  {
96  LoadEntries( result_list.m_Page, result_list.m_Results );
97  }
98 
100  {
101  GetNextPage();
102  return;
103  }
104 
105  if ( result_list.m_Page == result_list.m_Pages )
106  {
107  OnLoadServersAsyncFinished();
108  }
109  }
110 
111  void OnLoadServersAsyncFinished()
112  {
113  string msg = "#servers_found: "+ m_TotalLoadedServers;
114  if ( m_TotalLoadedServers == 0 )
115  {
116  msg = "#server_browser_tab_unable_to_get_server";
117  }
118  m_LoadingText.SetText( msg );
119  m_LoadingFinished = true;
120  }
121 
122  void LoadEntries( int cur_page_index , GetServersResultRowArray page )
123  {
124  if ( !m_Menu || m_Menu.GetServersLoadingTab() != m_TabType )
125  {
126  return;
127  }
128 
129  int index = cur_page_index * SERVER_BROWSER_PAGE_SIZE;
130  GetServersResultRowArray page_entries = page;
131  if ( page_entries )
132  {
133  foreach ( GetServersResultRow result : page_entries )
134  {
136 
137  if ( PassFilter( result ) )
138  {
139  ServerBrowserEntry entry = new ServerBrowserEntry( m_ServerList, index, this );
140  string ipPort = result.GetIpPort();
141  entry.FillInfo( result );
142  entry.SetFavorite( m_Menu.IsFavorited(ipPort));
143  entry.UpdateEntry();
144 
145  m_EntryWidgets.Insert(ipPort, entry);
146  index++;
147  m_EntriesSorted[m_SortType].Insert( result );
148 
149  if ( m_EntryWidgets.Count() > 0 )
150  {
151  SetFocusServers();
152  }
153  }
154 
155  if ( !m_Menu || m_Menu.GetServersLoadingTab() != m_TabType )
156  return;
157  }
158 
159  m_ServerList.Update();
160  }
161  /*
162  if ( cur_page_index == 1 && m_EntryWidgets.Count() > 0 )
163  {
164  SetFocusServers();
165  }
166  else
167  {
168  m_LoadingText.SetText( "#server_browser_unable_with_filter" );
169  SetFocusFilters();
170  }
171  */
172 
173  if ( m_EntriesSorted[m_SortType].Count() > 0 )
174  {
175  /*
176 
177  */
178  }
179  else
180  {
181  //m_LoadingText.SetText( "#server_browser_unable_with_filter" );
182 
183  }
184 
185  if ( !m_Menu )
186  return;
187 
189  {
190  //m_LoadingText.SetText( "#server_browser_tab_loaded" + " " + m_EntryWidgets.Count() + "/" + m_EntryWidgets.Count() + " " + "#server_browser_servers_desc" );
191  m_Menu.SetServersLoadingTab( TabType.NONE );
192  }
193  }
194 
195  override void OnFilterFocus( Widget w )
196  {
197  super.OnFilterFocus( w );
198 
199  //ColorHighlight( w );
200  }
201 
202  override void OnFilterChanged()
203  {
204  m_IsFilterChanged = true;
205  }
206 
207  override void RefreshList()
208  {
209  for ( int i = 0; i < m_EntriesSorted.Count(); i++ )
210  {
211  m_EntriesSorted.GetElement(i).Clear();
212  }
213 
214  m_Filters.SaveFilters();
215 
216  super.RefreshList();
217 
218  m_ServerListScroller.VScrollToPos01( 0 );
219 
220  m_LoadingText.SetText( "#dayz_game_loading" );
221 
222  SetFocusFilters();
223  //UpdateStatusBar();
224  }
225 
226  override void ResetFilters()
227  {
228  super.ResetFilters();
229 
230  m_IsFilterChanged = false;
231  }
232 
233  override void ApplyFilters()
234  {
235  m_IsFilterChanged = false;
236  m_CurrentFilterInput = m_Filters.GetFilterOptionsConsoles();
237  RefreshList();
238  }
239 
240  override void OnFilterFocusLost( Widget w )
241  {
242  super.OnFilterFocusLost( w );
243  }
244 
245  override void PressA()
246  {
247 
248  }
249 
250  override void PressX()
251  {
252  RefreshList();
253  }
254 
255  override void PressY()
256  {
257  /*
258  if( m_Menu.GetServersLoadingTab() != TabType.NONE )
259  {
260  return;
261  }
262  */
263 
264  switch ( m_SelectedPanel )
265  {
266  case SelectedPanel.BROWSER:
267  {
268  if ( m_SelectedServer )
269  {
270  m_Menu.ServerListFocus( true, m_SelectedServer.ToggleFavorite() );
271  }
272  break;
273  }
274  case SelectedPanel.FILTERS:
275  {
276  if ( m_Filters )
277  m_Filters.ResetFilters();
278  break;
279  }
280  }
281  }
282 
283  override void PressSholderLeft()
284  {
285  if ( m_IsFilterFocused )
286  {
287  SetFocusServers();
288  }
289  else
290  {
291  SetFocusFilters();
292  }
293  }
294 
295  override void PressSholderRight()
296  {
297  if ( m_IsFilterFocused )
298  {
299  SetFocusServers();
300  }
301  else
302  {
303  SetFocusFilters();
304  }
305  }
306 
307  void SetFocusFilters()
308  {
309  SetEnableFilters( true );
310  SetEnableServers( false );
311 
312  // if loaded servers is 0, then hide Top navigation menu <Left / Right>
313  m_WidgetNavFilters.Show( (m_EntryWidgets.Count() > 0) );
314  m_WidgetNavServers.Show( false );
315 
316  m_Filters.Focus();
317  m_IsFilterFocused = true;
318  }
319 
320  override void Focus()
321  {
322  if ( m_EntryWidgets.Contains( m_CurrentSelectedServer ) )
323  {
326  }
327  SetFocusServers();
328  }
329 
330  void SetFocusServers()
331  {
332  SetEnableServers( true );
333  SetEnableFilters( false );
334 
335  m_WidgetNavFilters.Show( false );
336  m_WidgetNavServers.Show( true );
337 
339  if ( entries.Count() > 0 )
340  {
341  m_EntryWidgets.Get(entries.Get(0).GetIpPort()).Focus();
342  m_IsFilterFocused = false;
343  }
344  else
345  {
346  SetFocusFilters();
347  }
348  }
349 
350  void SetEnableFilters(bool enable)
351  {
352  Widget w_filters = m_Root.FindAnyWidget("filters_content");
353  Widget w_content = m_Root.FindAnyWidget("server_list_scroller");
354  w_filters.Enable( enable );
355  w_content.Enable( !enable );
356  }
357 
358  void SetEnableServers(bool enable)
359  {
360  Widget w_filters = m_Root.FindAnyWidget("filters_content");
361  Widget w_content = m_Root.FindAnyWidget("server_list_scroller");
362  w_filters.Enable( !enable );
363  w_content.Enable( enable );
364  }
365 
366  //Coloring functions (Until WidgetStyles are useful)
367  override void ColorHighlight( Widget w )
368  {
369  if ( !w )
370  {
371  return;
372  }
373 
374  w.SetColor( ARGB( 255, 200, 0, 0) );
375  }
376 
377  override void ColorNormal( Widget w )
378  {
379  if ( !w)
380  {
381  return
382  }
383 
384  if ( (w.GetFlags() & WidgetFlags.IGNOREPOINTER) == WidgetFlags.IGNOREPOINTER )
385  {
386  return;
387  }
388 
389  if ( w.IsInherited( ButtonWidget ) )
390  {
391  ButtonWidget button = ButtonWidget.Cast( w );
392  button.SetTextColor( ARGB( 255, 255, 255, 255 ) );
393  }
394 
395  TextWidget text1 = TextWidget.Cast(w.FindAnyWidget( w.GetName() + "_text" ) );
396  TextWidget text2 = TextWidget.Cast(w.FindAnyWidget( w.GetName() + "_text_1" ) );
397  TextWidget text3 = TextWidget.Cast(w.FindAnyWidget( w.GetName() + "_label" ) );
398  ImageWidget image = ImageWidget.Cast( w.FindAnyWidget( w.GetName() + "_image" ) );
399 
400  Widget option = Widget.Cast( w.FindAnyWidget( w.GetName() + "_option_wrapper" ) );
401 
402  if ( text1 )
403  {
404  text1.SetColor( ARGB( 255, 255, 255, 255 ) );
405  }
406 
407  if ( text2 )
408  {
409  text2.SetColor( ARGB( 255, 255, 255, 255 ) );
410  }
411 
412  if ( text3 )
413  {
414  text3.SetColor( ARGB( 255, 255, 255, 255 ) );
415  w.SetAlpha(0);
416  }
417 
418  if ( image )
419  {
420  image.SetColor( ARGB( 255, 255, 255, 255 ) );
421  }
422 
423  if ( option )
424  {
425  option.SetColor( ARGB( 150, 255, 255, 255 ) );
426  }
427  }
428 
429  override void ColorDisable( Widget w )
430  {
431  #ifdef PLATFORM_WINDOWS
432  SetFocus( null );
433  #endif
434 
435  ButtonWidget button = ButtonWidget.Cast( w );
436  if ( button )
437  {
438  button.SetTextColor( ColorManager.COLOR_DISABLED_TEXT );
439  }
440  }
441 }
GetGame
proto native CGame GetGame()
m_SortType
protected ESortType m_SortType
Definition: serverbrowsertab.c:34
TabType
TabType
Definition: serverbrowsertab.c:1
m_TotalLoadedServers
protected int m_TotalLoadedServers
Definition: serverbrowsertab.c:42
m_LastLoadedPage
protected int m_LastLoadedPage
Definition: serverbrowsertab.c:43
Focus
void Focus()
Definition: serverbrowsertab.c:181
PressA
void PressA()
Definition: serverbrowsertab.c:298
m_TimeSort
protected Widget m_TimeSort
Definition: serverbrowsertab.c:57
m_LoadingFinished
protected bool m_LoadingFinished
Definition: serverbrowsertab.c:45
RefreshList
void RefreshList()
Definition: serverbrowsertab.c:407
m_EntryWidgets
protected ref map< string, ref ServerBrowserEntry > m_EntryWidgets
Definition: serverbrowsertab.c:25
m_TabType
protected TabType m_TabType
Definition: serverbrowsertab.c:33
m_TotalServers
protected int m_TotalServers
Definition: serverbrowsertab.c:41
PressY
void PressY()
m_ServerListScroller
protected ScrollWidget m_ServerListScroller
Definition: serverbrowsertab.c:20
OnLoadServersAsyncConsole
void OnLoadServersAsyncConsole(GetServersResult result_list, EBiosError error, string response)
Definition: serverbrowsertab.c:488
ScrollToEntry
void ScrollToEntry(ServerBrowserEntry entry)
Definition: serverbrowsertab.c:132
m_SelectedServer
protected ServerBrowserEntry m_SelectedServer
Definition: serverbrowsertab.c:31
m_ServerList
protected SpacerBaseWidget m_ServerList
Definition: serverbrowsertab.c:21
m_Menu
protected ServerBrowserMenuNew m_Menu
Definition: serverbrowsertab.c:30
ColorDisable
void ColorDisable(Widget w)
Definition: serverbrowsertab.c:720
m_TotalPages
protected int m_TotalPages
Definition: serverbrowsertab.c:44
ApplyFilters
void ApplyFilters()
Definition: serverbrowsertab.c:397
ErrorCategory
ErrorCategory
ErrorCategory - To decide what ErrorHandlerModule needs to be called and easily identify where it cam...
Definition: errormodulehandler.c:4
m_ApplyFilter
protected Widget m_ApplyFilter
Definition: serverbrowsertab.c:52
ESortType
ESortType
Definition: bioslobbyservice.c:6
m_FiltersChanged
protected Widget m_FiltersChanged
Definition: serverbrowsertab.c:55
m_CurrentSelectedServer
protected string m_CurrentSelectedServer
Definition: serverbrowsertab.c:48
map
map
Definition: controlsxboxnew.c:3
ServerBrowserTab
Definition: serverbrowsertabconsole.c:1
m_Filters
protected ref ServerBrowserFilterContainer m_Filters
Definition: serverbrowsertab.c:28
TextWidget
Definition: enwidgets.c:219
SetSort
proto native void SetSort(int sort, bool immedUpdate=true)
SERVER_BROWSER_PAGE_SIZE
const int SERVER_BROWSER_PAGE_SIZE
Definition: serverbrowsermenunew.c:6
ColorNormal
void ColorNormal(Widget w)
Definition: serverbrowsertab.c:668
m_EntriesSorted
protected ref map< ESortType, ref array< ref GetServersResultRow > > m_EntriesSorted
Definition: serverbrowsertab.c:67
ResetFilters
void ResetFilters()
Definition: serverbrowsertab.c:392
ColorManager
Definition: colormanager.c:1
PressSholderLeft
void PressSholderLeft()
m_RefreshList
protected Widget m_RefreshList
Definition: serverbrowsertab.c:53
EBiosError
EBiosError
Possible Error codes for bios API. This is the list of errors that can be returned from bios API....
Definition: bioserrormodule.c:6
Construct
protected void Construct(Widget parent, ServerBrowserMenuNew menu, TabType type)
Definition: serverbrowsertab.c:78
GetNextPage
void GetNextPage()
Definition: serverbrowsertab.c:460
ColorHighlight
void ColorHighlight(Widget w)
Definition: serverbrowsertab.c:619
GetServersResult
GetServersResult the output structure of the GetServers operation.
Definition: bioslobbyservice.c:224
m_SlotsSort
protected Widget m_SlotsSort
Definition: serverbrowsertab.c:59
PressSholderRight
void PressSholderRight()
OnFilterChanged
void OnFilterChanged()
Definition: serverbrowsertab.c:202
ESortOrder
ESortOrder
Definition: bioslobbyservice.c:18
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition: isboxcollidinggeometryproxyclasses.c:27
SetFocus
proto native void SetFocus(Widget w)
PressX
void PressX()
Definition: serverbrowsertab.c:303
m_HostSort
protected Widget m_HostSort
Definition: serverbrowsertab.c:56
m_PingSort
protected Widget m_PingSort
Definition: serverbrowsertab.c:60
m_LoadingText
protected TextWidget m_LoadingText
Definition: serverbrowsertab.c:63
WidgetFlags
WidgetFlags
Definition: enwidgets.c:57
OnFilterFocus
void OnFilterFocus(Widget w)
Definition: serverbrowsertab.c:196
m_PopulationSort
protected Widget m_PopulationSort
Definition: serverbrowsertab.c:58
PassFilter
bool PassFilter(GetServersResultRow result)
Definition: serverbrowsertab.c:508
m_CurrentFilterInput
protected ref GetServersInput m_CurrentFilterInput
Definition: serverbrowsertab.c:50
m_SelectedPanel
protected SelectedPanel m_SelectedPanel
Definition: serverbrowsertab.c:37
OnFilterFocusLost
void OnFilterFocusLost(Widget w)
Definition: serverbrowsertab.c:190
Widget
Definition: enwidgets.c:189
m_Root
protected Widget m_Root
Definition: sizetochild.c:91
ARGB
int ARGB(int a, int r, int g, int b)
Definition: proto.c:322
Count
@ Count
Definition: randomgeneratorsyncmanager.c:7
ErrorModuleHandler
The error handler itself, for managing and distributing errors to modules Manages the ErrorHandlerMod...
Definition: errormodulehandler.c:28