mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-06 13:40:50 -05:00
Relocate some logic
slightly reduces savefile.cs footprint
This commit is contained in:
parent
9a61f0de0f
commit
f2ac29ff4e
|
|
@ -51,13 +51,19 @@ public abstract class SAV6 : SAV_BEEF, ITrainerStatRecord
|
|||
protected int Trainer2 { get; set; } = int.MinValue;
|
||||
protected int WondercardFlags { get; set; } = int.MinValue;
|
||||
protected int PlayTime { get; set; } = int.MinValue;
|
||||
protected int Daycare2 { get; set; } = int.MinValue;
|
||||
protected int LinkInfo { get; set; } = int.MinValue;
|
||||
protected int JPEG { get; set; } = int.MinValue;
|
||||
public int SuperTrain { get; protected set; } = int.MinValue;
|
||||
|
||||
// Accessible as SAV6
|
||||
public int MaisonStats { get; protected set; } = int.MinValue;
|
||||
public int Accessories { get; protected set; } = int.MinValue;
|
||||
public int PSS { get; protected set; } = int.MinValue;
|
||||
public int SUBE { get; protected set; } = int.MinValue;
|
||||
public int BerryField { get; protected set; } = int.MinValue;
|
||||
|
||||
public virtual string JPEGTitle => string.Empty;
|
||||
public virtual byte[] JPEGData => Array.Empty<byte>();
|
||||
|
||||
protected internal const int LongStringLength = 0x22; // bytes, not characters
|
||||
protected internal const int ShortStringLength = 0x1A; // bytes, not characters
|
||||
|
|
|
|||
|
|
@ -172,6 +172,8 @@ private void Initialize()
|
|||
|
||||
public int EonTicket { get; private set; }
|
||||
public int Contest { get; private set; }
|
||||
private int Daycare2 { get; set; }
|
||||
public int SecretBase { get; private set; }
|
||||
|
||||
public Zukan6 Zukan { get; private set; }
|
||||
public Puff6 PuffBlock { get; private set; }
|
||||
|
|
|
|||
|
|
@ -100,8 +100,8 @@ protected virtual byte[] GetFinalData()
|
|||
public bool E => Version == GameVersion.E;
|
||||
public bool FRLG => Version == GameVersion.FRLG;
|
||||
public bool RS => Version == GameVersion.RS;
|
||||
public bool GSC => Version == GameVersion.GS || Version == GameVersion.C;
|
||||
public bool RBY => Version == GameVersion.RBY;
|
||||
public bool GSC => Generation == 2;
|
||||
public bool RBY => Generation == 1;
|
||||
public bool GameCube => new[] { GameVersion.COLO, GameVersion.XD, GameVersion.RSBOX }.Contains(Version);
|
||||
|
||||
public abstract int MaxMoveID { get; }
|
||||
|
|
@ -114,23 +114,15 @@ protected virtual byte[] GetFinalData()
|
|||
|
||||
// Flags
|
||||
public bool HasWondercards => WondercardData > -1;
|
||||
public bool HasSuperTrain => SuperTrain > -1;
|
||||
public bool HasBerryField => BerryField > -1;
|
||||
public bool HasHoF => HoF > -1;
|
||||
public bool HasSecretBase => SecretBase > -1;
|
||||
public bool HasPSS => PSS > -1;
|
||||
public bool HasJPEG => JPEGData.Length > 0;
|
||||
public bool HasBox => Box > -1;
|
||||
public virtual bool HasParty => Party > -1;
|
||||
public bool HasBattleBox => BattleBox > -1;
|
||||
public bool HasFused => Fused > -1;
|
||||
public bool HasDaycare => Daycare > -1;
|
||||
public virtual bool HasPokeDex => PokeDex > -1;
|
||||
public virtual bool HasBoxWallpapers => GetBoxWallpaperOffset(0) > -1;
|
||||
public virtual bool HasNamableBoxes => HasBoxWallpapers;
|
||||
public bool HasPokeBlock => ORAS && !ORASDEMO;
|
||||
public virtual bool HasEvents => EventFlags.Length != 0;
|
||||
public bool HasLink => (ORAS && !ORASDEMO) || XY;
|
||||
|
||||
// Counts
|
||||
protected virtual int GiftCountMax { get; } = int.MinValue;
|
||||
|
|
@ -156,12 +148,7 @@ protected virtual byte[] GetFinalData()
|
|||
public int GTS { get; protected set; } = int.MinValue;
|
||||
public int BattleBox { get; protected set; } = int.MinValue;
|
||||
public int Fused { get; protected set; } = int.MinValue;
|
||||
public int SUBE { get; protected set; } = int.MinValue;
|
||||
public int PokeDex { get; protected set; } = int.MinValue;
|
||||
public int SuperTrain { get; protected set; } = int.MinValue;
|
||||
public int SecretBase { get; protected set; } = int.MinValue;
|
||||
public int PSS { get; protected set; } = int.MinValue;
|
||||
public int BerryField { get; protected set; } = int.MinValue;
|
||||
public int HoF { get; protected set; } = int.MinValue;
|
||||
|
||||
// SAV Properties
|
||||
|
|
@ -401,8 +388,6 @@ public virtual MysteryGiftAlbum GiftAlbum
|
|||
}
|
||||
|
||||
public virtual bool BattleBoxLocked { get => false; set { } }
|
||||
public virtual string JPEGTitle => string.Empty;
|
||||
public virtual byte[] JPEGData => Array.Empty<byte>();
|
||||
public virtual int Country { get => -1; set { } }
|
||||
public virtual int ConsoleRegion { get => -1; set { } }
|
||||
public virtual int SubRegion { get => -1; set { } }
|
||||
|
|
|
|||
|
|
@ -746,7 +746,7 @@ byte[] GetSubsection(byte[] data, int start, int length = -1)
|
|||
/// <param name="sav">SaveFile data to force</param>
|
||||
/// <param name="ver">Version to retrieve for</param>
|
||||
/// <returns>New <see cref="SaveFile"/> object.</returns>
|
||||
public static SaveFile GetG3SaveOverride(SaveFile sav, GameVersion ver)
|
||||
public static SAV3 GetG3SaveOverride(SaveFile sav, GameVersion ver)
|
||||
{
|
||||
switch (ver) // Reset save file info
|
||||
{
|
||||
|
|
|
|||
|
|
@ -678,13 +678,14 @@ private void B_OUTHallofFame_Click(object sender, EventArgs e)
|
|||
|
||||
private void B_JPEG_Click(object sender, EventArgs e)
|
||||
{
|
||||
byte[] jpeg = SAV.JPEGData;
|
||||
if (SAV.JPEGData.Length == 0)
|
||||
var s6 = (SAV6)SAV;
|
||||
byte[] jpeg = s6.JPEGData;
|
||||
if (s6.JPEGData.Length == 0)
|
||||
{
|
||||
WinFormsUtil.Alert(MsgSaveJPEGExportFail);
|
||||
return;
|
||||
}
|
||||
string filename = $"{SAV.JPEGTitle}'s picture";
|
||||
string filename = $"{s6.JPEGTitle}'s picture";
|
||||
var sfd = new SaveFileDialog { FileName = filename, Filter = "JPEG|*.jpeg" };
|
||||
if (sfd.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
|
|
@ -1004,21 +1005,18 @@ private void ToggleViewSubEditors(SaveFile sav)
|
|||
{
|
||||
PAN_BattleBox.Visible = L_BattleBox.Visible = L_ReadOnlyPBB.Visible = sav.HasBattleBox;
|
||||
GB_Daycare.Visible = sav.HasDaycare;
|
||||
B_OpenSecretBase.Enabled = sav.HasSecretBase;
|
||||
B_OpenPokeblocks.Enabled = sav is SAV6AO;
|
||||
B_OpenSecretBase.Enabled = sav is SAV6AO;
|
||||
B_OpenPokepuffs.Enabled = sav is IPokePuff;
|
||||
B_OUTPasserby.Enabled = sav.HasPSS;
|
||||
B_JPEG.Visible = B_OpenLinkInfo.Enabled = B_OpenSuperTraining.Enabled = B_OUTPasserby.Enabled = sav is SAV6XY || sav is SAV6AO;
|
||||
B_OpenBoxLayout.Enabled = sav.HasNamableBoxes;
|
||||
B_OpenWondercards.Enabled = sav.HasWondercards;
|
||||
B_OpenSuperTraining.Enabled = sav.HasSuperTrain;
|
||||
B_OpenHallofFame.Enabled = sav.HasHoF;
|
||||
B_OpenOPowers.Enabled = sav is IOPower;
|
||||
B_OpenPokedex.Enabled = sav.HasPokeDex;
|
||||
B_OpenBerryField.Enabled = sav.HasBerryField && sav.XY;
|
||||
B_OpenBerryField.Enabled = sav is SAV6XY; // oras undocumented
|
||||
B_OpenFriendSafari.Enabled = sav.XY;
|
||||
B_OpenPokeblocks.Enabled = sav.HasPokeBlock;
|
||||
B_JPEG.Visible = sav.HasJPEG;
|
||||
B_OpenEventFlags.Enabled = sav.HasEvents;
|
||||
B_OpenLinkInfo.Enabled = sav.HasLink;
|
||||
B_CGearSkin.Enabled = sav.Generation == 5;
|
||||
B_OpenPokeBeans.Enabled = B_CellsStickers.Enabled = B_FestivalPlaza.Enabled = sav is SAV7;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@ namespace PKHeX.WinForms
|
|||
public partial class SAV_SecretBase : Form
|
||||
{
|
||||
private readonly SaveFile Origin;
|
||||
private readonly SAV6 SAV;
|
||||
private readonly SAV6AO SAV;
|
||||
|
||||
public SAV_SecretBase(SaveFile sav)
|
||||
{
|
||||
InitializeComponent();
|
||||
WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
|
||||
SAV = (SAV6)(Origin = sav).Clone();
|
||||
SAV = (SAV6AO)(Origin = sav).Clone();
|
||||
abilitylist = GameInfo.Strings.abilitylist;
|
||||
|
||||
SetupComboBoxes();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user