Esempio n. 1
0
        public static void Init()
        {
            if (Instance == null)
            {
                Instance = BeatSaberUI.CreateCustomMenu <CustomMenu>($"{Plugin.instance.Name} has been updated");

                CustomViewController middleViewController = BeatSaberUI.CreateViewController <CustomViewController>();


                Instance.SetMainViewController(middleViewController, true, (firstActivation, type) =>
                {
                    if (firstActivation)
                    {
                        TMPro.TextMeshProUGUI t = middleViewController.CreateText($"{Plugin.instance.Name} has been updated to v{Plugin.instance.UpdatedVersion}. Restart your game to take effect.", new Vector2(0f, 0f));
                        t.alignment             = TMPro.TextAlignmentOptions.Center;
                    }
                });
                Instance.Present();
                if (PluginUI.MultiplayerButton != null)
                {
                    PluginUI.MultiplayerButton.interactable = false;
                    PluginUI.MultiplayerButton.hintText     = "You cannot access multiplayer until you restart your game";
                    for (int i = PluginUI.MultiplayerButton.buttons.Count - 1; i >= 0; i--)
                    {
                        BeatSaberUI.AddHintText(PluginUI.MultiplayerButton.buttons[i].transform as RectTransform, PluginUI.MultiplayerButton.hintText);
                    }
                }
            }
        }
Esempio n. 2
0
        private void _SetupConfirmQuitPanel()
        {
            _CustomMenu           = BeatSaberUI.CreateCustomMenu <CustomMenu>("Quit");
            _CustomViewController = BeatSaberUI.CreateViewController <CustomViewController>();

            if (_CustomMenu != null && _CustomViewController != null)
            {
                _CustomViewController.didDeactivateEvent += (deactivationType) => { ConfirmExitDialogOpened = false; };
                _CustomMenu.SetMainViewController(_CustomViewController, false, (firstActivation, type) =>
                {
                    if (firstActivation && type == VRUI.VRUIViewController.ActivationType.AddedToHierarchy)
                    {
                        _TopText = _CustomViewController.CreateText(PluginConfig.QuitTextContent, new Vector2(0, 10f), new Vector2(105f, 10));
                        if (_TopText != null)
                        {
                            _TopText.alignment = TMPro.TextAlignmentOptions.Center;
                            _TopText.fontSize  = 6;
                        }
                        else
                        {
                            Console.WriteLine("[BeatSaberCustomExit.MainMenuUIOverload]: 'topText' was null.");
                        }

                        _CancelButton = _CustomViewController.CreateUIButton("CreditsButton", new Vector2(-20f, -20f), new Vector2(30f, 10f),
                                                                             delegate() { _CustomMenu.Dismiss(); }, "Cancel");
                        _ConfirmButton = _CustomViewController.CreateUIButton("CreditsButton", new Vector2(20, -20f), new Vector2(30f, 10f),
                                                                              delegate() { Plugin.QuitGame(); }, "Quit");
                        if (_CancelButton != null)
                        {
                            _CancelButton.ToggleWordWrapping(false);
                        }
                        else
                        {
                            Console.WriteLine("[BeatSaberCustomExit.MainMenuUIOverload]: 'buttonCancel' was null.");
                        }

                        if (_ConfirmButton != null)
                        {
                            _ConfirmButton.ToggleWordWrapping(false);
                        }
                        else
                        {
                            Console.WriteLine("[BeatSaberCustomExit.MainMenuUIOverload]: 'buttonConfirm' was null.");
                        }
                    }
                });
            }
            else
            {
                Console.WriteLine("[BeatSaberCustomExit.MainMenuUIOverload]: '_CustomMenu' or '_CustomViewController' was null.");
            }
        }
        private void _SetupDrinkWaterPanel()
        {
            if (_CustomMenu != null && _CustomViewController != null)
            {
                return;
            }

            _CustomMenu                = BeatSaberUI.CreateCustomMenu <CustomMenu>("Drink some cum!");
            _CustomViewController      = BeatSaberUI.CreateViewController <CustomViewController>();
            _CustomViewController.name = "DrinkCumPanel";

            if (_CustomMenu != null && _CustomViewController != null)
            {
                _CustomMenu.SetMainViewController(_CustomViewController, false, (firstActivation, type) =>
                {
                    if (firstActivation && type == VRUI.VRUIViewController.ActivationType.AddedToHierarchy)
                    {
                        _TextContent                    = _CustomViewController.CreateText("", new Vector2(0, 28f));
                        _TextContent.alignment          = TextAlignmentOptions.Center;
                        _TextContent.fontSize           = 5;
                        _TextContent.enableWordWrapping = false;
                        _ContinueButton                 = _CustomViewController.CreateUIButton("CreditsButton", new Vector2(0, -28f), new Vector2(37f, 10f),
                                                                                               null, "I understand!");
                        _ContinueButton.ToggleWordWrapping(false);
                        _ContinueButton.SetButtonTextSize(4);
                        _ContinueButton.onClick.AddListener(delegate() { _CustomMenu.Dismiss(); Destroy(_CustomViewController.gameObject, 1); _CustomMenu = null; _CustomViewController = null; });

                        _RefreshTextContent(_CurrentPanelMode);

                        if (PluginConfig.ShowGIFs)
                        {
                            GameObject go      = new GameObject("[BeatSaberDrinkCum] PreviewGif");
                            _RawImage          = go.AddComponent <RawImage>();
                            _RawImage.material = Instantiate(Resources.FindObjectsOfTypeAll <Material>().Where(m => m.name == "UINoGlow").FirstOrDefault());
                            go.transform.SetParent(_CustomViewController.transform, false);
                            go.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 0);
                            go.GetComponent <RectTransform>().sizeDelta        = new Vector2(30, 30);
                            _UniGifImage = go.AddComponent <UniGifImage>();
                            UniGifImageAspectController ugiac = go.AddComponent <UniGifImageAspectController>();
                            _UniGifImage.SetPrivateField("m_imgAspectCtrl", ugiac);
                            StartCoroutine(_DisplayGifFromRotation());
                        }
                    }
                });
            }
            else
            {
                Console.WriteLine("[BeatSaberCustomExit.MainMenuUIOverload]: '_CustomMenu' or '_CustomViewController' was null.");
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Set up the UI components for the Tag System
        /// </summary>
        /// <returns>yields for the Coroutine system</returns>
        private IEnumerator _SetupUI()
        {
            if (!Initialized)
            {
                _ButtonTags = new Dictionary <Button, bool>();

                _CustomMenu           = BeatSaberUI.CreateCustomMenu <CustomMenu>("Tags");
                _CustomViewController = BeatSaberUI.CreateViewController <CustomViewController>();
                _TagNames             = new string[] { "Flow", "Streams", "Inventive Patterns",
                                                       "Meme", "Jump Streams", "Beautiful Lighting", "Vision Blocks",
                                                       "Bad Walls", "Overstated Difficulty", "Ugly", "Useless", "Entertaining", "Impossible" };
                _CustomMenu.SetLeftViewController(_CustomViewController, false, (firstActivation, type) =>
                {
                    if (firstActivation && type == VRUI.VRUIViewController.ActivationType.AddedToHierarchy)
                    {
                        _TopTagLabel           = _CustomViewController.CreateText("Tags", new Vector2(2f, 32.5f));
                        _TopTagLabel.fontSize  = 5f;
                        _TopTagLabel.alignment = TextAlignmentOptions.Center;
                        _GenerateButtonTags(_CustomViewController, _TagNames, new Vector2(12.5f, 6.25f), new Vector2(0, 12f), new Vector2(10f, 8.5f), 2f);
                        _CloseButton = _CustomViewController.CreateUIButton("CreditsButton",
                                                                            new Vector2(43f, 31.5f),
                                                                            new Vector2(20f, 8f),
                                                                            () => { _CustomMenu.Dismiss(); },
                                                                            "Close");
                        _CloseButton.SetButtonTextSize(3f);
                        _CloseButton.ToggleWordWrapping(false);

                        _OKResultButton = _ResultViewController.GetComponentsInChildren <Button>().First(x => x.name == "Ok");
                        _OKResultButton.onClick.AddListener(_OKResultButtonClicked);
                    }
                });

                yield return(new WaitUntil(() => { return _CustomMenu.Present(false); }));

                _CustomMenu.Present();

                IsInitializing = false;
                Initialized    = true;
            }
        }
Esempio n. 5
0
        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);
                }
            }
        }
        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(VoiceChatWorker.VoipEnabled ? "Disable Voice Chat" : "Enable Voice Chat");
                                vc.onClick.AddListener(delegate
                                {
                                    try
                                    {
                                        if (!VoiceChatWorker.VoipEnabled)
                                        {
                                            vc.SetButtonText("Disable Voice Chat");
                                            VoiceChatWorker.VoipEnabled = true;
                                            SteamUser.StartVoiceRecording();
                                        }
                                        else
                                        {
                                            vc.SetButtonText("Enable Voice Chat");
                                            VoiceChatWorker.VoipEnabled = false;
                                            SteamUser.StopVoiceRecording();
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        Logger.Error(e);
                                    }
                                });
                                offs  += 10f;
                                rejoin = middleViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x, BASE.y + 2.5f - offs), new Vector2(25f, 7f));
                                rejoin.SetButtonTextSize(3f);
                                rejoin.ToggleWordWrapping(false);
                                rejoin.SetButtonText("Re-Join Song");
                                rejoin.interactable = false;
                                rejoin.onClick.AddListener(delegate
                                {
                                    if (SteamAPI.GetLobbyData().Screen == LobbyPacket.SCREEN_TYPE.IN_GAME && SteamAPI.GetLobbyData().CurrentSongOffset > 0f)
                                    {
                                        WaitingMenu.autoReady             = true;
                                        WaitingMenu.timeRequestedToLaunch = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds();
                                        WaitingMenu.Instance.Present();
                                    }
                                });
                                bodyText           = 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));
                                bodyText.alignment = TMPro.TextAlignmentOptions.Center;
                                tt.alignment       = TMPro.TextAlignmentOptions.Center;
                            } 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, (firstActivation, type) => {
                        if (firstActivation)
                        {
                            rightViewController.CreateText("Lobby Leaderboard", new Vector2(BASE.x + 62.5f, BASE.y));
                        }
                        RefreshScores();
                    });
                } catch (Exception e)
                {
                    Logger.Error(e);
                }
            }
        }