DayZ 1.24
Loading...
Searching...
No Matches
ServerBrowserTabConsolePages.c
Go to the documentation of this file.
2{
3 private bool m_IsFilterChanged;
4 private bool m_IsFilterFocused;
5 protected bool m_MouseKeyboardControlled
6
7 private Widget m_WidgetNavFilters;
8 private Widget m_WidgetNavServers;
9
12
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;
21
25
26 protected override void Construct(Widget parent, ServerBrowserMenuNew menu, TabType type)
27 {
28 m_Root = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/server_browser/xbox/server_browser_tab_console_pages.layout", parent);
29
30 m_ServerListScroller = ScrollWidget.Cast(m_Root.FindAnyWidget("server_list_scroller"));
31 m_ServerList = SpacerBaseWidget.Cast(m_ServerListScroller.FindAnyWidget("server_list_content"));
32 m_ServerListScroller.VScrollToPos01(0);
33
34 m_ServerListEntiers = new array<ref ServerBrowserEntry>;
37
40
41 m_Menu = menu;
42 m_TabType = type;
43
44 m_ApplyFilter = m_Root.FindAnyWidget("apply_filter_button");
45 m_ResetFilters = m_Root.FindAnyWidget("reset_filter_button");
46 m_RefreshList = m_Root.FindAnyWidget("refresh_list_button");
47 m_FiltersChanged = m_Root.FindAnyWidget("unapplied_filters_notify");
48 m_HostSort = m_Root.FindAnyWidget("server_list_content_header_host");
49 m_TimeSort = m_Root.FindAnyWidget("server_list_content_header_time");
50 m_PopulationSort = m_Root.FindAnyWidget("server_list_content_header_population");
51 m_SlotsSort = m_Root.FindAnyWidget("server_list_content_header_slots");
52 m_PingSort = m_Root.FindAnyWidget("server_list_content_header_ping");
53 m_FilterSearchText = m_Root.FindAnyWidget("search_name_button");
54 m_FilterSearchTextBox = m_Root.FindAnyWidget("search_name_setting_option");
55 m_LoadingText = TextWidget.Cast(m_Root.FindAnyWidget("loading_servers_info"));
56 m_WidgetNavFilters = m_Root.FindAnyWidget("filters_root_nav_wrapper");
57 m_WidgetNavServers = m_Root.FindAnyWidget("server_list_root_nav_wrapper");
58
59 m_BtnPagePrev = ButtonWidget.Cast(m_Root.FindAnyWidget("servers_navigation_prev")) ;
60 m_BtnPageNext = ButtonWidget.Cast(m_Root.FindAnyWidget("servers_navigation_next")) ;
61
62#ifdef PLATFORM_PS4
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);
67#else
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);
72#endif
73
74 ShowHideConsoleWidgets();
75
76 m_Filters = new ServerBrowserFilterContainer(m_Root.FindAnyWidget("filters_content"), this);
77
78 m_PnlPagesPanel = m_Root.FindAnyWidget("servers_navigation_spacer");
79 m_PreviousPage = 1;
81 m_PnlPagesPanel.Show(true);
82 m_LoadingFinished = true;
83
84 m_Filters.OnSortChanged(m_Filters.m_SortingFilter.GetValue());
86 UpdatePageButtons();
87
88 m_Root.SetHandler(this);
89 m_FilterSearchTextBox.SetHandler(this);
90
91 GetGame().GetMission().GetOnInputDeviceChanged().Insert(OnInputDeviceChanged);
92
93 OnInputDeviceChanged(GetGame().GetInput().GetCurrentInputDevice());
94 }
95
97 {
98 bool is_xbox = true;
99
100#ifdef PLATFORM_PS4
101 is_xbox = false;
102#endif
103
104 m_Root.FindAnyWidget("filters_button_wrapper").Show(GetGame().GetInput().IsEnabledMouseAndKeyboard());
105
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);
110
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);
115 }
116
118 {
119 switch (pInputDeviceType)
120 {
121 case EInputDeviceType.CONTROLLER:
122 ShowHideConsoleWidgets();
123 UpdatePageButtons();
124 m_WidgetNavFilters.Show(m_IsFilterFocused);
125 m_WidgetNavServers.Show(!m_IsFilterFocused);
127 break;
128
129 default:
130 if (GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer())
131 {
132 m_WidgetNavFilters.Show(false);
133 m_WidgetNavServers.Show(false);
134 m_ButtonPageLeftImg.Show(false);
135 m_ButtonPageRightImg.Show(false);
137 }
138 break;
139 }
140 }
141
143 {
144 if (error != EBiosError.OK)
145 {
146 m_LoadingText.SetText(string.Format("Error: %1", ErrorModuleHandler.GetClientMessage(ErrorCategory.BIOSError, error)));
147 m_Menu.SetServersLoadingTab(TabType.NONE);
148 m_LoadingFinished = true;
150 return;
151 }
152
153 m_PagesCount = result_list.m_Pages;
154 m_TotalServersCount = result_list.m_NumServers;
155
156 LoadEntries(result_list.m_Page, result_list.m_Results);
157
158 if (m_TotalLoadedServers == 0)
160
162 UpdatePageButtons();
163 }
164
166 {
167 string msg = "#servers_found: " + m_TotalLoadedServers;
168 if (m_TotalLoadedServers == 0)
169 msg = "#server_browser_tab_unable_to_get_server";
170 m_LoadingText.SetText(msg);
171 m_LoadingFinished = true;
172
173 m_Menu.SetServersLoadingTab(TabType.NONE);
174 }
175
177 {
178 int index = 0;
179 ServerBrowserEntry entry;
180 m_TotalLoadedServers = m_TotalServersCount;
181
182 if (!m_Menu || m_Menu.GetServersLoadingTab() != m_TabType)
183 return;
184
185 // only load servers if they correspond to current page
187 return;
188
189 if (m_PagesCount && page_entries)
190 {
192 {
193 if (PassFilter(result))
194 {
195 string ipPort = result.GetIpPort();
196 bool isFavorited = m_Menu.IsFavorited(ipPort);
197
198 entry = GetServerEntryByIndex(index);
199 entry.SetIsOnline(true);
200 entry.FillInfo(result);
201 entry.SetFavorite(isFavorited);
202 entry.UpdateEntry();
203
204 if (isFavorited && m_OnlineFavServers.Find(ipPort) == -1)
206
207 m_EntryWidgets.Insert(ipPort, entry);
209
210 index++;
211 }
212
213 if (!m_Menu || m_Menu.GetServersLoadingTab() != m_TabType)
214 return;
215 }
216 }
217
219 m_ServerList.Update();
220 SetFocusServers();
221 }
222
223 protected ServerBrowserEntry GetServerEntryByIndex(int index)
224 {
225 ServerBrowserEntry entry;
226
227 if (index >= 0)
228 {
229 if (index < m_ServerListEntiers.Count())
230 entry = m_ServerListEntiers[index];
231 else
232 {
233 entry = new ServerBrowserEntry(m_ServerList, index, this);
234 m_ServerListEntiers.Insert(entry);
235 }
236 }
237 else
238 return null;
239
240 entry.Show(true);
241
242 return entry;
243 }
244
245 override void OnFilterChanged()
246 {
247 m_IsFilterChanged = true;
248 }
249
251 {
252 return m_LoadingFinished;
253 }
254
255 override void RefreshList()
256 {
257 for (int i = 0; i < m_ServerListEntiers.Count(); i++)
258 m_ServerListEntiers[i].Show(false);
259
260 for (int j = 0; j < m_EntriesSorted.Count(); j++)
261 {
263
264 if (result_rows)
265 result_rows.Clear();
266 }
267
268 m_IsFilterChanged = false;
269 m_Filters.SaveFilters();
270
271 super.RefreshList();
272
273 m_ServerListScroller.VScrollToPos01(0);
274
275 m_LoadingText.SetText("#dayz_game_loading");
276 }
277
278 override void ResetFilters()
279 {
280 super.ResetFilters();
281
282 m_IsFilterChanged = false;
283 }
284
285 override void ApplyFilters()
286 {
287 if (m_IsFilterChanged)
289
290 m_IsFilterChanged = false;
291 m_CurrentFilterInput = m_Filters.GetFilterOptionsConsoles();
292 RefreshList();
293 }
294
295 override void PressA()
296 {
297
298 }
299
300 override void PressX()
301 {
302 if ((GetGame().GetTime() - m_TimeLastServerRefresh) > 1000)
303 {
304 m_TimeLastServerRefresh = GetGame().GetTime();
305
306 if (m_IsFilterChanged)
308 m_OnlineFavServers.Clear();
309 RefreshList();
310 }
311
312 }
313
314 override void PressY()
315 {
316 switch (m_SelectedPanel)
317 {
318 case SelectedPanel.BROWSER:
319 {
321 m_Menu.ServerListFocus(true, m_SelectedServer.ToggleFavorite());
322 break;
323 }
324 case SelectedPanel.FILTERS:
325 {
326 if (m_Filters)
327 m_Filters.ResetFilters();
328 break;
329 }
330 }
331 }
332
333 override void Left()
334 {
335 if (!m_IsFilterFocused)
336 {
338 m_PreviousPage = curr_page;
339 if (curr_page > 1)
340 {
342 UpdatePageButtons();
343 }
344 }
345 }
346
347 override void LeftHold()
348 {
349 if (!m_IsFilterFocused)
350 {
351 if ((GetGame().GetTime() - m_TimeLastServerRefreshHoldButton) > 100)
352 {
353 m_TimeLastServerRefreshHoldButton = GetGame().GetTime();
354 Left();
355 }
356 }
357 }
358
359 override void LeftRelease()
360 {
361 if (!m_IsFilterFocused && GetCurrentPage() != m_PreviousPage)
362 RefreshList();
363 }
364
365 override void Right()
366 {
367 if (!m_IsFilterFocused)
368 {
370 m_PreviousPage = curr_page;
371 if (curr_page < m_PagesCount)
372 {
374 UpdatePageButtons();
375 }
376 }
377 }
378
379 override void RightHold()
380 {
381 if (!m_IsFilterFocused)
382 {
383 if ((GetGame().GetTime() - m_TimeLastServerRefreshHoldButton) > 100)
384 {
385 m_TimeLastServerRefreshHoldButton = GetGame().GetTime();
386 Right();
387 }
388 }
389 }
390
391 override void RightRelease()
392 {
393 if (!m_IsFilterFocused && GetCurrentPage() != m_PreviousPage)
394 RefreshList();
395 }
396
397 override void PressSholderLeft()
398 {
399 if (m_IsFilterFocused)
400 SetFocusServers();
401 else
403 }
404
405 override void PressSholderRight()
406 {
407 if (m_IsFilterFocused)
408 SetFocusServers();
409 else
411 }
412 override void Focus()
413 {
415 {
418 }
419
421 if (entries && entries.Count() > 0)
422 SetFocusServers();
423 else
425 }
426
427
429 {
430 SetEnableFilters(true);
431 SetEnableServers(false);
432
433 // if loaded servers is 0, then hide Top navigation menu <Left / Right>
435 {
436 m_WidgetNavFilters.Show(true);
437 m_WidgetNavServers.Show(false);
438 }
439
440 m_Filters.Focus();
441 m_IsFilterFocused = true;
442
443 UpdatePageButtons();
444 }
445
447 {
448 SetEnableServers(true);
449 SetEnableFilters(false);
450
452 {
453 m_WidgetNavFilters.Show(false);
454 m_WidgetNavServers.Show(true);
455 }
456
458 if (entries && entries.Count() > 0)
459 m_EntryWidgets.Get(entries.Get(0).GetIpPort()).Focus();
460 else
461 SetFocus(null);
462
463 m_IsFilterFocused = false;
464 m_Menu.ShowYButton(true);
465 m_Menu.ShowAButton(true);
466
467 UpdatePageButtons();
468 }
469
471 {
472 Widget w_filters = m_Root.FindAnyWidget("filters_content");
473 Widget w_content = m_Root.FindAnyWidget("server_list_scroller");
474 w_content.Enable(!enable);
475
476 if (enable)
477 SetFocus(ButtonWidget.Cast(w_filters.FindWidget("sort_button")));
478 }
479
481 {
482 Widget w_filters = m_Root.FindAnyWidget("filters_content");
483 Widget w_content = m_Root.FindAnyWidget("server_list_scroller");
484 w_content.Enable(enable);
485 }
486
488 {
489 TextWidget wgt_page_stat = TextWidget.Cast(m_Root.FindAnyWidget("servers_navigation_page_status"));
490
491 wgt_page_stat.SetText(GetCurrentPage().ToString() + " / " + m_PagesCount.ToString());
492
493 if (!m_IsFilterFocused && (m_PagesCount > 1) && !m_MouseKeyboardControlled)
494 {
495 bool can_left = (GetCurrentPage() > 1);
496 m_ButtonPageLeftImg.Show(can_left);
498
499 bool can_right = (GetCurrentPage() < m_PagesCount);
500 m_ButtonPageRightImg.Show(can_right);
502 }
503 else
504 {
505 m_ButtonPageLeftImg.Show(false);
506 m_BtnPagePrev.Show(false);
507 m_ButtonPageRightImg.Show(false);
508 m_BtnPageNext.Show(false);
509 }
510 }
511
512 override bool OnClick(Widget w, int x, int y, int button)
513 {
514 super.OnClick(w, x, y, button);
515
516 if (button == MouseState.LEFT)
517 {
518 if (w == m_ResetFilters)
519 ResetFilters();
520 else if (w == m_ApplyFilter)
521 {
522 ApplyFilters();
523 return true;
524 }
525 else if (w == m_RefreshList)
526 {
528 PressX();
529 else
530 RefreshList();
531
532 return true;
533 }
534 else if (w == m_BtnPagePrev)
535 {
536 Left();
537 return true;
538 }
539 else if (w == m_BtnPageNext)
540 {
541 Right();
542 return true;
543 }
544 }
545 return false;
546 }
547
548 //Coloring functions (Until WidgetStyles are useful)
549 override void ColorHighlight(Widget w)
550 {
551 if (!w)
552 return;
553
554 w.SetColor(ARGB(255, 200, 0, 0));
555 }
556
557 override void ColorNormal(Widget w)
558 {
559 if (!w)
560 {
561 return
562 }
563
564 if ((w.GetFlags() & WidgetFlags.IGNOREPOINTER) == WidgetFlags.IGNOREPOINTER)
565 return;
566
567 if (w.IsInherited(ButtonWidget))
568 {
570 button.SetTextColor(ARGB(255, 255, 255, 255));
571 }
572 else if (!w.IsInherited(EditBoxWidget))
573 w.SetColor(ARGB(0, 255, 255, 255));
574
575 TextWidget text1 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text"));
576 TextWidget text2 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text_1"));
577 TextWidget text3 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_label"));
578 ImageWidget image = ImageWidget.Cast(w.FindAnyWidget(w.GetName() + "_image"));
579
580 Widget option = Widget.Cast(w.FindAnyWidget(w.GetName() + "_option_wrapper"));
581
582 if (text1)
583 text1.SetColor(ARGB(255, 255, 255, 255));
584
585 if (text2)
586 text2.SetColor(ARGB(255, 255, 255, 255));
587
588 if (text3)
589 {
590 text3.SetColor(ARGB(255, 255, 255, 255));
591 w.SetAlpha(0);
592 }
593
594 if (image)
595 image.SetColor(ARGB(255, 255, 255, 255));
596
597 if (option)
598 option.SetColor(ARGB(150, 255, 255, 255));
599 }
600
601 override void ColorDisable(Widget w)
602 {
603#ifdef PLATFORM_WINDOWS
604 SetFocus(null);
605#endif
606
608 if (button)
610 }
611}
void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
Definition Inventory.c:167
ActionInput GetInput()
Definition ActionBase.c:989
EBiosError
Possible Error codes for bios API. This is the list of errors that can be returned from bios API....
ESortType
void Show()
Definition DayZGame.c:155
proto string ToString()
ErrorCategory
ErrorCategory - To decide what ErrorHandlerModule needs to be called and easily identify where it cam...
Icon x
Icon y
float GetTime()
ref ServerBrowserFilterContainer m_Filters
ref map< ESortType, ref array< ref GetServersResultRow > > m_EntriesSorted
TabType m_TabType
void Right()
Widget m_FilterSearchText
Widget m_FiltersChanged
void ApplyFilters()
Widget m_SlotsSort
bool m_LoadingFinished
ServerBrowserEntry m_SelectedServer
ref GetServersInput m_CurrentFilterInput
ButtonWidget m_BtnPageNext
ref map< string, ref ServerBrowserEntry > m_EntryWidgets
void ScrollToEntry(ServerBrowserEntry entry)
TabType
ScrollWidget m_ServerListScroller
Widget m_PingSort
int m_TotalLoadedServers
string m_CurrentSelectedServer
Widget m_ApplyFilter
ServerBrowserMenuNew m_Menu
void ResetFilters()
bool m_Loading
SelectedPanel m_SelectedPanel
ESortType m_SortType
TextWidget m_LoadingText
Widget m_PopulationSort
Widget m_HostSort
ButtonWidget m_BtnPagePrev
SpacerBaseWidget m_ServerList
int m_CurrentPageNum
void Left()
int GetCurrentPage()
Widget m_FilterSearchTextBox
Widget m_ResetFilters
Widget m_RefreshList
Widget m_TimeSort
ref set< string > m_OnlineFavServers
void SetCurrentPage(int page_num)
Widget m_Root
Definition SizeToChild.c:85
static int COLOR_DISABLED_TEXT
The error handler itself, for managing and distributing errors to modules Manages the ErrorHandlerMod...
static proto string GetClientMessage(ErrorCategory category, int code, string additionalInfo="")
Gets the Client Message for specified error.
GetServersResult the output structure of the GetServers operation.
override bool PassFilter(GetServersResultRow result)
override void LoadEntries(int cur_page_index, GetServersResultRowArray page_entries)
ref array< ref ServerBrowserEntry > m_ServerListEntiers
override void ColorDisable(Widget w)
override bool OnClick(Widget w, int x, int y, int button)
ServerBrowserEntry GetServerEntryByIndex(int index)
override void ColorNormal(Widget w)
override void OnLoadServersAsyncConsole(GetServersResult result_list, EBiosError error, string response)
void LoadEntries(int cur_page_index, GetServersResultRowArray page_entries)
void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
override void Construct(Widget parent, ServerBrowserMenuNew menu, TabType type)
override void ColorHighlight(Widget w)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
MouseState
Definition EnSystem.c:311
WidgetFlags
Definition EnWidgets.c:58
proto native void SetFocus(Widget w)
EInputDeviceType
Definition input.c:3
int ARGB(int a, int r, int g, int b)
Definition proto.c:322