DayZ 1.24
Loading...
Searching...
No Matches
ServerBrowserTabConsole.c
Go to the documentation of this file.
2{
3 private bool m_IsFilterChanged;
4 private bool m_IsFilterFocused;
5
8
9 protected override void Construct(Widget parent, ServerBrowserMenuNew menu, TabType type)
10 {
11 m_Root = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/server_browser/xbox/server_browser_tab.layout", parent);
12
13 m_ServerListScroller = ScrollWidget.Cast(m_Root.FindAnyWidget("server_list_scroller"));
14 m_ServerList = SpacerBaseWidget.Cast(m_ServerListScroller.FindAnyWidget("server_list_content"));
15 m_ServerListScroller.VScrollToPos01(0);
16
19
22
23 m_Menu = menu;
24 m_TabType = type;
25
26 m_ApplyFilter = m_Root.FindAnyWidget("apply_filter_button");
27 m_RefreshList = m_Root.FindAnyWidget("refresh_list_button");
28 m_FiltersChanged = m_Root.FindAnyWidget("unapplied_filters_notify");
29 m_HostSort = m_Root.FindAnyWidget("server_list_content_header_host");
30 m_TimeSort = m_Root.FindAnyWidget("server_list_content_header_time");
31 m_PopulationSort = m_Root.FindAnyWidget("server_list_content_header_population");
32 m_SlotsSort = m_Root.FindAnyWidget("server_list_content_header_slots");
33 m_PingSort = m_Root.FindAnyWidget("server_list_content_header_ping");
34 m_LoadingText = TextWidget.Cast(m_Root.FindAnyWidget("loading_servers_info"));
35 m_WidgetNavFilters = m_Root.FindAnyWidget("filters_root_nav_wrapper");
36 m_WidgetNavServers = m_Root.FindAnyWidget("server_list_root_nav_wrapper");
37
38 ShowHideConsoleWidgets();
39
40 m_Filters = new ServerBrowserFilterContainer(m_Root.FindAnyWidget("filters_content"), this);
41
42 SetSort(ESortType.HOST, ESortOrder.ASCENDING);
43 SetFocusFilters();
44
45 m_Root.SetHandler(this);
46 }
47
49 {
50#ifdef PLATFORM_PS4
51 bool is_xbox = false;
52#else
53 bool is_xbox = true;
54#endif
55
56 m_Root.FindAnyWidget("filters_root_nav_img_lb_xbox").Show(is_xbox);
57 m_Root.FindAnyWidget("filters_root_nav_img_rb_xbox").Show(is_xbox);
58 m_Root.FindAnyWidget("server_list_root_nav_img_lb_xbox").Show(is_xbox);
59 m_Root.FindAnyWidget("server_list_root_nav_img_rb_xbox").Show(is_xbox);
60
61 m_Root.FindAnyWidget("filters_root_nav_img_l1_ps4").Show(!is_xbox);
62 m_Root.FindAnyWidget("filters_root_nav_img_r1_ps4").Show(!is_xbox);
63 m_Root.FindAnyWidget("server_list_root_nav_img_l1_ps4").Show(!is_xbox);
64 m_Root.FindAnyWidget("server_list_root_nav_img_r1_ps4").Show(!is_xbox);
65 }
66
68 {
69 //Print("m_NumServers: "+ result_list.m_NumServers +" m_Pages: "+ result_list.m_Pages + " m_Page: "+ result_list.m_Page);
70 //string smg = "m_NumServers: "+ result_list.m_NumServers +" m_Pages: "+ result_list.m_Pages + " m_Page: "+ result_list.m_Page +" response: "+ response +" error: "+ error;
71 //m_LoadingText.SetText( smg );
72
73 if (error != EBiosError.OK || !result_list)
74 {
75 m_LoadingText.SetText(string.Format("Error: %1", ErrorModuleHandler.GetClientMessage(ErrorCategory.BIOSError, error)));
76 return;
77 }
78
79 if (result_list.m_Page == 1)
80 {
81 m_TotalPages = result_list.m_Pages;
82 m_TotalServers = result_list.m_NumServers;
83
84 if (m_Menu.GetServersLoadingTab() != m_TabType || !result_list || (!result_list.m_Results || result_list.m_Results.Count() == 0))
85 {
86 m_Menu.SetServersLoadingTab(TabType.NONE);
87 m_LoadingText.SetText("#server_browser_tab_unable_to_get_server #server_browser_tab_no_servers_with_filter");
88 return;
89 }
90 }
91
93
94 if (m_TotalPages > 0)
95 LoadEntries(result_list.m_Page, result_list.m_Results);
96
98 {
100 return;
101 }
102
103 if (result_list.m_Page == result_list.m_Pages)
104 OnLoadServersAsyncFinished();
105 }
106
108 {
109 string msg = "#servers_found: " + m_TotalLoadedServers;
110 if (m_TotalLoadedServers == 0)
111 msg = "#server_browser_tab_unable_to_get_server";
112 m_LoadingText.SetText(msg);
113 m_LoadingFinished = true;
114 }
115
117 {
118 if (!m_Menu || m_Menu.GetServersLoadingTab() != m_TabType)
119 return;
120
123 if (page_entries)
124 {
126 {
128
129 if (PassFilter(result))
130 {
131 ServerBrowserEntry entry = new ServerBrowserEntry(m_ServerList, index, this);
132 string ipPort = result.GetIpPort();
133 entry.FillInfo(result);
134 entry.SetFavorite(m_Menu.IsFavorited(ipPort));
135 entry.UpdateEntry();
136
137 m_EntryWidgets.Insert(ipPort, entry);
138 index++;
140
141 if (m_EntryWidgets.Count() > 0)
142 SetFocusServers();
143 }
144
145 if (!m_Menu || m_Menu.GetServersLoadingTab() != m_TabType)
146 return;
147 }
148
149 m_ServerList.Update();
150 }
151 /*
152 if ( cur_page_index == 1 && m_EntryWidgets.Count() > 0 )
153 {
154 SetFocusServers();
155 }
156 else
157 {
158 m_LoadingText.SetText( "#server_browser_unable_with_filter" );
159 SetFocusFilters();
160 }
161 */
162
164 {
165 /*
166
167 */
168 }
169 else
170 {
171 //m_LoadingText.SetText( "#server_browser_unable_with_filter" );
172
173 }
174
175 if (!m_Menu)
176 return;
177
179 {
180 //m_LoadingText.SetText( "#server_browser_tab_loaded" + " " + m_EntryWidgets.Count() + "/" + m_EntryWidgets.Count() + " " + "#server_browser_servers_desc" );
181 m_Menu.SetServersLoadingTab(TabType.NONE);
182 }
183 }
184
185 override void OnFilterFocus(Widget w)
186 {
187 super.OnFilterFocus(w);
188
189 //ColorHighlight( w );
190 }
191
192 override void OnFilterChanged()
193 {
194 m_IsFilterChanged = true;
195 }
196
197 override void RefreshList()
198 {
199 for (int i = 0; i < m_EntriesSorted.Count(); i++)
200 m_EntriesSorted.GetElement(i).Clear();
201
202 m_Filters.SaveFilters();
203
204 super.RefreshList();
205
206 m_ServerListScroller.VScrollToPos01(0);
207
208 m_LoadingText.SetText("#dayz_game_loading");
209
210 SetFocusFilters();
211 //UpdateStatusBar();
212 }
213
214 override void ResetFilters()
215 {
216 super.ResetFilters();
217
218 m_IsFilterChanged = false;
219 }
220
221 override void ApplyFilters()
222 {
223 m_IsFilterChanged = false;
224 m_CurrentFilterInput = m_Filters.GetFilterOptionsConsoles();
225 RefreshList();
226 }
227
229 {
230 super.OnFilterFocusLost(w);
231 }
232
233 override void PressA()
234 {
235
236 }
237
238 override void PressX()
239 {
240 RefreshList();
241 }
242
243 override void PressY()
244 {
245 /*
246 if( m_Menu.GetServersLoadingTab() != TabType.NONE )
247 {
248 return;
249 }
250 */
251
252 switch (m_SelectedPanel)
253 {
254 case SelectedPanel.BROWSER:
255 {
257 m_Menu.ServerListFocus(true, m_SelectedServer.ToggleFavorite());
258 break;
259 }
260 case SelectedPanel.FILTERS:
261 {
262 if (m_Filters)
263 m_Filters.ResetFilters();
264 break;
265 }
266 }
267 }
268
269 override void PressSholderLeft()
270 {
271 if (m_IsFilterFocused)
272 SetFocusServers();
273 else
274 SetFocusFilters();
275 }
276
277 override void PressSholderRight()
278 {
279 if (m_IsFilterFocused)
280 SetFocusServers();
281 else
282 SetFocusFilters();
283 }
284
286 {
287 SetEnableFilters(true);
288 SetEnableServers(false);
289
290 // if loaded servers is 0, then hide Top navigation menu <Left / Right>
291 m_WidgetNavFilters.Show((m_EntryWidgets.Count() > 0));
292 m_WidgetNavServers.Show(false);
293
294 m_Filters.Focus();
295 m_IsFilterFocused = true;
296 }
297
298 override void Focus()
299 {
301 {
304 }
305 SetFocusServers();
306 }
307
309 {
310 SetEnableServers(true);
311 SetEnableFilters(false);
312
313 m_WidgetNavFilters.Show(false);
314 m_WidgetNavServers.Show(true);
315
317 if (entries.Count() > 0)
318 {
319 m_EntryWidgets.Get(entries.Get(0).GetIpPort()).Focus();
320 m_IsFilterFocused = false;
321 }
322 else
323 SetFocusFilters();
324 }
325
327 {
328 Widget w_filters = m_Root.FindAnyWidget("filters_content");
329 Widget w_content = m_Root.FindAnyWidget("server_list_scroller");
330 w_filters.Enable(enable);
331 w_content.Enable(!enable);
332 }
333
335 {
336 Widget w_filters = m_Root.FindAnyWidget("filters_content");
337 Widget w_content = m_Root.FindAnyWidget("server_list_scroller");
338 w_filters.Enable(!enable);
339 w_content.Enable(enable);
340 }
341
342 //Coloring functions (Until WidgetStyles are useful)
343 override void ColorHighlight(Widget w)
344 {
345 if (!w)
346 return;
347
348 w.SetColor(ARGB(255, 200, 0, 0));
349 }
350
351 override void ColorNormal(Widget w)
352 {
353 if (!w)
354 {
355 return
356 }
357
358 if ((w.GetFlags() & WidgetFlags.IGNOREPOINTER) == WidgetFlags.IGNOREPOINTER)
359 return;
360
361 if (w.IsInherited(ButtonWidget))
362 {
364 button.SetTextColor(ARGB(255, 255, 255, 255));
365 }
366
367 TextWidget text1 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text"));
368 TextWidget text2 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text_1"));
369 TextWidget text3 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_label"));
370 ImageWidget image = ImageWidget.Cast(w.FindAnyWidget(w.GetName() + "_image"));
371
372 Widget option = Widget.Cast(w.FindAnyWidget(w.GetName() + "_option_wrapper"));
373
374 if (text1)
375 text1.SetColor(ARGB(255, 255, 255, 255));
376
377 if (text2)
378 text2.SetColor(ARGB(255, 255, 255, 255));
379
380 if (text3)
381 {
382 text3.SetColor(ARGB(255, 255, 255, 255));
383 w.SetAlpha(0);
384 }
385
386 if (image)
387 image.SetColor(ARGB(255, 255, 255, 255));
388
389 if (option)
390 option.SetColor(ARGB(150, 255, 255, 255));
391 }
392
393 override void ColorDisable(Widget w)
394 {
395#ifdef PLATFORM_WINDOWS
396 SetFocus(null);
397#endif
398
400 if (button)
402 }
403}
EBiosError
Possible Error codes for bios API. This is the list of errors that can be returned from bios API....
ESortOrder
ESortType
ErrorCategory
ErrorCategory - To decide what ErrorHandlerModule needs to be called and easily identify where it cam...
const int SERVER_BROWSER_PAGE_SIZE
ref ServerBrowserFilterContainer m_Filters
ref map< ESortType, ref array< ref GetServersResultRow > > m_EntriesSorted
TabType m_TabType
Widget m_FiltersChanged
Widget m_SlotsSort
void GetNextPage()
bool m_LoadingFinished
ServerBrowserEntry m_SelectedServer
ref GetServersInput m_CurrentFilterInput
ref map< string, ref ServerBrowserEntry > m_EntryWidgets
int m_TotalPages
void ScrollToEntry(ServerBrowserEntry entry)
TabType
void RefreshList()
ScrollWidget m_ServerListScroller
bool PassFilter(GetServersResultRow result)
Widget m_PingSort
int m_TotalLoadedServers
string m_CurrentSelectedServer
Widget m_ApplyFilter
ServerBrowserMenuNew m_Menu
SelectedPanel m_SelectedPanel
int m_LastLoadedPage
ESortType m_SortType
TextWidget m_LoadingText
Widget m_PopulationSort
Widget m_HostSort
SpacerBaseWidget m_ServerList
int m_TotalServers
Widget m_RefreshList
Widget m_TimeSort
Widget m_Root
Definition SizeToChild.c:85
static int COLOR_DISABLED_TEXT
The error handler itself, for managing and distributing errors to modules Manages the ErrorHandlerMod...
static proto string GetClientMessage(ErrorCategory category, int code, string additionalInfo="")
Gets the Client Message for specified error.
GetServersResult the output structure of the GetServers operation.
override void OnFilterFocus(Widget w)
override void OnFilterFocusLost(Widget w)
override void PressSholderRight()
override void ColorDisable(Widget w)
void LoadEntries(int cur_page_index, GetServersResultRowArray page)
override void ColorNormal(Widget w)
override void OnLoadServersAsyncConsole(GetServersResult result_list, EBiosError error, string response)
override void PressSholderLeft()
override void OnFilterChanged()
void SetEnableServers(bool enable)
void SetEnableFilters(bool enable)
override void Construct(Widget parent, ServerBrowserMenuNew menu, TabType type)
override void ColorHighlight(Widget w)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
WidgetFlags
Definition EnWidgets.c:58
proto native void SetFocus(Widget w)
proto native void SetSort(int sort, bool immedUpdate=true)
int ARGB(int a, int r, int g, int b)
Definition proto.c:322