Пример #1
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.");
            }
        }
Пример #2
0
        /// <summary>
        /// Generate the main UI components for the tag system
        /// </summary>
        /// <param name="viewController">The <see cref="CustomViewController"/> where you want to add tags</param>
        /// <param name="tags">An array of tag names</param>
        /// <param name="size">The anchor size of a Tag</param>
        /// <param name="posStart">The anchor position where you want to start the Tag generation</param>
        /// <param name="gap">The gap between each tag</param>
        /// <param name="textSize">The text size for the text inside a Tag</param>
        private void _GenerateButtonTags(CustomViewController viewController, string[] tags,
                                         Vector2 size, Vector2 posStart, Vector2 gap, float textSize)
        {
            if (!_PageUpButton)
            {
                _PageUpButton = viewController.CreateUIButton("PageUpButton",
                                                              new Vector2(2f, posStart.y + gap.y),
                                                              size,
                                                              () => { _PageUpClicked(); },
                                                              "");
            }
            _PageUpButton.interactable = _CurrentPage > 1;

            int nbTags = 0;

            for (; nbTags < tags.Length; ++nbTags)
            {
                Vector2 buttonPos = new Vector2((nbTags % 2 == 0 && nbTags + 1 == tags.Length) ? (0) : (posStart.x + ((nbTags % 2 == 0) ? (-gap.x) : (gap.x))),
                                                posStart.y - gap.y * (nbTags % 10 / 2));
                Button button = viewController.CreateUIButton("CreditsButton",
                                                              buttonPos,
                                                              size,
                                                              () => { },
                                                              tags[nbTags]);

                button.onClick.AddListener(delegate { _TagClicked(button); });
                button.SetButtonTextSize(textSize);
                button.ToggleWordWrapping(false);
                if (nbTags >= 10)
                {
                    button.gameObject.SetActive(false);
                }
                _ButtonTags.Add(button, false);
            }

            if (!_PageDownButton)
            {
                _PageDownButton = viewController.CreateUIButton("PageDownButton",
                                                                new Vector2(2f, posStart.y - gap.y * 5),
                                                                size,
                                                                () => { _PageDownClicked(); },
                                                                "");
            }
            _PageDownButton.interactable = nbTags >= 10;
        }
        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.");
            }
        }
Пример #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;
            }
        }
Пример #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);
                }
            }
        }
Пример #6
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(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);
                }
            }
        }