Skip to content

Commit

Permalink
Merge pull request #30 from rithik-b/dev
Browse files Browse the repository at this point in the history
Bugfixes, Key Download and Readonly
  • Loading branch information
rithik-b authored Jul 15, 2021
2 parents 5f7494a + 5403bba commit da453ca
Show file tree
Hide file tree
Showing 23 changed files with 508 additions and 116 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build

on:
workflow_dispatch:
push:
branches: [ master ]
paths:
- 'PlaylistManager.sln'
- 'PlaylistManager/**'
- '.github/workflows/master.yml'

jobs:
Build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: GetStrippedRefs
env:
FILES_URL: ${{ secrets.BSFILES_URL }}
run: wget --no-check-certificate "$FILES_URL" -q -O bsfiles.zip
- name: ExtractRefs
run: unzip -q -n bsfiles.zip -d ${{github.workspace}}/Refs
- name: Download Mod Dependencies
uses: Goobwabber/[email protected]
with:
manifest: ${{github.workspace}}/PlaylistManager/manifest.json
- name: Download Playlists Lib
uses: dawidd6/[email protected]
with:
workflow: BuildMaster.yml
workflow_conclusion: success
name: BeatSaberPlaylistsLib_BS
repo: rithik-b/BeatSaberPlaylistsLib
path: ${{github.workspace}}/Refs
- name: Build
id: Build
run: dotnet build --configuration Release
- name: GitStatus
run: git status
- name: Echo Filename
run: echo $BUILDTEXT \($ASSEMBLYNAME\)
env:
BUILDTEXT: Filename=${{ steps.Build.outputs.filename }}
ASSEMBLYNAME: AssemblyName=${{ steps.Build.outputs.assemblyname }}
- name: Upload Artifact
uses: actions/upload-artifact@v1
with:
name: ${{ steps.Build.outputs.filename }}
path: ${{ steps.Build.outputs.artifactpath }}
51 changes: 51 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: PR Build

on:
pull_request:
branches: [ master ]
paths:
- 'PlaylistManager/**'
- '.github/workflows/**.yml'

jobs:
Build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: GetStrippedRefs
env:
FILES_URL: ${{ secrets.BSFILES_URL }}
run: wget --no-check-certificate "$FILES_URL" -q -O bsfiles.zip
- name: ExtractRefs
run: unzip -q -n bsfiles.zip -d ${{github.workspace}}/Refs
- name: Download Mod Dependencies
uses: Goobwabber/[email protected]
with:
manifest: ${{github.workspace}}/PlaylistManager/manifest.json
- name: Download Playlists Lib
uses: dawidd6/[email protected]
with:
workflow: BuildMaster.yml
workflow_conclusion: success
name: BeatSaberPlaylistsLib_BS
repo: rithik-b/BeatSaberPlaylistsLib
path: ${{github.workspace}}/Refs
- name: Build
id: Build
run: dotnet build --configuration Release
- name: GitStatus
run: git status
- name: Echo Filename
run: echo $BUILDTEXT \($ASSEMBLYNAME\)
env:
BUILDTEXT: Filename=${{ steps.Build.outputs.filename }}
ASSEMBLYNAME: AssemblyName=${{ steps.Build.outputs.assemblyname }}
- name: Upload Artifact
uses: actions/upload-artifact@v1
with:
name: ${{ steps.Build.outputs.filename }}
path: ${{ steps.Build.outputs.artifactpath }}
2 changes: 1 addition & 1 deletion PlaylistManager/Configuration/PluginConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ internal class PluginConfig
public virtual bool DefaultImageDisabled { get; set; } = false;
public virtual bool FoldersDisabled { get; set; } = false;
public virtual bool ManagementDisabled { get; set; } = false;

public virtual bool DefaultAllowDuplicates { get; set; } = true;
public virtual float PlaylistScrollSpeed { get; set; } = 1;
public virtual bool HighlightDifficulty { get; set; } = true;
public virtual bool EasterEggs { get; set; } = false;

/// <summary>
/// Call this to force BSIPA to update the config file. This is also called by BSIPA if it detects the file was modified.
Expand Down
3 changes: 3 additions & 0 deletions PlaylistManager/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
<Message Text="::set-output name=artifactpath::$(ProjectDir)$(ArtifactDestination)" Importance="high" />
<Message Text="Copying '$(OutputAssemblyName).dll' to '$(ProjectDir)$(ArtifactDestination)\Plugins\$(AssemblyName).dll'" Importance="high" />
<Copy SourceFiles="$(OutputAssemblyName).dll" DestinationFiles="$(ProjectDir)$(ArtifactDestination)\Plugins\$(AssemblyName).dll" />
<Copy SourceFiles="$(LocalRefsDir)\Plugins\BeatSaberPlaylistsLib.manifest" DestinationFiles="$(ProjectDir)$(ArtifactDestination)\Plugins\BeatSaberPlaylistsLib.manifest" />
<Copy SourceFiles="$(LocalRefsDir)\Libs\BeatSaberPlaylistsLib.dll" DestinationFiles="$(ProjectDir)$(ArtifactDestination)\Libs\BeatSaberPlaylistsLib.dll" />
<ZipDir SourceDirectory="$(ArtifactDestination)" DestinationFile="$(DestinationDirectory)$(ArtifactName).zip" />
</Target>
<!--Creates a BeatMods compliant zip file with the release.-->
<Target Name="ZipRelease" AfterTargets="Build" Condition="'$(DisableZipRelease)' != 'True' AND '$(Configuration)' == 'Release' AND '$(BSMTTaskAssembly)' != ''">
Expand Down
5 changes: 4 additions & 1 deletion PlaylistManager/Installers/PlaylistManagerMenuInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ public override void InstallBindings()
Container.BindInterfacesTo<FoldersViewController>().AsSingle();
}

Container.BindInterfacesTo<SettingsViewController>().AsSingle();

Container.BindInterfacesTo<TableViewButtonsController>().AsSingle();
Container.BindInterfacesTo<CoverImageUpdater>().AsSingle();
Container.BindInterfacesAndSelfTo<DifficultyHighlighter>().AsSingle();

Container.BindInterfacesTo<SettingsViewController>().AsSingle();
Container.BindInterfacesTo<RefreshButtonUI>().AsSingle();

Container.BindInterfacesTo<PlaylistUIManager>().AsSingle();
Expand Down
46 changes: 46 additions & 0 deletions PlaylistManager/UI/CoverImageUpdater.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using BeatSaberPlaylistsLib.Types;
using IPA.Utilities;
using PlaylistManager.Interfaces;
using System;

namespace PlaylistManager.UI
{
internal class CoverImageUpdater : ILevelCollectionUpdater
{
private readonly LevelPackDetailViewController levelPackDetailViewController;
private LevelCollectionNavigationController levelCollectionNavigationController;

private Playlist selectedPlaylist;

public CoverImageUpdater(LevelPackDetailViewController levelPackDetailViewController, LevelCollectionNavigationController levelCollectionNavigationController)
{
this.levelPackDetailViewController = levelPackDetailViewController;
this.levelCollectionNavigationController = levelCollectionNavigationController;
}

private void SelectedPlaylist_SpriteLoaded(object sender, EventArgs e)
{
levelPackDetailViewController.SetData((IBeatmapLevelPack)selectedPlaylist);
levelPackDetailViewController.ShowContent(LevelPackDetailViewController.ContentType.Owned);
levelCollectionNavigationController.SetField("_levelPack", (IBeatmapLevelPack)selectedPlaylist);
}

public void LevelCollectionUpdated(IAnnotatedBeatmapLevelCollection annotatedBeatmapLevelCollection, BeatSaberPlaylistsLib.PlaylistManager parentManager)
{
if (this.selectedPlaylist != null)
{
this.selectedPlaylist.SpriteLoaded -= SelectedPlaylist_SpriteLoaded;
}

if (annotatedBeatmapLevelCollection is Playlist selectedPlaylist)
{
this.selectedPlaylist = selectedPlaylist;
selectedPlaylist.SpriteLoaded += SelectedPlaylist_SpriteLoaded;
}
else
{
this.selectedPlaylist = null;
}
}
}
}
12 changes: 8 additions & 4 deletions PlaylistManager/UI/ViewControllers/AddPlaylistModalController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
using System.Threading;

namespace PlaylistManager.UI
{
Expand Down Expand Up @@ -80,7 +81,7 @@ internal void ShowPlaylistsForManager(BeatSaberPlaylistsLib.PlaylistManager pare

this.parentManager = parentManager;
childManagers = parentManager.GetChildManagers().ToArray();
var childPlaylists = parentManager.GetAllPlaylists(false);
var childPlaylists = parentManager.GetAllPlaylists(false).Where(playlist => !playlist.ReadOnly);
this.childPlaylists = childPlaylists.ToList();

foreach (BeatSaberPlaylistsLib.PlaylistManager playlistManager in childManagers)
Expand All @@ -91,9 +92,9 @@ internal void ShowPlaylistsForManager(BeatSaberPlaylistsLib.PlaylistManager pare
{
if (playlist is IDeferredSpriteLoad deferredSpriteLoadPlaylist && !deferredSpriteLoadPlaylist.SpriteWasLoaded)
{
_ = playlist.coverImage;
deferredSpriteLoadPlaylist.SpriteLoaded -= DeferredSpriteLoadPlaylist_SpriteLoaded;
deferredSpriteLoadPlaylist.SpriteLoaded += DeferredSpriteLoadPlaylist_SpriteLoaded;
_ = playlist.coverImage;
}
else
{
Expand All @@ -113,8 +114,11 @@ private void DeferredSpriteLoadPlaylist_SpriteLoaded(object sender, EventArgs e)
{
if (sender is IDeferredSpriteLoad deferredSpriteLoadPlaylist)
{
ShowPlaylist((BeatSaberPlaylistsLib.Types.IPlaylist)deferredSpriteLoadPlaylist);
customListTableData.tableView.ReloadData();
if (parentManager.GetAllPlaylists(false).Contains((BeatSaberPlaylistsLib.Types.IPlaylist)deferredSpriteLoadPlaylist))
{
ShowPlaylist((BeatSaberPlaylistsLib.Types.IPlaylist)deferredSpriteLoadPlaylist);
}
customListTableData.tableView.ReloadDataKeepingPosition();
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(UpButtonEnabled)));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(DownButtonEnabled)));
(deferredSpriteLoadPlaylist).SpriteLoaded -= DeferredSpriteLoadPlaylist_SpriteLoaded;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using UnityEngine;
using static BeatSaberMarkupLanguage.Components.CustomListTableData;

Expand All @@ -24,7 +25,7 @@ public class ImageSelectionModalController : INotifyPropertyChanged

private readonly string IMAGES_PATH = Path.Combine(PlaylistLibUtils.playlistManager.PlaylistPath, "CoverImages");
private readonly Sprite playlistManagerIcon;
private Dictionary<string, CoverImage> coverImages;
private readonly Dictionary<string, CoverImage> coverImages;
private bool parsed;
private int selectedIndex;

Expand All @@ -49,8 +50,18 @@ public ImageSelectionModalController(LevelPackDetailViewController levelPackDeta
{
this.levelPackDetailViewController = levelPackDetailViewController;
this.popupModalsController = popupModalsController;
Directory.CreateDirectory(IMAGES_PATH);
File.Create(Path.Combine(IMAGES_PATH, ".plignore"));

// Have to do this in case directory perms are not given
try
{
Directory.CreateDirectory(IMAGES_PATH);
File.Create(Path.Combine(IMAGES_PATH, ".plignore"));
}
catch (Exception e)
{
Plugin.Log.Error($"Could not make images path.\nExcepton:{e.Message}");
}

coverImages = new Dictionary<string, CoverImage>();
playlistManagerIcon = BeatSaberMarkupLanguage.Utilities.FindSpriteInAssembly("PlaylistManager.Icons.Logo.png");
parsed = false;
Expand All @@ -62,7 +73,7 @@ private void Parse()
{
BSMLParser.instance.Parse(BeatSaberMarkupLanguage.Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), "PlaylistManager.UI.Views.ImageSelectionModal.bsml"), levelPackDetailViewController.transform.Find("Detail").gameObject, this);
modalPosition = modalTransform.position;
FieldAccessor<ModalView, bool>.Set(ref modalView, "_animateParentCanvas", false);
modalView.SetField("_animateParentCanvas", false);
parsed = true;
}
modalTransform.position = modalPosition;
Expand Down Expand Up @@ -120,6 +131,7 @@ private void ShowImages(BeatSaberPlaylistsLib.Types.IPlaylist playlist)
}
customListTableData.tableView.ReloadData();
customListTableData.tableView.ScrollToCellWithIdx(0, TableView.ScrollPositionType.Beginning, false);
_ = ViewControllerMonkeyCleanup();

PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(UpButtonEnabled)));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(DownButtonEnabled)));
Expand All @@ -132,7 +144,13 @@ private void CoverImage_SpriteLoaded(object sender, EventArgs e)
if (coverImage.SpriteWasLoaded)
{
customListTableData.data.Add(new CustomCellInfo(Path.GetFileName(coverImage.Path), coverImage.Path, coverImage.Sprite));
customListTableData.tableView.ReloadData();
customListTableData.tableView.ReloadDataKeepingPosition();

if (customListTableData.data.Count == 4)
{
customListTableData.tableView.AddCellToReusableCells(customListTableData.tableView.dataSource.CellForIdx(customListTableData.tableView, 3));
}
_ = ViewControllerMonkeyCleanup();

PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(UpButtonEnabled)));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(DownButtonEnabled)));
Expand Down Expand Up @@ -187,6 +205,16 @@ private void ChangeImage()
}
}

private async Task ViewControllerMonkeyCleanup()
{
await SiraUtil.Utilities.PauseChamp;
ImageView[] imageViews = customListTableData.tableView.GetComponentsInChildren<ImageView>(true);
foreach (var imageView in imageViews)
{
imageView.SetField("_skew", 0f);
}
}

[UIValue("up-button-enabled")]
private bool UpButtonEnabled
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.ComponentModel;
using PlaylistManager.Utilities;
using System;
using PlaylistManager.Configuration;

namespace PlaylistManager.UI
{
Expand Down Expand Up @@ -97,7 +98,18 @@ private void RemoveSong()
parentManager.StorePlaylist(selectedPlaylist);

levelCollectionTableView.ClearSelection();
levelCollectionTableView.SetData(selectedPlaylist.beatmapLevelCollection.beatmapLevels, Accessors.FavoriteLevelIdsAccessor(ref levelCollectionTableView), false);

// The cutie list
if ((PluginConfig.Instance.AuthorName.ToUpper().Contains("GOOBIE") || PluginConfig.Instance.AuthorName.ToUpper().Contains("ERIS") ||
PluginConfig.Instance.AuthorName.ToUpper().Contains("PINK") || PluginConfig.Instance.AuthorName.ToUpper().Contains("CANDL3")) && PluginConfig.Instance.EasterEggs)
{
levelCollectionNavigationController.SetDataForPack(selectedPlaylist, true, true, true, $"{PluginConfig.Instance.AuthorName} Cute");
}
else
{
levelCollectionNavigationController.SetDataForPack(selectedPlaylist, true, true, true, "Play");
}

levelCollectionNavigationController.HideDetailViewController();
}

Expand Down Expand Up @@ -149,7 +161,7 @@ public void PreviewBeatmapLevelUpdated(IPreviewBeatmapLevel beatmapLevel)
AddActive = false;
IsPlaylistSong = false;
}
else if (beatmapLevel is IPlaylistSong)
else if (beatmapLevel is IPlaylistSong && selectedPlaylist is { ReadOnly: false })
{
AddActive = true;
IsPlaylistSong = true;
Expand Down
Loading

0 comments on commit da453ca

Please sign in to comment.