3 #ifdef PLATFORM_CONSOLE
13 protected Widget m_CustomizeCharacter;
16 protected TabberUI m_Tabber;
28 #ifdef PLATFORM_CONSOLE
29 layoutRoot =
GetGame().GetWorkspace().CreateWidgets(
"gui/layouts/new_ui/server_browser/xbox/server_browser.layout");
30 m_FavoritesTab =
new ServerBrowserFavoritesTabConsolePages(layoutRoot.FindAnyWidget(
"Tab_0"),
this,
TabType.FAVORITE);
34 layoutRoot =
GetGame().GetWorkspace().CreateWidgets(
"gui/layouts/new_ui/server_browser/pc/server_browser.layout");
35 m_FavoritesTab =
new ServerBrowserFavoritesTabPc(layoutRoot.FindAnyWidget(
"Tab_0"),
this,
TabType.FAVORITE);
41 layoutRoot.FindAnyWidget(
"Tabber").GetScript(m_Tabber);
43 m_Play = layoutRoot.FindAnyWidget(
"play");
44 m_Back = layoutRoot.FindAnyWidget(
"back_button");
45 m_CustomizeCharacter = layoutRoot.FindAnyWidget(
"customize_character");
46 m_PlayerName =
TextWidget.Cast(layoutRoot.FindAnyWidget(
"character_name_text"));
49 #ifndef PLATFORM_CONSOLE
50 layoutRoot.FindAnyWidget(
"customize_character").Show(
false);
51 layoutRoot.FindAnyWidget(
"character").Show(
false);
59 #ifdef PLATFORM_CONSOLE
60 version =
"#main_menu_version" +
" " + version +
" (" +
g_Game.GetDatabaseID() +
")";
63 layoutRoot.FindAnyWidget(
"play_panel_root").Show(
true);
64 layoutRoot.FindAnyWidget(
"MouseAndKeyboardWarning").Show(
true);
65 layoutRoot.FindAnyWidget(
"toolbar_bg").Show(
false);
68 version =
"#main_menu_version" +
" " + version;
73 LoadFavoriteServers();
75 m_Tabber.m_OnTabSwitch.Insert(OnTabSwitch);
77 m_FavoritesTab.RefreshList();
79 #ifdef PLATFORM_CONSOLE
83 sort_text.SetText(
"#str_serverbrowserroot_toolbar_bg_consoletoolbar_sort_sorttext0");
86 PPERequesterBank.GetRequester(PPERequester_ServerBrowserBlur).Start(
new Param1<float>(0.5));
95 void ~ServerBrowserMenuNew()
97 #ifdef PLATFORM_CONSOLE
98 SaveFavoriteServersConsoles();
103 m_Tabber.m_OnTabSwitch.Remove(OnTabSwitch);
104 PPERequesterBank.GetRequester(PPERequester_ServerBrowserBlur).Stop();
114 #ifdef PLATFORM_CONSOLE
121 switch (pInputDeviceType)
124 #ifdef PLATFORM_CONSOLE
126 layoutRoot.FindAnyWidget(
"toolbar_bg").Show(
true);
127 layoutRoot.FindAnyWidget(
"ConsoleControls").Show(
true);
132 #ifdef PLATFORM_CONSOLE
135 layoutRoot.FindAnyWidget(
"toolbar_bg").Show(
false);
136 layoutRoot.FindAnyWidget(
"ConsoleControls").Show(
false);
157 else if (w == m_CustomizeCharacter)
159 CustomizeCharacter();
186 void SetServersLoadingTab(
TabType refreshing)
188 m_IsRefreshing = refreshing;
196 return m_IsRefreshing;
201 foreach (
string id : m_Favorites)
204 id.Split(
":", output);
205 if (output.Count() == 2)
207 string ip = output[0];
208 int port = output[1].ToInt();
209 input.AddFavourite(ip, port);
214 bool IsFavorited(
string server_id)
219 index = m_Favorites.Find(server_id);
225 bool SetFavoriteConsoles(
string ipAddress,
int port,
bool favorite)
229 g_Game.GetUIManager().ShowDialog(
"#layout_notification_info_warning",
"#STR_MaxFavouriteReached", 0, DBT_OK, DBB_YES, DMT_EXCLAMATION,
this);
233 AddFavorite(ipAddress, port, favorite);
234 SaveFavoriteServersConsoles();
239 void AddFavorite(
string ipAddress,
int port,
bool favorite)
241 string serverId = ipAddress +
":" + port;
242 bool isFavorited = IsFavorited(serverId);
244 if (favorite && !isFavorited)
246 m_Favorites.Insert(serverId);
248 else if (isFavorited)
250 m_Favorites.RemoveItem(serverId);
251 m_OfficialTab.Unfavorite(serverId);
252 m_CommunityTab.Unfavorite(serverId);
253 m_FavoritesTab.Unfavorite(serverId);
254 #ifndef PLATFORM_CONSOLE
255 m_LANTab.Unfavorite(serverId);
262 GetGame().GetUIManager().Back();
265 void ShowYButton(
bool show)
281 void ShowAButton(
bool show)
298 void FilterFocus(
bool focus)
300 #ifdef PLATFORM_CONSOLE
307 con_text.SetText(
"#dialog_change");
308 ref_text.SetText(
"#server_browser_menu_refresh");
309 res_text.SetText(
"#server_browser_menu_reset_filters");
318 void BackButtonFocus()
325 #ifdef PLATFORM_CONSOLE
332 con_text.SetText(
"#server_browser_menu_connect");
335 res_text.GetSize(
x,
y);
338 res_text.SetText(
"#server_browser_menu_unfavorite");
342 res_text.SetText(
"#server_browser_menu_favorite");
374 #ifdef PLATFORM_CONSOLE
375 if (
GetGame().GetUserManager() &&
GetGame().GetUserManager().GetSelectedUser())
377 name =
GetGame().GetUserManager().GetSelectedUser().GetName();
378 if (
name.LengthUtf8() > 18)
389 m_PlayerName.SetText(
name);
393 #ifdef PLATFORM_CONSOLE
394 version =
"#main_menu_version" +
" " + version +
" (" +
g_Game.GetDatabaseID() +
")";
396 version =
"#main_menu_version" +
" " + version;
400 override void Update(
float timeslice)
404 if (
GetUApi().GetInputByID(UAUITabLeft).LocalPress())
406 m_Tabber.PreviousTab();
409 if (
GetUApi().GetInputByID(UAUITabRight).LocalPress())
414 if (
GetUApi().GetInputByID(UAUINextDown).LocalPress())
416 GetSelectedTab().PressSholderLeft();
419 if (
GetUApi().GetInputByID(UAUINextUp).LocalPress())
421 GetSelectedTab().PressSholderRight();
424 if (
GetUApi().GetInputByID(UAUISelect).LocalPress())
426 GetSelectedTab().PressA();
429 if (
GetUApi().GetInputByID(UAUICtrlX).LocalPress())
431 GetSelectedTab().PressX();
434 if (
GetUApi().GetInputByID(UAUICtrlY).LocalPress())
436 GetSelectedTab().PressY();
439 if (
GetUApi().GetInputByID(UAUILeft).LocalPress())
441 GetSelectedTab().Left();
445 if (
GetUApi().GetInputByID(UAUILeft).LocalHold())
447 GetSelectedTab().LeftHold();
451 if (
GetUApi().GetInputByID(UAUILeft).LocalRelease())
453 GetSelectedTab().LeftRelease();
456 if (
GetUApi().GetInputByID(UAUIRight).LocalPress())
458 GetSelectedTab().Right();
462 if (
GetUApi().GetInputByID(UAUIRight).LocalHold())
464 GetSelectedTab().RightHold();
468 if (
GetUApi().GetInputByID(UAUIRight).LocalRelease())
470 GetSelectedTab().RightRelease();
473 if (
GetUApi().GetInputByID(UAUIUp).LocalPress())
475 GetSelectedTab().Up();
478 if (
GetUApi().GetInputByID(UAUIDown).LocalPress())
480 GetSelectedTab().Down();
483 if (
GetUApi().GetInputByID(UAUIBack).LocalPress())
489 super.Update(timeslice);
496 return (w == m_Play || w == m_CustomizeCharacter || w ==
m_Back);
501 void LoadFavoriteServers()
505 #ifdef PLATFORM_WINDOWS
508 GetGame().GetProfileStringList(
"SB_Favorites", m_Favorites);
511 for (
int i = 0; i < m_Favorites.Count(); ++i)
513 string id = m_Favorites[i];
516 id.Split(
":", output);
517 if (output.Count() != 2)
519 m_Favorites.Remove(i);
529 m_Favorites.Invert();
531 m_Favorites.Invert();
536 void SaveFavoriteServersConsoles()
538 GetGame().SetProfileStringList(
"SB_Favorites", m_Favorites);
553 #ifdef PLATFORM_CONSOLE
558 aButton.Show(server.IsOnline());
559 connectText.Show(server.IsOnline());
563 void Connect(ServerBrowserEntry server)
566 #ifdef PLATFORM_CONSOLE
567 SaveFavoriteServersConsoles();
577 if (!
g_Game.VerifyWorldOwnership(mapNM))
579 GetGame().GetUIManager().ShowDialog(
"#server_browser_connect_label",
"#mod_detail_info_warning", 232, DBT_OK, DBB_NONE, DMT_INFO,
GetGame().GetUIManager().GetMenu());
580 g_Game.GoBuyWorldDLC(mapNM);
586 g_Game.ConnectFromServerBrowser(ip, port,
"");
590 void CustomizeCharacter()
592 PPERequesterBank.GetRequester(PPERequester_ServerBrowserBlur).Stop();
601 void PreviousCharacter()
608 switch (m_Tabber.GetSelectedIndex())
612 return m_FavoritesTab;
616 return m_OfficialTab;
620 return m_CommunityTab;
632 LoadFavoriteServers();
633 SetServersLoadingTab(
TabType.NONE);
637 GetSelectedTab().RefreshList();
640 GetSelectedTab().Focus();
645 if (GetSelectedTab())
647 GetSelectedTab().OnLoadServerModsAsync(result_list.m_Id, result_list.m_Mods);
653 #ifdef PLATFORM_WINDOWS
654 #ifdef PLATFORM_CONSOLE
655 GetSelectedTab().OnLoadServersAsyncConsole(result_list, error, response);
657 GetSelectedTab().OnLoadServersAsyncPC(result_list, error, response);
660 GetSelectedTab().OnLoadServersAsyncConsole(result_list, error, response);
670 int color_pnl =
ARGB(255, 0, 0, 0);
671 int color_lbl =
ARGB(255, 255, 0, 0);
673 #ifdef PLATFORM_CONSOLE
674 color_pnl =
ARGB(255, 200, 0, 0);
675 color_lbl =
ARGB(255, 255, 255, 255);
678 ButtonSetColor(w, color_pnl);
679 ButtonSetTextColor(w, color_lbl);
687 int color_pnl =
ARGB(0, 0, 0, 0);
688 int color_lbl =
ARGB(255, 255, 255, 255);
690 ButtonSetColor(w, color_pnl);
691 ButtonSetTextColor(w, color_lbl);
694 void ButtonSetText(
Widget w,
string text)
708 void ButtonSetColor(
Widget w,
int color)
713 Widget panel = w.FindWidget(w.GetName() +
"_panel");
717 panel.SetColor(color);
721 void ButtonSetTextColor(
Widget w,
int color)
732 label.SetColor(color);
737 text.SetColor(color);
742 text2.SetColor(color);
752 toolbar_a.SetText(
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUISelect",
"", EUAINPUT_DEVICE_CONTROLLER,
InputUtils.ICON_SCALE_TOOLBAR));
753 toolbar_b.SetText(
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUIBack",
"", EUAINPUT_DEVICE_CONTROLLER,
InputUtils.ICON_SCALE_TOOLBAR));
754 toolbar_x.SetText(
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUICtrlX",
"", EUAINPUT_DEVICE_CONTROLLER,
InputUtils.ICON_SCALE_TOOLBAR));
755 toolbar_y.SetText(
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUICtrlY",
"", EUAINPUT_DEVICE_CONTROLLER,
InputUtils.ICON_SCALE_TOOLBAR));