LoadingPatches.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using HarmonyLib;
  2. using IPA.Utilities;
  3. using System;
  4. using System.Linq;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. using UnityEngine;
  8. using System.Collections;
  9. using System.Collections.Generic;
  10. namespace SongCore.HarmonyPatches
  11. {
  12. [HarmonyPatch(typeof(CustomBeatmapLevel))]
  13. [HarmonyPatch(new Type[] { typeof(CustomPreviewBeatmapLevel), typeof(AudioClip)})]
  14. [HarmonyPatch(MethodType.Constructor)]
  15. internal class CustomBeatmapLevelDurationPatch
  16. {
  17. static void Postfix(CustomBeatmapLevel __instance, CustomPreviewBeatmapLevel customPreviewBeatmapLevel)
  18. {
  19. __instance.SetField<CustomPreviewBeatmapLevel, float>("_songDuration", customPreviewBeatmapLevel.songDuration);
  20. }
  21. }
  22. [HarmonyPatch(typeof(BeatmapLevelsModel))]
  23. [HarmonyPatch("ReloadCustomLevelPackCollectionAsync", MethodType.Normal)]
  24. internal class StopVanillaLoadingPatch
  25. {
  26. static void Prefix(Task<IBeatmapLevelPackCollection> __result)
  27. {
  28. var cancel = Resources.FindObjectsOfTypeAll<LevelFilteringNavigationController>().First().GetField<CancellationTokenSource, LevelFilteringNavigationController>("_cancellationTokenSource");
  29. cancel.Cancel();
  30. }
  31. }
  32. [HarmonyPatch(typeof(LevelFilteringNavigationController))]
  33. [HarmonyPatch("UpdateCustomSongs", MethodType.Normal)]
  34. internal class StopVanillaLoadingPatch2
  35. {
  36. static void Postfix(ref LevelFilteringNavigationController __instance, LevelSearchViewController ____levelSearchViewController, SelectLevelCategoryViewController ____selectLevelCategoryViewController, ref IBeatmapLevelPack[] ____ostBeatmapLevelPacks, ref IBeatmapLevelPack[] ____musicPacksBeatmapLevelPacks, ref IBeatmapLevelPack[] ____customLevelPacks, ref IBeatmapLevelPack[] ____allBeatmapLevelPacks)
  37. {
  38. ____customLevelPacks = Loader.CustomBeatmapLevelPackCollectionSO.beatmapLevelPacks;
  39. List<IBeatmapLevelPack> packs = new List<IBeatmapLevelPack>();
  40. if (____ostBeatmapLevelPacks != null)
  41. packs = packs.Concat(____ostBeatmapLevelPacks).ToList();
  42. if (____musicPacksBeatmapLevelPacks != null)
  43. packs = packs.Concat(____musicPacksBeatmapLevelPacks).ToList();
  44. if (____customLevelPacks != null)
  45. packs = packs.Concat(____customLevelPacks).ToList();
  46. ____allBeatmapLevelPacks = packs.ToArray();
  47. ____levelSearchViewController.Setup(____allBeatmapLevelPacks);
  48. __instance.UpdateSecondChildControllerContent(____selectLevelCategoryViewController.selectedLevelCategory);
  49. }
  50. }
  51. /*
  52. [HarmonyPatch(typeof(LevelFilteringNavigationController))]
  53. [HarmonyPatch("ReloadSongListIfNeeded", MethodType.Normal)]
  54. internal class StopVanillaLoadingPatch3
  55. {
  56. static bool Prefix(ref LevelFilteringNavigationController __instance, ref TabBarViewController ____tabBarViewController)
  57. {
  58. __instance.GetField("_customLevelsTabBarData")?.SetField("annotatedBeatmapLevelCollections", Loader.CustomBeatmapLevelPackCollectionSO?.beatmapLevelPacks);
  59. return false;
  60. }
  61. }
  62. */
  63. }