From fd4dd6e2fb3936e35a1a1b5b7909a8a7db4c9e66 Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 26 Nov 2021 19:54:07 -0800 Subject: [PATCH] Indicate teamlocks in boxes --- PKHeX.Core/Saves/SAV8BS.cs | 17 ++++++++++++++++- .../Saves/Substructures/Gen8/BS/BoxLayout8b.cs | 3 +++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/PKHeX.Core/Saves/SAV8BS.cs b/PKHeX.Core/Saves/SAV8BS.cs index da9dbdcd2..4e78b6b80 100644 --- a/PKHeX.Core/Saves/SAV8BS.cs +++ b/PKHeX.Core/Saves/SAV8BS.cs @@ -83,8 +83,10 @@ private void Initialize() Box = 0x14EF4; Party = PartyInfo.Offset; PokeDex = Zukan.PokeDex; - BoxLayout.LoadBattleTeams(); DaycareOffset = Daycare.Offset; + + ReloadBattleTeams(); + TeamSlots = BoxLayout.TeamSlots; } public override bool HasEvents => true; @@ -143,6 +145,19 @@ protected void ReloadBattleTeams() BoxLayout.LoadBattleTeams(); } + public override StorageSlotFlag GetSlotFlags(int index) + { + int team = Array.IndexOf(TeamSlots, index); + if (team < 0) + return StorageSlotFlag.None; + + team /= 6; + var val = (StorageSlotFlag)((int)StorageSlotFlag.BattleTeam1 << team); + if (BoxLayout.GetIsTeamLocked(team)) + val |= StorageSlotFlag.Locked; + return val; + } + #region Checksums private const int HashOffset = SaveUtil.SIZE_G8BDSP - 0x10; diff --git a/PKHeX.Core/Saves/Substructures/Gen8/BS/BoxLayout8b.cs b/PKHeX.Core/Saves/Substructures/Gen8/BS/BoxLayout8b.cs index 1896d30dc..28e87ca15 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/BS/BoxLayout8b.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/BS/BoxLayout8b.cs @@ -98,6 +98,7 @@ public void SaveBattleTeams() } } + // bitflags public byte LockedTeam { get => Data[Offset + 0x61C]; @@ -126,6 +127,8 @@ public byte CurrentBox set => Data[Offset + 0x61E] = value; } + public bool GetIsTeamLocked(int team) => (LockedTeam & (1 << team)) != 0; + public int GetBoxWallpaperOffset(int box) => Offset + 0x620 + box; public int GetBoxWallpaper(int box)