Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
serverbrowserfavoritestabpc.c
Go to the documentation of this file.
1 class ServerBrowserFavoritesTabPc extends ServerBrowserTabPc
2 {
3  // value = ip, name, connection port, query port
4  private ref array<ref CachedServerInfo> m_CachedFavoriteServerInfo;
5 
6  protected override void Construct(Widget parent, ServerBrowserMenuNew menu, TabType type)
7  {
8  m_CachedFavoriteServerInfo = new array<ref CachedServerInfo>();
9 
10  super.Construct(parent, menu, type);
11  DisableFilters();
12  }
13 
14  protected override void LoadExtraEntries(int index)
15  {
17  foreach (CachedServerInfo cachedInfo : m_CachedFavoriteServerInfo)
18  {
19  string serverId = GetConnEndPoint(cachedInfo);
20 
21  // ensure the cached server is still favorited
22  if (!m_Menu.IsFavorited(GetQueryEndPoint(cachedInfo)))
23  {
24  continue;
25  }
26 
27  if (m_OnlineFavServers.Find(serverId) > -1)
28  {
29  continue;
30  }
31 
32  relevantCachedInfo.Insert(new Param2<string, CachedServerInfo>(serverId, cachedInfo));
33  }
34 
35  // adding FAVORITED, OFFLINE servers to favorites tab
36  int totalServersAlreadyShown = m_PageIndex * SERVERS_VISIBLE_COUNT + index;
37  int startingIndex = totalServersAlreadyShown - m_TotalLoadedServers;
38  m_TotalLoadedServers += relevantCachedInfo.Count();
39  for (int i = startingIndex; i < relevantCachedInfo.Count(); ++i)
40  {
41  if (index >= SERVERS_VISIBLE_COUNT)
42  {
43  break;
44  }
45 
46  Param2<string, CachedServerInfo> relevantEntry = relevantCachedInfo[i];
47 
48  cachedInfo = relevantEntry.param2;
49  string ip = cachedInfo.param1;
50  string cachedName = cachedInfo.param2;
51  int connPort = cachedInfo.param3;
52  int queryPort = cachedInfo.param4;
53 
54  // do NOT insert offlineRow into m_EntriesSorted[m_SortType]!!
55  // we assume that rows already in m_EntriesSorted[m_SortType] are ONLINE,
56  // if we add offline info to m_EntriesSorted[m_SortType] then we cannot differente
57  // between online and offline servers
58  GetServersResultRow offlineRow = new GetServersResultRow();
59  offlineRow.m_Id = relevantEntry.param1;
60  offlineRow.m_Name = cachedName;
61  offlineRow.m_HostIp = ip;
62  offlineRow.m_SteamQueryPort = queryPort;
63  offlineRow.m_HostPort = connPort;
64  offlineRow.m_Favorite = true;
65 
66  ServerBrowserEntry entry = GetServerEntryByIndex(index, offlineRow.m_Id);
67  entry.Show(true);
68  entry.SetIsOnline(false);
69  entry.FillInfo(offlineRow);
70  entry.UpdateEntry();
71 
72  index++;
73  }
74  }
75 
76  override void RefreshList()
77  {
78  OnlineServices.GetCachedFavServerInfo(m_CachedFavoriteServerInfo);
79 
80  m_OnlineFavServers.Clear();
81  super.RefreshList();
82 
83  m_CurrentFilterInput.SetFavorited( true );
86  }
87 
88  private string GetConnEndPoint(CachedServerInfo cachedInfo)
89  {
90  string ip = cachedInfo.param1;
91  int connPort = cachedInfo.param3;
92  return ip + ":" + connPort;
93  }
94 
95  private string GetQueryEndPoint(CachedServerInfo cachedInfo)
96  {
97  string ip = cachedInfo.param1;
98  int queryPort = cachedInfo.param4;
99  return ip + ":" + queryPort;
100  }
101 }
Param2
Definition: ppeconstants.c:66
TabType
TabType
Definition: serverbrowsertab.c:1
m_TotalLoadedServers
protected int m_TotalLoadedServers
Definition: serverbrowsertab.c:42
ServerBrowserTabPc
Definition: serverbrowserfavoritestabpc.c:1
CachedServerInfo
Param4< string, string, int, int > CachedServerInfo
Definition: bioslobbyservice.c:2
RefreshList
void RefreshList()
Definition: serverbrowsertab.c:407
AddFavoritesToFilter
void AddFavoritesToFilter(ref GetServersInput input)
Definition: serverbrowsertab.c:402
m_Menu
protected ServerBrowserMenuNew m_Menu
Definition: serverbrowsertab.c:30
m_OnlineFavServers
protected ref set< string > m_OnlineFavServers
Definition: serverbrowsertab.c:69
Construct
protected void Construct(Widget parent, ServerBrowserMenuNew menu, TabType type)
Definition: serverbrowsertab.c:78
LoadExtraEntries
protected void LoadExtraEntries(int index)
Definition: serverbrowsertab.c:542
array< ref CachedServerInfo >
m_CurrentFilterInput
protected ref GetServersInput m_CurrentFilterInput
Definition: serverbrowsertab.c:50
Widget
Definition: enwidgets.c:189
OnlineServices
Definition: onlineservices.c:1
m_PageIndex
protected int m_PageIndex
Definition: uihintpanel.c:21