mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-14 16:27:21 +00:00
Add interface for revised savefile types (patches)
SWSH is the first common savefile type that has different revisions after official patches. We want to indicate in the Program Title which revision we're currently editing, because people still are not editing latest-format saves and complaining y no urshifu. Use short descriptions to indicate revision (Base, IoA, CT), rather than magic numbers (v0/v1) or 1.X or 1.X.Y+, because GameFreak can't follow semver rules. go away ranch platinum update, i might handle you another time
This commit is contained in:
parent
8aab4a2d8e
commit
efc17a1271
3 changed files with 24 additions and 2 deletions
|
@ -7,7 +7,7 @@ namespace PKHeX.Core
|
|||
/// <summary>
|
||||
/// Generation 8 <see cref="SaveFile"/> object for <see cref="GameVersion.SWSH"/> games.
|
||||
/// </summary>
|
||||
public sealed class SAV8SWSH : SAV8, ISaveBlock8SWSH, ITrainerStatRecord
|
||||
public sealed class SAV8SWSH : SAV8, ISaveBlock8SWSH, ITrainerStatRecord, ISaveFileRevision
|
||||
{
|
||||
public SAV8SWSH(byte[] data) : this(data, SwishCrypto.Decrypt(data))
|
||||
{
|
||||
|
@ -18,6 +18,7 @@ namespace PKHeX.Core
|
|||
Data = Array.Empty<byte>();
|
||||
AllBlocks = blocks;
|
||||
Blocks = new SaveBlockAccessor8SWSH(this);
|
||||
SaveRevision = Zukan.GetRevision();
|
||||
Initialize();
|
||||
}
|
||||
|
||||
|
@ -25,6 +26,7 @@ namespace PKHeX.Core
|
|||
{
|
||||
AllBlocks = Meta8.GetBlankDataSWSH();
|
||||
Blocks = new SaveBlockAccessor8SWSH(this);
|
||||
SaveRevision = Zukan.GetRevision();
|
||||
Initialize();
|
||||
ClearBoxes();
|
||||
}
|
||||
|
@ -40,6 +42,16 @@ namespace PKHeX.Core
|
|||
Edited = true;
|
||||
}
|
||||
|
||||
public int SaveRevision { get; }
|
||||
|
||||
public string SaveRevisionString => SaveRevision switch
|
||||
{
|
||||
0 => "-Base", // Vanilla
|
||||
1 => "-IoA", // DLC 1: Isle of Armor
|
||||
2 => "-CT", // DLC 2: Crown Tundra
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(SaveRevision)),
|
||||
};
|
||||
|
||||
public IReadOnlyList<SCBlock> AllBlocks { get; }
|
||||
public override bool ChecksumsValid => true;
|
||||
public override string ChecksumInfo => string.Empty;
|
||||
|
@ -103,7 +115,7 @@ namespace PKHeX.Core
|
|||
PokeDex = 0;
|
||||
TeamIndexes.LoadBattleTeams();
|
||||
|
||||
int rev = Zukan.GetRevision();
|
||||
int rev = SaveRevision;
|
||||
if (rev == 0)
|
||||
{
|
||||
m_move = Legal.MaxMoveID_8_O0;
|
||||
|
|
8
PKHeX.Core/Saves/Substructures/Misc/ISaveFileRevision.cs
Normal file
8
PKHeX.Core/Saves/Substructures/Misc/ISaveFileRevision.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
public interface ISaveFileRevision
|
||||
{
|
||||
public int SaveRevision { get; }
|
||||
string SaveRevisionString { get; }
|
||||
}
|
||||
}
|
|
@ -819,6 +819,8 @@ namespace PKHeX.WinForms
|
|||
private static string GetProgramTitle(SaveFile sav)
|
||||
{
|
||||
string title = GetProgramTitle() + $" - {sav.GetType().Name}: ";
|
||||
if (sav is ISaveFileRevision rev)
|
||||
title = title.Insert(title.Length - 2, rev.SaveRevisionString);
|
||||
var ver = GameInfo.GetVersionName(sav.Version);
|
||||
if (Settings.Default.HideSAVDetails)
|
||||
return title + $"[{ver}]";
|
||||
|
|
Loading…
Reference in a new issue