DayZ 1.24
Loading...
Searching...
No Matches
ServerBrowserTab.c
Go to the documentation of this file.
9
11{
14 MENU
15}
16
18{
19 protected Widget m_Root;
22
23 //protected ref array<ref GetServersResultRow> m_Entries;
24
27
28 protected ref ServerBrowserFilterContainer m_Filters;
29
31 protected ServerBrowserEntry m_SelectedServer;
32
33 protected TabType m_TabType;
36
38 protected bool m_Initialized;
39 protected bool m_BegunLoading;
40 protected bool m_Loading;
41 protected int m_TotalServers; // UNUSED
42 protected int m_TotalLoadedServers;
43 protected int m_LastLoadedPage;
44 protected int m_TotalPages;
45 protected bool m_LoadingFinished;
46 protected int m_CurrentPageNum;
47
48 protected string m_CurrentSelectedServer;
49 protected int m_CurrentLoadedPage;
51
56 protected Widget m_HostSort;
57 protected Widget m_TimeSort;
60 protected Widget m_PingSort;
66
70
72 {
73 Construct(parent, menu, type);
75 GetGame().GetContentDLCService().m_OnChange.Insert(OnDLCChange);
76 }
77
85
87 {
88 if (m_Filters)
89 m_Filters.SaveFilters();
90
91 if (m_Root)
92 delete m_Root;
93
94 if (GetGame().GetContentDLCService())
95 GetGame().GetContentDLCService().m_OnChange.Remove(OnDLCChange);
96 }
97
99 {
100 return m_Menu;
101 }
102
104 {
105 return m_LoadingFinished;
106 }
107
108 override bool OnClick(Widget w, int x, int y, int button)
109 {
110
111 }
112
114 {
115 switch (dlcId)
116 {
117 case EDLCId.DLC_BLISS:
118 {
120 foreach (ServerBrowserEntry entry : serverEntries)
121 entry.RefreshDLCIcon();
122 break;
123 }
124
125 default:
126 break;
127 }
128 }
129
130 void ScrollToEntry(ServerBrowserEntry entry)
131 {
132 if (entry)
133 {
134 float x, y;
135 float x_s, y_s;
136 float x_l, y_l;
137
138 Widget root = entry.GetRoot();
139 Widget first_child = root.GetParent().GetChildren();
141 while (last_child)
142 {
143 if (last_child.GetSibling())
144 last_child = last_child.GetSibling();
145 else
146 break;
147 }
148
149 root.GetParent().Update();
150 root.Update();
151
152 m_ServerListScroller.GetScreenPos(x, y);
153 m_ServerListScroller.GetScreenSize(x_s, y_s);
154
155 float bottom_pos = y + y_s;
156
157 root.GetScreenPos(x_l, y_l);
158 root.GetScreenSize(x_s, y_s);
159
160 if (root == first_child)
161 m_ServerListScroller.VScrollToPos01(0);
162 else if (root == last_child)
163 m_ServerListScroller.VScrollToPos01(1);
164 else if (y_l + y_s >= bottom_pos)
165 m_ServerListScroller.VScrollToPos(m_ServerListScroller.GetVScrollPos() + y_s);
166 else if (y_l <= y)
167 m_ServerListScroller.VScrollToPos(m_ServerListScroller.GetVScrollPos() - y_s);
168 }
169 }
170
179
181 {
183 m_Menu.FilterFocus(false);
184 }
185
187 {
189 m_Menu.FilterFocus(true);
190 }
191
193 {
194
195 }
196
198 {
200
201 if (!m_Menu)
202 return;
203
204 m_Menu.ServerListFocus(focus, favorite);
205 }
206
207 override bool OnFocus(Widget w, int x, int y)
208 {
209 if (IsFocusable(w))
210 {
212 {
214 return false;
215 }
216 else
218 return true;
219 }
220 return false;
221 }
222
223 override bool OnFocusLost(Widget w, int x, int y)
224 {
225 if (IsFocusable(w))
226 {
228 {
230 return true;
231 }
232 else
233 ColorNormal(w);
234 return true;
235 }
236 return false;
237 }
238
239 override bool OnMouseEnter(Widget w, int x, int y)
240 {
241 if (IsFocusable(w))
242 {
244 if (w == m_FilterSearchText)
245 {
247 return true;
248 }
249 return true;
250 }
251 return false;
252 }
253
254 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
255 {
256 if (IsFocusable(w))
257 {
259 {
260 }
261 else
262 ColorNormal(w);
263 return true;
264 }
265 return false;
266 }
267
269 {
270 if (w)
272 return false;
273 }
274
276 {
277
278 }
279
280 void PressA()
281 {
282
283 }
284
285 void PressX()
286 {
287 if (m_Menu.GetServersLoadingTab() == TabType.NONE)
288 RefreshList();
289 }
290
291 void PressY();
294 void Left();
295 void LeftHold();
297 void Right();
298 void RightHold();
300 void Up();
301 void Down();
302
307
309 {
311 if (!focused)
312 return;
313 Widget sibling = focused.GetSibling();
314 if (!sibling)
315 return;
316
317 if (focused.GetName() == "server_browser_list_entry_root")
318 {
319 if (sibling)
320 SetFocus(focused.GetSibling());
321 else
322 SetFocus(focused.GetParent().GetSibling().GetChildren());
323 }
324 }
325
327 {
329 if (focused && focused.GetName() == "server_browser_list_entry_root")
330 {
331 Widget sibling = focused.GetParent().GetChildren();
332 if (focused == sibling)
333 return;
334
335 while (sibling)
336 {
337 if (sibling && sibling.GetSibling() == focused)
339 else
340 sibling = sibling.GetSibling();
341 }
342 }
343 }
344
346 {
347
348 }
349
351 {
352
353 }
354
356 {
358 }
359
361 {
362 return m_CurrentPageNum;
363 }
364
366 {
368 }
369
371 {
372 m_Filters.ResetFilters();
373 }
374
376 {
377
378 }
379
381 {
382 m_Menu.AddFavoritesToFilter(input);
383 }
384
386 {
387 m_Menu.SetServersLoadingTab(m_TabType);
388
389 m_LoadingFinished = false;
390 m_Initialized = true;
391 m_BegunLoading = false;
393 m_TotalPages = -1;
394 m_TotalServers = 0;
397
398 m_EntryWidgets.Clear();
399
400#ifndef PLATFORM_WINDOWS // XBOX OR PS
401 m_CurrentFilterInput = m_Filters.GetFilterOptionsConsoles();
404 m_CurrentFilterInput.m_SortOrder = m_SortOrder;
405#else // PLATFORM_WINDOWS
406 m_CurrentFilterInput = m_Filters.GetFilterOptionsPC();
407#ifdef PLATFORM_CONSOLE // PC client with -XBOX flag
409#else
410 m_CurrentFilterInput.m_Page = 0;
411#endif
412#endif
413
414 m_Loading = true;
415 switch (m_TabType)
416 {
417 case TabType.OFFICIAL:
418 {
419 m_CurrentFilterInput.SetOfficialFilter(true);
421 break;
422 }
423 case TabType.COMMUNITY:
424 {
425 m_CurrentFilterInput.SetOfficialFilter(false);
427 break;
428 }
429 case TabType.LAN:
430 {
431 m_CurrentFilterInput.SetLAN();
433 break;
434 }
435 }
436 }
437
446
447 void SelectServer(ServerBrowserEntry server)
448 {
449#ifdef PLATFORM_CONSOLE
451#endif
452
454
455 if (!m_Menu)
456 return;
457
458 m_Menu.SelectServer(server);
459 }
460
465
470
472 {
474 m_SortType = type;
475 }
476
477 bool IsPingInRange(int ping, string max_ping)
478 {
479 int max = max_ping.Substring(1, max_ping.Length() - 1).ToInt();
480
481 if (ping < max)
482 return true;
483 return false;
484 }
485
487 {
488 if (!m_Menu || m_Menu.GetServersLoadingTab() != m_TabType)
489 return false;
490
491 if (m_Filters.m_PingFilter.IsSet())
492 {
493 if (!IsPingInRange(result.m_Ping, m_Filters.m_PingFilter.GetStringValue()))
494 return false;
495 }
496
497 if (m_Filters.m_PreviouslyPlayedFilter.IsSet())
498 {
499 bool is_visited = g_Game.IsVisited(result.m_HostIp, result.m_HostPort);
500
501 if (!is_visited && m_Filters.m_PreviouslyPlayedFilter.IsEnabled())
502 return false;
503
504 if (is_visited && m_Filters.m_PreviouslyPlayedFilter.IsEnabled())
505 return false;
506 }
507
508 return true;
509 }
510
511 // Adds extra servers to the END of the list
512 protected void LoadExtraEntries(int index)
513 {
514
515 }
516
517 void Connect(ServerBrowserEntry server)
518 {
519 if (!m_Menu)
520 return;
521
522 if (m_Menu.GetServersLoadingTab() != TabType.NONE)
523 return;
524
526 m_Menu.Connect(server);
527 }
528
530 {
531 switch (m_SortType)
532 {
533 case ESortType.HOST:
534 {
535 return "name";
536 }
537 case ESortType.TIME:
538 {
539 return "name";
540 }
541 case ESortType.POPULATION:
542 {
543 return "currentNumberPlayers";
544 }
545 case ESortType.SLOTS:
546 {
547 return "freeSlots";
548 }
549 case ESortType.PING:
550 {
551 return "name";
552 }
553 }
554 return "";
555 }
556
558 {
559 return -1;
560 }
561
562 void Unfavorite(string uid)
563 {
564 ServerBrowserEntry entry;
565 if (m_EntryWidgets.Find(uid, entry))
566 entry.SetFavorite(false);
567 }
568
570 {
571 return m_TabType;
572 }
573
575 {
576 w.ClearFlags(WidgetFlags.IGNOREPOINTER);
577 ColorNormal(w);
578 }
579
581 {
582 w.SetFlags(WidgetFlags.IGNOREPOINTER);
584 }
585
586 //Coloring functions (Until WidgetStyles are useful)
588 {
589 if (w.IsInherited(ButtonWidget))
590 {
592 button.SetTextColor(ARGB(255, 200, 0, 0));
593 }
594
595 w.SetColor(ARGB(255, 0, 0, 0));
596
597 TextWidget text1 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text"));
598 TextWidget text2 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_label"));
599 TextWidget text3 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text_1"));
600 ImageWidget image = ImageWidget.Cast(w.FindAnyWidget(w.GetName() + "_image"));
601 Widget option = Widget.Cast(w.FindAnyWidget(w.GetName() + "_option_wrapper"));
602 Widget option_label = w.FindAnyWidget("option_label");
603
604 if (text1)
605 text1.SetColor(ARGB(255, 255, 0, 0));
606
607 if (text2)
608 text2.SetColor(ARGB(255, 255, 0, 0));
609
610 if (text3)
611 {
612 text3.SetColor(ARGB(255, 255, 0, 0));
613 w.SetAlpha(1);
614 }
615
616 if (image)
617 image.SetColor(ARGB(255, 200, 0, 0));
618
619 if (option)
620 option.SetColor(ARGB(255, 255, 0, 0));
621
622 if (option_label)
623 option_label.SetColor(ARGB(255, 255, 0, 0));
624 }
625
627 {
628 if ((w.GetFlags() & WidgetFlags.IGNOREPOINTER) == WidgetFlags.IGNOREPOINTER)
629 return;
630
631 if (w.IsInherited(ButtonWidget))
632 {
634 button.SetTextColor(ARGB(255, 255, 255, 255));
635 }
636
637 TextWidget text1 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text"));
638 TextWidget text2 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text_1"));
639 TextWidget text3 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_label"));
640 ImageWidget image = ImageWidget.Cast(w.FindAnyWidget(w.GetName() + "_image"));
641 Widget option = w.FindAnyWidget(w.GetName() + "_option_wrapper");
642 Widget option_label = w.FindAnyWidget("option_label");
643
644 if (text1)
645 text1.SetColor(ARGB(255, 255, 255, 255));
646
647 if (text2)
648 text2.SetColor(ARGB(255, 255, 255, 255));
649
650 if (text3)
651 {
652 text3.SetColor(ARGB(255, 255, 255, 255));
653 w.SetAlpha(0);
654 }
655
656 if (image)
657 image.SetColor(ARGB(255, 255, 255, 255));
658
659 if (option)
660 option.SetColor(ARGB(150, 255, 255, 255));
661
662 if (option_label)
663 option_label.SetColor(ARGB(255, 255, 255, 255));
664 }
665
667 {
668#ifdef PLATFORM_WINDOWS
669 SetFocus(null);
670#endif
671
672 if (w)
673 {
675 if (button)
677 }
678 }
679}
EBiosError
Possible Error codes for bios API. This is the list of errors that can be returned from bios API....
ESortOrder
ESortType
EDLCId
Definition ContentDLC.c:4
DayZGame g_Game
Definition DayZGame.c:3528
Icon x
Icon y
void LoadExtraEntries(int index)
void ServerBrowserTab(Widget parent, ServerBrowserMenuNew menu, TabType type)
ref ServerBrowserFilterContainer m_Filters
void GetPrevFilter()
ref map< ESortType, ref array< ref GetServersResultRow > > m_EntriesSorted
TabType GetTabType()
TabType m_TabType
Widget m_FilterSearchText
Widget m_FiltersChanged
Widget m_SlotsSort
void GetNextPage()
bool m_LoadingFinished
ServerBrowserEntry m_SelectedServer
void GetNextEntry()
enum TabType BROWSER
int m_CurrentLoadedPage
void ButtonDisable(Widget w)
ref GetServersInput m_CurrentFilterInput
void SetPanelFocus()
void ServerListFocus(bool focus, bool favorite)
ButtonWidget m_BtnPageNext
ref map< ESortType, ESortOrder > m_SortInverted
bool IsPingInRange(int ping, string max_ping)
ref map< string, ref ServerBrowserEntry > m_EntryWidgets
int m_TotalPages
bool GetIsServerLoadingFinished()
void ScrollToEntry(ServerBrowserEntry entry)
bool m_BegunLoading
void Connect(ServerBrowserEntry server)
enum TabType FILTERS
TabType
@ COMMUNITY
@ NONE
@ LAN
@ OFFICIAL
@ FAVORITE
ScrollWidget m_ServerListScroller
bool PassFilter(GetServersResultRow result)
Widget m_PingSort
int m_TotalLoadedServers
string m_CurrentSelectedServer
string GetSortOption()
Widget m_ApplyFilter
void GetPrevEntry()
ServerBrowserMenuNew m_Menu
ref map< string, ref array< string > > m_EntryMods
void Down()
void AddFavoritesToFilter(ref GetServersInput input)
bool m_Loading
SelectedPanel m_SelectedPanel
int m_LastLoadedPage
ESortType m_SortType
void GetNextFilter()
TextWidget m_LoadingText
void Up()
Widget m_PopulationSort
Widget m_HostSort
void Unfavorite(string uid)
ButtonWidget m_BtnPagePrev
void ButtonEnable(Widget w)
ESortOrder m_SortOrder
SpacerBaseWidget m_ServerList
int m_TotalServers
int m_CurrentPageNum
bool IsNotInitialized()
override bool OnFocusLost(Widget w, int x, int y)
int GetCurrentPage()
Widget m_FilterSearchTextBox
Widget m_ResetFilters
Widget m_RefreshList
override bool OnFocus(Widget w, int x, int y)
Widget m_TimeSort
void ~ServerBrowserTab()
ref set< string > m_OnlineFavServers
void SetCurrentPage(int page_num)
void OnDLCChange(EDLCId dlcId)
ServerBrowserMenuNew GetRootMenu()
Widget m_Root
Definition SizeToChild.c:85
bool m_Initialized
static int COLOR_DISABLED_TEXT
GetServersInput the input structure of the GetServers operation.
GetServersResult the output structure of the GetServers operation.
static void LoadServers(notnull GetServersInput inputValues)
map: item x vector(index, width, height)
Definition EnWidgets.c:651
override void OnFilterFocus(Widget w)
override void OnLoadServersAsyncPC(ref GetServersResult result_list, EBiosError error, string response)
override void OnFilterFocusLost(Widget w)
override void PressSholderRight()
override bool IsFocusable(Widget w)
override void ColorDisable(Widget w)
override bool OnClick(Widget w, int x, int y, int button)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
override void SetSort(ESortType type, ESortOrder order)
override void SelectServer(ServerBrowserEntry server)
override void ColorNormal(Widget w)
override int AddSorted(GetServersResultRow entry)
override void OnLoadServersAsyncConsole(GetServersResult result_list, EBiosError error, string response)
override void PressSholderLeft()
override void OnFilterChanged()
override bool OnMouseEnter(Widget w, int x, int y)
override void OnLoadServerModsAsync(string server_id, array< string > mods)
override void Construct(Widget parent, ServerBrowserMenuNew menu, TabType type)
override void ColorHighlight(Widget w)
proto native CGame GetGame()
@ MENU
Definition EnSystem.c:343
WidgetFlags
Definition EnWidgets.c:58
proto native Widget GetFocus()
proto native void SetFocus(Widget w)
int ARGB(int a, int r, int g, int b)
Definition proto.c:322