public void OnApplicationQuit() { SteamAPI.Disconnect(); SceneManager.activeSceneChanged -= ActiveSceneChanged; }
public static void Init() { if (Instance == null) { try { Instance = BeatSaberUI.CreateCustomMenu <CustomMenu>("Multiplayer Lobby"); CustomViewController middleViewController = BeatSaberUI.CreateViewController <CustomViewController>(); ListViewController leftViewController = BeatSaberUI.CreateViewController <ListViewController>(); rightViewController = BeatSaberUI.CreateViewController <TableViewController>(); Instance.SetMainViewController(middleViewController, true, (firstActivation, type) => { if (firstActivation) { try { Button host = middleViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x, BASE.y + 2.5f), new Vector2(25f, 7f)); host.SetButtonTextSize(3f); host.ToggleWordWrapping(false); host.SetButtonText("Disconnect"); host.onClick.AddListener(delegate { try { SteamAPI.Disconnect(); Instance.Dismiss(); MultiplayerListing.Instance.Present(); } catch (Exception e) { Logger.Error(e); } }); float offs = 0; offs += 10f; Button vc = middleViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x, BASE.y + 2.5f - offs), new Vector2(25f, 7f)); vc.SetButtonTextSize(3f); vc.ToggleWordWrapping(false); vc.SetButtonText(Controllers.PlayerController.Instance.VoipEnabled ? "Disable Voice Chat" : "Enable Voice Chat"); vc.onClick.AddListener(delegate { try { if (!Controllers.PlayerController.Instance.VoipEnabled) { vc.SetButtonText("Disable Voice Chat"); Controllers.PlayerController.Instance.VoipEnabled = true; SteamUser.StartVoiceRecording(); } else { vc.SetButtonText("Enable Voice Chat"); Controllers.PlayerController.Instance.VoipEnabled = false; SteamUser.StopVoiceRecording(); } } catch (Exception e) { Logger.Error(e); } }); var t = middleViewController.CreateText("You can use Online Lobby in the Main Menu to choose songs for your lobby. \n\nYou can also control all the default Game Modifiers for the lobby through the Online Lobby Menu as well.", new Vector2(0, BASE.y - 10f)); var tt = middleViewController.CreateText("If something goes wrong, click the disconnect button above and just reconnect to the lobby.", new Vector2(0, 0 - BASE.y)); t.alignment = TMPro.TextAlignmentOptions.Center; tt.alignment = TMPro.TextAlignmentOptions.Center; } catch (Exception e) { Data.Logger.Error(e); } /* Button g = middleViewController.CreateUIButton("CreditsButton", new Vector2(0, 0), new Vector2(25f, 25f)); * g.SetButtonTextSize(7f); * g.ToggleWordWrapping(false); * g.SetButtonText("Select a Song"); * g.onClick.AddListener(delegate { * try * { * if (SteamAPI.IsHost()) * { * SteamAPI.SetSong("112D7FA45FA06F36FF41029099E95B98", "TaKillYa"); * SteamAPI.SetDifficulty((byte)2); * SteamAPI.RequestPlay(new GameplayModifiers(new GameplayModifiers())); * } * } * catch (Exception e) * { * Logger.Error(e); * } * });*/ } }); Instance.SetLeftViewController(leftViewController, false, (firstActivation, type) => { if (firstActivation) { refreshFriendsList(leftViewController); leftViewController.CreateText("Invite Friends", new Vector2(BASE.x + 62.5f, BASE.y)); Button b = leftViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x + 80f, BASE.y + 2.5f), new Vector2(25f, 7f)); b.SetButtonText("Refresh"); b.SetButtonTextSize(3f); b.ToggleWordWrapping(false); b.onClick.AddListener(delegate() { refreshFriendsList(leftViewController); }); invite = leftViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x + 80f, 0 - BASE.y + 2.5f), new Vector2(25f, 7f)); invite.SetButtonText("Invite"); invite.SetButtonTextSize(3f); invite.ToggleWordWrapping(false); invite.interactable = false; invite.onClick.AddListener(delegate() { if (selectedPlayer > 0) { SteamAPI.InviteUserToLobby(new CSteamID(selectedPlayer)); } }); } }); Instance.SetRightViewController(rightViewController, false, (active, type) => { if (active) { rightViewController.CreateText("Lobby Leaderboard", new Vector2(BASE.x + 62.5f, BASE.y)); } RefreshScores(); }); } catch (Exception e) { Data.Logger.Error(e); } } }