Skip to content
This repository has been archived by the owner on Apr 11, 2022. It is now read-only.

Commit

Permalink
Patch 1.06
Browse files Browse the repository at this point in the history
  • Loading branch information
TacoTechnica committed Dec 11, 2021
1 parent 4563616 commit 1f61284
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 57 deletions.
5 changes: 2 additions & 3 deletions CustomBeatmaps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using CustomBeatmaps.UI.ReactEsque;
using CustomBeatmaps.UI.Structure;
using HarmonyLib;
using Rhythm;
using UnityEngine;

namespace CustomBeatmaps
Expand Down Expand Up @@ -52,9 +53,7 @@ private void Awake()
});

Harmony.CreateAndPatchAll(typeof(CustomBeatmapLoadingOverridePatch));
Harmony.CreateAndPatchAll(typeof(BeatmapInfoAudioKeyOverridePatch));
Harmony.CreateAndPatchAll(typeof(MainMenuLoadPatch));
Harmony.CreateAndPatchAll(typeof(MemorySkipAfterCustomBeatmapPatch));
Harmony.CreateAndPatchAll(typeof(OsuEditorPatch));

MainMenuLoadPatch.OnOpen += () =>
Expand Down Expand Up @@ -156,7 +155,7 @@ private void DoOnlineSearch(SearchQuery searchQuery, Action<IList<CustomPackageI
private void OnPlayRequest(UniqueId id, string difficulty)
{
// TODO: If beatmap is not downloaded, download first then play.
JeffBezosController.beatmapToLoad = UnbeatableHelper.GetBeatmapUniqueKey(id, difficulty); // For high score loading
JeffBezosController.rhythmProgression = new DefaultProgression(UnbeatableHelper.GetBeatmapUniqueKey(id, difficulty), "TrainStationRhythm");
UnbeatableHelper.PlayBeatmap(_packageGrabber.GetLocalBeatmap(id, difficulty));
_uiMain?.Close();
}
Expand Down
6 changes: 4 additions & 2 deletions PackageManagement/CustomBeatmapInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ public class CustomBeatmapInfo : BeatmapInfo
{
public readonly string Artist;
public readonly string BeatmapCreator;
public readonly string SongName;
public readonly string RealAudioKey;

public CustomBeatmapInfo(TextAsset textAsset, string songName, string difficulty, string artist,
string beatmapCreator, string realAudioKey) : base(textAsset, songName, difficulty)
public CustomBeatmapInfo(TextAsset textAsset, string difficulty, string artist,
string beatmapCreator, string songName, string realAudioKey) : base(textAsset, difficulty)
{
RealAudioKey = realAudioKey;
Artist = artist;
SongName = songName;
BeatmapCreator = beatmapCreator;
}
}
Expand Down
4 changes: 2 additions & 2 deletions PackageManagement/PackageGrabberUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ public static CustomBeatmapInfo LoadBeatmap(string bmapPath)
var audioFolder = Path.GetDirectoryName(bmapPath);
var trueAudioPath = audioFolder + "/" + audioFile; // Path.Join fails.

return new CustomBeatmapInfo(new TextAsset(text), songName, difficulty, artist, beatmapCreator,
trueAudioPath);
return new CustomBeatmapInfo(new TextAsset(text), difficulty, artist, beatmapCreator,
songName, trueAudioPath);
}

public static void ListenToLocalChanges(string rootDirectory, Action onChange)
Expand Down
22 changes: 0 additions & 22 deletions Patches/BeatmapInfoAudioKeyOverridePatch.cs

This file was deleted.

16 changes: 9 additions & 7 deletions Patches/CustomBeatmapLoadingOverridePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ public static void ResetOverrideBeatmap()
_override = null;
}

private static void OverrideBeatmapParsing(out BeatmapInfo beatmapInfo, out Beatmap beatmap, out string audioKey)
private static void OverrideBeatmapParsing(out BeatmapInfo beatmapInfo, out Beatmap beatmap, out string audioKey, out string songName)
{
BeatmapParserEngine beatmapParserEngine = new BeatmapParserEngine();
beatmap = ScriptableObject.CreateInstance<Beatmap>();
beatmapInfo = _override;
beatmapParserEngine.ReadBeatmap(beatmapInfo.text, ref beatmap);
audioKey = beatmapInfo.audioKey;
songName = _override.SongName;
audioKey = _override.RealAudioKey;
}

[HarmonyPatch(typeof(BeatmapParser), "ParseBeatmap", new Type[0])]
Expand All @@ -42,28 +43,29 @@ private static void ParseBeatmapInstance(BeatmapParser __instance, ref bool __ru
if (ShouldOverride())
{
__runOriginal = false;
OverrideBeatmapParsing(out _, out __instance.beatmap, out __instance.audioKey);
OverrideBeatmapParsing(out _, out __instance.beatmap, out __instance.audioKey, out _);
}
}

[HarmonyPatch(
typeof(BeatmapParser), "ParseBeatmap",
new[]{typeof(BeatmapIndex), typeof(string), typeof(BeatmapInfo), typeof(Beatmap)},
new [] {ArgumentType.Normal, ArgumentType.Normal, ArgumentType.Out, ArgumentType.Out})
new[]{typeof(BeatmapIndex), typeof(string), typeof(BeatmapInfo), typeof(Beatmap), typeof(string)},
new [] {ArgumentType.Normal, ArgumentType.Normal, ArgumentType.Out, ArgumentType.Out, ArgumentType.Out})
]
[HarmonyPrefix]
private static void ParseBeatmapStatic(BeatmapIndex beatmapIndex, string beatmapPath, out BeatmapInfo beatmapInfo, out Beatmap beatmap, ref bool __runOriginal)
private static void ParseBeatmapStatic(BeatmapIndex beatmapIndex, string beatmapPath, out BeatmapInfo beatmapInfo, out Beatmap beatmap, out string songName, ref bool __runOriginal)
{
if (ShouldOverride())
{
__runOriginal = false;
OverrideBeatmapParsing(out beatmapInfo, out beatmap, out _);
OverrideBeatmapParsing(out beatmapInfo, out beatmap, out _, out songName);
}
else
{
// Required to set these, but they will get overriden by the original function.
beatmapInfo = null;
beatmap = null;
songName = null;
}
}

Expand Down
21 changes: 0 additions & 21 deletions Patches/MemorySkipAfterCustomBeatmapPatch.cs

This file was deleted.

0 comments on commit 1f61284

Please sign in to comment.