diff --git a/CustomAlbums.csproj b/CustomAlbums.csproj
index 36b7eb8..d7f825e 100644
--- a/CustomAlbums.csproj
+++ b/CustomAlbums.csproj
@@ -5,7 +5,7 @@
disable
false
true
- x64
+ AnyCPU;x64
true
diff --git a/Main.cs b/Main.cs
index 66d9346..4c995ba 100644
--- a/Main.cs
+++ b/Main.cs
@@ -12,7 +12,7 @@ public class Main : MelonMod
public const string MelonName = "CustomAlbums";
public const string MelonAuthor = "Two Fellas";
- public const string MelonVersion = "4.1.8";
+ public const string MelonVersion = "4.1.9";
public override void OnInitializeMelon()
{
diff --git a/Managers/SaveManager.cs b/Managers/SaveManager.cs
index 145ac78..7d53de0 100644
--- a/Managers/SaveManager.cs
+++ b/Managers/SaveManager.cs
@@ -3,7 +3,6 @@
using CustomAlbums.Data;
using CustomAlbums.Utilities;
using System.IO.Compression;
-using CustomAlbums.Patches;
namespace CustomAlbums.Managers
{
@@ -217,16 +216,6 @@ internal static void SaveScore(string uid, int musicDifficulty, int score, float
if (musicDifficulty is 2 && AlbumManager.LoadedAlbums[albumName].HasDifficulty(3) && newScore.Evaluate >= 4)
SaveData.UnlockedMasters.Add(albumName);
- // Update the IData for the played chart
- var dataIndex = DataInjectPatch.DataList.GetIndexByUid(album.Uid, musicDifficulty);
- if (dataIndex != -1)
- {
- DataInjectPatch.DataList.RemoveAt(dataIndex);
- }
-
- var newIData = DataInjectPatch.CreateIData(album, musicDifficulty, newScore);
- DataInjectPatch.DataList.Add(newIData);
-
// If there were no misses then add the chart/difficulty to the FullCombo list
if (miss != 0) return;
diff --git a/Patches/DataInjectPatch.cs b/Patches/DataInjectPatch.cs
deleted file mode 100644
index e78cf3c..0000000
--- a/Patches/DataInjectPatch.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-using CustomAlbums.Data;
-using CustomAlbums.Managers;
-using HarmonyLib;
-using Il2CppAssets.Scripts.Database;
-using Il2CppAssets.Scripts.PeroTools.Nice.Interface;
-using Il2CppAssets.Scripts.PeroTools.Nice.Variables;
-using IDataList = Il2CppSystem.Collections.Generic.List;
-
-namespace CustomAlbums.Patches
-{
- ///
- /// This patch modifies the highest property of DataHelper to include custom charts.
- ///
- [HarmonyPatch(typeof(DataHelper), nameof(DataHelper.highest), MethodType.Getter)]
- internal class DataInjectPatch
- {
- internal static readonly IDataList DataList = new();
-
- // ReSharper disable once InconsistentNaming
- private static void Postfix(ref IDataList __result)
- {
- var highest = DataHelper.s_DataManager["Achievement"]["highest"].GetResult();
- if (highest == null) return;
-
- if (DataList.Count > 0)
- {
- var combined1 = new IDataList();
- foreach (var item in highest)
- combined1.Add(item);
- foreach (var item in DataList)
- combined1.Add(item);
-
- __result = combined1;
- return;
- }
-
- var customsHighest = SaveManager.SaveData.Highest;
-
- foreach (var (albumName, albumDic) in customsHighest)
- {
- foreach (var (difficulty, save) in albumDic)
- {
- if (!AlbumManager.LoadedAlbums.TryGetValue(albumName, out var album))
- continue;
-
- var data = CreateIData(album, difficulty, save);
- DataList.Add(data);
- }
- }
-
- // combine the two lists highest and data
- var combined = new IDataList();
- foreach (var item in highest)
- {
- combined.Add(item);
- }
- foreach (var item in DataList)
- {
- combined.Add(item);
- }
-
- // set the result to the combined list
- __result = combined;
- }
-
- ///
- /// Creates a Muse Dash-compatible IData object from a CustomChartSave object.
- ///
- /// The album of the data to be created.
- /// The difficulty of the chart.
- /// The CustomChartSave object containing the save data.
- ///
- internal static IData CreateIData(Album album, int difficulty, ChartSave save)
- {
- var data = new Il2CppAssets.Scripts.PeroTools.Nice.Datas.Data();
-
- data.fields.Add("uid", CreateIVariable($"{album.Uid}_{difficulty}"));
- data.fields.Add("evaluate", CreateIVariable(save.Evaluate));
- data.fields.Add("score", CreateIVariable(save.Score));
- data.fields.Add("combo", CreateIVariable(save.Combo));
- data.fields.Add("accuracy", CreateIVariable(save.Accuracy));
- data.fields.Add("accuracyStr", CreateIVariable(save.AccuracyStr));
- data.fields.Add("clear", CreateIVariable(save.Clear));
- data.fields.Add("passed", CreateIVariable(save.Passed));
-
- return data.Cast();
- }
-
- ///
- /// Creates a Muse Dash-compatible IVariable object from an Il2CppSystem.Object.
- ///
- /// The object (Il2Cpp) to be converted to IVariable.
- ///
- internal static IVariable CreateIVariable(Il2CppSystem.Object obj)
- {
- var constance = new Constance
- {
- result = obj
- };
-
- return constance.Cast();
- }
- }
-}
diff --git a/Patches/DifficultyGradeIconPatch.cs b/Patches/DifficultyGradeIconPatch.cs
index eca89e3..e619284 100644
--- a/Patches/DifficultyGradeIconPatch.cs
+++ b/Patches/DifficultyGradeIconPatch.cs
@@ -1,4 +1,5 @@
-using CustomAlbums.Utilities;
+using CustomAlbums.Managers;
+using CustomAlbums.Utilities;
using HarmonyLib;
using Il2Cpp;
using Il2CppAssets.Scripts.Database;
@@ -7,36 +8,62 @@
namespace CustomAlbums.Patches
{
+
+ [HarmonyPatch(typeof(PnlStage), nameof(PnlStage.RefreshDiffUI))]
internal class DifficultyGradeIconPatch
- {
+ {
+ private static int GetEvaluate(Dictionary highest, int diff) => highest.GetValueOrDefault(diff)?.Evaluate ?? -1;
+
///
- /// Fixes vanilla bug where the difficulty grade icon on hidden charts does not update properly when triggerDiff is not 3.
+ /// Enables the S logos on the difficulties for custom charts.
///
- [HarmonyPatch(typeof(PnlStage), nameof(PnlStage.RefreshDiffUI))]
- internal class DiffUIFix
+ // ReSharper disable once InconsistentNaming
+ private static void Postfix(MusicInfo musicInfo, PnlStage __instance)
{
- private static void Postfix(MusicInfo musicInfo, PnlStage __instance)
+ var uid = musicInfo?.uid;
+ var specialSongInstance = Singleton.instance;
+
+ if (string.IsNullOrEmpty(uid)) return;
+
+ // For custom charts, we need to set the S logos for each difficulty
+ if (uid.StartsWith($"{AlbumManager.Uid}-"))
+ {
+ // Gets the highest data from save data
+ var customHighest = SaveManager.SaveData.GetChartSaveDataFromUid(uid).Highest;
+
+ // Get the Evaluate value from each, set diff3 to diff4 if hidden is invoked
+ var diff1 = GetEvaluate(customHighest, 1);
+ var diff2 = GetEvaluate(customHighest, 2);
+ var diff3 = Singleton.instance.IsInvokeHideBms(uid)
+ ? GetEvaluate(customHighest, 4)
+ : GetEvaluate(customHighest, 3);
+
+ // Set the S logos for each difficulty
+ __instance.m_Diff1Item.ChangeSchemeByEvalue(diff1, __instance.globalData);
+ __instance.m_Diff2Item.ChangeSchemeByEvalue(diff2, __instance.globalData);
+ __instance.m_Diff3Item.ChangeSchemeByEvalue(diff3, __instance.globalData);
+ }
+
+ // For vanilla and custom charts, this fixes the hidden difficulty icon for non-master charts
+ if (!specialSongInstance.IsInvokeHideBms(uid)) return;
+ if (!specialSongInstance.m_HideBmsInfos.TryGetValue(uid, out var info)) return;
+
+ // Get the difficulty evaluates
+ var hiddenEval = DataHelper.highest.GetIDataByUid(uid, 4).ToChartSave().Evaluate;
+ var masterEval = DataHelper.highest.GetIDataByUid(uid, 3).ToChartSave().Evaluate;
+
+ // The game handles case 3 already, don't need to reinvent the wheel here
+ switch (info.triggerDiff)
{
- var uid = musicInfo?.uid;
- var specialSongInstance = Singleton.instance;
-
- if (string.IsNullOrEmpty(uid) || !specialSongInstance.IsInvokeHideBms(uid)) return;
- if (!specialSongInstance.m_HideBmsInfos.TryGetValue(uid, out var info)) return;
-
- // Get the hidden difficulty evaluate
- var hiddenEval = DataHelper.highest.GetIDataByUid(uid, 4).ToChartSave().Evaluate;
-
- // The game handles case 3 already, don't need to reinvent the wheel here
- switch (info.triggerDiff)
- {
- case 1:
- __instance.m_Diff1Item.ChangeSchemeByEvalue(hiddenEval, __instance.globalData);
- break;
- case 2:
- __instance.m_Diff2Item.ChangeSchemeByEvalue(hiddenEval, __instance.globalData);
- break;
- }
+ case 1:
+ __instance.m_Diff3Item.ChangeSchemeByEvalue(masterEval, __instance.globalData);
+ __instance.m_Diff1Item.ChangeSchemeByEvalue(hiddenEval, __instance.globalData);
+ break;
+ case 2:
+ __instance.m_Diff3Item.ChangeSchemeByEvalue(masterEval, __instance.globalData);
+ __instance.m_Diff2Item.ChangeSchemeByEvalue(hiddenEval, __instance.globalData);
+ break;
}
}
}
-}
+}
\ No newline at end of file
diff --git a/Patches/ReportCardPatch.cs b/Patches/ReportCardPatch.cs
new file mode 100644
index 0000000..797139b
--- /dev/null
+++ b/Patches/ReportCardPatch.cs
@@ -0,0 +1,77 @@
+using System.Globalization;
+using System.Reflection;
+using CustomAlbums.Managers;
+using HarmonyLib;
+using Il2Cpp;
+using Il2CppAssets.Scripts.Database;
+using Il2CppAssets.Scripts.GameCore.Managers;
+using Il2CppAssets.Scripts.PeroTools.Commons;
+using Il2CppAssets.Scripts.UI.Panels;
+
+namespace CustomAlbums.Patches
+{
+ [HarmonyPatch(typeof(PnlReportCard), nameof(PnlReportCard.RefreshBestRecord))]
+ internal static class ReportCardPatch
+ {
+ // ReSharper disable once InconsistentNaming
+ private static bool Prefix(PnlReportCard __instance)
+ {
+ var musicInfo = GlobalDataBase.s_DbMusicTag.CurMusicInfo();
+ if (musicInfo.albumIndex != 999) return true;
+
+ var mapDifficulty = GlobalDataBase.s_DbBattleStage.m_MapDifficulty;
+ var curMusicBestRankOrder = Singleton.instance.GetCurMusicBestRankOrder();
+
+ var album = AlbumManager.GetByUid(musicInfo.uid);
+ if (album == null) return false;
+
+ var save = SaveManager.SaveData.Highest[album.AlbumName][mapDifficulty];
+ if (save == null) return false;
+
+ __instance.RefreshRecord(musicInfo, mapDifficulty, save.Score, save.Combo, save.AccuracyStr, save.Evaluate, save.Clear.ToString(CultureInfo.InvariantCulture), curMusicBestRankOrder);
+ return false;
+ }
+ }
+
+ [HarmonyPatch]
+ internal static class TogglePatch
+ {
+ private static IEnumerable TargetMethods()
+ {
+ return new[] { nameof(PnlPreparation.OnDiffTglChanged), nameof(PnlPreparation.OnEnable) }
+ .Select(methodName => typeof(PnlPreparation).GetMethod(methodName))
+ .ToArray();
+ }
+ // ReSharper disable once InconsistentNaming
+ private static void Postfix(PnlPreparation __instance)
+ {
+ var musicInfo = GlobalDataBase.s_DbMusicTag.CurMusicInfo();
+ if (musicInfo.albumIndex != 999) return;
+
+ var mapDifficulty = GlobalDataBase.s_DbBattleStage.m_MapDifficulty;
+ var gameObject = __instance.btnDownloadReport.gameObject;
+
+ var album = AlbumManager.GetByUid(musicInfo.uid);
+ if (album == null)
+ {
+ gameObject.SetActive(false);
+ return;
+ }
+
+ if (!SaveManager.SaveData.Highest.TryGetValue(album.AlbumName, out var chart))
+ {
+ gameObject.SetActive(false);
+ return;
+ }
+
+ if (!chart.ContainsKey(mapDifficulty))
+ {
+ gameObject.SetActive(false);
+ return;
+ }
+
+ gameObject.SetActive(true);
+ }
+ }
+}
+