DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
ServerBrowserTab.c
Go to the documentation of this file.
2{
7 NONE
9
10enum SelectedPanel
11{
14 MENU
15}
16
18{
19 protected Widget m_Root;
20 protected ScrollWidget m_ServerListScroller;
21 protected SpacerBaseWidget m_ServerList;
22
23 //protected ref array<ref GetServersResultRow> m_Entries;
24
27
28 protected ref ServerBrowserFilterContainer m_Filters;
29
30 protected ServerBrowserMenuNew m_Menu;
31 protected ServerBrowserEntry m_SelectedServer;
32
33 protected TabType m_TabType;
36
37 protected SelectedPanel m_SelectedPanel;
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;
64 protected ButtonWidget m_BtnPagePrev;
65 protected ButtonWidget m_BtnPageNext;
66
69 protected ref set<string> m_OnlineFavServers;
70
71 void ServerBrowserTab( Widget parent, ServerBrowserMenuNew menu, TabType type )
72 {
73 Construct(parent, menu, type);
74 m_OnlineFavServers = new set<string>();
76 }
77
78 protected void Construct( Widget parent, ServerBrowserMenuNew menu, TabType type )
79 {
83 m_LoadingText = TextWidget.Cast( m_Root.FindAnyWidget( "loading_servers_info" ) );
84 }
85
87 {
88 if ( m_Filters )
89 m_Filters.SaveFilters();
90
91 if (m_Root)
92 delete m_Root;
93
95 }
96
97 ServerBrowserMenuNew GetRootMenu()
98 {
99 return m_Menu;
100 }
101
103 {
104 return m_LoadingFinished;
105 }
106
107 override bool OnClick( Widget w, int x, int y, int button )
108 {
109
110 }
111
112 void OnDLCChange(EDLCId dlcId)
113 {
114 switch (dlcId)
115 {
116 case EDLCId.DLC_BLISS:
117 {
118 array<ServerBrowserEntry> serverEntries = m_EntryWidgets.GetValueArray();
119 foreach (ServerBrowserEntry entry : serverEntries)
120 {
121 entry.RefreshDLCIcon();
122 }
123 break;
124 }
125
126 default:
127 break;
128 }
129 }
130
131 void ScrollToEntry( ServerBrowserEntry entry )
132 {
133 if ( entry )
134 {
135 float x, y;
136 float x_s, y_s;
137 float x_l, y_l;
138
139 Widget root = entry.GetRoot();
140 Widget first_child = root.GetParent().GetChildren();
141 Widget last_child = first_child;
142 while ( last_child )
143 {
144 if ( last_child.GetSibling() )
145 last_child = last_child.GetSibling();
146 else
147 break;
148 }
149
150 root.GetParent().Update();
151 root.Update();
152
153 m_ServerListScroller.GetScreenPos( x, y );
154 m_ServerListScroller.GetScreenSize( x_s, y_s );
155
156 float bottom_pos = y + y_s;
157
158 root.GetScreenPos( x_l, y_l );
159 root.GetScreenSize( x_s, y_s );
160
161 if ( root == first_child )
162 {
163 m_ServerListScroller.VScrollToPos01( 0 );
164 }
165 else if ( root == last_child )
166 {
167 m_ServerListScroller.VScrollToPos01( 1 );
168 }
169 else if ( y_l + y_s >= bottom_pos )
170 {
171 m_ServerListScroller.VScrollToPos( m_ServerListScroller.GetVScrollPos() + y_s );
172 }
173 else if ( y_l <= y )
174 {
175 m_ServerListScroller.VScrollToPos( m_ServerListScroller.GetVScrollPos() - y_s );
176 }
177 }
178 }
179
180 void Focus()
181 {
182 if ( m_EntryWidgets.Contains( m_CurrentSelectedServer ) )
183 {
186 }
187 }
188
190 {
191 m_SelectedPanel = SelectedPanel.FILTERS;
192 m_Menu.FilterFocus( false );
193 }
194
196 {
197 m_SelectedPanel = SelectedPanel.FILTERS;
198 m_Menu.FilterFocus( true );
199 }
200
202 {
203
204 }
205
206 void ServerListFocus( bool focus, bool favorite )
207 {
208 m_SelectedPanel = SelectedPanel.BROWSER;
209
210 if (!m_Menu)
211 return;
212
213 m_Menu.ServerListFocus( focus, favorite );
214 }
215
216 override bool OnFocus( Widget w, int x, int y )
217 {
218 if ( IsFocusable( w ) )
219 {
220 if ( w == m_FilterSearchTextBox )
221 {
223 return false;
224 }
225 else
226 {
227 ColorHighlight( w );
228 }
229 return true;
230 }
231 return false;
232 }
233
234 override bool OnFocusLost( Widget w, int x, int y )
235 {
236 if ( IsFocusable( w ) )
237 {
238 if ( w == m_FilterSearchTextBox )
239 {
241 return true;
242 }
243 else
244 {
245 ColorNormal( w );
246 }
247 return true;
248 }
249 return false;
250 }
251
252 override bool OnMouseEnter( Widget w, int x, int y )
253 {
254 if ( IsFocusable( w ) )
255 {
256 ColorHighlight( w );
257 if ( w == m_FilterSearchText )
258 {
260 return true;
261 }
262 return true;
263 }
264 return false;
265 }
266
267 override bool OnMouseLeave( Widget w, Widget enterW, int x, int y )
268 {
269 if ( IsFocusable( w ) )
270 {
271 if ( enterW == m_FilterSearchText || enterW == m_FilterSearchTextBox )
272 {
273 }
274 else
275 {
276 ColorNormal( w );
277 }
278 return true;
279 }
280 return false;
281 }
282
284 {
285 if ( w )
286 {
287 return ( w == m_ApplyFilter || w == m_RefreshList || w == m_ResetFilters || w == m_FilterSearchText || w == m_FilterSearchTextBox );
288 }
289 return false;
290 }
291
293 {
294
295 }
296
297 void PressA()
298 {
299
300 }
301
302 void PressX()
303 {
304 if ( m_Menu.GetServersLoadingTab() == TabType.NONE )
305 RefreshList();
306 }
307
308 void PressY();
311 void Left();
312 void LeftHold();
314 void Right();
315 void RightHold();
317 void Up();
318 void Down();
319
320 void OnLoadServerModsAsync(string server_id, array<string> mods)
321 {
322 m_EntryMods.Set( server_id, mods );
323 }
324
326 {
327 Widget focused = GetFocus();
328 if ( !focused )
329 return;
330 Widget sibling = focused.GetSibling();
331 if ( !sibling )
332 return;
333
334 if ( focused.GetName() == "server_browser_list_entry_root" )
335 {
336 if ( sibling )
337 SetFocus( focused.GetSibling() );
338 else
339 SetFocus( focused.GetParent().GetSibling().GetChildren() );
340 }
341 }
342
344 {
345 Widget focused = GetFocus();
346 if ( focused && focused.GetName() == "server_browser_list_entry_root" )
347 {
348 Widget sibling = focused.GetParent().GetChildren();
349 if ( focused == sibling )
350 return;
351
352 while ( sibling )
353 {
354 if ( sibling && sibling.GetSibling() == focused )
355 {
356 SetFocus( sibling );
357 }
358 else
359 {
360 sibling = sibling.GetSibling();
361 }
362 }
363 }
364 }
365
367 {
368
369 }
370
372 {
373
374 }
375
376 void SetCurrentPage(int page_num)
377 {
378 m_CurrentPageNum = page_num;
379 }
380
382 {
383 return m_CurrentPageNum;
384 }
385
387 {
389 }
390
392 {
393 m_Filters.ResetFilters();
394 }
395
397 {
398
399 }
400
402 {
403 m_Menu.AddFavoritesToFilter( input );
404 }
405
407 {
408 m_Menu.SetServersLoadingTab( m_TabType );
409
410 m_LoadingFinished = false;
411 m_Initialized = true;
412 m_BegunLoading = false;
414 m_TotalPages = -1;
415 m_TotalServers = 0;
418
419 m_EntryWidgets.Clear();
420
421#ifndef PLATFORM_CONSOLE // PLATFORM_WINDOWS
422 m_CurrentFilterInput = m_Filters.GetFilterOptionsPC();
424#else
425 m_CurrentFilterInput = m_Filters.GetFilterOptionsConsoles();
429#endif
430 m_Loading = true;
431 switch ( m_TabType )
432 {
433 case TabType.OFFICIAL:
434 {
437 break;
438 }
439 case TabType.COMMUNITY:
440 {
443 break;
444 }
445 case TabType.LAN:
446 {
449 break;
450 }
451 }
452 }
453
455 {
457 {
460 }
461 }
462
463 void SelectServer( ServerBrowserEntry server )
464 {
465#ifdef PLATFORM_CONSOLE
466 ScrollToEntry( server );
467#endif
468
469 m_SelectedServer = server;
470
471 if (!m_Menu)
472 return;
473
474 m_Menu.SelectServer( server );
475 }
476
477 void OnLoadServersAsyncPC( ref GetServersResult result_list, EBiosError error, string response )
478 {
479
480 }
481
482 void OnLoadServersAsyncConsole( GetServersResult result_list, EBiosError error, string response )
483 {
484
485 }
486
487 void SetSort( ESortType type, ESortOrder order )
488 {
489 m_SortOrder = order;
490 m_SortType = type;
491 }
492
493 bool IsPingInRange( int ping, string max_ping )
494 {
495 int max = max_ping.Substring( 1, max_ping.Length() - 1 ).ToInt();
496
497 if ( ping < max )
498 return true;
499 return false;
500 }
501
502 bool PassFilter( GetServersResultRow result )
503 {
504 if ( !m_Menu || m_Menu.GetServersLoadingTab() != m_TabType )
505 {
506 return false;
507 }
508
509 if ( m_Filters.m_PingFilter.IsSet() )
510 {
511 if ( !IsPingInRange( result.m_Ping, m_Filters.m_PingFilter.GetStringValue() ) )
512 {
513 return false;
514 }
515 }
516
517 if ( m_Filters.m_PreviouslyPlayedFilter.IsSet() )
518 {
519 bool is_visited = g_Game.IsVisited( result.m_HostIp, result.m_HostPort );
520
521 if ( !is_visited && m_Filters.m_PreviouslyPlayedFilter.IsEnabled() )
522 {
523 return false;
524 }
525
526 if ( is_visited && m_Filters.m_PreviouslyPlayedFilter.IsEnabled() )
527 {
528 return false;
529 }
530 }
531
532 return true;
533 }
534
535 // Adds extra servers to the END of the list
536 protected void LoadExtraEntries(int index)
537 {
538
539 }
540
541 void Connect( ServerBrowserEntry server )
542 {
543 if ( !m_Menu )
544 return;
545
546 if ( m_Menu.GetServersLoadingTab() != TabType.NONE )
547 return;
548
549 m_SelectedServer = server;
550 m_Menu.Connect( server );
551 }
552
554 {
555 switch ( m_SortType )
556 {
557 case ESortType.HOST:
558 {
559 return "name";
560 }
561 case ESortType.TIME:
562 {
563 return "name";
564 }
565 case ESortType.POPULATION:
566 {
567 return "currentNumberPlayers";
568 }
569 case ESortType.SLOTS:
570 {
571 return "freeSlots";
572 }
573 case ESortType.PING:
574 {
575 return "name";
576 }
577 }
578 return "";
579 }
580
581 int AddSorted( GetServersResultRow entry )
582 {
583 return -1;
584 }
585
586 void Unfavorite( string uid )
587 {
588 ServerBrowserEntry entry;
589 if ( m_EntryWidgets.Find( uid, entry ) )
590 {
591 entry.SetFavorite( false );
592 }
593 }
594
596 {
597 return m_TabType;
598 }
599
601 {
602 w.ClearFlags( WidgetFlags.IGNOREPOINTER );
603 ColorNormal(w);
604 }
605
607 {
608 w.SetFlags( WidgetFlags.IGNOREPOINTER );
609 ColorDisable(w);
610 }
611
612 //Coloring functions (Until WidgetStyles are useful)
614 {
615 if ( w.IsInherited( ButtonWidget ) )
616 {
617 ButtonWidget button = ButtonWidget.Cast( w );
618 button.SetTextColor( ARGB( 255, 200, 0, 0 ) );
619 }
620
621 w.SetColor( ARGB( 255, 0, 0, 0) );
622
623 TextWidget text1 = TextWidget.Cast(w.FindAnyWidget( w.GetName() + "_text" ) );
624 TextWidget text2 = TextWidget.Cast(w.FindAnyWidget( w.GetName() + "_label" ) );
625 TextWidget text3 = TextWidget.Cast(w.FindAnyWidget( w.GetName() + "_text_1" ) );
626 ImageWidget image = ImageWidget.Cast( w.FindAnyWidget( w.GetName() + "_image" ) );
627 Widget option = Widget.Cast( w.FindAnyWidget( w.GetName() + "_option_wrapper" ) );
628 Widget option_label = w.FindAnyWidget( "option_label" );
629
630 if ( text1 )
631 {
632 text1.SetColor( ARGB( 255, 255, 0, 0 ) );
633 }
634
635 if ( text2 )
636 {
637 text2.SetColor( ARGB( 255, 255, 0, 0 ) );
638 }
639
640 if ( text3 )
641 {
642 text3.SetColor( ARGB( 255, 255, 0, 0 ) );
643 w.SetAlpha(1);
644 }
645
646 if ( image )
647 {
648 image.SetColor( ARGB( 255, 200, 0, 0 ) );
649 }
650
651 if ( option )
652 {
653 option.SetColor( ARGB( 255, 255, 0, 0 ) );
654 }
655
656 if ( option_label )
657 {
658 option_label.SetColor( ARGB( 255, 255, 0, 0 ) );
659 }
660 }
661
663 {
664 if ( (w.GetFlags() & WidgetFlags.IGNOREPOINTER) == WidgetFlags.IGNOREPOINTER )
665 {
666 return;
667 }
668
669 if ( w.IsInherited( ButtonWidget ) )
670 {
671 ButtonWidget button = ButtonWidget.Cast( w );
672 button.SetTextColor( ARGB( 255, 255, 255, 255 ) );
673 }
674
675 TextWidget text1 = TextWidget.Cast(w.FindAnyWidget( w.GetName() + "_text" ) );
676 TextWidget text2 = TextWidget.Cast(w.FindAnyWidget( w.GetName() + "_text_1" ) );
677 TextWidget text3 = TextWidget.Cast(w.FindAnyWidget( w.GetName() + "_label" ) );
678 ImageWidget image = ImageWidget.Cast( w.FindAnyWidget( w.GetName() + "_image" ) );
679 Widget option = w.FindAnyWidget( w.GetName() + "_option_wrapper" );
680 Widget option_label = w.FindAnyWidget( "option_label" );
681
682 if ( text1 )
683 {
684 text1.SetColor( ARGB( 255, 255, 255, 255 ) );
685 }
686
687 if ( text2 )
688 {
689 text2.SetColor( ARGB( 255, 255, 255, 255 ) );
690 }
691
692 if ( text3 )
693 {
694 text3.SetColor( ARGB( 255, 255, 255, 255 ) );
695 w.SetAlpha(0);
696 }
697
698 if ( image )
699 {
700 image.SetColor( ARGB( 255, 255, 255, 255 ) );
701 }
702
703 if ( option )
704 {
705 option.SetColor( ARGB( 150, 255, 255, 255 ) );
706 }
707
708 if ( option_label )
709 {
710 option_label.SetColor( ARGB( 255, 255, 255, 255 ) );
711 }
712 }
713
715 {
716 #ifdef PLATFORM_WINDOWS
717 SetFocus( null );
718 #endif
719
720 if ( w )
721 {
722 ButtonWidget button = ButtonWidget.Cast( w );
723 if ( button )
724 {
725 button.SetTextColor( ColorManager.COLOR_DISABLED_TEXT );
726 }
727 }
728 }
729}
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:3654
Icon x
Icon y
protected Widget m_SlotsSort
protected int m_CurrentLoadedPage
void GetPrevFilter()
protected int m_LastLoadedPage
protected Widget m_PopulationSort
TabType GetTabType()
protected ref ServerBrowserFilterContainer m_Filters
protected ServerBrowserMenuNew m_Menu
protected Widget m_ResetFilters
void GetNextPage()
protected int m_CurrentPageNum
protected int m_TotalPages
protected TextWidget m_LoadingText
void GetNextEntry()
enum TabType BROWSER
protected void LoadExtraEntries(int index)
void ButtonDisable(Widget w)
protected ref map< ESortType, ref array< ref GetServersResultRow > > m_EntriesSorted
void SetPanelFocus()
void ServerListFocus(bool focus, bool favorite)
bool IsPingInRange(int ping, string max_ping)
bool GetIsServerLoadingFinished()
void ScrollToEntry(ServerBrowserEntry entry)
protected string m_CurrentSelectedServer
protected ref map< string, ref ServerBrowserEntry > m_EntryWidgets
void Connect(ServerBrowserEntry server)
protected int m_TotalServers
enum TabType FILTERS
protected TabType m_TabType
TabType
@ COMMUNITY
@ NONE
@ LAN
@ OFFICIAL
@ FAVORITE
bool PassFilter(GetServersResultRow result)
protected ref map< ESortType, ESortOrder > m_SortInverted
protected Widget m_ApplyFilter
protected ref GetServersInput m_CurrentFilterInput
protected ESortOrder m_SortOrder
string GetSortOption()
void GetPrevEntry()
protected Widget m_RefreshList
protected Widget m_TimeSort
protected bool m_LoadingFinished
void Down()
void AddFavoritesToFilter(ref GetServersInput input)
protected Widget m_HostSort
protected ESortType m_SortType
void GetNextFilter()
void Up()
protected int m_TotalLoadedServers
void Unfavorite(string uid)
protected ref map< string, ref array< string > > m_EntryMods
void ButtonEnable(Widget w)
bool IsNotInitialized()
protected Widget m_FilterSearchText
protected SpacerBaseWidget m_ServerList
protected SelectedPanel m_SelectedPanel
override bool OnFocusLost(Widget w, int x, int y)
protected Widget m_FiltersChanged
int GetCurrentPage()
protected ServerBrowserEntry m_SelectedServer
protected ButtonWidget m_BtnPagePrev
protected bool m_BegunLoading
protected Widget m_FilterSearchTextBox
override bool OnFocus(Widget w, int x, int y)
void ~ServerBrowserTab()
protected ButtonWidget m_BtnPageNext
protected ScrollWidget m_ServerListScroller
void SetCurrentPage(int page_num)
protected ref set< string > m_OnlineFavServers
void OnDLCChange(EDLCId dlcId)
protected Widget m_PingSort
ServerBrowserMenuNew GetRootMenu()
protected bool m_Loading
protected Widget m_Root
Definition SizeToChild.c:91
protected bool m_Initialized
proto native ContentDLC GetContentDLCService()
Return DLC service (service for entitlement keys for unlock content)
static int COLOR_DISABLED_TEXT
ref ScriptInvoker m_OnChange
void(EDLCId dlcId)
Definition ContentDLC.c:13
GetServersInput the input structure of the GetServers operation.
void SetOfficialFilter(bool official)
GetServersResult the output structure of the GetServers operation.
static void LoadServers(notnull GetServersInput inputValues)
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
map: item x vector(index, width, height)
Definition EnWidgets.c:538
override bool IsFocusable(Widget w)
override void ColorDisable(Widget w)
override void OnLoadServersAsyncPC(ref GetServersResult result_list, EBiosError error, string response)
override void OnFilterChanged()
override void OnFilterFocus(Widget w)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
override void SetSort(ESortType type, ESortOrder order)
override void OnFilterFocusLost(Widget w)
override void PressSholderLeft()
override int AddSorted(GetServersResultRow entry)
override void PressSholderRight()
override void ColorNormal(Widget w)
override void OnLoadServerModsAsync(string server_id, array< string > mods)
protected override void Construct(Widget parent, ServerBrowserMenuNew menu, TabType type)
override bool OnMouseEnter(Widget w, int x, int y)
override void SelectServer(ServerBrowserEntry server)
override bool OnClick(Widget w, int x, int y, int button)
override void ColorHighlight(Widget w)
override void OnLoadServersAsyncConsole(GetServersResult result_list, EBiosError error, string response)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
@ MENU
Definition EnSystem.c:343
proto string Substring(int start, int len)
Substring of 'str' from 'start' position 'len' number of characters.
proto native int ToInt()
Converts string to integer.
proto native int Length()
Returns length of string.
WidgetFlags
Definition EnWidgets.c:57
proto native Widget GetFocus()
proto native void SetFocus(Widget w)
int ARGB(int a, int r, int g, int b)
Definition proto.c:322