mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 20:43:07 +00:00
Generalize box wallpaper interaction
Move get/set logic into abstract class, only offset fetch is overridden
This commit is contained in:
parent
5e54466816
commit
ade97e0067
12 changed files with 67 additions and 39 deletions
|
@ -403,10 +403,6 @@ namespace PKHeX
|
||||||
get { return Data[Japanese ? 0x2842 : 0x284C] & 0x7F; }
|
get { return Data[Japanese ? 0x2842 : 0x284C] & 0x7F; }
|
||||||
set { Data[Japanese ? 0x2842 : 0x284C] = (byte)((Data[Japanese ? 0x2842 : 0x284C] & 0x80) | (value & 0x7F)); }
|
set { Data[Japanese ? 0x2842 : 0x284C] = (byte)((Data[Japanese ? 0x2842 : 0x284C] & 0x80) | (value & 0x7F)); }
|
||||||
}
|
}
|
||||||
public override int getBoxWallpaper(int box)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
public override string getBoxName(int box)
|
public override string getBoxName(int box)
|
||||||
{
|
{
|
||||||
return $"BOX {box + 1}";
|
return $"BOX {box + 1}";
|
||||||
|
|
|
@ -554,10 +554,6 @@ namespace PKHeX
|
||||||
get { return Data[CurrentBoxIndexOffset] & 0x7F; }
|
get { return Data[CurrentBoxIndexOffset] & 0x7F; }
|
||||||
set { Data[CurrentBoxIndexOffset] = (byte)((Data[Japanese ? 0x2842 : 0x284C] & 0x80) | (value & 0x7F)); }
|
set { Data[CurrentBoxIndexOffset] = (byte)((Data[Japanese ? 0x2842 : 0x284C] & 0x80) | (value & 0x7F)); }
|
||||||
}
|
}
|
||||||
public override int getBoxWallpaper(int box)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
public override string getBoxName(int box)
|
public override string getBoxName(int box)
|
||||||
{
|
{
|
||||||
return PKX.getG1Str(Data.Skip(BoxNamesOffset + box*9).Take(9).ToArray(), Japanese);
|
return PKX.getG1Str(Data.Skip(BoxNamesOffset + box*9).Take(9).ToArray(), Japanese);
|
||||||
|
|
|
@ -434,12 +434,11 @@ namespace PKHeX
|
||||||
get { return Data[Box]; }
|
get { return Data[Box]; }
|
||||||
set { Data[Box] = (byte)value; }
|
set { Data[Box] = (byte)value; }
|
||||||
}
|
}
|
||||||
public override int getBoxWallpaper(int box)
|
protected override int getBoxWallpaperOffset(int box)
|
||||||
{
|
{
|
||||||
// Box Wallpaper is directly after the Box Names
|
|
||||||
int offset = getBoxOffset(BoxCount);
|
int offset = getBoxOffset(BoxCount);
|
||||||
offset += BoxCount * 0x9 + box;
|
offset += BoxCount * 0x9 + box;
|
||||||
return Data[offset];
|
return offset;
|
||||||
}
|
}
|
||||||
public override string getBoxName(int box)
|
public override string getBoxName(int box)
|
||||||
{
|
{
|
||||||
|
|
|
@ -255,11 +255,6 @@ namespace PKHeX
|
||||||
{
|
{
|
||||||
return Box + (30 * SIZE_STORED + 0x14)*box + 0x14;
|
return Box + (30 * SIZE_STORED + 0x14)*box + 0x14;
|
||||||
}
|
}
|
||||||
public override int CurrentBox { get { return 0; } set { } }
|
|
||||||
public override int getBoxWallpaper(int box)
|
|
||||||
{
|
|
||||||
return box;
|
|
||||||
}
|
|
||||||
public override string getBoxName(int box)
|
public override string getBoxName(int box)
|
||||||
{
|
{
|
||||||
return PKX.getColoStr(Data, Box + 0x24A4*box, 8);
|
return PKX.getColoStr(Data, Box + 0x24A4*box, 8);
|
||||||
|
|
|
@ -127,11 +127,11 @@ namespace PKHeX
|
||||||
get { return Data[Box + 4]*2; }
|
get { return Data[Box + 4]*2; }
|
||||||
set { Data[Box + 4] = (byte)(value/2); }
|
set { Data[Box + 4] = (byte)(value/2); }
|
||||||
}
|
}
|
||||||
public override int getBoxWallpaper(int box)
|
protected override int getBoxWallpaperOffset(int box)
|
||||||
{
|
{
|
||||||
// Box Wallpaper is directly after the Box Names
|
// Box Wallpaper is directly after the Box Names
|
||||||
int offset = Box + 0x1ED19 + box/2;
|
int offset = Box + 0x1ED19 + box/2;
|
||||||
return Data[offset];
|
return offset;
|
||||||
}
|
}
|
||||||
public override string getBoxName(int box)
|
public override string getBoxName(int box)
|
||||||
{
|
{
|
||||||
|
|
|
@ -229,11 +229,6 @@ namespace PKHeX
|
||||||
{
|
{
|
||||||
return Box + (30 * SIZE_STORED + 0x14)*box + 0x14;
|
return Box + (30 * SIZE_STORED + 0x14)*box + 0x14;
|
||||||
}
|
}
|
||||||
public override int CurrentBox { get { return 0; } set { } }
|
|
||||||
public override int getBoxWallpaper(int box)
|
|
||||||
{
|
|
||||||
return box;
|
|
||||||
}
|
|
||||||
public override string getBoxName(int box)
|
public override string getBoxName(int box)
|
||||||
{
|
{
|
||||||
return PKX.getColoStr(Data, Box + (30 * SIZE_STORED + 0x14)*box, 8);
|
return PKX.getColoStr(Data, Box + (30 * SIZE_STORED + 0x14)*box, 8);
|
||||||
|
|
|
@ -571,13 +571,13 @@ namespace PKHeX
|
||||||
get { return Data[Version == GameVersion.HGSS ? getBoxOffset(BoxCount) : Box - 4]; }
|
get { return Data[Version == GameVersion.HGSS ? getBoxOffset(BoxCount) : Box - 4]; }
|
||||||
set { Data[Version == GameVersion.HGSS ? getBoxOffset(BoxCount) : Box - 4] = (byte)value; }
|
set { Data[Version == GameVersion.HGSS ? getBoxOffset(BoxCount) : Box - 4] = (byte)value; }
|
||||||
}
|
}
|
||||||
public override int getBoxWallpaper(int box)
|
protected override int getBoxWallpaperOffset(int box)
|
||||||
{
|
{
|
||||||
// Box Wallpaper is directly after the Box Names
|
// Box Wallpaper is directly after the Box Names
|
||||||
int offset = getBoxOffset(BoxCount);
|
int offset = getBoxOffset(BoxCount);
|
||||||
if (Version == GameVersion.HGSS) offset += 0x18;
|
if (Version == GameVersion.HGSS) offset += 0x18;
|
||||||
offset += BoxCount*0x28 + box;
|
offset += BoxCount*0x28 + box;
|
||||||
return Data[offset];
|
return offset;
|
||||||
}
|
}
|
||||||
public override string getBoxName(int box)
|
public override string getBoxName(int box)
|
||||||
{
|
{
|
||||||
|
|
|
@ -126,8 +126,6 @@ namespace PKHeX
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save file does not have Box Name / Wallpaper info
|
// Save file does not have Box Name / Wallpaper info
|
||||||
public override int CurrentBox { get { return 0; } set { } }
|
|
||||||
public override int getBoxWallpaper(int box) { return box; }
|
|
||||||
public override string getBoxName(int box) { return $"BOX {box + 1}"; }
|
public override string getBoxName(int box) { return $"BOX {box + 1}"; }
|
||||||
public override void setBoxName(int box, string value) { }
|
public override void setBoxName(int box, string value) { }
|
||||||
|
|
||||||
|
|
|
@ -450,9 +450,9 @@ namespace PKHeX
|
||||||
Encoding.Unicode.GetBytes(val.PadRight(0x14, '\0')).CopyTo(Data, PCLayout + 0x28 * box + 4);
|
Encoding.Unicode.GetBytes(val.PadRight(0x14, '\0')).CopyTo(Data, PCLayout + 0x28 * box + 4);
|
||||||
Edited = true;
|
Edited = true;
|
||||||
}
|
}
|
||||||
public override int getBoxWallpaper(int box)
|
protected override int getBoxWallpaperOffset(int box)
|
||||||
{
|
{
|
||||||
return Data[PCLayout + 0x3C4 + box];
|
return PCLayout + 0x3C4 + box;
|
||||||
}
|
}
|
||||||
public override int CurrentBox
|
public override int CurrentBox
|
||||||
{
|
{
|
||||||
|
|
|
@ -651,10 +651,12 @@ namespace PKHeX
|
||||||
{
|
{
|
||||||
return Box + SIZE_STORED*box*30;
|
return Box + SIZE_STORED*box*30;
|
||||||
}
|
}
|
||||||
public override int getBoxWallpaper(int box)
|
protected override int getBoxWallpaperOffset(int box)
|
||||||
{
|
{
|
||||||
int ofs = PCBackgrounds > 0 && PCBackgrounds < Data.Length ? PCBackgrounds : 0;
|
int ofs = PCBackgrounds > 0 && PCBackgrounds < Data.Length ? PCBackgrounds : -1;
|
||||||
return Data[ofs + box];
|
if (ofs > -1)
|
||||||
|
return ofs + box;
|
||||||
|
return ofs;
|
||||||
}
|
}
|
||||||
public override string getBoxName(int box)
|
public override string getBoxName(int box)
|
||||||
{
|
{
|
||||||
|
@ -773,6 +775,17 @@ namespace PKHeX
|
||||||
get { return Data[BattleBox + 6 * SIZE_STORED] != 0; }
|
get { return Data[BattleBox + 6 * SIZE_STORED] != 0; }
|
||||||
set { Data[BattleBox + 6 * SIZE_STORED] = (byte)(value ? 1 : 0); }
|
set { Data[BattleBox + 6 * SIZE_STORED] = (byte)(value ? 1 : 0); }
|
||||||
}
|
}
|
||||||
|
public override int BoxesUnlocked { get { return Data[PCFlags + 1] - 1; } set { Data[PCFlags + 1] = (byte)(value + 1); } }
|
||||||
|
public override byte[] BoxFlags
|
||||||
|
{
|
||||||
|
get { return new[] { Data[PCFlags], Data[PCFlags + 2] }; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value.Length != 2) return;
|
||||||
|
Data[PCFlags] = value[0];
|
||||||
|
Data[PCFlags + 2] = value[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Mystery Gift
|
// Mystery Gift
|
||||||
protected override bool[] MysteryGiftReceivedFlags
|
protected override bool[] MysteryGiftReceivedFlags
|
||||||
|
@ -847,7 +860,7 @@ namespace PKHeX
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private WC6 getWC6(int index)
|
private MysteryGift getWC6(int index)
|
||||||
{
|
{
|
||||||
if (WondercardData < 0)
|
if (WondercardData < 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -430,10 +430,19 @@ namespace PKHeX
|
||||||
{
|
{
|
||||||
return Box + SIZE_STORED*box*30;
|
return Box + SIZE_STORED*box*30;
|
||||||
}
|
}
|
||||||
public override int getBoxWallpaper(int box)
|
protected override int getBoxWallpaperOffset(int box)
|
||||||
{
|
{
|
||||||
|
int ofs = PCBackgrounds > 0 && PCBackgrounds < Data.Length ? PCBackgrounds : -1;
|
||||||
|
if (ofs > -1)
|
||||||
|
return ofs + box;
|
||||||
|
return ofs;
|
||||||
|
}
|
||||||
|
public override void setBoxWallpaper(int box, int value)
|
||||||
|
{
|
||||||
|
if (PCBackgrounds < 0)
|
||||||
|
return;
|
||||||
int ofs = PCBackgrounds > 0 && PCBackgrounds < Data.Length ? PCBackgrounds : 0;
|
int ofs = PCBackgrounds > 0 && PCBackgrounds < Data.Length ? PCBackgrounds : 0;
|
||||||
return Data[ofs + box];
|
Data[ofs + box] = (byte)value;
|
||||||
}
|
}
|
||||||
public override string getBoxName(int box)
|
public override string getBoxName(int box)
|
||||||
{
|
{
|
||||||
|
@ -575,6 +584,16 @@ namespace PKHeX
|
||||||
get { return Data[Party + 6 * SIZE_PARTY]; }
|
get { return Data[Party + 6 * SIZE_PARTY]; }
|
||||||
protected set { Data[Party + 6 * SIZE_PARTY] = (byte)value; }
|
protected set { Data[Party + 6 * SIZE_PARTY] = (byte)value; }
|
||||||
}
|
}
|
||||||
|
public override int BoxesUnlocked { get { return -1; } set { Data[PCFlags + 1] = (byte)(value + 1); } }
|
||||||
|
public override byte[] BoxFlags {
|
||||||
|
get { return null; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value.Length != 2) return;
|
||||||
|
Data[PCFlags] = value[0];
|
||||||
|
Data[PCFlags + 2] = value[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override int DaycareSeedSize => 16;
|
public override int DaycareSeedSize => 16;
|
||||||
public override int getDaycareSlotOffset(int loc, int slot)
|
public override int getDaycareSlotOffset(int loc, int slot)
|
||||||
|
|
|
@ -95,7 +95,7 @@ namespace PKHeX
|
||||||
public bool HasGTS => GTS > -1;
|
public bool HasGTS => GTS > -1;
|
||||||
public bool HasDaycare => Daycare > -1;
|
public bool HasDaycare => Daycare > -1;
|
||||||
public virtual bool HasPokeDex => PokeDex > -1;
|
public virtual bool HasPokeDex => PokeDex > -1;
|
||||||
public virtual bool HasBoxWallpapers => PCLayout > -1;
|
public virtual bool HasBoxWallpapers => getBoxWallpaperOffset(0) > -1;
|
||||||
public virtual bool HasSUBE => SUBE > -1 && !ORAS;
|
public virtual bool HasSUBE => SUBE > -1 && !ORAS;
|
||||||
public virtual bool HasGeolocation => false;
|
public virtual bool HasGeolocation => false;
|
||||||
public bool HasPokeBlock => ORAS && !ORASDEMO;
|
public bool HasPokeBlock => ORAS && !ORASDEMO;
|
||||||
|
@ -319,14 +319,12 @@ namespace PKHeX
|
||||||
public virtual uint Money { get; set; }
|
public virtual uint Money { get; set; }
|
||||||
public abstract int BoxCount { get; }
|
public abstract int BoxCount { get; }
|
||||||
public virtual int PartyCount { get; protected set; }
|
public virtual int PartyCount { get; protected set; }
|
||||||
public abstract int CurrentBox { get; set; }
|
|
||||||
public abstract string Extension { get; }
|
public abstract string Extension { get; }
|
||||||
|
|
||||||
// Varied Methods
|
// Varied Methods
|
||||||
protected abstract void setChecksums();
|
protected abstract void setChecksums();
|
||||||
public abstract int getBoxOffset(int box);
|
public abstract int getBoxOffset(int box);
|
||||||
public abstract int getPartyOffset(int slot);
|
public abstract int getPartyOffset(int slot);
|
||||||
public abstract int getBoxWallpaper(int box);
|
|
||||||
public abstract string getBoxName(int box);
|
public abstract string getBoxName(int box);
|
||||||
public abstract void setBoxName(int box, string val);
|
public abstract void setBoxName(int box, string val);
|
||||||
public virtual ulong? GameSyncID { get { return null; } set { } }
|
public virtual ulong? GameSyncID { get { return null; } set { } }
|
||||||
|
@ -349,6 +347,25 @@ namespace PKHeX
|
||||||
|
|
||||||
// Storage
|
// Storage
|
||||||
public virtual int BoxSlotCount => 30;
|
public virtual int BoxSlotCount => 30;
|
||||||
|
public virtual int BoxesUnlocked { get { return -1; } set { } }
|
||||||
|
public virtual byte[] BoxFlags { get { return null; } set { } }
|
||||||
|
public virtual int CurrentBox { get { return 0; } set { } }
|
||||||
|
|
||||||
|
protected virtual int getBoxWallpaperOffset(int box) { return -1; }
|
||||||
|
public int getBoxWallpaper(int box)
|
||||||
|
{
|
||||||
|
int offset = getBoxWallpaperOffset(box);
|
||||||
|
if (offset < 0 || box > BoxCount)
|
||||||
|
return box;
|
||||||
|
return Data[offset];
|
||||||
|
}
|
||||||
|
public virtual void setBoxWallpaper(int box, int val)
|
||||||
|
{
|
||||||
|
int offset = getBoxWallpaperOffset(box);
|
||||||
|
if (offset < 0 || box > BoxCount)
|
||||||
|
return;
|
||||||
|
Data[offset] = (byte)val;
|
||||||
|
}
|
||||||
|
|
||||||
public virtual PKM getPartySlot(int offset)
|
public virtual PKM getPartySlot(int offset)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue