-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
280 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
PlaylistManager/HarmonyPatches/AnnotatedBeatmapLevelCollectionsViewController_SetData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using BeatSaberPlaylistsLib.Types; | ||
using HarmonyLib; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace PlaylistManager.HarmonyPatches | ||
{ | ||
[HarmonyPatch(typeof(AnnotatedBeatmapLevelCollectionsViewController), nameof(AnnotatedBeatmapLevelCollectionsViewController.SetData))] | ||
internal class AnnotatedBeatmapLevelCollectionsViewController_SetData | ||
{ | ||
private static readonly Dictionary<IPlaylist, AnnotatedBeatmapLevelCollectionsViewController> eventTable = new(); | ||
|
||
private static void Postfix(AnnotatedBeatmapLevelCollectionsViewController __instance, IReadOnlyList<BeatmapLevelPack> annotatedBeatmapLevelCollections) | ||
{ | ||
foreach (PlaylistLevelPack playlistLevelPack in annotatedBeatmapLevelCollections.OfType<PlaylistLevelPack>()) | ||
{ | ||
IPlaylist playlist = playlistLevelPack.playlist; | ||
|
||
if (playlist.SmallSpriteWasLoaded) | ||
{ | ||
continue; | ||
} | ||
|
||
eventTable.Remove(playlist); | ||
eventTable.Add(playlist, __instance); | ||
playlist.SpriteLoaded -= OnSpriteLoaded; | ||
playlist.SpriteLoaded += OnSpriteLoaded; | ||
} | ||
} | ||
|
||
private static void OnSpriteLoaded(object sender, EventArgs e) | ||
{ | ||
if (sender is not IPlaylist playlist) | ||
{ | ||
return; | ||
} | ||
|
||
playlist.SpriteLoaded -= OnSpriteLoaded; | ||
|
||
if (!eventTable.TryGetValue(playlist, out var vc) || vc == null) | ||
{ | ||
return; | ||
} | ||
|
||
var annotatedBeatmapLevelCollections = CloneAndOverwriteEntry(vc._annotatedBeatmapLevelCollections, playlist.PlaylistLevelPack); | ||
vc._annotatedBeatmapLevelCollections = annotatedBeatmapLevelCollections; | ||
vc._annotatedBeatmapLevelCollectionsGridView.SetData(annotatedBeatmapLevelCollections); | ||
} | ||
|
||
private static IReadOnlyList<BeatmapLevelPack> CloneAndOverwriteEntry(IReadOnlyList<BeatmapLevelPack> original, BeatmapLevelPack item) | ||
{ | ||
BeatmapLevelPack[] beatmapLevelPackCollection = new BeatmapLevelPack[original.Count]; | ||
|
||
for (int i = 0; i < beatmapLevelPackCollection.Length; ++i) | ||
{ | ||
if (original[i].packID == item.packID) | ||
{ | ||
beatmapLevelPackCollection[i] = item; | ||
} | ||
else | ||
{ | ||
beatmapLevelPackCollection[i] = original[i]; | ||
} | ||
} | ||
|
||
return beatmapLevelPackCollection; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
PlaylistManager/HarmonyPatches/LevelCollectionTableView_SetData.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace PlaylistManager.Interfaces | ||
{ | ||
interface ILevelCollectionsTableUpdater | ||
{ | ||
public event Action<IAnnotatedBeatmapLevelCollection[], int> LevelCollectionTableViewUpdatedEvent; | ||
public event Action<IReadOnlyList<BeatmapLevelPack>, int> LevelCollectionTableViewUpdatedEvent; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.