Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
b-rad15 committed Oct 21, 2019
2 parents 9d1b6e9 + 0a1539b commit 3deca90
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 45 deletions.
31 changes: 22 additions & 9 deletions VideoPlayer/UI/VideosFlowCoordinator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using MusicVideoPlayer.YT;
using SongCore.Utilities;
using Object = System.Object;
using System.Collections;

namespace MusicVideoPlayer.UI
{
Expand Down Expand Up @@ -50,15 +51,7 @@ protected override void DidActivate(bool firstActivation, ActivationType activat
if (_videoDetailViewController == null)
{
_videoDetailViewController = BeatSaberUI.CreateViewController<MusicVideoPlayer.UI.ViewControllers.VideoDetailViewController>();
_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)
Expand Down Expand Up @@ -90,6 +83,8 @@ protected override void DidActivate(bool firstActivation, ActivationType activat
}
}



private void DetailViewDownloadDeletePressed()
{
switch (selectedLevelVideo.downloadState) {
Expand Down Expand Up @@ -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);
Expand Down
40 changes: 4 additions & 36 deletions VideoPlayer/UI/ViewControllers/VideoDetailViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -176,40 +178,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<Button>();
yield return null;
}

var _progressButton = Instantiate(_playbutton, _thumbnail.transform);
_progressButton.name = "DownloadProgress";
(_progressButton.transform as RectTransform).anchorMax = new Vector2(0.5f, 0.5f);
(_progressButton.transform as RectTransform).anchorMin = new Vector2(0.5f, 0.5f);
(_progressButton.transform as RectTransform).anchoredPosition = new Vector2(0, 0);
(_progressButton.transform as RectTransform).pivot = new Vector2(0.5f, 0.5f);
(_progressButton.transform as RectTransform).sizeDelta = new Vector2(18, 18);
_progressText = _progressButton.GetComponentInChildren<TextMeshProUGUI>();
_progressText.text = "100%";

_progressRingGlow = _progressButton.GetComponentsInChildren<Image>().First(x => x.name == "Glow");
Destroy(_progressButton);
_progressRingGlow.gameObject.SetActive(false);

var hlg = _progressButton.GetComponentsInChildren<HorizontalLayoutGroup>().First(x => x.name == "Content");
hlg.padding = new RectOffset(2, 2, 2, 2);

_progressCircle = _progressButton.GetComponentsInChildren<Image>().First(x => x.name == "Stroke");
_progressCircle.type = Image.Type.Filled;
_progressCircle.fillMethod = Image.FillMethod.Radial360;
_progressCircle.fillAmount = 1f;
}

public void SetPreviewState(bool playing)
{
if (playing)
Expand Down Expand Up @@ -260,7 +228,7 @@ public void UpdateContent()
return;
}

_title.SetText(selectedVideo.title.CleanASCII());
_title.SetText(selectedVideo.title.CleanASCII().ShortenTitle(MAX_TITLE_LENGTH));
_description.SetText(selectedVideo.description);
_uploader.SetText(selectedVideo.author);
_duration.SetText($"[{selectedVideo.duration}]");
Expand Down
12 changes: 12 additions & 0 deletions VideoPlayer/Util/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,17 @@ public static string CleanASCII(this string s)
}
return sb.ToString();
}

public static string ShortenTitle(this string s, int maxLength)
{
StringBuilder builder = new StringBuilder(s);

if(builder.Length > maxLength)
{
builder.Remove(maxLength, builder.Length - maxLength).Insert(maxLength, "...."); ;
}

return builder.ToString();
}
}
}
Binary file modified VideoPlayer/bin/Release/MusicVideoPlayer.dll
Binary file not shown.
Binary file modified zipitup.zip
Binary file not shown.
Binary file modified zipitup/Plugins/MusicVideoPlayer.dll
Binary file not shown.

0 comments on commit 3deca90

Please sign in to comment.