private void SetupTweaks() { YouTubeDownloader.Instance.downloadProgress += VideoDownloaderDownloadProgress; _videoFlowCoordinator = gameObject.AddComponent <VideoFlowCoordinator>(); _videoFlowCoordinator.finished += VideoFlowCoordinatorFinished; _videoFlowCoordinator.Init(); BSEvents.levelSelected += HandleDidSelectLevel; var _levelDetailViewController = Resources.FindObjectsOfTypeAll <StandardLevelDetailViewController>().First(); var _buttons = _levelDetailViewController.transform.Find("LevelDetail/PlayContainer/PlayButtons"); var _playbutton = _buttons.GetComponentsInChildren <Button>().First(x => x.name == "PlayButton"); var _practiceButton = _buttons.GetComponentsInChildren <Button>().First(x => x.name == "PracticeButton"); var _coverImage = _levelDetailViewController.transform.Find("LevelDetail/Level/CoverImage"); _videoButton = Instantiate(_practiceButton, _coverImage); _videoButton.name = "VideoButton"; _videoButton.SetButtonIcon(Base64Sprites.PlayIcon); (_videoButton.transform as RectTransform).anchoredPosition = new Vector2(0, 0); (_videoButton.transform as RectTransform).anchorMax = new Vector2(0.5f, 0.5f); (_videoButton.transform as RectTransform).anchorMin = new Vector2(0.5f, 0.5f); (_videoButton.transform as RectTransform).sizeDelta = new Vector2(8, 8); _videoButton.onClick.AddListener(delegate() { _videoFlowCoordinator.Present(); }); _videoButtonHint = BeatSaberUI.AddHintText(_videoButton.transform as RectTransform, "Download a video"); var glow = _playbutton.GetComponentsInChildren <RectTransform>().First(x => x.name == "GlowContainer"); var videoWrapper = _videoButton.GetComponentsInChildren <RectTransform>().First(x => x.name == "Wrapper"); _videoButtonGlow = Instantiate(glow.gameObject, videoWrapper).gameObject.GetComponentInChildren <Image>(); var hlg = _videoButton.GetComponentsInChildren <HorizontalLayoutGroup>().First(x => x.name == "Content"); hlg.padding = new RectOffset(3, 2, 2, 2); _progressCircle = videoWrapper.GetComponentsInChildren <Image>().First(x => x.name == "Stroke"); _progressCircle.type = Image.Type.Filled; _progressCircle.fillMethod = Image.FillMethod.Radial360; _progressCircle.fillAmount = 1f; }
private void SetupTweaks() { YouTubeDownloader.Instance.downloadProgress += VideoDownloaderDownloadProgress; _videoFlowCoordinator = gameObject.AddComponent <VideoFlowCoordinator>(); _videoFlowCoordinator.finished += VideoFlowCoordinatorFinished; _videoFlowCoordinator.Init(); _difficultyViewController = Resources.FindObjectsOfTypeAll <BeatmapDifficultyViewController>().FirstOrDefault(); _difficultyViewController.didSelectDifficultyEvent += DifficultyViewControllerDidSelectDifficultyEvent; var _detailViewController = Resources.FindObjectsOfTypeAll <StandardLevelDetailViewController>().First(x => x.name == "StandardLevelDetailViewController"); RectTransform buttonsRect = _detailViewController.GetComponentsInChildren <RectTransform>().First(x => x.name == "Buttons"); var _playbutton = buttonsRect.GetComponentsInChildren <Button>().First(x => x.name == "PlayButton"); var _practiceButton = buttonsRect.GetComponentsInChildren <Button>().First(x => x.name == "PracticeButton"); _videoButton = Instantiate(_practiceButton, buttonsRect.parent); _videoButton.name = "VideoButton"; _videoButton.SetButtonIcon(Base64Sprites.PlayIcon); (_videoButton.transform as RectTransform).anchoredPosition = new Vector2(46, -6); (_videoButton.transform as RectTransform).sizeDelta = new Vector2(8, 8); _videoButton.onClick.AddListener(delegate() { _videoFlowCoordinator.Present(); }); _videoButtonHint = BeatSaberUI.AddHintText(_videoButton.transform as RectTransform, "Download a video"); var glow = _playbutton.GetComponentsInChildren <RectTransform>().First(x => x.name == "GlowContainer"); var videoWrapper = _videoButton.GetComponentsInChildren <RectTransform>().First(x => x.name == "Wrapper"); _videoButtonGlow = Instantiate(glow.gameObject, videoWrapper).gameObject.GetComponentInChildren <Image>(); var hlg = _videoButton.GetComponentsInChildren <HorizontalLayoutGroup>().First(x => x.name == "Content"); hlg.padding = new RectOffset(3, 2, 2, 2); _progressCircle = videoWrapper.GetComponentsInChildren <Image>().First(x => x.name == "Stroke"); _progressCircle.type = Image.Type.Filled; _progressCircle.fillMethod = Image.FillMethod.Radial360; _progressCircle.fillAmount = 1f; }