Skip to content

Commit

Permalink
Merge pull request rithik-b#15 from rithik-b/master
Browse files Browse the repository at this point in the history
Next Version
  • Loading branch information
Zingabopp authored Jul 15, 2021
2 parents 43b4c0f + 7a02ba9 commit e40a2bf
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/BuildMaster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
uses: actions/upload-artifact@v2
if: matrix.configuration == 'Release-BeatSaber'
with:
name: ${{ steps.Build.outputs.filename }}
name: 'BeatSaberPlaylistsLib_BS'
path: ${{ steps.Build.outputs.artifactpath }}
- name: Upload ${{ matrix.configuration }} Nuget
uses: actions/upload-artifact@v2
Expand Down
13 changes: 9 additions & 4 deletions BeatSaberPlaylistsLib.BeatSaber/BeatSaberPlaylistsLib.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<Authors>Zingabopp</Authors>

<Version>1.3.0</Version>
<Version>1.4.0</Version>
<GameVersion>1.16.0</GameVersion>

<Copyright>Copyright © Zingabopp 2021</Copyright>
Expand Down
3 changes: 0 additions & 3 deletions Shared/Legacy/LegacyPlaylist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,6 @@ protected byte[]? CoverData
}
}

///<inheritdoc/>
public override bool IsReadOnly => false;

///<inheritdoc/>
public override bool HasCover => CoverData != null && CoverData.Length > 0;

Expand Down
27 changes: 26 additions & 1 deletion Shared/PlaylistManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -805,8 +805,33 @@ public void StorePlaylist(IPlaylist playlist, IPlaylistHandler playlistHandler,
if (playlist.SuggestedExtension != null && playlistHandler.GetSupportedExtensions().Contains(playlist.SuggestedExtension))
extension = playlist.SuggestedExtension;
string fileName = playlist.Filename;

if (string.IsNullOrEmpty(fileName))
throw new ArgumentException(nameof(playlist), "Playlist's filename is null or empty.");
{
// Generate Name
fileName = string.Join("_", string.Join("", playlist.Title.Split(Path.GetInvalidFileNameChars(), StringSplitOptions.RemoveEmptyEntries)).Split());
if (string.IsNullOrEmpty(fileName))
{
fileName = "playlist";
}

string path = Path.Combine(PlaylistPath, fileName + "." + extension);
string originalPath = Path.Combine(PlaylistPath, fileName);
int dupNum = 0;
while (File.Exists(path))
{
dupNum++;
path = originalPath + $"({dupNum}).{extension}";
}

if (dupNum != 0)
{
fileName += $"({dupNum})";
}

playlist.Filename = fileName;
}

playlistHandler.SerializeToFile(playlist, Path.Combine(PlaylistPath, fileName + "." + extension));
RegisterPlaylist(playlist, false);
if (removeFromChanged)
Expand Down
2 changes: 1 addition & 1 deletion Shared/Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
<Compile Include="$(MSBuildThisFileDirectory)Utilities.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="$(MSBuildThisFileDirectory)Icons\FolderIcon.png" />
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Icons\FolderIcon.png" />
</ItemGroup>
</Project>
4 changes: 4 additions & 0 deletions Shared/Types/IPlaylist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public partial interface IPlaylist : IList<IPlaylistSong>
/// </summary>
bool AllowDuplicates { get; set; }
/// <summary>
/// Disable editing of playlist. This has to be handled by the UI itself, the lib does not handle it.
/// </summary>
bool ReadOnly { get; set; }
/// <summary>
/// Adds the <see cref="ISong"/> to the playlist.
/// Does nothing if <see cref="AllowDuplicates"/> is false and the song is already in the playlist.
/// Converts the <see cref="ISong"/> if needed.
Expand Down
14 changes: 13 additions & 1 deletion Shared/Types/Playlist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,16 @@ public bool AllowDuplicates
}

/// <inheritdoc/>
public virtual bool IsReadOnly => false;
public bool ReadOnly
{
get
{
if (TryGetCustomData("ReadOnly", out object? returnVal) && returnVal is bool boolVal)
return boolVal;
return false;
}
set => SetCustomData("ReadOnly", value);
}

/// <inheritdoc/>
public abstract bool HasCover { get; }
Expand Down Expand Up @@ -152,6 +161,9 @@ public IPlaylistSong this[int index]
/// <inheritdoc/>
public int Count => Songs.Count;

/// <inheritdoc/>
public virtual bool IsReadOnly => ReadOnly;

/// <summary>
/// Creates a new <see cref="IPlaylistSong"/> of type <typeparamref name="T"/> from the given <paramref name="song"/>.
/// </summary>
Expand Down

0 comments on commit e40a2bf

Please sign in to comment.