DayZ 1.24
Loading...
Searching...
No Matches
ServerBrowserFavoritesTabConsolePages.c
Go to the documentation of this file.
2{
3 protected override void Construct(Widget parent, ServerBrowserMenuNew menu, TabType type)
4 {
5 super.Construct(parent, menu, type);
6
7 // disabling filter section
8 m_Root.FindAnyWidget("filters_content").Show(false);
9 m_Root.FindAnyWidget("reset_filter_button").Show(false);
10 }
11
13 {
14 // m_TotalLoadedServers for FAVORITES tab is determined by total number of favorited servers
15 TStringArray favIds = m_Menu.GetFavoritedServerIds();
17 super.OnLoadServersAsyncFinished();
18 }
19
21 {
22 if (cur_page_index == 1)
23 m_OnlineFavServers.Clear();
24
25 super.LoadEntries(cur_page_index, page_entries);
26 }
27
28 protected override void LoadExtraEntries(int index)
29 {
30 if (!m_Menu || m_Menu.GetServersLoadingTab() != m_TabType)
31 return;
32
33 // m_PagesCount for FAVORITES tab is determined by total number of favorited servers
34 TStringArray favIds = m_Menu.GetFavoritedServerIds();
35 m_PagesCount = Math.Ceil((float)favIds.Count() / SERVER_BROWSER_PAGE_SIZE);
36
37 // offlineFavIds will always have same order, even across pages,
38 // to ensure we display only fav servers that HAVEN'T been displayed yet
40 offlineFavIds.Reserve(favIds.Count() - m_OnlineFavServers.Count());
41 foreach (string ipPort : favIds)
42 {
43 if (m_OnlineFavServers.Find(ipPort) == -1)
44 offlineFavIds.Insert(ipPort);
45 }
46
47 // appending offline servers to server list
50 for (int i = startingIndex; i < offlineFavIds.Count(); ++i)
51 {
52 string favServerId = offlineFavIds[i];
53
54 // only append server if there is a free entry left on the page
56 break;
57
58 if (m_OnlineFavServers.Find(favServerId) > -1)
59 continue;
60
62 favServerId.Split(":", parts);
63
64 // ensure server id has correct format
65 if (parts.Count() != 2)
66 continue;
67
69 offlineRow.m_Name = favServerId;
71 offlineRow.m_HostIp = parts[0];
72 offlineRow.m_HostPort = parts[1].ToInt();
73 offlineRow.m_SteamQueryPort = offlineRow.m_HostPort;
74 offlineRow.m_Favorite = true;
75
76 ServerBrowserEntry entry = GetServerEntryByIndex(index);
77 entry.SetIsOnline(false);
78 entry.FillInfo(offlineRow);
79 entry.UpdateEntry();
80
81 m_EntryWidgets.Insert(favServerId, entry);
83
84 index++;
85 }
86 }
87
88 override void RefreshList()
89 {
90 super.RefreshList();
91#ifdef PLATFORM_WINDOWS
92 m_CurrentFilterInput.SetFavorited(true);
93#endif
96 }
97
99 {
100 if (m_TabType == TabType.FAVORITE)
101 {
102 if (!m_Menu.IsFavorited(result.GetIpPort()))
103 return false;
104 }
105
106 return super.PassFilter(result);
107 }
108
109 override void PressY()
110 {
111 switch (m_SelectedPanel)
112 {
113 // filters are disabled for console FAVORITES tab, so do nothing
114 case SelectedPanel.FILTERS:
115 {
116 break;
117 }
118 default:
119 {
120 super.PressY();
121 break;
122 }
123 }
124 }
125
126 override void PressX()
127 {
128 if ((GetGame().GetTime() - m_TimeLastServerRefresh) > 1000)
129 {
131 super.PressX();
132 }
133 }
134
135 override void SetFocusFilters()
136 {
137 super.SetFocusFilters();
138
139 m_Menu.ShowYButton(false);
140 m_Menu.ShowAButton(false);
141
142 // focus on the back button instead of filter section
143 m_Menu.BackButtonFocus();
144
145 UpdatePageButtons();
146 }
147}
float GetTime()
const int SERVER_BROWSER_PAGE_SIZE
ref map< ESortType, ref array< ref GetServersResultRow > > m_EntriesSorted
TabType m_TabType
ref GetServersInput m_CurrentFilterInput
ref map< string, ref ServerBrowserEntry > m_EntryWidgets
TabType
int m_TotalLoadedServers
ServerBrowserMenuNew m_Menu
void AddFavoritesToFilter(ref GetServersInput input)
SelectedPanel m_SelectedPanel
ESortType m_SortType
int GetCurrentPage()
ref set< string > m_OnlineFavServers
void SetCurrentPage(int page_num)
Widget m_Root
Definition SizeToChild.c:85
Definition EnMath.c:7
static void LoadServers(notnull GetServersInput inputValues)
override void Construct(Widget parent, ServerBrowserMenuNew menu, TabType type)
override bool PassFilter(GetServersResultRow result)
override void LoadEntries(int cur_page_index, GetServersResultRowArray page_entries)
proto native CGame GetGame()
array< string > TStringArray
Definition EnScript.c:666
static proto float Ceil(float f)
Returns ceil of value.