From e5cc0ffd6bf73bd9eb3376ef7391496083d8f33c Mon Sep 17 00:00:00 2001 From: sora10pls <17801814+sora10pls@users.noreply.github.com> Date: Sun, 30 Apr 2023 18:59:51 -0400 Subject: [PATCH] SAV5: expose number of unlocked boxes --- PKHeX.Core/Saves/SAV5.cs | 1 + PKHeX.Core/Saves/Substructures/Gen5/BoxLayout5.cs | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/PKHeX.Core/Saves/SAV5.cs b/PKHeX.Core/Saves/SAV5.cs index 4b69154c2..0816e3685 100644 --- a/PKHeX.Core/Saves/SAV5.cs +++ b/PKHeX.Core/Saves/SAV5.cs @@ -95,6 +95,7 @@ public override int PartyCount public override int GetPartyOffset(int slot) => Party + 8 + (SIZE_PARTY * slot); protected override int GetBoxWallpaperOffset(int box) => BoxLayout.GetBoxWallpaperOffset(box); + public override int BoxesUnlocked { get => BoxLayout.BoxesUnlocked; set => BoxLayout.BoxesUnlocked = (byte)value; } public override int GetBoxWallpaper(int box) => BoxLayout.GetBoxWallpaper(box); public override void SetBoxWallpaper(int box, int value) => BoxLayout.SetBoxWallpaper(box, value); public override string GetBoxName(int box) => BoxLayout[box]; diff --git a/PKHeX.Core/Saves/Substructures/Gen5/BoxLayout5.cs b/PKHeX.Core/Saves/Substructures/Gen5/BoxLayout5.cs index 547af7b9d..977c275d9 100644 --- a/PKHeX.Core/Saves/Substructures/Gen5/BoxLayout5.cs +++ b/PKHeX.Core/Saves/Substructures/Gen5/BoxLayout5.cs @@ -39,6 +39,17 @@ public void SetBoxName(int box, ReadOnlySpan value) SAV.SetString(GetBoxNameSpan(box), value, 13, StringConverterOption.ClearZero); } + public byte BoxesUnlocked + { + get => Data[Offset + 0x3DD]; + set + { + if (value > SAV.BoxCount) + value = (byte)SAV.BoxCount; + Data[Offset + 0x3DD] = value; + } + } + public string this[int i] { get => GetBoxName(i);