diff --git a/VideoPlayer/UI/VideosFlowCoordinator.cs b/VideoPlayer/UI/VideosFlowCoordinator.cs index e9a0e1e..f845f55 100644 --- a/VideoPlayer/UI/VideosFlowCoordinator.cs +++ b/VideoPlayer/UI/VideosFlowCoordinator.cs @@ -13,6 +13,7 @@ using MusicVideoPlayer.YT; using SongCore.Utilities; using Object = System.Object; +using System.Collections; namespace MusicVideoPlayer.UI { @@ -50,15 +51,7 @@ protected override void DidActivate(bool firstActivation, ActivationType activat if (_videoDetailViewController == null) { _videoDetailViewController = BeatSaberUI.CreateViewController(); - _videoDetailViewController.Init(); - _videoDetailViewController.backButtonPressed += DetailViewBackPressed; - _videoDetailViewController.addOffsetPressed += DetailViewAddOffsetPressed; - _videoDetailViewController.subOffsetPressed += DetailViewSubOffsetPressed; - _videoDetailViewController.changeOffsetMagnitudePressed += DetailsViewChangeMagnitudePressed; - _videoDetailViewController.previewButtonPressed += DetailViewPreviewPressed; - _videoDetailViewController.loopButtonPressed += DetailViewLoopPressed; - _videoDetailViewController.listButtonPressed += DetailViewSearchPressed; - _videoDetailViewController.downloadDeleteButtonPressed += DetailViewDownloadDeletePressed; + StartCoroutine(LoadDetailView()); } if (_videoListViewController == null) @@ -90,6 +83,8 @@ protected override void DidActivate(bool firstActivation, ActivationType activat } } + + private void DetailViewDownloadDeletePressed() { switch (selectedLevelVideo.downloadState) { @@ -127,6 +122,24 @@ private void DoSearch(string query) } #region DetailView + private IEnumerator LoadDetailView() + { + while (GameObject.Find("PlayButton") == null) + { + yield return null; + } + + _videoDetailViewController.Init(); + _videoDetailViewController.backButtonPressed += DetailViewBackPressed; + _videoDetailViewController.addOffsetPressed += DetailViewAddOffsetPressed; + _videoDetailViewController.subOffsetPressed += DetailViewSubOffsetPressed; + _videoDetailViewController.changeOffsetMagnitudePressed += DetailsViewChangeMagnitudePressed; + _videoDetailViewController.previewButtonPressed += DetailViewPreviewPressed; + _videoDetailViewController.loopButtonPressed += DetailViewLoopPressed; + _videoDetailViewController.listButtonPressed += DetailViewSearchPressed; + _videoDetailViewController.downloadDeleteButtonPressed += DetailViewDownloadDeletePressed; + } + private void DetailViewBackPressed() { VideoLoader.SaveVideoToDisk(selectedLevelVideo); diff --git a/VideoPlayer/UI/ViewControllers/VideoDetailViewController.cs b/VideoPlayer/UI/ViewControllers/VideoDetailViewController.cs index b642ce7..afcbfd0 100644 --- a/VideoPlayer/UI/ViewControllers/VideoDetailViewController.cs +++ b/VideoPlayer/UI/ViewControllers/VideoDetailViewController.cs @@ -51,6 +51,8 @@ class VideoDetailViewController : VRUIViewController private TextMeshProUGUI _progressText; + private const int MAX_TITLE_LENGTH = 43; + protected override void DidActivate(bool firstActivation, ActivationType type) { if (type == ActivationType.AddedToHierarchy) @@ -140,7 +142,7 @@ public void Init() _duration.rectTransform.sizeDelta = new Vector2(80, 5); _description = BeatSaberUI.CreateText(rectTransform, - "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", + "DESCRIPTION", new Vector2(0, -14)); _description.alignment = TextAlignmentOptions.TopLeft; _description.rectTransform.sizeDelta = new Vector2(80, 10); @@ -174,40 +176,6 @@ public void Init() _hoverHint = BeatSaberUI.AddHintText(_thumbnail.transform as RectTransform, "Banana banana banana"); } - private IEnumerator FindPlayButton() - { - // Download Progress ring - Button _playbutton = null; - - while(_playbutton == null) - { - _playbutton = GameObject.Find("PlayButton")?.GetComponent