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); } } } }
public void ShowConfirmQuitPanel() { if (!ConfirmExitDialogOpened && _CustomMenu != null) { _CustomMenu.Present(false); } }
/// <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; } }
private void HandleMenuSceneLoadedFresh() { if (_platformMenu == null) { _platformMenu = BeatSaberUI.CreateCustomMenu <CustomMenu>("Platform Select"); PlatformListViewController platformListViewController = BeatSaberUI.CreateViewController <PlatformListViewController>(); platformListViewController.backButtonPressed += delegate() { _platformMenu.Dismiss(); }; _platformMenu.SetMainViewController(platformListViewController, true); platformListViewController.DidSelectRowEvent += delegate(TableView view, int row) { PlatformManager.Instance.ChangeToPlatform(row); }; } MenuButtonUI.AddButton("Platforms", delegate() { _platformMenu.Present(); }); CreateSettingsUI(); }
public void ShowDrinkWaterPanel(DrinkWaterPanelMode mode) { if (_CustomMenu != null && _CustomViewController != null) { _CurrentPanelMode = mode; if (PluginConfig.ShowGIFs) { StartCoroutine(_DisplayGifFromRotation()); } _CustomMenu.Present(); _RefreshTextContent(mode); StartCoroutine(MakeButtonInteractableDelay(_ContinueButton, PluginConfig.WaitDuration, 0.1f, "0.0")); DisplayPanelNeeded = false; } }
private void RequestQueueControllerMain() { _customMenu = BeatSaberUI.CreateCustomMenu <CustomMenu>("QueueButtonOptions"); _customListViewController = BeatSaberUI.CreateViewController <CustomListViewController>(); CreateNextButton(); CreateRandomizeButton(); CreateSongToTopButton(); CreateSubOnlyButton(); CreateClearQueueButton(); CreateBanSongButton(); _customMenu.SetLeftViewController(_customListViewController, true); _customMenu.Present(); }
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(); }); }
public void ShowConfirmQuitPanel(PanelState state) { if (!ConfirmExitDialogOpened && _CustomMenu != null) { _CustomMenu.Present(false); if (_CurrentPanelState != state) { switch (state) { case PanelState.QUIT: _ChangeForPanelQuitting(); break; case PanelState.RESTART: _ChangeForPanelRestarting(); break; } _CurrentPanelState = state; } } }
private IEnumerator _WaitForPresenting() { yield return(new WaitUntil(() => { return _CustomMenu.Present(false); })); }
//static bool test(string x) //{ // File.AppendAllText("c:\\sehria\\objects.txt", x + "\r\n"); // return false; //} protected override void DidActivate(bool firstActivation, ActivationType type) { if (firstActivation) { if (!SongCore.Loader.AreSongsLoaded) { SongCore.Loader.SongsLoadedEvent += SongLoader_SongsLoadedEvent; } // get table cell instance _requestListTableCellInstance = Resources.FindObjectsOfTypeAll <LevelListTableCell>().First((LevelListTableCell x) => x.name == "LevelListTableCell"); InitConfirmationDialog(); //Resources.FindObjectsOfTypeAll<UnityEngine.Object>().Any(x => (test(x.name))); ; _songListTableCellInstance = Resources.FindObjectsOfTypeAll <LevelListTableCell>().First(o => (o.name == "LevelListTableCell")); _songPreviewPlayer = Resources.FindObjectsOfTypeAll <SongPreviewPlayer>().FirstOrDefault(); DidSelectRowEvent += DidSelectRow; RectTransform container = new GameObject("RequestBotContainer", typeof(RectTransform)).transform as RectTransform; container.SetParent(rectTransform, false); container.sizeDelta = new Vector2(60f, 0f); try { InitKeyboardDialog(); } catch (Exception ex) { Plugin.Log(ex.ToString()); } CenterKeys = new KEYBOARD(container, "", false, -15, 15); #if UNRELEASED // BUG: Need additional modes disabling one shot buttons // BUG: Need to make sure the buttons are usable on older headsets _CurrentSongName = BeatSaberUI.CreateText(container, "", new Vector2(-35, 37f)); _CurrentSongName.fontSize = 3f; _CurrentSongName.color = Color.cyan; _CurrentSongName.alignment = TextAlignmentOptions.Left; _CurrentSongName.enableWordWrapping = false; _CurrentSongName.text = ""; _CurrentSongName2 = BeatSaberUI.CreateText(container, "", new Vector2(-35, 34f)); _CurrentSongName2.fontSize = 3f; _CurrentSongName2.color = Color.cyan; _CurrentSongName2.alignment = TextAlignmentOptions.Left; _CurrentSongName2.enableWordWrapping = false; _CurrentSongName2.text = ""; //CenterKeys.AddKeys(SONGLISTKEY); RequestBot.AddKeyboard(CenterKeys, "mainpanel.kbd"); ColorDeckButtons(CenterKeys, Color.white, Color.magenta); #endif RequestBot.AddKeyboard(CenterKeys, "CenterPanel.kbd"); CenterKeys.DefaultActions(); // History button _historyButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(o => (o.name == "OkButton")), container, false); _historyButton.ToggleWordWrapping(false); (_historyButton.transform as RectTransform).anchoredPosition = new Vector2(90f, 30f); _historyButton.SetButtonText("History"); _historyButton.onClick.RemoveAllListeners(); _historyButton.onClick.AddListener(delegate() { isShowingHistory = !isShowingHistory; Resources.FindObjectsOfTypeAll <VRUIScreenSystem>().First().title = isShowingHistory ? "Song Request History" : "Song Request Queue"; UpdateRequestUI(true); SetUIInteractivity(); _lastSelection = -1; }); _historyHintText = BeatSaberUI.AddHintText(_historyButton.transform as RectTransform, ""); // Blacklist button _blacklistButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(o => (o.name == "OkButton")), container, false); _blacklistButton.ToggleWordWrapping(false); (_blacklistButton.transform as RectTransform).anchoredPosition = new Vector2(90f, 10f); _blacklistButton.SetButtonText("Blacklist"); //_blacklistButton.GetComponentInChildren<Image>().color = Color.red; _blacklistButton.onClick.RemoveAllListeners(); _blacklistButton.onClick.AddListener(delegate() { if (NumberOfCells() > 0) { _onConfirm = () => { RequestBot.Blacklist(_selectedRow, isShowingHistory, true); if (_selectedRow > 0) { _selectedRow--; } }; var song = SongInfoForRow(_selectedRow).song; _warningTitle.text = "Blacklist Song Warning"; _warningMessage.text = $"Blacklisting {song["songName"].Value} by {song["authorName"].Value}\r\nDo you want to continue?"; confirmDialogActive = true; _confirmationDialog.Present(); } }); BeatSaberUI.AddHintText(_blacklistButton.transform as RectTransform, "Block the selected request from being queued in the future."); // Skip button _skipButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(o => (o.name == "OkButton")), container, false); _skipButton.ToggleWordWrapping(false); (_skipButton.transform as RectTransform).anchoredPosition = new Vector2(90f, 0f); _skipButton.SetButtonText("Skip"); //_skipButton.GetComponentInChildren<Image>().color = Color.yellow; _skipButton.onClick.RemoveAllListeners(); _skipButton.onClick.AddListener(delegate() { if (NumberOfCells() > 0) { _onConfirm = () => { currentsong = SongInfoForRow(_selectedRow); RequestBot.Skip(_selectedRow); if (_selectedRow > 0) { _selectedRow--; } }; var song = SongInfoForRow(_selectedRow).song; _warningTitle.text = "Skip Song Warning"; _warningMessage.text = $"Skipping {song["songName"].Value} by {song["authorName"].Value}\r\nDo you want to continue?"; confirmDialogActive = true; _confirmationDialog.Present(); } }); BeatSaberUI.AddHintText(_skipButton.transform as RectTransform, "Remove the selected request from the queue."); // Play button _playButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(o => (o.name == "OkButton")), container, false); _playButton.ToggleWordWrapping(false); (_playButton.transform as RectTransform).anchoredPosition = new Vector2(90f, -10f); _playButton.SetButtonText("Play"); _playButton.GetComponentInChildren <Image>().color = Color.green; _playButton.onClick.RemoveAllListeners(); _playButton.onClick.AddListener(delegate() { if (NumberOfCells() > 0) { currentsong = SongInfoForRow(_selectedRow); RequestBot.played.Add(currentsong.song); RequestBot.WriteJSON(RequestBot.playedfilename, ref RequestBot.played); SetUIInteractivity(false); RequestBot.Process(_selectedRow, isShowingHistory); _selectedRow = -1; } }); BeatSaberUI.AddHintText(_playButton.transform as RectTransform, "Download and scroll to the currently selected request."); // Queue button _queueButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(o => (o.name == "OkButton")), container, false); _queueButton.ToggleWordWrapping(false); _queueButton.SetButtonTextSize(3.5f); (_queueButton.transform as RectTransform).anchoredPosition = new Vector2(90f, -30f); _queueButton.SetButtonText(RequestBotConfig.Instance.RequestQueueOpen ? "Queue Open" : "Queue Closed"); _queueButton.GetComponentInChildren <Image>().color = RequestBotConfig.Instance.RequestQueueOpen ? Color.green : Color.red;; _queueButton.interactable = true; _queueButton.onClick.RemoveAllListeners(); _queueButton.onClick.AddListener(delegate() { RequestBotConfig.Instance.RequestQueueOpen = !RequestBotConfig.Instance.RequestQueueOpen; RequestBotConfig.Instance.Save(); RequestBot.WriteQueueStatusToFile(RequestBotConfig.Instance.RequestQueueOpen ? "Queue is open." : "Queue is closed."); RequestBot.Instance.QueueChatMessage(RequestBotConfig.Instance.RequestQueueOpen ? "Queue is open." : "Queue is closed."); UpdateRequestUI(); }); BeatSaberUI.AddHintText(_queueButton.transform as RectTransform, "Open/Close the queue."); } base.DidActivate(firstActivation, type); UpdateRequestUI(); SetUIInteractivity(true); }
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 void OnSceneLoaded(Scene scene, LoadSceneMode sceneMode) { if (scene.name == "MenuCore") { if (_notesMenu == null) { _notesMenu = BeatSaberUI.CreateCustomMenu <CustomMenu>("Custom Notes"); UI.NoteListViewController noteListViewController = BeatSaberUI.CreateViewController <UI.NoteListViewController>(); noteListViewController.backButtonPressed += delegate() { _notesMenu.Dismiss(); }; _notesMenu.SetMainViewController(noteListViewController, true); noteListViewController.DidSelectRowEvent += delegate(TableView view, int row) { selectedNote = row; }; } CustomUI.MenuButton.MenuButtonUI.AddButton("CustomNotes", delegate() { _notesMenu.Present(); }); } }
public static void OnLoad() { _levelSelectionFlowCoordinator = Resources.FindObjectsOfTypeAll <SoloFreePlayFlowCoordinator>().First(); if (_levelSelectionFlowCoordinator) { _levelSelectionNavigationController = _levelSelectionFlowCoordinator.GetPrivateField <DismissableNavigationController>("_navigationController"); } if (_levelSelectionNavigationController) { if (_songRequestMenu == null) { _songRequestMenu = BeatSaberUI.CreateCustomMenu <CustomMenu>("Song Request Queue"); _songRequestListViewController = BeatSaberUI.CreateViewController <RequestBotListViewController>(); _songRequestMenu.SetMainViewController(_songRequestListViewController, true); } _requestButton = BeatSaberUI.CreateUIButton(_levelSelectionNavigationController.rectTransform, "QuitButton", new Vector2(60f, 36.8f), new Vector2(15.0f, 5.5f), () => { _requestButton.interactable = false; _songRequestMenu.Present(); _requestButton.interactable = true; }, "Song Requests"); _requestButton.gameObject.GetComponentInChildren <TextMeshProUGUI>().enableWordWrapping = false; _requestButton.SetButtonTextSize(2.0f); _requestButton.interactable = FinalRequestQueue.Count > 0; _requestButton.gameObject.GetComponentInChildren <Image>().color = FinalRequestQueue.Count > 0 ? Color.green : Color.red; BeatSaberUI.AddHintText(_requestButton.transform as RectTransform, $"{(!Config.Instance.SongRequestBot ? "To enable the song request bot, look in the Enhanced Twitch Chat settings menu." : "Manage the current request queue")}"); Plugin.Log("Created request button!"); } SongListUtils.Initialize(); if (Instance) { return; } new GameObject("EnhancedTwitchChatRequestBot").AddComponent <RequestBot>(); }
protected override void DidActivate(bool firstActivation, ActivationType type) { if (firstActivation) { if (!SongLoader.AreSongsLoaded) { SongLoader.SongsLoadedEvent += SongLoader_SongsLoadedEvent; } InitConfirmationDialog(); _songListTableCellInstance = Resources.FindObjectsOfTypeAll <LevelListTableCell>().First(x => (x.name == "LevelListTableCell")); _songPreviewPlayer = Resources.FindObjectsOfTypeAll <SongPreviewPlayer>().FirstOrDefault(); DidSelectRowEvent += DidSelectRow; RequestBot.SongRequestQueued += (song) => RefreshTable(); RequestBot.SongRequestDequeued += (song) => RefreshTable(); RectTransform container = new GameObject("CustomListContainer", typeof(RectTransform)).transform as RectTransform; container.SetParent(rectTransform, false); container.sizeDelta = new Vector2(60f, 0f); // Blacklist button _blacklistButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "QuitButton")), container, false); _blacklistButton.ToggleWordWrapping(false); (_blacklistButton.transform as RectTransform).anchoredPosition = new Vector2(90f, 10f); _blacklistButton.SetButtonText("Blacklist"); //_blacklistButton.GetComponentInChildren<Image>().color = Color.red; _blacklistButton.onClick.RemoveAllListeners(); _blacklistButton.onClick.AddListener(delegate() { _onConfirm = () => { RequestBot.Blacklist(_selectedRow); }; var song = RequestBot.FinalRequestQueue[_selectedRow].song; _warningTitle.text = "Blacklist Song Warning"; _warningMessage.text = $"Blacklisting {song["songName"].Value} by {song["authorName"].Value}\r\nDo you want to continue?"; _confirmationDialog.Present(); }); BeatSaberUI.AddHintText(_blacklistButton.transform as RectTransform, "Block the selected request from being queued in the future."); // Skip button _skipButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "QuitButton")), container, false); _skipButton.ToggleWordWrapping(false); (_skipButton.transform as RectTransform).anchoredPosition = new Vector2(90f, 0f); _skipButton.SetButtonText("Skip"); //_skipButton.GetComponentInChildren<Image>().color = Color.yellow; _skipButton.onClick.RemoveAllListeners(); _skipButton.onClick.AddListener(delegate() { _onConfirm = () => { _lastSelection = -1; RequestBot.Skip(_selectedRow); }; var song = RequestBot.FinalRequestQueue[_selectedRow].song; _warningTitle.text = "Skip Song Warning"; _warningMessage.text = $"Skipping {song["songName"].Value} by {song["authorName"].Value}\r\nDo you want to continue?"; _confirmationDialog.Present(); }); BeatSaberUI.AddHintText(_skipButton.transform as RectTransform, "Remove the selected request from the queue."); // Play button _playButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "QuitButton")), container, false); _playButton.ToggleWordWrapping(false); (_playButton.transform as RectTransform).anchoredPosition = new Vector2(90f, -10f); _playButton.SetButtonText("Play"); _playButton.GetComponentInChildren <Image>().color = Color.green; _playButton.onClick.RemoveAllListeners(); _playButton.onClick.AddListener(delegate() { SetUIInteractivity(false); RequestBot.Process(_selectedRow); }); BeatSaberUI.AddHintText(_playButton.transform as RectTransform, "Download and scroll to the currently selected request."); } base.DidActivate(firstActivation, type); RefreshTable(); SetUIInteractivity(true); }