示例#1
0
        internal static void CreateMenu()
        {
            if (SaberForgeMenu == null)
            {
                SaberForgeMenu = BeatSaberUI.CreateCustomMenu <CustomMenu>("Saber Forge");

                //create views
                mainViewController  = BeatSaberUI.CreateViewController <MainViewController>();
                rightViewController = BeatSaberUI.CreateViewController <RightViewController>();
                leftViewController  = BeatSaberUI.CreateViewController <LeftViewController>();

                //set back button
                mainViewController.backButtonPressed += delegate()
                {
                    SaberForgeMenu.Dismiss();
                };

                //set view positions
                SaberForgeMenu.SetMainViewController(mainViewController, true);
                SaberForgeMenu.SetRightViewController(rightViewController, false);
                SaberForgeMenu.SetLeftViewController(leftViewController, false);
            }

            if (HelpMenu == null)
            {
                HelpMenu = BeatSaberUI.CreateCustomMenu <CustomMenu>("Saber Forge Help");

                HelpMainViewController  helpMainViewController  = BeatSaberUI.CreateViewController <HelpMainViewController>();
                HelpRightViewController helpRightViewController = BeatSaberUI.CreateViewController <HelpRightViewController>();
                HelpLeftViewController  helpLeftViewController  = BeatSaberUI.CreateViewController <HelpLeftViewController>();

                //set back button
                helpMainViewController.backButtonPressed += delegate()
                {
                    HelpMenu.Dismiss(); rightViewController.ForceSliders(); leftViewController.ForceSliders();;
                };

                //set view positions
                HelpMenu.SetMainViewController(helpMainViewController, true);
                HelpMenu.SetRightViewController(helpRightViewController, false);
                HelpMenu.SetLeftViewController(helpLeftViewController, false);
            }

            MenuButtonUI.AddButton("Saber Forge", delegate() { SaberForgeMenu.Present(); rightViewController.ForceSliders(); leftViewController.ForceSliders(); });
        }
示例#2
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);
                }
            }
        }
示例#3
0
        public static void OnLoad()
        {
            try
            {
                var _levelListViewController = Resources.FindObjectsOfTypeAll <LevelPackLevelsViewController>().First();
                if (_levelListViewController)
                {
                    _requestButton = BeatSaberUI.CreateUIButton(_levelListViewController.rectTransform, "OkButton", new Vector2(66, -3.5f),
                                                                new Vector2(9f, 5.5f), () => { _requestButton.interactable = false; _songRequestMenu.Present(); _requestButton.interactable = true; }, "SRM");

                    (_requestButton.transform as RectTransform).anchorMin = new Vector2(1, 1);
                    (_requestButton.transform as RectTransform).anchorMax = new Vector2(1, 1);

                    _requestButton.ToggleWordWrapping(false);
                    _requestButton.SetButtonTextSize(3.5f);
                    BeatSaberUI.AddHintText(_requestButton.transform as RectTransform, "Manage the current request queue");

                    UpdateRequestUI();
                    Plugin.Log("Created request button!");
                }
            }
            catch
            {
                Plugin.Log("Unable to create request button");
            }

            if (_songRequestListViewController == null)
            {
                _songRequestListViewController = BeatSaberUI.CreateViewController <RequestBotListViewController>();
            }


            if (_KeyboardViewController == null)
            {
                _KeyboardViewController = BeatSaberUI.CreateViewController <CustomViewController>();

                RectTransform KeyboardContainer = new GameObject("KeyboardContainer", typeof(RectTransform)).transform as RectTransform;
                KeyboardContainer.SetParent(_KeyboardViewController.rectTransform, false);
                KeyboardContainer.sizeDelta = new Vector2(60f, 40f);

                var mykeyboard = new KEYBOARD(KeyboardContainer, "");

#if UNRELEASED
                //mykeyboard.AddKeys(BOTKEYS, 0.4f);
                AddKeyboard(mykeyboard, "emotes.kbd", 0.4f);
#endif
                mykeyboard.AddKeys(KEYBOARD.QWERTY); // You can replace this with DVORAK if you like
                mykeyboard.DefaultActions();



#if UNRELEASED
                const string SEARCH = @"

[CLEAR SEARCH]/0 /2 [NEWEST]/0 /2 [UNFILTERED]/30 /2 [PP]/0'!addsongs/top/pp pp%CR%' /2 [SEARCH]/0";
#else
                const string SEARCH = @"

[CLEAR SEARCH]/0 /2 [NEWEST]/0 /2 [UNFILTERED]/30 /2 [SEARCH]/0";
#endif


                mykeyboard.SetButtonType("OkButton"); // Adding this alters button positions??! Why?
                mykeyboard.AddKeys(SEARCH, 0.75f);

                mykeyboard.SetAction("CLEAR SEARCH", ClearSearch);
                mykeyboard.SetAction("UNFILTERED", UnfilteredSearch);
                mykeyboard.SetAction("SEARCH", MSD);
                mykeyboard.SetAction("NEWEST", Newest);


#if UNRELEASED
                AddKeyboard(mykeyboard, "decks.kbd", 0.4f);
#endif

                // The UI for this might need a bit of work.

                AddKeyboard(mykeyboard, "RightPanel.kbd");
            }

            if (_songRequestMenu == null)
            {
                _songRequestMenu = BeatSaberUI.CreateCustomMenu <CustomMenu>("Song Request Queue");
                _songRequestMenu.SetMainViewController(_songRequestListViewController, true);
                _songRequestMenu.SetRightViewController(_KeyboardViewController, false);
            }

            SongListUtils.Initialize();

            WriteQueueSummaryToFile();
            WriteQueueStatusToFile(QueueMessage(RequestBotConfig.Instance.RequestQueueOpen));

            // Yes, this is disabled on purpose. StreamCore will init this class for you now, so don't uncomment this! -Brian
            //if (Instance) return;
            //new GameObject("SongRequestManager").AddComponent<RequestBot>();
        }
        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);
                }
            }
        }