Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CustomAlbums.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Nullable>disable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Platforms>x64</Platforms>
<Platforms>AnyCPU;x64</Platforms>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
11 changes: 0 additions & 11 deletions Managers/SaveManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using CustomAlbums.Data;
using CustomAlbums.Utilities;
using System.IO.Compression;
using CustomAlbums.Patches;

namespace CustomAlbums.Managers
{
Expand Down Expand Up @@ -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;

Expand Down
104 changes: 0 additions & 104 deletions Patches/DataInjectPatch.cs

This file was deleted.

79 changes: 53 additions & 26 deletions Patches/DifficultyGradeIconPatch.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CustomAlbums.Utilities;
using CustomAlbums.Managers;
using CustomAlbums.Utilities;
using HarmonyLib;
using Il2Cpp;
using Il2CppAssets.Scripts.Database;
Expand All @@ -7,36 +8,62 @@

namespace CustomAlbums.Patches
{

[HarmonyPatch(typeof(PnlStage), nameof(PnlStage.RefreshDiffUI))]
internal class DifficultyGradeIconPatch
{
{
private static int GetEvaluate(Dictionary<int, Data.ChartSave> highest, int diff) => highest.GetValueOrDefault(diff)?.Evaluate ?? -1;

/// <summary>
/// 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.
/// </summary>
[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<SpecialSongManager>.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<SpecialSongManager>.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<SpecialSongManager>.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;
}
}
}
}
}
77 changes: 77 additions & 0 deletions Patches/ReportCardPatch.cs
Original file line number Diff line number Diff line change
@@ -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<TempRankDataManager>.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<MethodBase> 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);
}
}
}

Loading