mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-06-03 01:44:19 -05:00
Increase abstraction for arbitrary slot get/set operations, and fracture SAV4 behavior for each game type. Adds: Undo/Redo of party slot changes Fixes: Fixed Gen5 daycare slot 2 reading, and EXP reading Fixes: Some slot color glitchiness Fixed: Box layout editor now hides the flag label if no flags are present Fixed: Gen7 box flags are now shown (unknown purpose lol) Changed: savefile objects are generally smaller (removed a few shared offset fields)
31 lines
1.4 KiB
C#
31 lines
1.4 KiB
C#
namespace PKHeX.Core
|
|
{
|
|
/// <summary>
|
|
/// <see cref="SaveFile"/> format which stores Box Data in a separate buffer from the game data.
|
|
/// </summary>
|
|
public abstract class DualBufferSAV : SaveFile
|
|
{
|
|
protected DualBufferSAV(byte[] data) : base(data) { }
|
|
protected DualBufferSAV() { }
|
|
|
|
// SaveData is chunked into two pieces.
|
|
public byte[] Storage { get; protected set; }
|
|
public byte[] General { get; protected set; }
|
|
|
|
protected abstract int StorageSize { get; }
|
|
protected abstract int GeneralSize { get; }
|
|
protected abstract int StorageStart { get; }
|
|
|
|
/// <inheritdoc />
|
|
public override bool GetFlag(int offset, int bitIndex) => FlagUtil.GetFlag(General, offset, bitIndex);
|
|
|
|
/// <inheritdoc />
|
|
public override void SetFlag(int offset, int bitIndex, bool value) => FlagUtil.SetFlag(General, offset, bitIndex, value);
|
|
|
|
public override PKM GetPartySlot(int offset) => GetDecryptedPKM(General.Slice(offset, SIZE_PARTY));
|
|
|
|
protected override void WritePartySlot(PKM pkm, int offset) => SetData(General, pkm.EncryptedPartyData, offset);
|
|
protected override void WriteStoredSlot(PKM pkm, int offset) => SetData(General, pkm.EncryptedBoxData, offset);
|
|
protected override void WriteBoxSlot(PKM pkm, int offset) => SetData(Storage, pkm.EncryptedBoxData, offset);
|
|
}
|
|
} |