protected void CreateUI() { try { _mainMenuViewController = Resources.FindObjectsOfTypeAll <MainMenuViewController>().First(); _mainMenuRectTransform = _mainMenuViewController.transform as RectTransform; _mockPartyViewController = new MockPartyViewController(); if (Config.Instance.AutoStartLobby) { SteamAPI.CreateLobby(!Config.Instance.IsPublic); } AvatarController.LoadAvatars(); SongListUtils.Initialize(); MultiplayerListing.Init(); MultiplayerLobby.Init(); WaitingMenu.Init(); CreateMainMenuButton(); CreateSettingsMenu(); } catch (Exception e) { Logger.Error($"Unable to create UI! Exception: {e}"); } }
public static void Init() { if (Instance == null) { Instance = BeatSaberUI.CreateCustomMenu <CustomMenu>("Online Multiplayer"); middleViewController = BeatSaberUI.CreateViewController <ListViewController>(); Instance.SetMainViewController(middleViewController, true, (firstActivation, type) => { refreshAvailableLobbies(); if (firstActivation) { middleViewController.CreateText("Available Lobbies", new Vector2(BASE.x + 60f, BASE.y)); refresh = middleViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x + 80f, BASE.y + 2.5f), new Vector2(25f, 7f)); refresh.SetButtonText("Refresh"); refresh.SetButtonTextSize(3f); refresh.ToggleWordWrapping(false); refresh.onClick.AddListener(delegate() { refreshAvailableLobbies(); }); if (!SteamAPI.isLobbyConnected()) { Button host = middleViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x, BASE.y + 2.5f), new Vector2(25f, 7f)); host.SetButtonTextSize(3f); host.ToggleWordWrapping(false); host.onClick.RemoveAllListeners(); host.SetButtonText("Host Public Lobby"); host.onClick.AddListener(delegate() { SteamAPI.CreateLobby(false); Instance.Dismiss(); MultiplayerLobby.Instance.Present(); }); Button hostP = middleViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x, BASE.y + 2.5f - 10f), new Vector2(25f, 7f)); hostP.SetButtonTextSize(3f); hostP.ToggleWordWrapping(false); hostP.onClick.RemoveAllListeners(); hostP.SetButtonText("Host Private Lobby"); hostP.onClick.AddListener(delegate() { SteamAPI.CreateLobby(true); Instance.Dismiss(); MultiplayerLobby.Instance.Present(); }); } } }); } }
protected void CreateUI() { try { _mainMenuViewController = Resources.FindObjectsOfTypeAll <MainMenuViewController>().First(); _mainMenuViewController.didFinishEvent += (sender, result) => { Logger.Debug($"finish \"{result}\""); if (result == MainMenuViewController.MenuButton.Party) { try { _mockPartyViewController = new MockPartyViewController(); } catch (Exception e) { Logger.Error(e); } } }; _mainMenuRectTransform = _mainMenuViewController.transform as RectTransform; if (Config.Instance.AutoStartLobby) { SteamAPI.CreateLobby(!Config.Instance.IsPublic); } try { AvatarController.LoadAvatars(); } catch (Exception e) { Logger.Error($"Unable to load avatars! Exception: {e}"); } SongListUtils.Initialize(); MultiplayerListing.Init(); MultiplayerLobby.Init(); WaitingMenu.Init(); CreateSettingsMenu(); CreateMainMenuButton(); } catch (Exception e) { Logger.Error($"Unable to create UI! Exception: {e}"); } }