private void LinkClicked(string link)
 {
     _simpleDialog.Init("Open link?", $"Are you sure you want to open this link?\n<color=blue>{link}</color>", "Open", "Cancel",
                        (buttonIndex) =>
     {
         SetRightScreenViewController(_descriptionViewController);
         _descriptionViewController.SetDescription(_lastSelectedSong.description);
         if (buttonIndex == 0)
         {
             Application.OpenURL(link);
         }
     }
                        );
     SetRightScreenViewController(_simpleDialog);
 }
示例#2
0
        IEnumerator LoadWarning()
        {
            string warningText = "The folling plugins are obsolete:\n";

            foreach (var text in warningPlugins)
            {
                warningText += text + ", ";
            }
            warningText = warningText.Substring(0, warningText.Length - 2);

            warningText += "\nPlease remove them before playing or you my encounter errors.\nDo you want to continue?";

            yield return(new WaitForSeconds(0.1f));

            var _menuMasterViewController = Resources.FindObjectsOfTypeAll <MenuMasterViewController>().First();
            var _simpleDialogPromptViewControllerPrefab = ReflectionUtil.GetPrivateField <SimpleDialogPromptViewController>(_menuMasterViewController, "_simpleDialogPromptViewControllerPrefab");
            SimpleDialogPromptViewController warning    = Instantiate(_simpleDialogPromptViewControllerPrefab);

            warning.gameObject.SetActive(false);
            warning.Init("Plugin warning", warningText, "YES", "NO");
            warning.didFinishEvent += Warning_didFinishEvent;

            yield return(new WaitForSeconds(0.1f));

            _mainMenuViewController.PresentModalViewController(warning, null, false);
        }
        public static void PresentConnectionError(ConnectionFailedReason reason)
        {
            _mpLobbyConnectionController.LeaveLobby();
            _joiningLobbyViewController.HideLoading();

            if (reason != ConnectionFailedReason.ConnectionCanceled)
            {
                var canRetry = (LastConnectToHostedGame != null &&
                                reason != ConnectionFailedReason.InvalidPassword &&
                                reason != ConnectionFailedReason.VersionMismatch);

                _simpleDialogPromptViewController.Init("Connection failed", ConnectionErrorText.Generate(reason), "Back to browser", canRetry ? "Retry connection" : null, delegate(int btnId)
                {
                    switch (btnId)
                    {
                    default:
                    case 0:     // Back to browser
                        ReplaceTopViewController(PluginUi.ServerBrowserViewController, null, ViewController.AnimationType.In, ViewController.AnimationDirection.Vertical);
                        break;

                    case 1:     // Retry connection
                        ConnectToHostedGame(LastConnectToHostedGame);
                        break;
                    }
                });
                ReplaceTopViewController(_simpleDialogPromptViewController, null, ViewController.AnimationType.In, ViewController.AnimationDirection.Vertical);
            }
            else
            {
                ReplaceTopViewController(PluginUi.ServerBrowserViewController, null, ViewController.AnimationType.In, ViewController.AnimationDirection.Vertical);
            }
        }
        public static void PresentConnectionFailedError(string errorTitle = "Connection failed", string errorMessage = null, bool canRetry = true)
        {
            CancelLobbyJoin();

            if (LastConnectToHostedGame == null)
            {
                canRetry = false; // we don't have game info to retry with
            }
            _simpleDialogPromptViewController.Init(errorTitle, errorMessage, "Back to browser", canRetry ? "Retry connection" : null, delegate(int btnId)
            {
                switch (btnId)
                {
                default:
                case 0:     // Back to browser
                    MakeServerBrowserTopView();
                    break;

                case 1:     // Retry connection
                    ConnectToHostedGame(LastConnectToHostedGame);
                    break;
                }
            });

            ReplaceTopViewController(_simpleDialogPromptViewController, null, ViewController.AnimationType.In, ViewController.AnimationDirection.Vertical);
        }
        private void ListViewDownloadPressed(YTResult result)
        {
            // TODO
            // confirm dialogue if a videodata already exists for this song
            // delete pre-existing mp4 for overwriting

            if (selectedLevelVideo != null)
            {
                // present
                _simpleDialog.Init("Overwrite video?", $"Do you really want to delete \"{ selectedLevelVideo.title }\"\n and replace it with \"{result.title }\"", "Overwrite", "Cancel");
                _simpleDialog.didFinishEvent -= (SimpleDialogPromptViewController sender, bool delete) => { DismissViewController(_simpleDialog, null, false); if (delete)
                                                                                                            {
                                                                                                                StartDownload(result);
                                                                                                            }
                };
                _simpleDialog.didFinishEvent += (SimpleDialogPromptViewController sender, bool delete) => { DismissViewController(_simpleDialog, null, false); if (delete)
                                                                                                            {
                                                                                                                StartDownload(result);
                                                                                                            }
                };
                PresentViewController(_simpleDialog, null, false);
            }
            else
            {
                StartDownload(result);
            }
        }
示例#6
0
        public void LeaveRoom(bool force = false)
        {
            if (Client.Instance != null && Client.Instance.isHost && !force)
            {
                _hostLeaveDialog.Init("Leave room?", $"You're the host, are you sure you want to leave the room?", "Leave", "Cancel",
                                      (selectedButton) =>
                {
                    DismissViewController(_hostLeaveDialog);
                    if (selectedButton == 0)
                    {
                        LeaveRoom(true);
                    }
                });
                PresentViewController(_hostLeaveDialog);
                return;
            }

            try
            {
                if (joined)
                {
                    InGameOnlineController.Instance.needToSendUpdates = false;
                    Client.Instance.LeaveRoom();
                    joined = false;
                }
                if (Client.Instance.connected)
                {
                    Client.Instance.Disconnect();
                }
            }
            catch
            {
                Plugin.log.Warn("Unable to disconnect from ServerHub properly!");
            }

            Client.Instance.MessageReceived -= PacketReceived;
            Client.Instance.ClearMessageQueue();

            if (songToDownload != null)
            {
                songToDownload.songQueueState = SongQueueState.Error;
                Client.Instance.playerInfo.updateInfo.playerState = PlayerState.Lobby;
            }

            InGameOnlineController.Instance.DestroyPlayerControllers();
            InGameOnlineController.Instance.VoiceChatStopRecording();
            PreviewPlayer.CrossfadeToDefault();
            lastSelectedSong       = "";
            _lastSortMode          = SortMode.Default;
            _lastSearchRequest     = "";
            Client.Instance.inRoom = false;
            PopAllViewControllers();
            if (leftScreenViewController == _passHostDialog)
            {
                SetLeftScreenViewController(_playerManagementViewController);
            }
            didFinishEvent?.Invoke();
        }
示例#7
0
        private void DeletePressed()
        {
            IBeatmapLevel level = _detailViewController.difficultyBeatmap.level;

            _simpleDialog.Init("Delete song", $"Do you really want to delete \"{ level.songName} {level.songSubName}\"?", "Delete", "Cancel");
            _simpleDialog.didFinishEvent -= _simpleDialog_didFinishEvent;
            _simpleDialog.didFinishEvent += _simpleDialog_didFinishEvent;
            _freePlayFlowCoordinator.InvokePrivateMethod("PresentViewController", new object[] { _simpleDialog, null, false });
        }
        private static void ShowWarningDialog()
        {
            WarningEntry warning = _warningsQueue.Dequeue();

            _warningDialog.Init("Unmet Dependencies", $"Mod <b>{warning.ModName}</b> has unmet dependencies!" +
                                (warning.MissingDependencies.Length > 0 ? $"\nMissing:\n<color=red>{string.Join("\n", warning.MissingDependencies)}</color>" : "") +
                                (warning.IgnoredDependencies.Length > 0 ? $"\nIgnored:\n<color=#C2B2B2>{string.Join("\n", warning.IgnoredDependencies)}</color>" : "") +
                                (warning.DisabledDependencies.Length > 0 ? $"\nDisabled:\n<color=#C2C2C2>{string.Join("\n", warning.DisabledDependencies)}</color>" : "")
                                , "Okay", WarningDialogDidFinish);
            _mainFlow.InvokeMethod("PresentViewController", _warningDialog, null, true);
        }
示例#9
0
 public void TransferHostConfirmation(PlayerInfo newHost)
 {
     _passHostDialog.Init("Pass host?", $"Are you sure you want to pass host to <b>{newHost.playerName}</b>?", "Pass host", "Cancel",
                          (selectedButton) =>
     {
         SetLeftScreenViewController(_playerManagementViewController);
         if (selectedButton == 0)
         {
             Client.Instance.TransferHost(newHost);
         }
     });
     SetLeftScreenViewController(_passHostDialog);
 }
示例#10
0
        public void SubmitPressed()
        {
            _simpleDialog.Init("Post a review?", "All reviews are final and you will no longer be able to leave a review about this song!\n\nAre you sure you want to continue?", "Yes", "No",
                               (selectedIndex) =>
            {
                DismissViewController(_simpleDialog, null, false);

                if (selectedIndex == 0)
                {
                    StartCoroutine(PostReview(_lastReview.fun_factor, _lastReview.rhythm, _lastReview.flow, _lastReview.pattern_quality, _lastReview.readability, _lastReview.level_quality));
                }
            });
            PresentViewController(_simpleDialog, null, false);
        }
 private void ListViewDownloadPressed(YTResult result)
 {
     if (selectedLevelVideo != null)
     {
         // present
         _simpleDialog.Init("Overwrite video?", $"Do you really want to delete \"{ selectedLevelVideo.title }\"\n and replace it with \"{result.title }\"", "Overwrite", "Cancel", delegate(int button) { if (button == 0)
                                                                                                                                                                                                          {
                                                                                                                                                                                                              QueueDownload(result);
                                                                                                                                                                                                          }
                            });
         PresentViewController(_simpleDialog, null, false);
     }
     else
     {
         QueueDownload(result);
     }
 }
示例#12
0
        private void DeletePressed()
        {
            IBeatmapLevel level = _detailViewController.selectedDifficultyBeatmap.level;

            _simpleDialog.Init("Delete song", $"Do you really want to delete \"{ level.songName} {level.songSubName}\"?", "Delete", "Cancel",
                               (selectedButton) =>
            {
                freePlayFlowCoordinator.InvokePrivateMethod("DismissViewController", new object[] { _simpleDialog, null, false });
                if (selectedButton == 0)
                {
                    try
                    {
                        var levelsTableView = _levelListViewController.GetPrivateField <LevelPackLevelsTableView>("_levelPackLevelsTableView");

                        List <IPreviewBeatmapLevel> levels = levelsTableView.GetPrivateField <IBeatmapLevelPack>("_pack").beatmapLevelCollection.beatmapLevels.ToList();
                        int selectedIndex = levels.FindIndex(x => x.levelID == _detailViewController.selectedDifficultyBeatmap.level.levelID);

                        SongDownloader.Instance.DeleteSong(new Song(SongLoader.CustomLevels.First(x => x.levelID == _detailViewController.selectedDifficultyBeatmap.level.levelID)));

                        if (selectedIndex > -1)
                        {
                            int removedLevels = levels.RemoveAll(x => x.levelID == _detailViewController.selectedDifficultyBeatmap.level.levelID);
                            Logger.Log("Removed " + removedLevels + " level(s) from song list!");

                            _levelListViewController.SetData(CustomHelpers.GetLevelPackWithLevels(levels.Cast <BeatmapLevelSO>().ToArray(), lastPlaylist?.playlistTitle ?? "Custom Songs", lastPlaylist?.icon));
                            TableView listTableView = levelsTableView.GetPrivateField <TableView>("_tableView");
                            listTableView.ScrollToCellWithIdx(selectedIndex, TableView.ScrollPositionType.Beginning, false);
                            levelsTableView.SetPrivateField("_selectedRow", selectedIndex);
                            listTableView.SelectCellWithIdx(selectedIndex, true);
                        }
                    }
                    catch (Exception e)
                    {
                        Logger.Error("Unable to delete song! Exception: " + e);
                    }
                }
            });
            freePlayFlowCoordinator.InvokePrivateMethod("PresentViewController", new object[] { _simpleDialog, null, false });
        }
示例#13
0
 public void Update()
 {
     if (SettingsUI.isMenuScene(SceneManager.GetActiveScene()))
     {
         if (_mainMenuViewController.childViewController == null &&
             (Input.GetAxis("TriggerLeftHand") > 0.75f) &&
             (Input.GetAxis("TriggerRightHand") > 0.75f))
         {
             carTime += Time.deltaTime;
             if (carTime > 5.0f)
             {
                 carTime = 0;
                 prompt.didFinishEvent += CarEvent;
                 prompt.Init("Flying Cars", "Turn Flying Cars?", "ON", "OFF");
                 _mainMenuViewController.PresentModalViewController(prompt, null, false);
             }
         }
         else
         {
             carTime = 0;
         }
     }
 }
示例#14
0
 private void _songDetailViewController_downloadButtonPressed(Song song)
 {
     if (!SongDownloader.Instance.IsSongDownloaded(song))
     {
         _downloadQueueViewController.EnqueueSong(song, true);
         _songDetailViewController.SetDownloadState(DownloadState.Downloading);
     }
     else
     {
         _simpleDialog.Init("Delete song", $"Do you really want to delete \"{song.songName} {song.songSubName}\"?", "Delete", "Cancel",
                            (selectedButton) =>
         {
             DismissViewController(_simpleDialog, null, false);
             if (selectedButton == 0)
             {
                 DeleteSong(_lastDeletedSong);
             }
             _lastDeletedSong = null;
         });
         _lastDeletedSong = song;
         PresentViewController(_simpleDialog, null, false);
     }
 }
 private void _songDetailViewController_downloadButtonPressed(Song song)
 {
     if (!SongDownloader.Instance.IsSongDownloaded(song))
     {
         _downloadQueueViewController.EnqueueSong(song, true);
         _songDetailViewController.SetDownloadState(DownloadState.Downloading);
     }
     else
     {
         _simpleDialog.Init("Delete song", $"Do you really want to delete \"{ song.songName} {song.songSubName}\"?", "Delete", "Cancel");
         _simpleDialog.didFinishEvent -= (SimpleDialogPromptViewController sender, bool delete) => { DismissViewController(_simpleDialog, null, false); if (delete)
                                                                                                     {
                                                                                                         DeleteSong(song);
                                                                                                     }
         };
         _simpleDialog.didFinishEvent += (SimpleDialogPromptViewController sender, bool delete) => { DismissViewController(_simpleDialog, null, false); if (delete)
                                                                                                     {
                                                                                                         DeleteSong(song);
                                                                                                     }
         };
         PresentViewController(_simpleDialog, null, false);
     }
 }
示例#16
0
        private void CreateOnlineButton()
        {
            _newVersionText             = BeatSaberUI.CreateText(_mainMenuRectTransform, "A new version of the mod\nis available!", new Vector2(55.5f, 33f));
            _newVersionText.fontSize    = 5f;
            _newVersionText.lineSpacing = -52;
            _newVersionText.gameObject.SetActive(false);

            Button[] mainButtons = Resources.FindObjectsOfTypeAll <RectTransform>().First(x => x.name == "MainButtons" && x.parent.name == "MainMenuViewController").GetComponentsInChildren <Button>();

            foreach (var item in mainButtons)
            {
                (item.transform as RectTransform).sizeDelta = new Vector2(35f, 30f);
            }

            _multiplayerButton      = Instantiate(Resources.FindObjectsOfTypeAll <Button>().Last(x => (x.name == "SoloFreePlayButton")), _mainMenuRectTransform, false);
            _multiplayerButton.name = "BSMultiplayerButton";
            Destroy(_multiplayerButton.GetComponentInChildren <LocalizedTextMeshProUGUI>());
            Destroy(_multiplayerButton.GetComponentInChildren <HoverHint>());
            _multiplayerButton.transform.SetParent(mainButtons.First(x => x.name == "SoloFreePlayButton").transform.parent);
            _multiplayerButton.transform.SetAsLastSibling();

            _multiplayerButton.SetButtonText("Online");
            _multiplayerButton.SetButtonIcon(Sprites.onlineIcon);

            _multiplayerButton.interactable = !SongCore.Loader.AreSongsLoading;

            _multiplayerButton.onClick = new Button.ButtonClickedEvent();
            _multiplayerButton.onClick.AddListener(delegate()
            {
                try
                {
                    SetLobbyDiscordActivity();

                    MainFlowCoordinator mainFlow = Resources.FindObjectsOfTypeAll <MainFlowCoordinator>().First();

                    if (_noUserInfoWarning == null)
                    {
                        var dialogOrig     = ReflectionUtil.GetPrivateField <SimpleDialogPromptViewController>(mainFlow, "_simpleDialogPromptViewController");
                        _noUserInfoWarning = Instantiate(dialogOrig.gameObject).GetComponent <SimpleDialogPromptViewController>();
                    }

                    if (DateTime.Now.Month == 4 && DateTime.Now.Day == 1)
                    {
                        _noUserInfoWarning.Init("No access to multiplayer", $"You need \"Multiplayer Pro Elite Pack\" to continue\nWould you like to buy it now?", "Buy access", "Go back",
                                                (selectedButton) =>
                        {
                            mainFlow.InvokeMethod("DismissViewController", _noUserInfoWarning, null, selectedButton == 0);
                            if (selectedButton == 0)
                            {
                                mainFlow.InvokeMethod("PresentFlowCoordinator", modeSelectionFlowCoordinator, null, true, false);
                            }
                        });
                        mainFlow.InvokeMethod("PresentViewController", _noUserInfoWarning, null, false);
                    }
                    else if (GetUserInfo.GetUserID() == 0)
                    {
                        _noUserInfoWarning.Init("Invalid username and ID", $"Your username and ID are invalid\nMake sure you are logged in", "Go back", "Continue anyway",
                                                (selectedButton) =>
                        {
                            mainFlow.InvokeMethod("DismissViewController", _noUserInfoWarning, null, selectedButton == 1);
                            if (selectedButton == 1)
                            {
                                mainFlow.InvokeMethod("PresentFlowCoordinator", modeSelectionFlowCoordinator, null, true, false);
                            }
                        });
                        mainFlow.InvokeMethod("PresentViewController", _noUserInfoWarning, null, false);
                    }
                    else
                    {
                        mainFlow.InvokeMethod("PresentFlowCoordinator", modeSelectionFlowCoordinator, null, false, false);
                    }
                }
                catch (Exception e)
                {
                    Plugin.log.Critical($"Unable to present flow coordinator! Exception: {e}");
                }
            });
        }
        private void CreateOnlineButton()
        {
            _newVersionText             = BeatSaberUI.CreateText(_mainMenuRectTransform, "A new version of the mod\nis available!", new Vector2(55.5f, 33f));
            _newVersionText.fontSize    = 5f;
            _newVersionText.lineSpacing = -52;
            _newVersionText.gameObject.SetActive(false);

            Button[] mainButtons = Resources.FindObjectsOfTypeAll <RectTransform>().First(x => x.name == "MainButtons" && x.parent.name == "MainMenuViewController").GetComponentsInChildren <Button>();

            foreach (var item in mainButtons)
            {
                (item.transform as RectTransform).sizeDelta = new Vector2(35f, 30f);
            }

            _multiplayerButton = BeatSaberUI.CreateUIButton(_mainMenuRectTransform, "SoloFreePlayButton");
            Destroy(_multiplayerButton.GetComponentInChildren <LocalizedTextMeshProUGUI>());
            Destroy(_multiplayerButton.GetComponentInChildren <HoverHint>());
            _multiplayerButton.transform.SetParent(mainButtons.First(x => x.name == "SoloFreePlayButton").transform.parent);
            _multiplayerButton.transform.SetAsLastSibling();

            _multiplayerButton.SetButtonText("Online");
            _multiplayerButton.SetButtonIcon(Sprites.onlineIcon);
            BeatSaberUI.AddHintText(_multiplayerButton.transform as RectTransform, "Play with your friends online!");

            _multiplayerButton.onClick.AddListener(delegate()
            {
                try
                {
                    MainFlowCoordinator mainFlow = Resources.FindObjectsOfTypeAll <MainFlowCoordinator>().First();

                    if (_noUserInfoWarning == null)
                    {
                        var dialogOrig     = ReflectionUtil.GetPrivateField <SimpleDialogPromptViewController>(mainFlow, "_simpleDialogPromptViewController");
                        _noUserInfoWarning = Instantiate(dialogOrig.gameObject).GetComponent <SimpleDialogPromptViewController>();
                    }

                    if (GetUserInfo.GetUserID() == 0 && string.IsNullOrWhiteSpace(GetUserInfo.GetUserName()) || GetUserInfo.GetUserID() == 0)
                    {
                        _noUserInfoWarning.Init("Invalid username and ID", $"Your username and ID are invalid\nMake sure you are logged in", "Go back", "Continue anyway",
                                                (selectedButton) =>
                        {
                            mainFlow.InvokeMethod("DismissViewController", _noUserInfoWarning, null, selectedButton == 1);
                            if (selectedButton == 1)
                            {
                                mainFlow.InvokeMethod("PresentFlowCoordinator", modeSelectionFlowCoordinator, null, true, false);
                            }
                        });

                        mainFlow.InvokeMethod("PresentViewController", _noUserInfoWarning, null, false);
                    }
                    else
                    {
                        mainFlow.InvokeMethod("PresentFlowCoordinator", modeSelectionFlowCoordinator, null, false, false);
                    }
                }
                catch (Exception e)
                {
                    Plugin.log.Critical($"Unable to present flow coordinator! Exception: {e}");
                }
            });
        }