Skip to content

Commit

Permalink
Merge pull request #1 from rie-kumar/master
Browse files Browse the repository at this point in the history
Fixed offset and thumbnails.
  • Loading branch information
b-rad15 authored Oct 13, 2019
2 parents 37c0429 + b8b4d4a commit 71c001a
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 41 deletions.
54 changes: 27 additions & 27 deletions VideoPlayer/MusicVideoPlayer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,32 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>D:\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="BeatSaberCustomUI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\SteamLibrary\steamapps\common\Beat Saber\Plugins\BeatSaberCustomUI.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Plugins\BeatSaberCustomUI.dll</HintPath>
</Reference>
<Reference Include="BS_Utils, Version=1.2.1.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\SteamLibrary\steamapps\common\Beat Saber\Plugins\BS_Utils.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Plugins\BS_Utils.dll</HintPath>
</Reference>
<Reference Include="HtmlAgilityPack, Version=1.8.11.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<HintPath>..\packages\HtmlAgilityPack.1.8.11\lib\Net45\HtmlAgilityPack.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Plugins\HtmlAgilityPack.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="IPA.Loader">
<HintPath>D:\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\IPA.Loader.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\IPA.Loader.dll</HintPath>
</Reference>
<Reference Include="Oculus.VR">
<HintPath>D:\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Oculus.VR.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Oculus.VR.dll</HintPath>
</Reference>
<Reference Include="SongCore">
<HintPath>D:\SteamLibrary\steamapps\common\Beat Saber\Plugins\SongCore.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Plugins\SongCore.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -69,53 +69,53 @@
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="Unity.TextMeshPro">
<HintPath>D:\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Unity.TextMeshPro.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\Unity.TextMeshPro.dll</HintPath>
</Reference>
<Reference Include="UnityEngine">
<HintPath>D:\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AssetBundleModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.AssetBundleModule.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.AssetBundleModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AudioModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.AudioModule.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.AudioModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>D:\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.ImageConversionModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.ImageConversionModule.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.ImageConversionModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.IMGUIModule">
<HintPath>D:\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.IMGUIModule.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.IMGUIModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.JSONSerializeModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.JSONSerializeModule.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.JSONSerializeModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.TextCoreModule">
<HintPath>D:\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.TextCoreModule.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.TextCoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.TextRenderingModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>D:\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.TextRenderingModule.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.TextRenderingModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.UI.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.UI.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UnityWebRequestWWWModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.UnityWebRequestWWWModule.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.UnityWebRequestWWWModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.VideoModule">
<HintPath>D:\SteamLibrary\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.VideoModule.dll</HintPath>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Beat Saber\Beat Saber_Data\Managed\UnityEngine.VideoModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -148,11 +148,11 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy /Y "$(TargetDir)$(TargetFileName)" "D:\SteamLibrary\steamapps\common\Beat Saber\Plugins"
copy /Y "C:\Users\brado\Source\Repos\MusicVideoPlayer\VideoPlayer\bin\Release\HtmlAgilityPack.dll" "C:\Users\brado\Source\Repos\MusicVideoPlayer\zipitup\Lib"
copy /Y "C:\Users\brado\Source\Repos\MusicVideoPlayer\VideoPlayer\bin\Release\MusicVideoPlayer.dll" "C:\Users\brado\Source\Repos\MusicVideoPlayer\zipitup\Plugins"
copy /Y "C:\Users\brado\Source\Repos\MusicVideoPlayer\Youtube-dl" "C:\Users\brado\Source\Repos\MusicVideoPlayer\zipitup"
7z a "C:\Users\brado\Source\Repos\MusicVideoPlayer\zipitup.zip" "C:\Users\brado\Source\Repos\MusicVideoPlayer\zipitup\*"</PostBuildEvent>
<PostBuildEvent>copy /Y "$(TargetDir)$(TargetFileName)" "C:\Program Files (x86)\Steam\steamapps\common\Beat Saber\Plugins"
copy /Y "C:\Users\verte200\Documents\Mods\MusicVideoPlayerUpdated\VideoPlayer\bin\Release\HtmlAgilityPack.dll" "C:\Users\verte200\Documents\Mods\MusicVideoPlayerUpdated\zipitup\Lib"
copy /Y "C:\Users\verte200\Documents\Mods\MusicVideoPlayerUpdated\VideoPlayer\bin\Release\MusicVideoPlayer.dll" "C:\Users\verte200\Documents\Mods\MusicVideoPlayerUpdated\zipitup\Plugins"
copy /Y "C:\Users\verte200\Documents\Mods\MusicVideoPlayerUpdated\Youtube-dl" "C:\Users\verte200\Documents\Mods\MusicVideoPlayerUpdated\zipitup"
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
1 change: 1 addition & 0 deletions VideoPlayer/UI/VideosFlowCoordinator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ private void DetailViewPreviewPressed()

private void DetailViewAddOffsetPressed()
{
Plugin.logger.Info("Pressed Subtract Offset");
selectedLevelVideo.offset += 100;
_videoDetailViewController.SetOffsetText(selectedLevelVideo.offset.ToString());
StopPreview();
Expand Down
27 changes: 17 additions & 10 deletions VideoPlayer/UI/ViewControllers/VideoDetailViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ public void Init()
}, "Loop");
Plugin.logger.Info("loop");

_addOffset = BeatSaberUI.CreateUIButton(rectTransform, "QuitButton", new Vector2(71, -10), new Vector2(8, 8), null, "+");
Plugin.logger.Info("offset");
foreach (StackLayoutGroup stack in _addOffset.GetComponentsInChildren<StackLayoutGroup>())
{
Plugin.logger.Info("foreach");
stack.childForceExpandHeight = false;
stack.childForceExpandWidth = false;
stack.padding = new RectOffset(0, 0, 0, 0);
}
_addOffset = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton", new Vector2(71, -10), new Vector2(8, 8), null, "+");

//foreach (StackLayoutGroup stack in _addOffset.GetComponentsInChildren<StackLayoutGroup>())
//{
// Plugin.logger.Info("foreach");
// stack.childForceExpandHeight = false;
// stack.childForceExpandWidth = false;
// stack.padding = new RectOffset(0, 0, 0, 0);
//}

// _addOffset.GetComponentInChildren<HorizontalLayoutGroup>().padding = new RectOffset(0, 0, 0, 0);

Expand Down Expand Up @@ -168,8 +168,11 @@ public void Init()

// Download Progress ring
var buttonsRect = Resources.FindObjectsOfTypeAll<RectTransform>().First(x => x.name == "PlayButtons");

Plugin.logger.Info("a2.5");
var _playbutton = buttonsRect.GetComponentsInChildren<Button>().First(x => x.name == "PlayButton");

Plugin.logger.Info("a3");
var _progressButton = Instantiate(_playbutton, _thumbnail.transform);
_progressButton.name = "DownloadProgress";
(_progressButton.transform as RectTransform).anchorMax = new Vector2(0.5f, 0.5f);
Expand All @@ -180,20 +183,24 @@ public void Init()
_progressText = _progressButton.GetComponentInChildren<TextMeshProUGUI>();
_progressText.text = "100%";
// _progressButton.SetButtonText("100%");
Plugin.logger.Info("a4");

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

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

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

_hoverHint = BeatSaberUI.AddHintText(_thumbnail.transform as RectTransform, "Banana banana banana");
Plugin.logger.Info("a3");
Plugin.logger.Info("a7");
}

public void SetPreviewState(bool playing)
Expand Down
12 changes: 8 additions & 4 deletions VideoPlayer/UI/ViewControllers/VideoListViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,13 @@ public override TableCell CellForIdx(TableView tableView, int row)
Plugin.logger.Info($"Row:{row}");
LevelListTableCell _tableCell = GetTableCell(false);
Plugin.logger.Info("gotTableCell");


var coverImage = _tableCell.transform.Find("CoverImage");

// fix aspect ratios
(_tableCell.transform.Find("CoverImage") as RectTransform).sizeDelta = new Vector2(160f / 9f, 10);
(coverImage as RectTransform).sizeDelta = new Vector2(160f / 9f, 10);
Plugin.logger.Info("coverimage");
(_tableCell.transform.Find("CoverImage") as RectTransform).anchoredPosition += new Vector2(160f / 9f / 2f, 0f);
(coverImage as RectTransform).anchoredPosition += new Vector2(160f / 9f / 2f, 0f);
Plugin.logger.Info("anchored");
// (_tableCell.transform.Find("CoverImage") as RectTransform).GetComponent<UnityEngine.UI.Image>().preserveAspect = true;
// (_tableCell.transform.Find("CoverImage") as RectTransform).preserveAspect = true;
Expand All @@ -163,7 +165,9 @@ public override TableCell CellForIdx(TableView tableView, int row)
_tableCell.GetPrivateField<TextMeshProUGUI>("_authorText").text = "[" + resultsList[row].duration + "]" + resultsList[row].description;
_tableCell.GetPrivateField<TextMeshProUGUI>("_authorText").color = Color.white;
Plugin.logger.Info("Loading Sprites");
StartCoroutine(LoadScripts.LoadSprite(resultsList[row].thumbnailURL, _tableCell.transform.Find("CoverImage").GetComponent<UnityEngine.UI.Image>(), 16f/9f));


StartCoroutine(LoadScripts.LoadSprite(resultsList[row].thumbnailURL, coverImage.GetComponent<UnityEngine.UI.RawImage>(), 16f/9f));
_tableCell.reuseIdentifier = "VideosTableCell";
Plugin.logger.Info("filled data");

Expand Down
50 changes: 50 additions & 0 deletions VideoPlayer/Util/LoadScripts.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using HMUI;
using Image = UnityEngine.UI.Image;
using RawImage = UnityEngine.UI.RawImage;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -43,6 +44,55 @@ static public IEnumerator LoadSprite(string spritePath, Image image, float aspec
}
}

static public IEnumerator LoadSprite(string spritePath, RawImage image, float aspectRatio)
{
Texture2D tex;
Plugin.logger.Info("tex");

if (_cachedSprites.ContainsKey(spritePath))
{
Plugin.logger.Info("spritepath");
image.texture = textureFromSprite(_cachedSprites[spritePath]);
Plugin.logger.Info("set sprite 4");
yield break;
}

using (WWW www = new WWW(spritePath))
{
yield return www;
tex = www.texture;
Plugin.logger.Info("tex3");

float newHeight = tex.width / aspectRatio;
Plugin.logger.Info("height");
float bottom = (tex.height - newHeight) / 2;
Plugin.logger.Info("botto");

var newSprite = Sprite.Create(tex, new Rect(0, bottom, tex.width, newHeight), Vector2.one * 0.5f, 100, 1);
Plugin.logger.Info("newsprite");
_cachedSprites.Add(spritePath, newSprite);
Plugin.logger.Info("added");
image.texture = textureFromSprite(newSprite);
}
}

public static Texture2D textureFromSprite(Sprite sprite)
{
if (sprite.rect.width != sprite.texture.width)
{
Texture2D newText = new Texture2D((int)sprite.rect.width, (int)sprite.rect.height);
Color[] newColors = sprite.texture.GetPixels((int)sprite.textureRect.x,
(int)sprite.textureRect.y,
(int)sprite.textureRect.width,
(int)sprite.textureRect.height);
newText.SetPixels(newColors);
newText.Apply();
return newText;
}
else
return sprite.texture;
}

static public IEnumerator LoadSprite(string spritePath, TableCell obj)
{
Texture2D tex;
Expand Down
Binary file modified VideoPlayer/bin/Debug/MusicVideoPlayer.dll
Binary file not shown.

0 comments on commit 71c001a

Please sign in to comment.