mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 04:23:12 +00:00
Change signatures to use readonly if possible
Extract get/set team methods for battle video
This commit is contained in:
parent
c1ae32ba8b
commit
6f7602f2ad
47 changed files with 317 additions and 313 deletions
|
@ -68,10 +68,10 @@ namespace PKHeX.Core
|
|||
if (!SanityCheckSaveInfo(s1, s2))
|
||||
return;
|
||||
|
||||
bool[] oldBits = s1.EventFlags;
|
||||
bool[] newBits = s2.EventFlags;
|
||||
var oldConst = s1.EventConsts;
|
||||
var newConst = s2.EventConsts;
|
||||
bool[] oldBits = s1.GetEventFlags();
|
||||
bool[] newBits = s2.GetEventFlags();
|
||||
var oldConst = s1.GetEventConsts();
|
||||
var newConst = s2.GetEventConsts();
|
||||
|
||||
for (int i = 0; i < newBits.Length; i++)
|
||||
{
|
||||
|
|
|
@ -325,7 +325,10 @@ namespace PKHeX.Core
|
|||
public override int Stat_SPE { get => BitConverter.ToUInt16(Data, 0x96); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x96); }
|
||||
public override int Stat_SPA { get => BitConverter.ToUInt16(Data, 0x98); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x98); }
|
||||
public override int Stat_SPD { get => BitConverter.ToUInt16(Data, 0x9A); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x9A); }
|
||||
public byte[] HeldMailData { get => Data.Slice(0x9C, 0x38); set => value.CopyTo(Data, 0x9C); }
|
||||
|
||||
public byte[] GetHeldMailData() => Data.Slice(0x9C, 0x38);
|
||||
public void SetHeldMailData(byte[] value) => value.CopyTo(Data, 0x9C);
|
||||
|
||||
#endregion
|
||||
|
||||
// Methods
|
||||
|
|
|
@ -373,7 +373,7 @@ namespace PKHeX.Core
|
|||
|
||||
private readonly ushort[] LegalItems = Legal.Pouch_Items_RBY;
|
||||
|
||||
public override InventoryPouch[] Inventory
|
||||
public override IReadOnlyList<InventoryPouch> Inventory
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -460,7 +460,7 @@ namespace PKHeX.Core
|
|||
private static ushort[] LegalBalls => Legal.Pouch_Ball_GSC;
|
||||
private static ushort[] LegalTMHMs => Legal.Pouch_TMHM_GSC;
|
||||
|
||||
public override InventoryPouch[] Inventory
|
||||
public override IReadOnlyList<InventoryPouch> Inventory
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -654,23 +654,23 @@ namespace PKHeX.Core
|
|||
|
||||
/// <summary>All Event Constant values for the save file</summary>
|
||||
/// <remarks>These are all bytes</remarks>
|
||||
public override ushort[] EventConsts
|
||||
public override ushort[] GetEventConsts()
|
||||
{
|
||||
get
|
||||
{
|
||||
ushort[] Constants = new ushort[EventConstMax];
|
||||
for (int i = 0; i < Constants.Length; i++)
|
||||
Constants[i] = Data[EventConst + i];
|
||||
return Constants;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value.Length != EventConstMax)
|
||||
return;
|
||||
ushort[] Constants = new ushort[EventConstMax];
|
||||
for (int i = 0; i < Constants.Length; i++)
|
||||
Constants[i] = Data[EventConst + i];
|
||||
return Constants;
|
||||
}
|
||||
|
||||
for (int i = 0; i < value.Length; i++)
|
||||
Data[EventConst + i] = Math.Min(byte.MaxValue, (byte)value[i]);
|
||||
}
|
||||
/// <summary>All Event Constant values for the save file</summary>
|
||||
/// <remarks>These are all bytes</remarks>
|
||||
public override void SetEventConsts(ushort[] value)
|
||||
{
|
||||
if (value.Length != EventConstMax)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < value.Length; i++)
|
||||
Data[EventConst + i] = Math.Min(byte.MaxValue, (byte)value[i]);
|
||||
}
|
||||
|
||||
// Misc
|
||||
|
|
|
@ -625,7 +625,7 @@ namespace PKHeX.Core
|
|||
|
||||
private int OFS_PCItem, OFS_PouchHeldItem, OFS_PouchKeyItem, OFS_PouchBalls, OFS_PouchTMHM, OFS_PouchBerry, OFS_Decorations;
|
||||
|
||||
public override InventoryPouch[] Inventory
|
||||
public override IReadOnlyList<InventoryPouch> Inventory
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -367,7 +367,7 @@ namespace PKHeX.Core
|
|||
public uint Coupons { get => BigEndian.ToUInt32(Data, 0xB00); set => BigEndian.GetBytes(value).CopyTo(Data, 0xB00); }
|
||||
public string RUI_Name { get => GetString(0xB3A, 20); set => SetString(value, 10).CopyTo(Data, 0xB3A); }
|
||||
|
||||
public override InventoryPouch[] Inventory
|
||||
public override IReadOnlyList<InventoryPouch> Inventory
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -332,7 +332,7 @@ namespace PKHeX.Core
|
|||
*/
|
||||
}
|
||||
|
||||
public override InventoryPouch[] Inventory
|
||||
public override IReadOnlyList<InventoryPouch> Inventory
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -928,28 +928,27 @@ namespace PKHeX.Core
|
|||
}
|
||||
|
||||
/// <summary> All Event Constant values for the savegame </summary>
|
||||
public override ushort[] EventConsts
|
||||
public override ushort[] GetEventConsts()
|
||||
{
|
||||
get
|
||||
{
|
||||
if (EventConstMax <= 0)
|
||||
return Array.Empty<ushort>();
|
||||
if (EventConstMax <= 0)
|
||||
return Array.Empty<ushort>();
|
||||
|
||||
ushort[] Constants = new ushort[EventConstMax];
|
||||
for (int i = 0; i < Constants.Length; i++)
|
||||
Constants[i] = BitConverter.ToUInt16(General, EventConst + (i * 2));
|
||||
return Constants;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (EventConstMax <= 0)
|
||||
return;
|
||||
if (value.Length != EventConstMax)
|
||||
return;
|
||||
ushort[] Constants = new ushort[EventConstMax];
|
||||
for (int i = 0; i < Constants.Length; i++)
|
||||
Constants[i] = BitConverter.ToUInt16(General, EventConst + (i * 2));
|
||||
return Constants;
|
||||
}
|
||||
|
||||
for (int i = 0; i < value.Length; i++)
|
||||
BitConverter.GetBytes(value[i]).CopyTo(General, EventConst + (i * 2));
|
||||
}
|
||||
/// <summary> All Event Constant values for the savegame </summary>
|
||||
public override void SetEventConsts(ushort[] value)
|
||||
{
|
||||
if (EventConstMax <= 0)
|
||||
return;
|
||||
if (value.Length != EventConstMax)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < value.Length; i++)
|
||||
BitConverter.GetBytes(value[i]).CopyTo(General, EventConst + (i * 2));
|
||||
}
|
||||
|
||||
// Seals
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace PKHeX.Core
|
|||
}
|
||||
#endregion
|
||||
|
||||
public override InventoryPouch[] Inventory
|
||||
public override IReadOnlyList<InventoryPouch> Inventory
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -118,7 +118,7 @@ namespace PKHeX.Core
|
|||
}
|
||||
#endregion
|
||||
|
||||
public override InventoryPouch[] Inventory
|
||||
public override IReadOnlyList<InventoryPouch> Inventory
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -150,20 +150,18 @@ namespace PKHeX.Core
|
|||
public PokegearNumber GetCallerAtIndex(int index) => (PokegearNumber)General[OFS_GearRolodex + index];
|
||||
public void SetCallerAtIndex(int index, PokegearNumber caller) => General[OFS_GearRolodex + index] = (byte)caller;
|
||||
|
||||
public PokegearNumber[] PokeGearRoloDex
|
||||
public PokegearNumber[] GetPokeGearRoloDex()
|
||||
{
|
||||
get
|
||||
{
|
||||
var arr = new PokegearNumber[GearMaxCallers];
|
||||
for (int i = 0; i < arr.Length; i++)
|
||||
arr[i] = GetCallerAtIndex(i);
|
||||
return arr;
|
||||
}
|
||||
set
|
||||
{
|
||||
for (int i = 0; i < value.Length; i++)
|
||||
SetCallerAtIndex(i, value[i]);
|
||||
}
|
||||
var arr = new PokegearNumber[GearMaxCallers];
|
||||
for (int i = 0; i < arr.Length; i++)
|
||||
arr[i] = GetCallerAtIndex(i);
|
||||
return arr;
|
||||
}
|
||||
|
||||
public void SetPokeGearRoloDex(IReadOnlyList<PokegearNumber> value)
|
||||
{
|
||||
for (int i = 0; i < value.Count; i++)
|
||||
SetCallerAtIndex(i, value[i]);
|
||||
}
|
||||
|
||||
public void PokeGearUnlockAllCallers()
|
||||
|
@ -211,11 +209,8 @@ namespace PKHeX.Core
|
|||
public uint PokewalkerSteps { get => BitConverter.ToUInt32(General, OFS_WALKER); set => SetData(General, BitConverter.GetBytes(value), OFS_WALKER); }
|
||||
public uint PokewalkerWatts { get => BitConverter.ToUInt32(General, OFS_WALKER + 0x4); set => SetData(General, BitConverter.GetBytes(value), OFS_WALKER + 0x4); }
|
||||
|
||||
public bool[] PokewalkerCoursesUnlocked
|
||||
{
|
||||
get => ArrayUtil.GitBitFlagArray(General, OFS_WALKER + 0x8, 32);
|
||||
set => ArrayUtil.SetBitFlagArray(General, OFS_WALKER + 0x8, value);
|
||||
}
|
||||
public bool[] GetPokewalkerCoursesUnlocked() => ArrayUtil.GitBitFlagArray(General, OFS_WALKER + 0x8, 32);
|
||||
public void SetPokewalkerCoursesUnlocked(bool[] value) => ArrayUtil.SetBitFlagArray(General, OFS_WALKER + 0x8, value);
|
||||
|
||||
public void PokewalkerCoursesSetAll(uint value = 0x07FF_FFFFu) => SetData(General, BitConverter.GetBytes(value), OFS_WALKER + 0x8);
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ namespace PKHeX.Core
|
|||
}
|
||||
#endregion
|
||||
|
||||
public override InventoryPouch[] Inventory
|
||||
public override IReadOnlyList<InventoryPouch> Inventory
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -168,31 +168,21 @@ namespace PKHeX.Core
|
|||
protected int OFS_UG_Items;
|
||||
|
||||
public const int UG_POUCH_SIZE = 0x28; // 40 for each of the inventory pouches
|
||||
public byte[] UGI_Traps
|
||||
{
|
||||
get => General.Slice(OFS_UG_Items, UG_POUCH_SIZE);
|
||||
set => SetData(General, value, OFS_UG_Items);
|
||||
}
|
||||
|
||||
public byte[] UGI_Goods
|
||||
{
|
||||
get => General.Slice(OFS_UG_Items + 0x28, UG_POUCH_SIZE);
|
||||
set => SetData(General, value, OFS_UG_Items + 0x28);
|
||||
}
|
||||
public byte[] GetUGI_Traps() => General.Slice(OFS_UG_Items, UG_POUCH_SIZE);
|
||||
public void SetUGI_Traps(byte[] value) => SetData(General, value, OFS_UG_Items);
|
||||
|
||||
public byte[] UGI_Treasures
|
||||
{
|
||||
get => General.Slice(OFS_UG_Items + 0x50, UG_POUCH_SIZE);
|
||||
set => SetData(General, value, OFS_UG_Items + 0x50);
|
||||
}
|
||||
public byte[] GetUGI_Goods() => General.Slice(OFS_UG_Items + 0x28, UG_POUCH_SIZE);
|
||||
public void SetUGI_Goods(byte[] value) => SetData(General, value, OFS_UG_Items + 0x28);
|
||||
|
||||
public byte[] GetUGI_Treasures() => General.Slice(OFS_UG_Items + 0x50, UG_POUCH_SIZE);
|
||||
public void SetUGI_Treasures(byte[] value) => SetData(General, value, OFS_UG_Items + 0x50);
|
||||
|
||||
// first 40 are the sphere type, last 40 are the sphere sizes
|
||||
public byte[] GetUGI_Spheres() => General.Slice(OFS_UG_Items + 0x78, UG_POUCH_SIZE * 2);
|
||||
public void SetUGI_Spheres(byte[] value) => SetData(General, value, OFS_UG_Items + 0x78);
|
||||
|
||||
public byte[] UGI_Spheres
|
||||
{
|
||||
get => General.Slice(OFS_UG_Items + 0x78, UG_POUCH_SIZE * 2); // first 40 are the sphere type, last 40 are the sphere sizes
|
||||
set => SetData(General, value, OFS_UG_Items + 0x78);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
public enum PoketchColor
|
||||
|
|
|
@ -127,7 +127,7 @@ namespace PKHeX.Core
|
|||
public override uint SecondsToStart { get => BitConverter.ToUInt32(Data, AdventureInfo + 0x34); set => BitConverter.GetBytes(value).CopyTo(Data, AdventureInfo + 0x34); }
|
||||
public override uint SecondsToFame { get => BitConverter.ToUInt32(Data, AdventureInfo + 0x3C); set => BitConverter.GetBytes(value).CopyTo(Data, AdventureInfo + 0x3C); }
|
||||
public override MysteryGiftAlbum GiftAlbum { get => Mystery.GiftAlbum; set => Mystery.GiftAlbum = (EncryptedMysteryGiftAlbum)value; }
|
||||
public override InventoryPouch[] Inventory { get => Items.Inventory; set => Items.Inventory = value; }
|
||||
public override IReadOnlyList<InventoryPouch> Inventory { get => Items.Inventory; set => Items.Inventory = value; }
|
||||
|
||||
protected override void SetDex(PKM pkm) => Zukan.SetDex(pkm);
|
||||
public override bool GetCaught(int species) => Zukan.GetCaught(species);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
|
@ -47,7 +48,7 @@ namespace PKHeX.Core
|
|||
public int GetBattleBoxSlot(int slot) => BattleBoxOffset + (slot * SIZE_STORED);
|
||||
|
||||
public virtual string JPEGTitle => string.Empty;
|
||||
public virtual byte[] JPEGData => Array.Empty<byte>();
|
||||
public virtual byte[] GetJPEGData() => Array.Empty<byte>();
|
||||
|
||||
protected internal const int LongStringLength = 0x22; // bytes, not characters
|
||||
protected internal const int ShortStringLength = 0x1A; // bytes, not characters
|
||||
|
@ -75,7 +76,7 @@ namespace PKHeX.Core
|
|||
|
||||
public override uint SecondsToStart { get => GameTime.SecondsToStart; set => GameTime.SecondsToStart = value; }
|
||||
public override uint SecondsToFame { get => GameTime.SecondsToFame; set => GameTime.SecondsToFame = value; }
|
||||
public override InventoryPouch[] Inventory { get => Items.Inventory; set => Items.Inventory = value; }
|
||||
public override IReadOnlyList<InventoryPouch> Inventory { get => Items.Inventory; set => Items.Inventory = value; }
|
||||
|
||||
// Daycare
|
||||
public override int DaycareSeedSize => 16;
|
||||
|
|
|
@ -186,8 +186,7 @@ namespace PKHeX.Core
|
|||
}
|
||||
|
||||
public override string JPEGTitle => HasJPPEGData ? string.Empty : Util.TrimFromZero(Encoding.Unicode.GetString(Data, JPEG, 0x1A));
|
||||
public override byte[] JPEGData => HasJPPEGData ? Array.Empty<byte>() : GetData(JPEG + 0x54, 0xE004);
|
||||
|
||||
public override byte[] GetJPEGData() => HasJPPEGData ? Array.Empty<byte>() : GetData(JPEG + 0x54, 0xE004);
|
||||
private bool HasJPPEGData => Data[JPEG + 0x54] == 0xFF;
|
||||
|
||||
protected override bool[] MysteryGiftReceivedFlags { get => Blocks.MysteryGift.GetReceivedFlags(); set => Blocks.MysteryGift.SetReceivedFlags(value); }
|
||||
|
|
|
@ -118,8 +118,7 @@ namespace PKHeX.Core
|
|||
}
|
||||
|
||||
public override string JPEGTitle => HasJPPEGData ? string.Empty : Util.TrimFromZero(Encoding.Unicode.GetString(Data, JPEG, 0x1A));
|
||||
public override byte[] JPEGData => HasJPPEGData ? Array.Empty<byte>() : GetData(JPEG + 0x54, 0xE004);
|
||||
|
||||
public override byte[] GetJPEGData() => HasJPPEGData ? Array.Empty<byte>() : GetData(JPEG + 0x54, 0xE004);
|
||||
private bool HasJPPEGData => Data[JPEG + 0x54] == 0xFF;
|
||||
|
||||
public void UnlockAllFriendSafariSlots()
|
||||
|
|
|
@ -162,7 +162,7 @@ namespace PKHeX.Core
|
|||
public int GetRecordOffset(int recordID) => Records.GetRecordOffset(recordID);
|
||||
|
||||
// Inventory
|
||||
public override InventoryPouch[] Inventory { get => Items.Inventory; set => Items.Inventory = value; }
|
||||
public override IReadOnlyList<InventoryPouch> Inventory { get => Items.Inventory; set => Items.Inventory = value; }
|
||||
|
||||
// Storage
|
||||
public override int GetPartyOffset(int slot) => Party + (SIZE_PARTY * slot);
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace PKHeX.Core
|
|||
|
||||
// Save Block accessors
|
||||
|
||||
public override InventoryPouch[] Inventory { get => Blocks.Items.Inventory; set => Blocks.Items.Inventory = value; }
|
||||
public override IReadOnlyList<InventoryPouch> Inventory { get => Blocks.Items.Inventory; set => Blocks.Items.Inventory = value; }
|
||||
|
||||
// Feature Overrides
|
||||
public override int Generation => 7;
|
||||
|
|
|
@ -95,7 +95,7 @@ namespace PKHeX.Core
|
|||
public override int PlayedSeconds { get => Played.PlayedSeconds; set => Played.PlayedSeconds = value; }
|
||||
|
||||
// Inventory
|
||||
public override InventoryPouch[] Inventory { get => Items.Inventory; set => Items.Inventory = value; }
|
||||
public override IReadOnlyList<InventoryPouch> Inventory { get => Items.Inventory; set => Items.Inventory = value; }
|
||||
|
||||
// Storage
|
||||
public override int GetPartyOffset(int slot) => Party + (SIZE_PARTY * slot);
|
||||
|
|
|
@ -122,59 +122,57 @@ namespace PKHeX.Core
|
|||
#endregion
|
||||
|
||||
#region Event Work
|
||||
public virtual bool HasEvents => EventFlags.Length != 0;
|
||||
public virtual bool HasEvents => GetEventFlags().Length != 0;
|
||||
protected virtual int EventFlagMax { get; } = int.MinValue;
|
||||
protected virtual int EventConstMax { get; } = int.MinValue;
|
||||
protected int EventFlag { get; set; } = int.MinValue;
|
||||
protected int EventConst { get; set; } = int.MinValue;
|
||||
|
||||
/// <summary> All Event Flag values for the savegame </summary>
|
||||
public bool[] EventFlags
|
||||
public bool[] GetEventFlags()
|
||||
{
|
||||
get
|
||||
{
|
||||
if (EventFlagMax < 0)
|
||||
return Array.Empty<bool>();
|
||||
if (EventFlagMax < 0)
|
||||
return Array.Empty<bool>();
|
||||
|
||||
bool[] Flags = new bool[EventFlagMax];
|
||||
for (int i = 0; i < Flags.Length; i++)
|
||||
Flags[i] = GetEventFlag(i);
|
||||
return Flags;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (EventFlagMax < 0)
|
||||
return;
|
||||
if (value.Length != EventFlagMax)
|
||||
return;
|
||||
for (int i = 0; i < value.Length; i++)
|
||||
SetEventFlag(i, value[i]);
|
||||
}
|
||||
bool[] result = new bool[EventFlagMax];
|
||||
for (int i = 0; i < result.Length; i++)
|
||||
result[i] = GetEventFlag(i);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary> All Event Flag values for the savegame </summary>
|
||||
public void SetEventFlags(bool[] value)
|
||||
{
|
||||
if (EventFlagMax < 0)
|
||||
return;
|
||||
if (value.Length != EventFlagMax)
|
||||
return;
|
||||
for (int i = 0; i < value.Length; i++)
|
||||
SetEventFlag(i, value[i]);
|
||||
}
|
||||
|
||||
/// <summary> All Event Constant values for the savegame </summary>
|
||||
public virtual ushort[] EventConsts
|
||||
public virtual ushort[] GetEventConsts()
|
||||
{
|
||||
get
|
||||
{
|
||||
if (EventConstMax <= 0 || Data.Length == 0)
|
||||
return Array.Empty<ushort>();
|
||||
if (EventConstMax <= 0 || Data.Length == 0)
|
||||
return Array.Empty<ushort>();
|
||||
|
||||
ushort[] Constants = new ushort[EventConstMax];
|
||||
for (int i = 0; i < Constants.Length; i++)
|
||||
Constants[i] = BitConverter.ToUInt16(Data, EventConst + (i * 2));
|
||||
return Constants;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (EventConstMax <= 0)
|
||||
return;
|
||||
if (value.Length != EventConstMax)
|
||||
return;
|
||||
ushort[] Constants = new ushort[EventConstMax];
|
||||
for (int i = 0; i < Constants.Length; i++)
|
||||
Constants[i] = BitConverter.ToUInt16(Data, EventConst + (i * 2));
|
||||
return Constants;
|
||||
}
|
||||
|
||||
for (int i = 0; i < value.Length; i++)
|
||||
BitConverter.GetBytes(value[i]).CopyTo(Data, EventConst + (i * 2));
|
||||
}
|
||||
/// <summary> All Event Constant values for the savegame </summary>
|
||||
public virtual void SetEventConsts(ushort[] value)
|
||||
{
|
||||
if (EventConstMax <= 0)
|
||||
return;
|
||||
if (value.Length != EventConstMax)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < value.Length; i++)
|
||||
BitConverter.GetBytes(value[i]).CopyTo(Data, EventConst + (i * 2));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -220,7 +218,7 @@ namespace PKHeX.Core
|
|||
public virtual void SetFlag(int offset, int bitIndex, bool value) => FlagUtil.SetFlag(Data, offset, bitIndex, value);
|
||||
#endregion
|
||||
|
||||
public virtual InventoryPouch[] Inventory { get; set; } = Array.Empty<InventoryPouch>();
|
||||
public virtual IReadOnlyList<InventoryPouch> Inventory { get => Array.Empty<InventoryPouch>(); set { } }
|
||||
|
||||
#region Mystery Gift
|
||||
protected virtual int GiftCountMax { get; } = int.MinValue;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
// ReSharper disable UnusedType.Local
|
||||
|
@ -10,6 +11,10 @@ namespace PKHeX.Core
|
|||
internal const int SIZE = 0x2E60;
|
||||
private const string NPC = "NPC";
|
||||
private readonly byte[] Data;
|
||||
private const int PlayerCount = 4;
|
||||
|
||||
public override IReadOnlyList<PKM> BattlePKMs => PlayerTeams.SelectMany(t => t).ToArray();
|
||||
public override int Generation => 6;
|
||||
|
||||
internal new static bool IsValid(byte[] data)
|
||||
{
|
||||
|
@ -44,66 +49,69 @@ namespace PKHeX.Core
|
|||
public int IntroID { get => BitConverter.ToUInt16(Data, 0x1E4); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x1E4); }
|
||||
public int MusicID { get => BitConverter.ToUInt16(Data, 0x1F0); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x1F0); }
|
||||
|
||||
public override PKM[] BattlePKMs => PlayerTeams.SelectMany(t => t).ToArray();
|
||||
public override int Generation => 6;
|
||||
|
||||
public string[] PlayerNames
|
||||
public string[] GetPlayerNames()
|
||||
{
|
||||
get
|
||||
string[] trainers = new string[PlayerCount];
|
||||
for (int i = 0; i < PlayerCount; i++)
|
||||
{
|
||||
string[] trainers = new string[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
trainers[i] = Util.TrimFromZero(Encoding.Unicode.GetString(Data, 0xEC + (0x1A * i), 0x1A));
|
||||
if (string.IsNullOrWhiteSpace(trainers[i]))
|
||||
trainers[i] = NPC;
|
||||
}
|
||||
return trainers;
|
||||
trainers[i] = Util.TrimFromZero(Encoding.Unicode.GetString(Data, 0xEC + (0x1A * i), 0x1A));
|
||||
if (string.IsNullOrWhiteSpace(trainers[i]))
|
||||
trainers[i] = NPC;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value.Length != 4)
|
||||
return;
|
||||
return trainers;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
string tr = value[i] == NPC ? string.Empty : value[i];
|
||||
Encoding.Unicode.GetBytes(tr.PadRight(0x1A/2)).CopyTo(Data, 0xEC + (0x1A * i));
|
||||
}
|
||||
public void SetPlayerNames(IReadOnlyList<string> value)
|
||||
{
|
||||
if (value.Count != PlayerCount)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < PlayerCount; i++)
|
||||
{
|
||||
string tr = value[i] == NPC ? string.Empty : value[i];
|
||||
Encoding.Unicode.GetBytes(tr.PadRight(0x1A / 2)).CopyTo(Data, 0xEC + (0x1A * i));
|
||||
}
|
||||
}
|
||||
|
||||
public PKM[][] PlayerTeams
|
||||
public IReadOnlyList<PKM[]> PlayerTeams
|
||||
{
|
||||
get
|
||||
{
|
||||
var Teams = new PKM[4][];
|
||||
const int start = 0xE18;
|
||||
for (int t = 0; t < 4; t++)
|
||||
{
|
||||
Teams[t] = new PKM[6];
|
||||
for (int p = 0; p < 6; p++)
|
||||
{
|
||||
int offset = start + (PokeCrypto.SIZE_6PARTY*((t * 6) + p));
|
||||
offset += 8*(((t * 6) + p)/6); // 8 bytes padding between teams
|
||||
Teams[t][p] = new PK6(Data.Slice(offset, PokeCrypto.SIZE_6PARTY)) {Identifier = $"Team {t}, Slot {p}"};
|
||||
}
|
||||
}
|
||||
var Teams = new PKM[PlayerCount][];
|
||||
for (int t = 0; t < PlayerCount; t++)
|
||||
Teams[t] = GetTeam(t);
|
||||
return Teams;
|
||||
}
|
||||
set
|
||||
{
|
||||
var Teams = value;
|
||||
const int start = 0xE18;
|
||||
for (int t = 0; t < 4; t++)
|
||||
{
|
||||
for (int p = 0; p < 6; p++)
|
||||
{
|
||||
int offset = start + (PokeCrypto.SIZE_6PARTY*((t * 6) + p));
|
||||
offset += 8*(((t * 6) + p)/6); // 8 bytes padding between teams
|
||||
Teams[t][p].EncryptedPartyData.CopyTo(Data, offset);
|
||||
}
|
||||
}
|
||||
for (int t = 0; t < PlayerCount; t++)
|
||||
SetTeam(Teams[t], t);
|
||||
}
|
||||
}
|
||||
|
||||
public PKM[] GetTeam(int t)
|
||||
{
|
||||
var team = new PKM[6];
|
||||
const int start = 0xE18;
|
||||
for (int p = 0; p < 6; p++)
|
||||
{
|
||||
int offset = start + (PokeCrypto.SIZE_6PARTY * ((t * 6) + p));
|
||||
offset += 8 * (((t * 6) + p) / 6); // 8 bytes padding between teams
|
||||
team[p] = new PK6(Data.Slice(offset, PokeCrypto.SIZE_6PARTY)) { Identifier = $"Team {t}, Slot {p}" };
|
||||
}
|
||||
|
||||
return team;
|
||||
}
|
||||
|
||||
public void SetTeam(IReadOnlyList<PKM> team, int t)
|
||||
{
|
||||
const int start = 0xE18;
|
||||
for (int p = 0; p < 6; p++)
|
||||
{
|
||||
int offset = start + (PokeCrypto.SIZE_6PARTY * ((t * 6) + p));
|
||||
offset += 8 * (((t * 6) + p) / 6); // 8 bytes padding between teams
|
||||
team[p].EncryptedPartyData.CopyTo(Data, offset);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
|
@ -7,78 +8,79 @@ namespace PKHeX.Core
|
|||
public sealed class BV7 : BattleVideo
|
||||
{
|
||||
internal const int SIZE = 0x2BC0;
|
||||
private const string NPC = "NPC";
|
||||
private const int PlayerCount = 4;
|
||||
|
||||
internal new static bool IsValid(byte[] data)
|
||||
{
|
||||
return data.Length == SIZE;
|
||||
}
|
||||
|
||||
public BV7(byte[] data)
|
||||
{
|
||||
Data = (byte[])data.Clone();
|
||||
}
|
||||
|
||||
private readonly byte[] Data;
|
||||
public override PKM[] BattlePKMs => PlayerTeams.SelectMany(t => t).ToArray();
|
||||
public override int Generation => 7;
|
||||
private readonly byte[] Data;
|
||||
|
||||
private PKM[][] PlayerTeams
|
||||
public override IReadOnlyList<PKM> BattlePKMs => PlayerTeams.SelectMany(t => t).ToArray();
|
||||
internal new static bool IsValid(byte[] data) => data.Length == SIZE;
|
||||
|
||||
public BV7(byte[] data) => Data = (byte[])data.Clone();
|
||||
|
||||
private static readonly int[] offsets = { 0xE41, 0x145E, 0x1A7B, 0x2098 };
|
||||
|
||||
public IReadOnlyList<PKM[]> PlayerTeams
|
||||
{
|
||||
get
|
||||
{
|
||||
var Teams = new PKM[4][];
|
||||
int[] offsets = {0xE41, 0x145E, 0x1A7B, 0x2098};
|
||||
for (int t = 0; t < 4; t++)
|
||||
{
|
||||
Teams[t] = new PKM[6];
|
||||
for (int p = 0; p < 6; p++)
|
||||
{
|
||||
int offset = offsets[t] + (PokeCrypto.SIZE_6PARTY * p);
|
||||
Teams[t][p] = new PK7(Data.Slice(offset, PokeCrypto.SIZE_6STORED)) {Identifier = $"Team {t}, Slot {p}"};
|
||||
}
|
||||
}
|
||||
var Teams = new PKM[PlayerCount][];
|
||||
for (int t = 0; t < PlayerCount; t++)
|
||||
Teams[t] = GetTeam(t);
|
||||
return Teams;
|
||||
}
|
||||
set
|
||||
{
|
||||
var Teams = value;
|
||||
int[] offsets = { 0xE41, 0x145E, 0x1A7B, 0x2098 };
|
||||
for (int t = 0; t < 4; t++)
|
||||
{
|
||||
for (int p = 0; p < 6; p++)
|
||||
{
|
||||
int offset = offsets[t] + (PokeCrypto.SIZE_6PARTY * p);
|
||||
Teams[t][p].EncryptedPartyData.CopyTo(Data, offset);
|
||||
}
|
||||
}
|
||||
for (int t = 0; t < PlayerCount; t++)
|
||||
SetTeam(value[t], t);
|
||||
}
|
||||
}
|
||||
|
||||
private const string NPC = "NPC";
|
||||
|
||||
public string[] PlayerNames
|
||||
public PKM[] GetTeam(int teamIndex)
|
||||
{
|
||||
get
|
||||
var team = new PKM[6];
|
||||
var ofs = offsets[teamIndex];
|
||||
for (int p = 0; p < 6; p++)
|
||||
{
|
||||
string[] trainers = new string[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
trainers[i] = Util.TrimFromZero(Encoding.Unicode.GetString(Data, 0x12C + (0x1A * i), 0x1A));
|
||||
if (string.IsNullOrWhiteSpace(trainers[i]))
|
||||
trainers[i] = NPC;
|
||||
}
|
||||
return trainers;
|
||||
int offset = ofs + (PokeCrypto.SIZE_6PARTY * p);
|
||||
team[p] = new PK7(Data.Slice(offset, PokeCrypto.SIZE_6STORED)) { Identifier = $"Team {teamIndex}, Slot {p}" };
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value.Length != 4)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
string tr = value[i] == NPC ? string.Empty : value[i];
|
||||
Encoding.Unicode.GetBytes(tr.PadRight(0x1A / 2)).CopyTo(Data, 0xEC + (0x1A * i));
|
||||
}
|
||||
return team;
|
||||
}
|
||||
|
||||
public void SetTeam(IReadOnlyList<PKM> team, int teamIndex)
|
||||
{
|
||||
var ofs = offsets[teamIndex];
|
||||
for (int p = 0; p < 6; p++)
|
||||
{
|
||||
int offset = ofs + (PokeCrypto.SIZE_6PARTY * p);
|
||||
team[p].EncryptedPartyData.CopyTo(Data, offset);
|
||||
}
|
||||
}
|
||||
|
||||
public string[] GetPlayerNames()
|
||||
{
|
||||
string[] trainers = new string[PlayerCount];
|
||||
for (int i = 0; i < PlayerCount; i++)
|
||||
{
|
||||
trainers[i] = Util.TrimFromZero(Encoding.Unicode.GetString(Data, 0x12C + (0x1A * i), 0x1A));
|
||||
if (string.IsNullOrWhiteSpace(trainers[i]))
|
||||
trainers[i] = NPC;
|
||||
}
|
||||
return trainers;
|
||||
}
|
||||
|
||||
public void SetPlayerNames(IReadOnlyList<string> value)
|
||||
{
|
||||
if (value.Count != PlayerCount)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < PlayerCount; i++)
|
||||
{
|
||||
string tr = value[i] == NPC ? string.Empty : value[i];
|
||||
Encoding.Unicode.GetBytes(tr.PadRight(0x1A / 2)).CopyTo(Data, 0xEC + (0x1A * i));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace PKHeX.Core
|
|||
{
|
||||
public abstract class BattleVideo : IPokeGroup
|
||||
{
|
||||
public abstract PKM[] BattlePKMs { get; }
|
||||
public abstract IReadOnlyList<PKM> BattlePKMs { get; }
|
||||
public abstract int Generation { get; }
|
||||
|
||||
public IEnumerable<PKM> Contents => BattlePKMs;
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace PKHeX.Core
|
|||
public G1OverworldSpawner(SAV1 sav)
|
||||
{
|
||||
SAV = sav;
|
||||
EventFlags = sav.EventFlags;
|
||||
EventFlags = sav.GetEventFlags();
|
||||
SpawnFlags = sav.EventSpawnFlags;
|
||||
bool yellow = SAV.Yellow;
|
||||
|
||||
|
@ -78,7 +78,7 @@ namespace PKHeX.Core
|
|||
|
||||
public void Save()
|
||||
{
|
||||
SAV.EventFlags = EventFlags;
|
||||
SAV.SetEventFlags(EventFlags);
|
||||
SAV.EventSpawnFlags = SpawnFlags;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,17 +58,11 @@ namespace PKHeX.Core
|
|||
public byte TimesEntered { get => Data[Offset + 0x10]; set => Data[Offset + 0x10] = value; }
|
||||
public int Unused11 { get => Data[Offset + 0x11]; set => Data[Offset + 0x11] = (byte)value; } // alignment padding
|
||||
|
||||
public byte[] Decorations
|
||||
{
|
||||
get => Data.Slice(Offset + 0x12, 0x10);
|
||||
set => value.CopyTo(Data, Offset + 0x12);
|
||||
}
|
||||
public byte[] GetDecorations() => Data.Slice(Offset + 0x12, 0x10);
|
||||
public void SetDecorations(byte[] value) => value.CopyTo(Data, Offset + 0x12);
|
||||
|
||||
public byte[] DecorationCoordinates
|
||||
{
|
||||
get => Data.Slice(Offset + 0x22, 0x10);
|
||||
set => value.CopyTo(Data, Offset + 0x22);
|
||||
}
|
||||
public byte[] GetDecorationCoordinates() => Data.Slice(Offset + 0x22, 0x10);
|
||||
public void SetDecorationCoordinates(byte[] value) => value.CopyTo(Data, Offset + 0x22);
|
||||
|
||||
public SecretBase3Team Team
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace PKHeX.Core
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public sealed class MyItem5B2W2 : MyItem
|
||||
{
|
||||
|
@ -17,7 +19,7 @@
|
|||
|
||||
public MyItem5B2W2(SaveFile SAV, int offset) : base(SAV) => Offset = offset;
|
||||
|
||||
public override InventoryPouch[] Inventory
|
||||
public override IReadOnlyList<InventoryPouch> Inventory
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace PKHeX.Core
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public sealed class MyItem5BW : MyItem
|
||||
{
|
||||
|
@ -17,7 +19,7 @@
|
|||
|
||||
public MyItem5BW(SaveFile SAV, int offset) : base(SAV) => Offset = offset;
|
||||
|
||||
public override InventoryPouch[] Inventory
|
||||
public override IReadOnlyList<InventoryPouch> Inventory
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace PKHeX.Core
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public sealed class MyItem6AO : MyItem
|
||||
{
|
||||
|
@ -11,7 +13,7 @@
|
|||
public MyItem6AO(SAV6AO SAV, int offset) : base(SAV) => Offset = offset;
|
||||
public MyItem6AO(SAV6AODemo SAV, int offset) : base(SAV) => Offset = offset;
|
||||
|
||||
public override InventoryPouch[] Inventory
|
||||
public override IReadOnlyList<InventoryPouch> Inventory
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace PKHeX.Core
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public sealed class MyItem6XY : MyItem
|
||||
{
|
||||
|
@ -10,7 +12,7 @@
|
|||
|
||||
public MyItem6XY(SaveFile SAV, int offset) : base(SAV) => Offset = offset;
|
||||
|
||||
public override InventoryPouch[] Inventory
|
||||
public override IReadOnlyList<InventoryPouch> Inventory
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -30,27 +30,25 @@ namespace PKHeX.Core
|
|||
}
|
||||
}
|
||||
|
||||
public GP1[] AllEntities
|
||||
public GP1[] GetAllEntities()
|
||||
{
|
||||
get
|
||||
{
|
||||
var value = new GP1[Count];
|
||||
for (int i = 0; i < value.Length; i++)
|
||||
value[i] = this[i];
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
Debug.Assert(value.Length == Count);
|
||||
for (int i = 0; i < value.Length; i++)
|
||||
this[i] = value[i];
|
||||
}
|
||||
var value = new GP1[Count];
|
||||
for (int i = 0; i < value.Length; i++)
|
||||
value[i] = this[i];
|
||||
return value;
|
||||
}
|
||||
|
||||
public IEnumerable<string> DumpAll(IReadOnlyList<string> speciesNames) => AllEntities.Select((z, i) => new {Index = i, Entry = z}).Where(z => z.Entry.Species > 0).Select(z => z.Entry.Dump(speciesNames, z.Index));
|
||||
public void SetAllEntities(IReadOnlyList<GP1> value)
|
||||
{
|
||||
Debug.Assert(value.Count == Count);
|
||||
for (int i = 0; i < value.Count; i++)
|
||||
this[i] = value[i];
|
||||
}
|
||||
|
||||
public IEnumerator<GP1> GetEnumerator() => (IEnumerator<GP1>)AllEntities.GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => AllEntities.GetEnumerator();
|
||||
public IEnumerable<string> DumpAll(IReadOnlyList<string> speciesNames) => GetAllEntities().Select((z, i) => new {Index = i, Entry = z}).Where(z => z.Entry.Species > 0).Select(z => z.Entry.Dump(speciesNames, z.Index));
|
||||
|
||||
public IEnumerator<GP1> GetEnumerator() => (IEnumerator<GP1>)GetAllEntities().GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetAllEntities().GetEnumerator();
|
||||
|
||||
public void DeleteAll()
|
||||
{
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public abstract class MyItem : SaveBlock
|
||||
{
|
||||
public abstract InventoryPouch[] Inventory { get; set; }
|
||||
public abstract IReadOnlyList<InventoryPouch> Inventory { get; set; }
|
||||
protected MyItem(SaveFile SAV) : base(SAV) { }
|
||||
protected MyItem(SaveFile SAV, byte[] data) : base(SAV, data) { }
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace PKHeX.Core
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public sealed class MyItem7SM : MyItem
|
||||
{
|
||||
|
@ -11,7 +13,7 @@
|
|||
|
||||
public MyItem7SM(SAV7SM SAV, int offset) : base(SAV) => Offset = offset;
|
||||
|
||||
public override InventoryPouch[] Inventory
|
||||
public override IReadOnlyList<InventoryPouch> Inventory
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace PKHeX.Core
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public sealed class MyItem7USUM : MyItem
|
||||
{
|
||||
|
@ -12,7 +14,7 @@
|
|||
|
||||
public MyItem7USUM(SaveFile SAV, int offset) : base(SAV) => Offset = offset;
|
||||
|
||||
public override InventoryPouch[] Inventory
|
||||
public override IReadOnlyList<InventoryPouch> Inventory
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public sealed class MyItem7b : MyItem
|
||||
|
@ -12,7 +14,7 @@ namespace PKHeX.Core
|
|||
|
||||
public MyItem7b(SAV7b sav, int offset) : base(sav) => Offset = offset;
|
||||
|
||||
public override InventoryPouch[] Inventory
|
||||
public override IReadOnlyList<InventoryPouch> Inventory
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public sealed class MyItem8 : MyItem
|
||||
|
@ -14,7 +16,7 @@ namespace PKHeX.Core
|
|||
|
||||
public MyItem8(SaveFile SAV, SCBlock block) : base(SAV, block.Data) { }
|
||||
|
||||
public override InventoryPouch[] Inventory
|
||||
public override IReadOnlyList<InventoryPouch> Inventory
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -214,14 +214,14 @@ namespace PKHeX.Core
|
|||
|
||||
public static class InventoryPouchExtensions
|
||||
{
|
||||
public static InventoryPouch[] LoadAll(this InventoryPouch[] value, byte[] Data)
|
||||
public static IReadOnlyList<InventoryPouch> LoadAll(this IReadOnlyList<InventoryPouch> value, byte[] Data)
|
||||
{
|
||||
foreach (var p in value)
|
||||
p.GetPouch(Data);
|
||||
return value;
|
||||
}
|
||||
|
||||
public static void SaveAll(this InventoryPouch[] value, byte[] Data)
|
||||
public static void SaveAll(this IReadOnlyList<InventoryPouch> value, byte[] Data)
|
||||
{
|
||||
foreach (var p in value)
|
||||
p.SetPouch(Data);
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace PKHeX.Core
|
|||
}
|
||||
}
|
||||
|
||||
public override void CopyTo(PK4 pk4) => pk4.HeldMailData = Data;
|
||||
public override void CopyTo(PK4 pk4) => pk4.SetHeldMailData(Data);
|
||||
public override ushort AuthorTID { get => BitConverter.ToUInt16(Data, 0); set => BitConverter.GetBytes(value).CopyTo(Data, 0); }
|
||||
public override ushort AuthorSID { get => BitConverter.ToUInt16(Data, 2); set => BitConverter.GetBytes(value).CopyTo(Data, 2); }
|
||||
public override byte AuthorGender { get => Data[4]; set => Data[4] = value; }
|
||||
|
|
|
@ -698,8 +698,8 @@ namespace PKHeX.WinForms.Controls
|
|||
private void B_JPEG_Click(object sender, EventArgs e)
|
||||
{
|
||||
var s6 = (SAV6)SAV;
|
||||
byte[] jpeg = s6.JPEGData;
|
||||
if (s6.JPEGData.Length == 0)
|
||||
byte[] jpeg = s6.GetJPEGData();
|
||||
if (jpeg.Length == 0)
|
||||
{
|
||||
WinFormsUtil.Alert(MsgSaveJPEGExportFail);
|
||||
return;
|
||||
|
|
|
@ -155,7 +155,7 @@ namespace PKHeX.WinForms
|
|||
if (!SAV.Japanese && DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, $"Non Japanese save file. Add {itemlist[oldsea]} (unreleased)?"))
|
||||
tickets = tickets.Take(tickets.Length - 1).ToArray(); // remove old sea map
|
||||
|
||||
var p = Array.Find(Pouches, z => z.Type == InventoryType.KeyItems);
|
||||
var p = Pouches.FirstOrDefault(z => z.Type == InventoryType.KeyItems);
|
||||
if (p == null)
|
||||
throw new ArgumentException(nameof(InventoryPouch.Type));
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@ namespace PKHeX.WinForms
|
|||
RefreshList();
|
||||
}
|
||||
|
||||
public void Save() => SAV.PokeGearRoloDex = Rolodex;
|
||||
public void Save() => SAV.SetPokeGearRoloDex(Rolodex);
|
||||
|
||||
private void RefreshList()
|
||||
{
|
||||
PG_Rolodex.SelectedObject = Rolodex = SAV.PokeGearRoloDex;
|
||||
PG_Rolodex.SelectedObject = Rolodex = SAV.GetPokeGearRoloDex();
|
||||
PG_Rolodex.Refresh();
|
||||
}
|
||||
|
||||
|
|
|
@ -785,7 +785,7 @@ namespace PKHeX.WinForms
|
|||
private void ReadWalker(SAV4HGSS s)
|
||||
{
|
||||
string[] walkercourses = GameInfo.Sources.Source.walkercourses;
|
||||
bool[] isChecked = s.PokewalkerCoursesUnlocked;
|
||||
bool[] isChecked = s.GetPokewalkerCoursesUnlocked();
|
||||
CLB_WalkerCourses.Items.Clear();
|
||||
for (int i = 0; i < walkercourses.Length; i++)
|
||||
CLB_WalkerCourses.Items.Add(walkercourses[i], isChecked[i]);
|
||||
|
@ -798,7 +798,7 @@ namespace PKHeX.WinForms
|
|||
bool[] courses = new bool[32];
|
||||
for (int i = 0; i < CLB_WalkerCourses.Items.Count; i++)
|
||||
courses[i] = CLB_WalkerCourses.GetItemChecked(i);
|
||||
s.PokewalkerCoursesUnlocked = courses;
|
||||
s.SetPokewalkerCoursesUnlocked(courses);
|
||||
s.PokewalkerWatts = (uint)NUD_Watts.Value;
|
||||
s.PokewalkerSteps = (uint)NUD_Steps.Value;
|
||||
}
|
||||
|
|
|
@ -70,10 +70,10 @@ namespace PKHeX.WinForms
|
|||
|
||||
private void ReadUGData()
|
||||
{
|
||||
byte[] goodsList = SAV.UGI_Goods;
|
||||
byte[] spheresList = SAV.UGI_Spheres;
|
||||
byte[] trapsList = SAV.UGI_Traps;
|
||||
byte[] treasuresList = SAV.UGI_Treasures;
|
||||
byte[] goodsList = SAV.GetUGI_Goods();
|
||||
byte[] spheresList = SAV.GetUGI_Spheres();
|
||||
byte[] trapsList = SAV.GetUGI_Traps();
|
||||
byte[] treasuresList = SAV.GetUGI_Treasures();
|
||||
|
||||
// Goods
|
||||
for (int i = 0; i < goodsList.Length; i++)
|
||||
|
@ -104,10 +104,10 @@ namespace PKHeX.WinForms
|
|||
|
||||
private void SaveUGData()
|
||||
{
|
||||
byte[] goodsList = new byte[SAV.UGI_Goods.Length];
|
||||
byte[] spheresList = new byte[SAV.UGI_Spheres.Length];
|
||||
byte[] trapsList = new byte[SAV.UGI_Traps.Length];
|
||||
byte[] treasuresList = new byte[SAV.UGI_Treasures.Length];
|
||||
byte[] goodsList = new byte[SAV.GetUGI_Goods().Length];
|
||||
byte[] spheresList = new byte[SAV.GetUGI_Spheres().Length];
|
||||
byte[] trapsList = new byte[SAV.GetUGI_Traps().Length];
|
||||
byte[] treasuresList = new byte[SAV.GetUGI_Treasures().Length];
|
||||
|
||||
// Goods
|
||||
int ctr = 0;
|
||||
|
@ -168,10 +168,10 @@ namespace PKHeX.WinForms
|
|||
ctr++;
|
||||
}
|
||||
|
||||
SAV.UGI_Goods = goodsList;
|
||||
SAV.UGI_Spheres = spheresList;
|
||||
SAV.UGI_Traps = trapsList;
|
||||
SAV.UGI_Treasures = treasuresList;
|
||||
SAV.SetUGI_Goods(goodsList);
|
||||
SAV.SetUGI_Spheres(spheresList);
|
||||
SAV.SetUGI_Traps(trapsList);
|
||||
SAV.SetUGI_Treasures(treasuresList);
|
||||
}
|
||||
|
||||
private void GetUGScores()
|
||||
|
|
|
@ -146,7 +146,7 @@ namespace PKHeX.WinForms
|
|||
|
||||
private void B_ExportGoFiles_Click(object sender, EventArgs e)
|
||||
{
|
||||
var gofiles = Park.AllEntities.Where(z => z.Species != 0).ToArray();
|
||||
var gofiles = Park.GetAllEntities().Where(z => z.Species != 0).ToArray();
|
||||
if (gofiles.Length == 0)
|
||||
{
|
||||
WinFormsUtil.Alert("No entities present in Go Park to dump.");
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace PKHeX.WinForms
|
|||
// Constants @ 0x1C00
|
||||
// Cell Data @ 0x1D8C
|
||||
// Use constants 0x18C/2 = 198 thru +95
|
||||
ushort[] constants = SAV.EventConsts;
|
||||
ushort[] constants = SAV.GetEventConsts();
|
||||
ushort[] cells = constants.Skip(celloffset).Take(CellCount).ToArray();
|
||||
|
||||
int cellCount = constants[cellstotal];
|
||||
|
@ -55,7 +55,7 @@ namespace PKHeX.WinForms
|
|||
|
||||
private void B_Save_Click(object sender, EventArgs e)
|
||||
{
|
||||
ushort[] constants = SAV.EventConsts;
|
||||
ushort[] constants = SAV.GetEventConsts();
|
||||
for (int i = 0; i < CellCount; i++)
|
||||
{
|
||||
string str = (string)dgv.Rows[i].Cells[2].Value;
|
||||
|
@ -71,7 +71,7 @@ namespace PKHeX.WinForms
|
|||
if (SAV is SAV7USUM)
|
||||
SAV.SetRecord(72, (int)NUD_Collected.Value);
|
||||
|
||||
SAV.EventConsts = constants;
|
||||
SAV.SetEventConsts(constants);
|
||||
Origin.CopyChangesFrom(SAV);
|
||||
|
||||
Close();
|
||||
|
|
|
@ -23,8 +23,8 @@ namespace PKHeX.WinForms
|
|||
DragEnter += Main_DragEnter;
|
||||
DragDrop += Main_DragDrop;
|
||||
|
||||
flags = SAV.EventFlags;
|
||||
Constants = SAV.EventConsts;
|
||||
flags = SAV.GetEventFlags();
|
||||
Constants = SAV.GetEventConsts();
|
||||
|
||||
CB_Stats.Items.Clear();
|
||||
for (int i = 0; i < Constants.Length; i++)
|
||||
|
@ -81,11 +81,11 @@ namespace PKHeX.WinForms
|
|||
// Gather Updated Flags
|
||||
foreach (CheckBox flag in TLP_Flags.Controls.OfType<CheckBox>())
|
||||
flags[GetControlNum(flag)] = flag.Checked;
|
||||
SAV.EventFlags = flags;
|
||||
SAV.SetEventFlags(flags);
|
||||
|
||||
// Copy back Constants
|
||||
ChangeConstantIndex(sender, EventArgs.Empty); // Trigger Saving
|
||||
SAV.EventConsts = Constants;
|
||||
SAV.SetEventConsts(Constants);
|
||||
|
||||
HandleSpecialFlags();
|
||||
Origin.CopyChangesFrom(SAV);
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace PKHeX.WinForms
|
|||
ChangeViewedPouch(0);
|
||||
}
|
||||
|
||||
private readonly InventoryPouch[] Pouches;
|
||||
private readonly IReadOnlyList<InventoryPouch> Pouches;
|
||||
private readonly bool HasFreeSpace;
|
||||
private readonly bool HasNew;
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ namespace PKHeX.WinForms
|
|||
case SAV4 sav4:
|
||||
m = new Mail4[p.Count + 20];
|
||||
for (int i = 0; i < p.Count; i++)
|
||||
m[i] = new Mail4(((PK4)p[i]).HeldMailData);
|
||||
m[i] = new Mail4(((PK4)p[i]).GetHeldMailData());
|
||||
for (int i = p.Count, j = 0; i < m.Length; i++, j++)
|
||||
{
|
||||
int ofs = sav4.GetMailOffset(j);
|
||||
|
|
Loading…
Reference in a new issue