5 protected ref array<SCR_ServerBrowserEntryComponent> m_aRoomEntries = {};
6 protected ref array<Room> m_aRooms = {};
8 protected int m_iLoadedPage;
15 override protected Widget CreateEntry(Widget parent)
17 Widget entry = super.CreateEntry(parent);
30 serverEntry.GetOnFocus().Insert(OnServerEntryFocusEnter);
33 m_aRoomEntries.Insert(serverEntry);
40 override protected void FillEntry(Widget w)
53 if (!IsPageLoaded(w.GetParent()))
62 if (w.GetParent() == m_wPage0)
63 roomId = entryId + m_iPageEntriesCount;
64 if (w.GetParent() == m_wPage1)
65 roomId = entryId - m_iPageEntriesCount;
70 ClientLobbyApi lobby =
GetGame().GetBackendApi().GetClientLobby();
74 if (roomId < 0 || roomId >= m_aRooms.Count())
77 if (IsEntryVisible(w))
79 serverEntry.SetRoomInfo(m_aRooms[roomId]);
80 m_aRoomEntries[entryId].EmptyVisuals(
false);
84 serverEntry.SetRoomInfo(
null);
90 override void MoveToTop()
98 override protected void SetCurrentPage(
int page)
101 SetCurrentPageBase(page);
104 if (m_iLoadedPage == m_iCurrentPage)
108 if (Math.AbsInt(m_iLoadedPage - m_iCurrentPage) > 1)
112 entry.EmptyVisuals(
true);
122 if (m_iLoadedPage + 1 == m_iCurrentPage)
124 if (!m_bPagesInverted)
125 start = m_iPageEntriesCount;
128 for (
int i = m_iPageEntriesCount + start - 1; i >= start; i--)
130 m_aRoomEntries[i].EmptyVisuals(
true);
137 if (m_iLoadedPage - 1 == m_iCurrentPage)
139 if (m_bPagesInverted)
140 start = m_iPageEntriesCount;
143 for (
int i = start, max = m_iPageEntriesCount + start; i < max; i++)
145 m_aRoomEntries[i].EmptyVisuals(
true);
151 protected bool IsPageLoaded(Widget wPage)
154 if (Math.AbsInt(m_iLoadedPage - m_iCurrentPage) > 1)
158 if (m_iLoadedPage + 1 == m_iCurrentPage)
160 if (m_bPagesInverted && wPage == m_wPage1)
163 if (!m_bPagesInverted && wPage == m_wPage0)
170 if (m_iLoadedPage - 1 == m_iCurrentPage)
172 if (m_bPagesInverted && wPage == m_wPage1)
175 if (!m_bPagesInverted && wPage == m_wPage0)
198 int entryId = m_aRoomEntries.Find(serverEntry);
201 if (m_bPagesInverted)
204 if (serverEntry.GetRootWidget().GetParent() == m_wPage0)
205 entryId += m_iPageEntriesCount;
206 else if (serverEntry.GetRootWidget().GetParent() == m_wPage1)
207 entryId -= m_iPageEntriesCount;
226 id = m_aEntryWidgets.Find(entryWidget);
228 if (0 <=
id &&
id < m_aRoomEntries.Count())
229 return m_aRoomEntries[id];
242 void SetRooms(array<Room> rooms,
int allRoomsCount = -1,
bool animate =
false)
248 int roomsCount = rooms.Count();
251 int dataCount = allRoomsCount;
252 if (allRoomsCount == -1)
253 dataCount = m_aRooms.Count();
255 SetDataEntries(allRoomsCount);
257 UpdateEntries(animate);
262 void ShowEmptyRooms()
265 UpdateEntries(
false);
268 foreach (Widget widget : m_aEntryWidgets)
270 widget.SetVisible(
false);
275 m_wRoot.ClearFlags(WidgetFlags.CLIPCHILDREN);
276 m_wRoot.ClearFlags(WidgetFlags.INHERIT_CLIPPING);
282 void UpdateLoadedPage()
294 if (m_aRoomEntries.IsEmpty())
297 int id = m_aRoomEntries.Find(entry);
307 protected bool IsEntryVisible(Widget entry)
310 int id = m_aEntryWidgets.Find(entry);
314 if (
id > m_iAllEntriesCount)
322 array<SCR_ServerBrowserEntryComponent> GetRoomEntries()
324 return m_aRoomEntries;
331 return m_iLoadedPage;