Skip to content

Commit

Permalink
Use the existing ProgressBar instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Meivyn committed Jun 12, 2024
1 parent 2cc1fdf commit e3ee48c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
19 changes: 8 additions & 11 deletions PlaylistManager/UI/RefreshButtonUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@
using SongCore;
using SongCore.UI;
using System;
using System.Threading.Tasks;
using Zenject;

namespace PlaylistManager.UI
{
public class RefreshButtonUI : IInitializable, IDisposable
{
private readonly ProgressBar _progressBar;

private MenuButton refreshButton;
private ProgressBar progressBar;
private const int kMessageTime = 5;

private RefreshButtonUI(ProgressBar progressBar)
{
_progressBar = progressBar;
}

public void Initialize()
{
Expand All @@ -30,14 +34,7 @@ private async void SongsLoaded(Loader _, System.Collections.Concurrent.Concurren

PlaylistLibUtils.playlistManager.RefreshPlaylists(true);
var numPlaylists = PlaylistLibUtils.playlistManager.GetPlaylistCount(true);

// This event handler is loading sprites and accessing Unity objects so it must be done on the main thread.
// Although SongsLoadedEvent is already invoked on the main thread, the default event handler in ProgressBar
// will overwrite our message. We're essentially skipping a frame to let the default event handler run first.
await Task.Yield();

progressBar.enabled = true;
progressBar.ShowMessage($"\n{numPlaylists} playlists loaded.", kMessageTime, false);
_progressBar.AppendText($"\n{numPlaylists} playlists loaded");
}

public void Dispose()
Expand Down
4 changes: 2 additions & 2 deletions PlaylistManager/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"icon": "PlaylistManager.Icons.Logo.png",
"dependsOn": {
"BSIPA": "^4.3.0",
"SongCore": "^3.9.5",
"SongCore": "^3.14.5",
"BeatSaberMarkupLanguage": "^1.7.5",
"SiraUtil": "^3.0.0",
"BeatSaberPlaylistsLib": "^1.6.8",
"BeatSaberPlaylistsLib": "^1.7.0",
"BeatSaverSharp": "^3.4.5",
"System.IO.Compression": "^4.6.57",
"System.IO.Compression.FileSystem": "^4.7.3056"
Expand Down

0 comments on commit e3ee48c

Please sign in to comment.