Example #1
0
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation)
            {
                //firstLoad = Plugin.config.GetBoolean("behavior", "onstartup") ?? true;

                title = "BSMOTD Plus";

                _postList   = BeatSaberUI.CreateViewController <PostListViewController>();
                _postDetail = BeatSaberUI.CreateViewController <PostDetailViewController>();
                _channels   = BeatSaberUI.CreateViewController <ChannelsViewController>();
                _settings   = BeatSaberUI.CreateViewController <SettingsViewController>();

                _navCon = BeatSaberUI.CreateDismissableNavigationController();

                _postList.newPostClicked    += ClickedPost;
                _channels.newChannelClicked += ClickedChannel;
                _navCon.didFinishEvent      += Dismiss;
            }

            if (activationType == ActivationType.AddedToHierarchy)
            {
                SetViewControllersToNavigationConctroller(_navCon, _postList);
                ProvideInitialViewControllers(_navCon, _channels, _settings);

                firstClick = true;

                channels.Clear();
                SharedCoroutineStarter.instance.StartCoroutine(GetChannelInfo());
            }
        }
        /// <summary>
        /// Constructor.  Acquire all necessary BeatSaberUi elements.
        /// </summary>
        /// <param name="flowCoordinator"></param>
        public BeatSaberUIController(FlowCoordinator flowCoordinator)
        {
            LevelSelectionFlowCoordinator = flowCoordinator;

            // gather controllers and ui elements.
            LevelPackViewController = LevelSelectionFlowCoordinator.GetPrivateField <LevelPacksViewController>("_levelPacksViewController");
            Logger.Debug("Acquired LevelPacksViewController [{0}]", LevelPackViewController.GetInstanceID());

            LevelPackDetailViewController = LevelSelectionFlowCoordinator.GetPrivateField <LevelPackDetailViewController>("_levelPackDetailViewController");
            Logger.Debug("Acquired LevelPackDetailViewController [{0}]", LevelPackDetailViewController.GetInstanceID());

            LevelPacksTableView = LevelPackViewController.GetPrivateField <LevelPacksTableView>("_levelPacksTableView");
            Logger.Debug("Acquired LevelPacksTableView [{0}]", LevelPacksTableView.GetInstanceID());

            LevelPackLevelsViewController = LevelSelectionFlowCoordinator.GetPrivateField <LevelPackLevelsViewController>("_levelPackLevelsViewController");
            Logger.Debug("Acquired LevelPackLevelsViewController [{0}]", LevelPackLevelsViewController.GetInstanceID());

            LevelPackLevelsTableView = this.LevelPackLevelsViewController.GetPrivateField <LevelPackLevelsTableView>("_levelPackLevelsTableView");
            Logger.Debug("Acquired LevelPackLevelsTableView [{0}]", LevelPackLevelsTableView.GetInstanceID());

            LevelDetailViewController = LevelSelectionFlowCoordinator.GetPrivateField <StandardLevelDetailViewController>("_levelDetailViewController");
            Logger.Debug("Acquired StandardLevelDetailViewController [{0}]", LevelDetailViewController.GetInstanceID());

            StandardLevelDetailView = LevelDetailViewController.GetPrivateField <StandardLevelDetailView>("_standardLevelDetailView");
            Logger.Debug("Acquired StandardLevelDetailView [{0}]", StandardLevelDetailView.GetInstanceID());

            BeatmapCharacteristicSelectionViewController = Resources.FindObjectsOfTypeAll <BeatmapCharacteristicSegmentedControlController>().First();
            Logger.Debug("Acquired BeatmapCharacteristicSegmentedControlController [{0}]", BeatmapCharacteristicSelectionViewController.GetInstanceID());

            LevelSelectionNavigationController = LevelSelectionFlowCoordinator.GetPrivateField <DismissableNavigationController>("_navigationController");
            Logger.Debug("Acquired DismissableNavigationController [{0}]", LevelSelectionNavigationController.GetInstanceID());

            LevelDifficultyViewController = StandardLevelDetailView.GetPrivateField <BeatmapDifficultySegmentedControlController>("_beatmapDifficultySegmentedControlController");
            Logger.Debug("Acquired BeatmapDifficultySegmentedControlController [{0}]", LevelDifficultyViewController.GetInstanceID());

            LevelPackLevelsTableViewRectTransform = LevelPackLevelsTableView.transform as RectTransform;
            Logger.Debug("Acquired TableViewRectTransform from LevelPackLevelsTableView [{0}]", LevelPackLevelsTableViewRectTransform.GetInstanceID());

            TableView tableView = ReflectionUtil.GetPrivateField <TableView>(LevelPackLevelsTableView, "_tableView");

            TableViewPageUpButton   = tableView.GetPrivateField <Button>("_pageUpButton");
            TableViewPageDownButton = tableView.GetPrivateField <Button>("_pageDownButton");
            Logger.Debug("Acquired Page Up and Down buttons...");

            PlayContainer = StandardLevelDetailView.GetComponentsInChildren <RectTransform>().First(x => x.name == "PlayContainer");
            PlayButtons   = PlayContainer.GetComponentsInChildren <RectTransform>().First(x => x.name == "PlayButtons");

            PlayButton     = Resources.FindObjectsOfTypeAll <Button>().First(x => x.name == "PlayButton");
            PracticeButton = PlayButtons.GetComponentsInChildren <Button>().First(x => x.name == "PracticeButton");

            SimpleDialogPromptViewControllerPrefab = Resources.FindObjectsOfTypeAll <SimpleDialogPromptViewController>().First();
        }
Example #3
0
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation && activationType == ActivationType.AddedToHierarchy)
            {
                title = "Alpha Twitch";

                _twitchChannelVC  = BeatSaberUI.CreateViewController <TwitchChannelViewController>();
                _twitchViewListVC = BeatSaberUI.CreateViewController <TwitchViewersListViewController>();
                _twitchViewListVC.viewerClicked += ViewerClicked;
                _twitchViewerVC = BeatSaberUI.CreateViewController <TwitchViewerViewController>();

                _dismissableNavController = Instantiate(Resources.FindObjectsOfTypeAll <DismissableNavigationController>().First());
                _dismissableNavController.didFinishEvent += Dismiss;

                SetViewControllersToNavigationConctroller(_dismissableNavController, _twitchViewListVC);
                ProvideInitialViewControllers(_dismissableNavController, _twitchChannelVC);

                SharedCoroutineStarter.instance.StartCoroutine(GetThenSetTwitchData(TwitchLoginConfig.Instance.TwitchChannelName));
            }
        }
        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>();
        }
Example #5
0
 private void Dismiss(DismissableNavigationController navController)
 {
     MenuLightsSO().SetColorsFromPreset(defaultPreset);
     (mainFlowCoordinator as FlowCoordinator).InvokePrivateMethod("DismissFlowCoordinator", new object[] { this, null, false });
 }
        /// <summary>
        /// Adapts some BeatSaverDownloader buttons to this mod.
        /// </summary>
        /// <returns>true, if buttons were modified successfully; false, otherwise</returns>
        /// <param name="newButtonSize"></param>
        public static bool Init(Vector2 newButtonSize)
        {
            if (!ModLoaded)
            {
                return(false);
            }

            Logger.log.Info("Attempting to initialize BeatSaverDownloader tweaks.");

            // acquire all UI elements first, before modifying
            List <Button> buttonList;
            Button        searchButton;

            try
            {
                RectTransform viewControllersContainer = Resources.FindObjectsOfTypeAll <RectTransform>().First(x => x.name == "ViewControllers");
                var           parent = viewControllersContainer.GetComponentInChildren <LevelPackLevelsViewController>(true);

                buttonList = parent.transform.GetComponentsInChildren <Button>(true).Where(x => x.name == "CustomUIButton").ToList();

                searchButton       = buttonList.First(x => x.GetComponentInChildren <TextMeshProUGUI>(true)?.text.Contains("Search") == true);
                _sortButton        = buttonList.First(x => x.GetComponentInChildren <TextMeshProUGUI>(true)?.text.Contains("Sort By") == true);
                _defaultSortButton = buttonList.First(x => x.GetComponentInChildren <TextMeshProUGUI>(true)?.text.Contains("Default") == true);
                _newestSortButton  = buttonList.First(x => x.GetComponentInChildren <TextMeshProUGUI>(true)?.text.Contains("Newest") == true);
                _authorSortButton  = buttonList.First(x => x.GetComponentInChildren <TextMeshProUGUI>(true)?.text.Contains("Song Author") == true);
                //_difficultySortButton = buttonList.First(x => x.GetComponentInChildren<TextMeshProUGUI>(true)?.text.Contains("Difficulty") == true);
                _randomButton = buttonList.First(x =>
                                                 x.GetComponentInChildren <TextMeshProUGUI>(true)?.text == null &&
                                                 x.transform.parent == _sortButton.transform.parent);
            }
            catch (InvalidOperationException)
            {
                Logger.log.Debug("Unable to find the buttons created by BeatSaverDownloader mod.");
                return(false);
            }

            // modify BeatSaverDownloader's Search button to create our FlowCoordinator
            searchButton.onClick = new Button.ButtonClickedEvent();
            searchButton.onClick.AddListener(SongListUI.Instance.SearchButtonPressed);

            // move BeatSaverDownloader's Sort and Random buttons to make room for our "Filter" and "Clear Filter" buttons
            DismissableNavigationController parentViewController = SongListUI.Instance.ButtonParentViewController;

            searchButton.transform.SetParent(parentViewController.transform, false);
            _sortButton.transform.SetParent(parentViewController.transform, false);
            _randomButton.transform.SetParent(parentViewController.transform, false);
            (searchButton.transform as RectTransform).sizeDelta         = newButtonSize;
            (_sortButton.transform as RectTransform).sizeDelta          = newButtonSize;
            (searchButton.transform as RectTransform).anchoredPosition  = new Vector2(-52f, 36.75f);
            (_sortButton.transform as RectTransform).anchoredPosition   = new Vector2(-32f, 36.75f);
            (_randomButton.transform as RectTransform).anchoredPosition = new Vector2(26f, 36.75f);
            _sortButton.onClick.RemoveAllListeners();
            _sortButton.onClick.AddListener(() =>
            {
                SongListUI.Instance.ToggleButtonsActive(false);
                SetTopButtons(true);
            });
            _defaultSortButton.onClick.AddListener(() =>
            {
                SongListUI.Instance.ToggleButtonsActive(true);
                SongListUI.Instance.UnapplyFilters();
            });
            _newestSortButton.onClick.AddListener(() =>
            {
                SongListUI.Instance.ToggleButtonsActive(true);
                SongListUI.Instance.UnapplyFilters();
            });
            _authorSortButton.onClick.AddListener(() =>
            {
                SongListUI.Instance.ToggleButtonsActive(true);
                SongListUI.Instance.UnapplyFilters();
            });

            SongListUI.Instance.SearchButton = searchButton;

            Initialized = true;
            Logger.log.Info("Modified BeatSaverDownloader's search, sort, and random buttons");
            return(true);
        }
Example #7
0
 private void Dismiss(DismissableNavigationController navCon)
 {
     (_mainFlowCoordinator as FlowCoordinator).InvokePrivateMethod("DismissFlowCoordinator", new object[] { this, null, false });
     //HarmonyUtil.UnpatchGame();
 }