Skip to content

Commit

Permalink
Merge pull request #3 from MDMods/development
Browse files Browse the repository at this point in the history
Release CustomAlbums v4.0.1
  • Loading branch information
AshtonMemer authored Feb 7, 2024
2 parents 78b3559 + d520430 commit ecbf042
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
12 changes: 12 additions & 0 deletions Data/Bms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ public enum BmsId
FlashbangStart,
FlashbangMid,
FlashbangEnd,
BgStopOn,
BgStopOff,
MosaicOn,
MosaicOff,
SepiaOn,
SepiaOff,
MediumBullet,
MediumBulletUp,
MediumBulletDown,
Expand Down Expand Up @@ -276,6 +282,12 @@ public enum ChannelType
["2I"] = BmsId.FlashbangStart,
["2J"] = BmsId.FlashbangMid,
["2K"] = BmsId.FlashbangEnd,
["2N"] = BmsId.BgStopOn,
["2O"] = BmsId.BgStopOff,
["2P"] = BmsId.MosaicOn,
["2Q"] = BmsId.MosaicOff,
["2R"] = BmsId.SepiaOn,
["2S"] = BmsId.SepiaOff,
["30"] = BmsId.MediumBullet,
["31"] = BmsId.MediumBulletUp,
["32"] = BmsId.MediumBulletDown,
Expand Down
17 changes: 13 additions & 4 deletions Patches/SavePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ private static void CleanCustomData()
(Il2CppSystem.Predicate<string>)(uid => uid.StartsWith($"{AlbumManager.Uid}-")));
DataHelper.collections.RemoveAll(
(Il2CppSystem.Predicate<string>)(uid => uid.StartsWith($"{AlbumManager.Uid}-")));
DataHelper.tasks.RemoveAll((Il2CppSystem.Predicate<string>)(uid => uid.StartsWith($"{AlbumManager.Uid}-")));

if (DataHelper.selectedAlbumUid == "music_package_999")
DataHelper.selectedAlbumUid = "music_package_0";
Expand All @@ -211,6 +210,7 @@ private static void CleanCustomData()

if (ModSettings.SavingEnabled) SaveData.SelectedAlbum = AlbumManager.GetAlbumNameFromUid(DataHelper.selectedMusicUidFromInfoList);
DataHelper.selectedMusicUidFromInfoList = "0-0";
DataHelper.unlockMasters.RemoveAll((Il2CppSystem.Predicate<string>)(uid => uid.StartsWith($"{AlbumManager.Uid}-")));
}

private static void InjectCustomData()
Expand All @@ -220,7 +220,13 @@ private static void InjectCustomData()
DataHelper.hides.AddManagedRange(SaveData.Hides.GetAlbumUidsFromNames());
DataHelper.history.AddManagedRange(SaveData.History.GetAlbumUidsFromNames());
DataHelper.collections.AddManagedRange(SaveData.Collections.GetAlbumUidsFromNames());
Logger.Msg("SelectedAlbum = " + SaveData.SelectedAlbum);

// Wild one-liner to get the UIDs that should have unlocked masters
//
// Logic: Get all the charts where there is a master difficulty (3), and if the value of hard difficulty exists (2), make sure that its evaluate is an S rank. If it is, add it to the list
// Once the list has been lazily created, select only the keys (album_{nameOfFile}) from that list, and then get the UIDs from those album names, adding it to the game's data list
DataHelper.unlockMasters.AddManagedRange(SaveData.Highest.Where(kv =>
kv.Value.ContainsKey(3) && kv.Value.TryGetValue(2, out var chartSave) && chartSave.Evaluate >= 4).Select(kv => kv.Key).GetAlbumUidsFromNames());

if (!SaveData.SelectedAlbum.StartsWith("album_")) return;
DataHelper.selectedAlbumUid = "music_package_999";
Expand Down Expand Up @@ -410,6 +416,10 @@ private static void Postfix(PnlVictory __instance)

// If the chart has been played then enable the "HI-SCORE" UI element
var difficulty = GlobalDataBase.s_DbBattleStage.m_MapDifficulty;
if (difficulty is 2 && AlbumManager.LoadedAlbums[albumName].Sheets.ContainsKey(3) && highest[2].Evaluate >= 4)
{
DataHelper.unlockMasters.Add(GlobalDataBase.dbBattleStage.musicUid);
}
__instance.m_CurControls.highScoreTitle.enabled = PreviousScore != "-";
__instance.m_CurControls.highScoreTxt.enabled = PreviousScore != "-";

Expand Down Expand Up @@ -471,8 +481,7 @@ internal class LoadLocalPatch
private static void Postfix()
{
CleanCustomData();
if (!ModSettings.SavingEnabled) return;
InjectCustomData();
if (ModSettings.SavingEnabled) InjectCustomData();
}
}

Expand Down
6 changes: 3 additions & 3 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.0.0.0")]
[assembly: AssemblyFileVersion("4.0.0.0")]
[assembly: MelonInfo(typeof(CustomAlbums.Main), "CustomAlbums", "4.0.0", "Team Baller")]
[assembly: AssemblyVersion("4.0.1.0")]
[assembly: AssemblyFileVersion("4.0.1.0")]
[assembly: MelonInfo(typeof(CustomAlbums.Main), "CustomAlbums", "4.0.1", "Team Baller")]
[assembly: MelonGame("PeroPeroGames", "MuseDash")]
[assembly: MelonColor(255, 0, 255, 150)]
2 changes: 1 addition & 1 deletion Utilities/Backup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private static void ClearOldBackups()

if (!File.Exists(BackupZip)) return;

using var zip = ZipFile.OpenRead(BackupZip);
using var zip = ZipFile.Open(BackupZip, ZipArchiveMode.Update);
foreach (var entry in zip.Entries.ToList().Where(entry =>
(DateTime.Now - entry.LastWriteTime).Duration() > MaxBackupTime.Duration()))
{
Expand Down

0 comments on commit ecbf042

Please sign in to comment.