mirror of
https://github.com/kwsch/PKHeX
synced 2024-09-20 22:32:00 +00:00
Refactoring
split Core.PKX into smaller classes, only StringConverter is exposed for outside namespaces
This commit is contained in:
parent
2344098745
commit
80196f75ef
32 changed files with 2392 additions and 2240 deletions
|
@ -305,7 +305,7 @@ namespace PKHeX.Core
|
|||
{
|
||||
int method = BitConverter.ToUInt16(data, offset + 0);
|
||||
int arg = BitConverter.ToUInt16(data, offset + 2);
|
||||
int species = PKX.GetG4Species(BitConverter.ToUInt16(data, offset + 4));
|
||||
int species = SpeciesConverter.GetG4Species(BitConverter.ToUInt16(data, offset + 4));
|
||||
//2 bytes padding
|
||||
|
||||
switch (method)
|
||||
|
@ -338,7 +338,7 @@ namespace PKHeX.Core
|
|||
evos[0] = new EvolutionSet3 { PossibleEvolutions = new EvolutionMethod[0] };
|
||||
for (int i = 0; i <= Legal.MaxSpeciesIndex_3; i++)
|
||||
{
|
||||
int g4species = PKX.GetG4Species(i);
|
||||
int g4species = SpeciesConverter.GetG4Species(i);
|
||||
if (g4species == 0)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace PKHeX.Core
|
|||
public int Language { get => Data[0x1D]; set => Data[0x1D] = (byte)value; }
|
||||
public string Nickname
|
||||
{
|
||||
get => PKX.TrimFromFFFF(Encoding.Unicode.GetString(Data, 0x1E, 0x16));
|
||||
get => StringConverter.TrimFromFFFF(Encoding.Unicode.GetString(Data, 0x1E, 0x16));
|
||||
set => Encoding.Unicode.GetBytes(value.PadRight(0xB, (char)0xFFFF)).CopyTo(Data, 0x1E);
|
||||
}
|
||||
public int Nature { get => Data[0x34]; set => Data[0x34] = (byte)value; }
|
||||
|
@ -75,7 +75,7 @@ namespace PKHeX.Core
|
|||
public int IV_SPD { get => Data[0x48]; set => Data[0x48] = (byte)value; }
|
||||
// Unused 0x49
|
||||
public string OT {
|
||||
get => PKX.TrimFromFFFF(Encoding.Unicode.GetString(Data, 0x4A, 0x10));
|
||||
get => StringConverter.TrimFromFFFF(Encoding.Unicode.GetString(Data, 0x4A, 0x10));
|
||||
set => Encoding.Unicode.GetBytes(value.PadRight(0x08, (char)0xFFFF)).CopyTo(Data, 0x4A); }
|
||||
public int OTGender { get => Data[0x5A]; set => Data[0x5A] = (byte)value; }
|
||||
public override int Level { get => Data[0x5B]; set => Data[0x5C] = (byte)value; }
|
||||
|
@ -83,7 +83,7 @@ namespace PKHeX.Core
|
|||
// Unused 0x5D 0x5E 0x5F
|
||||
public override string CardTitle
|
||||
{
|
||||
get => PKX.TrimFromFFFF(Encoding.Unicode.GetString(Data, 0x60, 0x4A));
|
||||
get => StringConverter.TrimFromFFFF(Encoding.Unicode.GetString(Data, 0x60, 0x4A));
|
||||
set => Encoding.Unicode.GetBytes((value + '\uFFFF').PadRight(0x4A / 2, '\0')).CopyTo(Data, 0x60);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,10 +60,10 @@ namespace PKHeX.Core
|
|||
}
|
||||
public override string CardTitle
|
||||
{
|
||||
get => PKX.GetString4(Data, 0x104, 0x48);
|
||||
get => StringConverter.GetString4(Data, 0x104, 0x48);
|
||||
set
|
||||
{
|
||||
byte[] data = PKX.SetString4(value, 0x48/2-1, 0x48/2, 0xFFFF);
|
||||
byte[] data = StringConverter.SetString4(value, 0x48/2-1, 0x48/2, 0xFFFF);
|
||||
int len = data.Length;
|
||||
Array.Resize(ref data, 0x48);
|
||||
for (int i = 0; i < len; i++)
|
||||
|
|
|
@ -33,8 +33,8 @@ namespace PKHeX.Core
|
|||
}
|
||||
public override PKM Clone() { return new BK4(Encrypt()); }
|
||||
|
||||
public override string GetString(int Offset, int Count) => PKX.GetBEString4(Data, Offset, Count);
|
||||
public override byte[] SetString(string value, int maxLength) => PKX.SetBEString4(value, maxLength);
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetBEString4(Data, Offset, Count);
|
||||
public override byte[] SetString(string value, int maxLength) => StringConverter.SetBEString4(value, maxLength);
|
||||
|
||||
// Trash Bytes
|
||||
public override byte[] Nickname_Trash { get => GetData(0x48, 24); set { if (value?.Length == 24) value.CopyTo(Data, 0x48); } }
|
||||
|
|
|
@ -27,8 +27,8 @@ namespace PKHeX.Core
|
|||
}
|
||||
public override PKM Clone() { return new CK3(Data); }
|
||||
|
||||
public override string GetString(int Offset, int Count) => PKX.GetBEString3(Data, Offset, Count);
|
||||
public override byte[] SetString(string value, int maxLength) => PKX.SetBEString3(value, maxLength);
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetBEString3(Data, Offset, Count);
|
||||
public override byte[] SetString(string value, int maxLength) => StringConverter.SetBEString3(value, maxLength);
|
||||
|
||||
// Trash Bytes
|
||||
public override byte[] Nickname_Trash { get => GetData(0x2E, 20); set { if (value?.Length == 20) value.CopyTo(Data, 0x2E); } }
|
||||
|
@ -52,7 +52,7 @@ namespace PKHeX.Core
|
|||
public override ushort Checksum { get => SaveUtil.CRC16_CCITT(Data); set { } } // totally false, just a way to get a 'random' ident for the pkm.
|
||||
public override bool ChecksumValid => Valid;
|
||||
|
||||
public override int Species { get => PKX.GetG4Species(BigEndian.ToUInt16(Data, 0x00)); set => BigEndian.GetBytes((ushort)PKX.GetG3Species(value)).CopyTo(Data, 0x00); }
|
||||
public override int Species { get => SpeciesConverter.GetG4Species(BigEndian.ToUInt16(Data, 0x00)); set => BigEndian.GetBytes((ushort)SpeciesConverter.GetG3Species(value)).CopyTo(Data, 0x00); }
|
||||
// 02-04 unused
|
||||
public override uint PID { get => BigEndian.ToUInt32(Data, 0x04); set => BigEndian.GetBytes(value).CopyTo(Data, 0x04); }
|
||||
public override int Version { get => SaveUtil.GetG3VersionID(Data[0x08]); set => Data[0x08] = (byte)SaveUtil.GetCXDVersionID(value); }
|
||||
|
@ -88,7 +88,7 @@ namespace PKHeX.Core
|
|||
public override int Move4_PP { get => Data[0x86]; set => Data[0x86] = (byte)value; }
|
||||
public override int Move4_PPUps { get => Data[0x87]; set => Data[0x87] = (byte)value; }
|
||||
|
||||
public override int SpriteItem => PKX.GetG4Item((ushort)HeldItem);
|
||||
public override int SpriteItem => ItemConverter.GetG4Item((ushort)HeldItem);
|
||||
public override int HeldItem { get => BigEndian.ToUInt16(Data, 0x88); set => BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x88); }
|
||||
|
||||
// More party stats
|
||||
|
|
625
PKHeX.Core/PKM/FormConverter.cs
Normal file
625
PKHeX.Core/PKM/FormConverter.cs
Normal file
|
@ -0,0 +1,625 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
internal static class FormConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a list of formes that the species can have.
|
||||
/// </summary>
|
||||
/// <param name="species">National Dex number of the Pokémon.</param>
|
||||
/// <param name="types">List of type names</param>
|
||||
/// <param name="forms">List of form names</param>
|
||||
/// <param name="genders">List of genders names</param>
|
||||
/// <param name="generation">Generation number for exclusive formes</param>
|
||||
/// <returns>A list of strings corresponding to the formes that a Pokémon can have.</returns>
|
||||
internal static string[] GetFormList(int species, IReadOnlyList<string> types, IReadOnlyList<string> forms, IReadOnlyList<string> genders, int generation)
|
||||
{
|
||||
// Mega List
|
||||
if (IsFormListSingleMega(species))
|
||||
return new[]
|
||||
{
|
||||
types[000], // Normal
|
||||
forms[804], // Mega
|
||||
};
|
||||
|
||||
if (species <= Legal.MaxSpeciesID_1)
|
||||
return GetFormsGen1(species, types, forms, generation);
|
||||
if (species <= Legal.MaxSpeciesID_2)
|
||||
return GetFormsGen2(species, types, forms, generation);
|
||||
if (species <= Legal.MaxSpeciesID_3)
|
||||
return GetFormsGen3(species, types, forms);
|
||||
if (species <= Legal.MaxSpeciesID_4)
|
||||
return GetFormsGen4(species, types, forms, generation);
|
||||
if (species <= Legal.MaxSpeciesID_5)
|
||||
return GetFormsGen5(species, types, forms);
|
||||
if (species <= Legal.MaxSpeciesID_6)
|
||||
return GetFormsGen6(species, types, forms, genders);
|
||||
//if (species <= Legal.MaxSpeciesID_7)
|
||||
return GetFormsGen7(species, types, forms);
|
||||
}
|
||||
|
||||
private static string[] GetFormsGen1(int species, IReadOnlyList<string> types, IReadOnlyList<string> forms, int generation)
|
||||
{
|
||||
switch (species)
|
||||
{
|
||||
case 6:
|
||||
case 150:
|
||||
return new[]
|
||||
{
|
||||
types[000], // Normal
|
||||
forms[805], // Mega X
|
||||
forms[806], // Mega Y
|
||||
};
|
||||
case 025:
|
||||
return GetFormsPikachu(generation, forms, types);
|
||||
|
||||
default:
|
||||
return GetFormsAlolan(generation, forms, types, species);
|
||||
}
|
||||
}
|
||||
private static string[] GetFormsGen2(int species, IReadOnlyList<string> types, IReadOnlyList<string> forms, int generation)
|
||||
{
|
||||
switch (species)
|
||||
{
|
||||
default:
|
||||
return new[] { "" };
|
||||
|
||||
case 172:
|
||||
return GetFormsPichu(generation, types, forms);
|
||||
case 201:
|
||||
return GetFormsUnown(generation);
|
||||
}
|
||||
}
|
||||
private static string[] GetFormsGen3(int species, IReadOnlyList<string> types, IReadOnlyList<string> forms)
|
||||
{
|
||||
switch (species)
|
||||
{
|
||||
default:
|
||||
return new[] { "" };
|
||||
|
||||
case 351: // Casftorm
|
||||
return new[]
|
||||
{
|
||||
types[000], // Normal
|
||||
forms[889], // Sunny
|
||||
forms[890], // Rainy
|
||||
forms[891], // Snowy
|
||||
};
|
||||
case 382: // Kyogre
|
||||
case 383: // Groudon
|
||||
return new[]
|
||||
{
|
||||
types[000], // Normal
|
||||
forms[899], // Primal
|
||||
};
|
||||
case 386: // Deoxys
|
||||
return new[]
|
||||
{
|
||||
types[000], // Normal
|
||||
forms[902], // Attack
|
||||
forms[903], // Defense
|
||||
forms[904], // Speed
|
||||
};
|
||||
}
|
||||
}
|
||||
private static string[] GetFormsGen4(int species, IReadOnlyList<string> types, IReadOnlyList<string> forms, int generation)
|
||||
{
|
||||
switch (species)
|
||||
{
|
||||
default:
|
||||
return new[] { "" };
|
||||
|
||||
case 412:
|
||||
case 413:
|
||||
case 414:
|
||||
return new[]
|
||||
{
|
||||
forms[412], // Plant
|
||||
forms[905], // Sandy
|
||||
forms[906], // Trash
|
||||
};
|
||||
|
||||
case 421:
|
||||
return new[]
|
||||
{
|
||||
forms[421], // Overcast
|
||||
forms[909], // Sunshine
|
||||
};
|
||||
|
||||
case 422:
|
||||
case 423:
|
||||
return new[]
|
||||
{
|
||||
forms[422], // West
|
||||
forms[911], // East
|
||||
};
|
||||
|
||||
case 479:
|
||||
return new[]
|
||||
{
|
||||
types[000], // Normal
|
||||
forms[917], // Heat
|
||||
forms[918], // Wash
|
||||
forms[919], // Frost
|
||||
forms[920], // Fan
|
||||
forms[921], // Mow
|
||||
};
|
||||
|
||||
case 487:
|
||||
return new[]
|
||||
{
|
||||
forms[487], // Altered
|
||||
forms[922], // Origin
|
||||
};
|
||||
|
||||
case 492:
|
||||
return new[]
|
||||
{
|
||||
forms[492], // Land
|
||||
forms[923], // Sky
|
||||
};
|
||||
|
||||
case 493: // Arceus
|
||||
case 773: // Silvally
|
||||
return GetFormsArceus(generation, types);
|
||||
}
|
||||
}
|
||||
private static string[] GetFormsGen5(int species, IReadOnlyList<string> types, IReadOnlyList<string> forms)
|
||||
{
|
||||
switch (species)
|
||||
{
|
||||
default:
|
||||
return new[] { "" };
|
||||
|
||||
case 550:
|
||||
return new[]
|
||||
{
|
||||
forms[550], // Red
|
||||
forms[942], // Blue
|
||||
};
|
||||
|
||||
case 555:
|
||||
return new[]
|
||||
{
|
||||
forms[555], // Standard
|
||||
forms[943], // Zen
|
||||
};
|
||||
|
||||
case 585:
|
||||
case 586:
|
||||
return new[]
|
||||
{
|
||||
forms[585], // Spring
|
||||
forms[947], // Summer
|
||||
forms[948], // Autumn
|
||||
forms[949], // Winter
|
||||
};
|
||||
|
||||
case 641:
|
||||
case 642:
|
||||
case 645:
|
||||
return new[]
|
||||
{
|
||||
forms[641], // Incarnate
|
||||
forms[952], // Therian
|
||||
};
|
||||
|
||||
case 646:
|
||||
return new[]
|
||||
{
|
||||
types[000], // Normal
|
||||
forms[953], // White
|
||||
forms[954], // Black
|
||||
};
|
||||
|
||||
case 647:
|
||||
return new[]
|
||||
{
|
||||
forms[647], // Ordinary
|
||||
forms[955], // Resolute
|
||||
};
|
||||
|
||||
case 648:
|
||||
return new[]
|
||||
{
|
||||
forms[648], // Aria
|
||||
forms[956], // Pirouette
|
||||
};
|
||||
|
||||
case 649:
|
||||
return new[]
|
||||
{
|
||||
types[000], // Normal
|
||||
types[010], // Douse (Water)
|
||||
types[012], // Shock (Electric)
|
||||
types[009], // Burn (Fire)
|
||||
types[014], // Chill (Ice)
|
||||
};
|
||||
}
|
||||
}
|
||||
private static string[] GetFormsGen6(int species, IReadOnlyList<string> types, IReadOnlyList<string> forms, IReadOnlyList<string> genders)
|
||||
{
|
||||
switch (species)
|
||||
{
|
||||
default:
|
||||
return new[] { "" };
|
||||
|
||||
case 658:
|
||||
return new[]
|
||||
{
|
||||
types[000], // Normal
|
||||
forms[962], // "Ash",
|
||||
forms[1012], // "Bonded" - Active
|
||||
};
|
||||
|
||||
case 664:
|
||||
case 665:
|
||||
case 666:
|
||||
return new[]
|
||||
{
|
||||
forms[666], // Icy Snow
|
||||
forms[963], // Polar
|
||||
forms[964], // Tundra
|
||||
forms[965], // Continental
|
||||
forms[966], // Garden
|
||||
forms[967], // Elegant
|
||||
forms[968], // Meadow
|
||||
forms[969], // Modern
|
||||
forms[970], // Marine
|
||||
forms[971], // Archipelago
|
||||
forms[972], // High-Plains
|
||||
forms[973], // Sandstorm
|
||||
forms[974], // River
|
||||
forms[975], // Monsoon
|
||||
forms[976], // Savannah
|
||||
forms[977], // Sun
|
||||
forms[978], // Ocean
|
||||
forms[979], // Jungle
|
||||
forms[980], // Fancy
|
||||
forms[981], // Poké Ball
|
||||
};
|
||||
|
||||
case 669:
|
||||
case 671:
|
||||
return new[]
|
||||
{
|
||||
forms[669], // Red
|
||||
forms[986], // Yellow
|
||||
forms[987], // Orange
|
||||
forms[988], // Blue
|
||||
forms[989], // White
|
||||
};
|
||||
|
||||
case 670:
|
||||
return new[]
|
||||
{
|
||||
forms[669], // Red
|
||||
forms[986], // Yellow
|
||||
forms[987], // Orange
|
||||
forms[988], // Blue
|
||||
forms[989], // White
|
||||
forms[990], // Eternal
|
||||
};
|
||||
|
||||
case 676:
|
||||
return new[]
|
||||
{
|
||||
forms[676], // Natural
|
||||
forms[995], // Heart
|
||||
forms[996], // Star
|
||||
forms[997], // Diamond
|
||||
forms[998], // Deputante
|
||||
forms[999], // Matron
|
||||
forms[1000], // Dandy
|
||||
forms[1001], // La Reine
|
||||
forms[1002], // Kabuki
|
||||
forms[1003], // Pharaoh
|
||||
};
|
||||
|
||||
case 678:
|
||||
return new[]
|
||||
{
|
||||
genders[000], // Male
|
||||
genders[001], // Female
|
||||
};
|
||||
|
||||
case 681:
|
||||
return new[]
|
||||
{
|
||||
forms[681], // Shield
|
||||
forms[1005], // Blade
|
||||
};
|
||||
|
||||
case 710:
|
||||
case 711:
|
||||
return new[]
|
||||
{
|
||||
forms[710], // Average
|
||||
forms[1006], // Small
|
||||
forms[1007], // Large
|
||||
forms[1008], // Super
|
||||
};
|
||||
|
||||
case 716:
|
||||
return new[]
|
||||
{
|
||||
forms[716], // Neutral
|
||||
forms[1012], // Active
|
||||
};
|
||||
|
||||
case 720:
|
||||
return new[]
|
||||
{
|
||||
forms[720], // Confined
|
||||
forms[1018], // Unbound
|
||||
};
|
||||
|
||||
case 718: // Zygarde
|
||||
return new[]
|
||||
{
|
||||
forms[718], // 50% (Aura Break)
|
||||
"10%", // (Aura Break)
|
||||
"10%-C", // Cell (Power Construct)
|
||||
"50%-C", // Cell (Power Construct)
|
||||
"100%-C" // Cell (Power Construct)
|
||||
};
|
||||
}
|
||||
}
|
||||
private static string[] GetFormsGen7(int species, IReadOnlyList<string> types, IReadOnlyList<string> forms)
|
||||
{
|
||||
switch (species)
|
||||
{
|
||||
default:
|
||||
return new[] { "" };
|
||||
|
||||
case 741: // Oricorio
|
||||
return new[]
|
||||
{
|
||||
forms[741], // "RED" - Baile
|
||||
forms[1021], // "YLW" - Pom-Pom
|
||||
forms[1022], // "PNK" - Pa'u
|
||||
forms[1023], // "BLU" - Sensu
|
||||
};
|
||||
|
||||
case 745: // Lycanroc
|
||||
return new[]
|
||||
{
|
||||
forms[745], // Midday
|
||||
forms[1024], // Midnight
|
||||
};
|
||||
|
||||
case 746: // Wishiwashi
|
||||
return new[]
|
||||
{
|
||||
forms[746],
|
||||
forms[1025], // School
|
||||
};
|
||||
|
||||
case 773: // Silvally
|
||||
return GetFormsArceus(7, types);
|
||||
|
||||
case 774: // Minior
|
||||
return new[]
|
||||
{
|
||||
forms[774], // "R-Meteor", // Meteor Red
|
||||
forms[1045], // "O-Meteor", // Meteor Orange
|
||||
forms[1046], // "Y-Meteor", // Meteor Yellow
|
||||
forms[1047], // "G-Meteor", // Meteor Green
|
||||
forms[1048], // "B-Meteor", // Meteor Blue
|
||||
forms[1049], // "I-Meteor", // Meteor Indigo
|
||||
forms[1050], // "V-Meteor", // Meteor Violet
|
||||
forms[1051], // "R-Core", // Core Red
|
||||
forms[1052], // "O-Core", // Core Orange
|
||||
forms[1053], // "Y-Core", // Core Yellow
|
||||
forms[1054], // "G-Core", // Core Green
|
||||
forms[1055], // "B-Core", // Core Blue
|
||||
forms[1056], // "I-Core", // Core Indigo
|
||||
forms[1057], // "V-Core", // Core Violet
|
||||
};
|
||||
|
||||
case 778: // Mimikyu
|
||||
return new[]
|
||||
{
|
||||
forms[778], // Disguised
|
||||
forms[1058], // Busted
|
||||
};
|
||||
|
||||
case 801: // Magearna
|
||||
return new[]
|
||||
{
|
||||
types[000],
|
||||
forms[1062], // Original
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private static string[] GetFormsAlolan (int generation, IReadOnlyList<string> types, IReadOnlyList<string> forms, int species)
|
||||
{
|
||||
if (generation < 7)
|
||||
return new[] { "" };
|
||||
|
||||
switch (species)
|
||||
{
|
||||
default:
|
||||
return new[] { "" };
|
||||
|
||||
case 19: // Rattata
|
||||
case 20: // Raticate
|
||||
case 26: // Raichu
|
||||
case 27: // Sandshrew
|
||||
case 28: // Sandslash
|
||||
case 37: // Vulpix
|
||||
case 38: // Ninetails
|
||||
case 50: // Diglett
|
||||
case 51: // Dugtrio
|
||||
case 52: // Meowth
|
||||
case 53: // Persian
|
||||
case 74: // Geodude
|
||||
case 75: // Graveler
|
||||
case 76: // Golem
|
||||
case 88: // Grimer
|
||||
case 89: // Muk
|
||||
case 105: // Marowak
|
||||
case 103: // Exeggutor
|
||||
return new[]
|
||||
{
|
||||
types[000],
|
||||
forms[810] // Alolan
|
||||
};
|
||||
}
|
||||
}
|
||||
private static string[] GetFormsPikachu(int generation, IReadOnlyList<string> types, IReadOnlyList<string> forms)
|
||||
{
|
||||
switch (generation)
|
||||
{
|
||||
default:
|
||||
return new[] { "" };
|
||||
|
||||
case 6:
|
||||
return new[]
|
||||
{
|
||||
types[000], // Normal
|
||||
forms[729], // Rockstar
|
||||
forms[730], // Belle
|
||||
forms[731], // Pop
|
||||
forms[732], // PhD
|
||||
forms[733], // Libre
|
||||
forms[734], // Cosplay
|
||||
};
|
||||
case 7:
|
||||
return new[]
|
||||
{
|
||||
types[000], // Normal
|
||||
forms[813], // Original
|
||||
forms[814], // Hoenn
|
||||
forms[815], // Sinnoh
|
||||
forms[816], // Unova
|
||||
forms[817], // Kalos
|
||||
forms[818], // Alola
|
||||
};
|
||||
}
|
||||
}
|
||||
private static string[] GetFormsPichu (int generation, IReadOnlyList<string> types, IReadOnlyList<string> forms)
|
||||
{
|
||||
if (generation == 4)
|
||||
return new[]
|
||||
{
|
||||
types[000], // Normal
|
||||
forms[000], // Spiky
|
||||
};
|
||||
return new[] { "" };
|
||||
}
|
||||
private static string[] GetFormsArceus (int generation, IReadOnlyList<string> types)
|
||||
{
|
||||
switch (generation)
|
||||
{
|
||||
case 4:
|
||||
return new[]
|
||||
{
|
||||
types[00], // Normal
|
||||
types[01], // Fighting
|
||||
types[02], // Flying
|
||||
types[03], // Poison
|
||||
types[04], // etc
|
||||
types[05],
|
||||
types[06],
|
||||
types[07],
|
||||
types[08],
|
||||
"???", // ???-type arceus
|
||||
types[09],
|
||||
types[10],
|
||||
types[11],
|
||||
types[12],
|
||||
types[13],
|
||||
types[14],
|
||||
types[15],
|
||||
types[16] // No Fairy Type
|
||||
};
|
||||
case 5:
|
||||
return new[]
|
||||
{
|
||||
types[00], // Normal
|
||||
types[01], // Fighting
|
||||
types[02], // Flying
|
||||
types[03], // Poison
|
||||
types[04], // etc
|
||||
types[05],
|
||||
types[06],
|
||||
types[07],
|
||||
types[08],
|
||||
types[09],
|
||||
types[10],
|
||||
types[11],
|
||||
types[12],
|
||||
types[13],
|
||||
types[14],
|
||||
types[15],
|
||||
types[16] // No Fairy type
|
||||
};
|
||||
default:
|
||||
return new[]
|
||||
{
|
||||
types[00], // Normal
|
||||
types[01], // Fighting
|
||||
types[02], // Flying
|
||||
types[03], // Poison
|
||||
types[04], // etc
|
||||
types[05],
|
||||
types[06],
|
||||
types[07],
|
||||
types[08],
|
||||
types[09],
|
||||
types[10],
|
||||
types[11],
|
||||
types[12],
|
||||
types[13],
|
||||
types[14],
|
||||
types[15],
|
||||
types[16],
|
||||
types[17],
|
||||
};
|
||||
}
|
||||
}
|
||||
private static string[] GetFormsUnown(int generation)
|
||||
{
|
||||
switch (generation)
|
||||
{
|
||||
case 2:
|
||||
return new[]
|
||||
{
|
||||
"A", "B", "C", "D", "E",
|
||||
"F", "G", "H", "I", "J",
|
||||
"K", "L", "M", "N", "O",
|
||||
"P", "Q", "R", "S", "T",
|
||||
"U", "V", "W", "X", "Y",
|
||||
"Z",
|
||||
// "!", "?", not in Gen II
|
||||
};
|
||||
default:
|
||||
return new[]
|
||||
{
|
||||
"A", "B", "C", "D", "E",
|
||||
"F", "G", "H", "I", "J",
|
||||
"K", "L", "M", "N", "O",
|
||||
"P", "Q", "R", "S", "T",
|
||||
"U", "V", "W", "X", "Y",
|
||||
"Z",
|
||||
"!", "?",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsFormListSingleMega(int species) => Mega_6_Single.Contains(species);
|
||||
private static readonly HashSet<int> Mega_6_Single = new HashSet<int>
|
||||
{
|
||||
// XY
|
||||
003, 009, 065, 094, 115, 127, 130, 142, 181, 212, 214, 229, 248, 257, 282, 303, 306, 308, 310, 354, 359,
|
||||
380, 381, 445, 448, 460,
|
||||
|
||||
// AO
|
||||
003, 009, 065, 094, 115, 127, 130, 142, 181, 212, 214, 229, 248, 257, 282, 303, 306, 308, 310, 354, 359,
|
||||
380, 381, 445, 448, 460,
|
||||
};
|
||||
}
|
||||
}
|
101
PKHeX.Core/PKM/ItemConverter.cs
Normal file
101
PKHeX.Core/PKM/ItemConverter.cs
Normal file
|
@ -0,0 +1,101 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
internal static class ItemConverter
|
||||
{
|
||||
/// <summary>Unused item ID, placeholder for item/sprite finding</summary>
|
||||
private const ushort NaN = 128;
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the item can be kept during 3->4 conversion.
|
||||
/// </summary>
|
||||
/// <param name="item">Generation 3 Item ID.</param>
|
||||
/// <returns>True if transferrable, False if not transferrable.</returns>
|
||||
public static bool IsItemTransferrable34(ushort item) => item != NaN && item > 0;
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Generation 3 Item ID to Generation 4+ Item ID.
|
||||
/// </summary>
|
||||
/// <param name="g3val">Generation 3 Item ID.</param>
|
||||
/// <returns>Generation 4+ Item ID.</returns>
|
||||
public static ushort GetG4Item(ushort g3val) => g3val > arr3.Length ? NaN : arr3[g3val];
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Generation 2 Item ID to Generation 4+ Item ID.
|
||||
/// </summary>
|
||||
/// <param name="g2val">Generation 2 Item ID.</param>
|
||||
/// <returns>Generation 4+ Item ID.</returns>
|
||||
public static ushort GetG4Item(byte g2val) => g2val > arr2.Length ? NaN : arr2[g2val];
|
||||
|
||||
#region Item Mapping Tables
|
||||
/// <summary> Gen2 items (index) and their corresponding Gen4 item ID (value) </summary>
|
||||
private static readonly ushort[] arr2 =
|
||||
{
|
||||
000, 001, 002, 213, 003, 004, NaN, 450, 081, 018,
|
||||
019, 020, 021, 022, 023, 024, 025, 026, 017, 078,
|
||||
079, 041, 082, 083, 084, NaN, 045, 046, 047, 048,
|
||||
256, 049, 050, 060, 085, 257, 092, 063, 027, 028,
|
||||
029, 055, 076, 077, 056, NaN, 030, 031, 032, 057,
|
||||
NaN, 058, 059, 061, 444, NaN, NaN, 216, 445, 446,
|
||||
NaN, 447, 051, 038, 039, 040, 478, 464, 456, 484,
|
||||
NaN, 482, 033, 217, NaN, NaN, 237, 244, NaN, NaN,
|
||||
NaN, 245, 221, NaN, NaN, 485, 086, 087, 222, 487,
|
||||
NaN, 223, 486, 488, 224, 243, 248, 490, 241, 491,
|
||||
NaN, 489, 240, 473, NaN, 259, 228, 246, 242, NaN,
|
||||
088, 089, 229, 247, 504, NaN, NaN, 239, 258, 230,
|
||||
NaN, 034, 035, 036, 037, 238, 231, 475, 481, NaN,
|
||||
NaN, 090, 091, 476, 480, NaN, NaN, NaN, 249, 043,
|
||||
232, NaN, NaN, 233, 250, NaN, 234, NaN, NaN, NaN,
|
||||
NaN, 235, NaN, NaN, NaN, NaN, 044, 495, NaN, 493,
|
||||
NaN, 492, NaN, 236, 497, 498, 496, NaN, NaN, 080,
|
||||
NaN, NaN, 252, NaN, NaN, 477, NaN, 500, 483, NaN,
|
||||
NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN,
|
||||
NaN, 328, 329, 330, 331, 331, 332, 333, 334, 335,
|
||||
336, 337, 338, 339, 340, 341, 342, 343, 344, 345,
|
||||
346, 347, 348, 349, 350, 351, 352, 353, 354, 355,
|
||||
355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
|
||||
365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
|
||||
375, 376, 377, 420, 421, 422, 423, 424, 425, 426,
|
||||
427, NaN, NaN, NaN, NaN, NaN,
|
||||
};
|
||||
/// <summary> Gen3 items (index) and their corresponding Gen4 item ID (value) </summary>
|
||||
private static readonly ushort[] arr3 =
|
||||
{
|
||||
000, 001, 002, 003, 004, 005, 006, 007, 008, 009,
|
||||
010, 011, 012, 017, 018, 019, 020, 021, 022, 023,
|
||||
024, 025, 026, 027, 028, 029, 030, 031, 032, 033,
|
||||
034, 035, 036, 037, 038, 039, 040, 041, 042, 065,
|
||||
066, 067, 068, 069, 043, 044, 070, 071, 072, 073,
|
||||
074, 075, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN,
|
||||
NaN, NaN, NaN, 045, 046, 047, 048, 049, 050, 051,
|
||||
052, 053, NaN, 055, 056, 057, 058, 059, 060, 061,
|
||||
063, 064, NaN, 076, 077, 078, 079, NaN, NaN, NaN,
|
||||
NaN, NaN, NaN, 080, 081, 082, 083, 084, 085, NaN,
|
||||
NaN, NaN, NaN, 086, 087, NaN, 088, 089, 090, 091,
|
||||
092, 093, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN,
|
||||
NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN,
|
||||
NaN, NaN, NaN, 149, 150, 151, 152, 153, 154, 155,
|
||||
156, 157, 158, 159, 160, 161, 162, 163, 164, 165,
|
||||
166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
|
||||
176, 177, 178, 179, 180, 181, 182, 183, 201, 202,
|
||||
203, 204, 205, 206, 207, 208, NaN, NaN, NaN, 213,
|
||||
214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
|
||||
224, 225, 226, 227, 228, 229, 230, 231, 232, 233,
|
||||
234, 235, 236, 237, 238, 239, 240, 241, 242, 243,
|
||||
244, 245, 246, 247, 248, 249, 250, 251, 252, 253,
|
||||
254, 255, 256, 257, 258, 259, NaN, NaN, NaN, NaN,
|
||||
NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN,
|
||||
NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN,
|
||||
NaN, NaN, NaN, NaN, 260, 261, 262, 263, 264,
|
||||
|
||||
NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN,
|
||||
NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN,
|
||||
NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN,
|
||||
328, 329, 330, 331, 332, 333, 334, 335, 336, 337,
|
||||
338, 339, 340, 341, 342, 343, 344, 345, 346, 347,
|
||||
348, 349, 350, 351, 352, 353, 354, 355, 356, 357,
|
||||
358, 359, 360, 361, 362, 363, 364, 365, 366, 367,
|
||||
368, 369, 370, 371, 372, 373, 374, 375, 376, 377,
|
||||
};
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -20,8 +20,8 @@ namespace PKHeX.Core
|
|||
internal const int STRLEN_U = 11;
|
||||
private int StringLength => Japanese ? STRLEN_J : STRLEN_U;
|
||||
|
||||
public override string GetString(int Offset, int Count) => PKX.GetString1(Data, Offset, Count, Japanese);
|
||||
public override byte[] SetString(string value, int maxLength) => PKX.SetString1(value, maxLength, Japanese);
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetString1(Data, Offset, Count, Japanese);
|
||||
public override byte[] SetString(string value, int maxLength) => StringConverter.SetString1(value, maxLength, Japanese);
|
||||
|
||||
// Trash Bytes
|
||||
public override byte[] Nickname_Trash { get => nick; set { if (value?.Length == nick.Length) nick = value; } }
|
||||
|
@ -53,7 +53,7 @@ namespace PKHeX.Core
|
|||
}
|
||||
public override string Nickname
|
||||
{
|
||||
get => PKX.GetString1(nick, 0, nick.Length, Japanese);
|
||||
get => StringConverter.GetString1(nick, 0, nick.Length, Japanese);
|
||||
set
|
||||
{
|
||||
byte[] strdata = SetString(value, StringLength);
|
||||
|
@ -71,7 +71,7 @@ namespace PKHeX.Core
|
|||
|
||||
public override string OT_Name
|
||||
{
|
||||
get => PKX.GetString1(otname, 0, otname.Length, Japanese);
|
||||
get => StringConverter.GetString1(otname, 0, otname.Length, Japanese);
|
||||
set
|
||||
{
|
||||
byte[] strdata = SetString(value, StringLength);
|
||||
|
@ -131,10 +131,10 @@ namespace PKHeX.Core
|
|||
#region Stored Attributes
|
||||
public override int Species
|
||||
{
|
||||
get => PKX.GetG1Species(Data[0]);
|
||||
get => SpeciesConverter.GetG1Species(Data[0]);
|
||||
set
|
||||
{
|
||||
Data[0] = (byte)PKX.SetG1Species(value);
|
||||
Data[0] = (byte)SpeciesConverter.SetG1Species(value);
|
||||
|
||||
// Before updating catch rate, check if non-standard
|
||||
if (!CatchRateIsItem)
|
||||
|
@ -348,7 +348,7 @@ namespace PKHeX.Core
|
|||
Move4_PP = Move4_PP,
|
||||
Met_Location = 30013, // "Kanto region", hardcoded.
|
||||
Gender = PersonalTable.SM[Species].RandomGender,
|
||||
OT_Name = PKX.GetG1ConvertedString(otname, Japanese),
|
||||
OT_Name = StringConverter.GetG1ConvertedString(otname, Japanese),
|
||||
IsNicknamed = false,
|
||||
|
||||
Country = PKMConverter.Country,
|
||||
|
@ -364,7 +364,7 @@ namespace PKHeX.Core
|
|||
pk7.Nickname = PKX.GetSpeciesNameGeneration(pk7.Species, pk7.Language, pk7.Format);
|
||||
if (otname[0] == 0x5D) // Ingame Trade
|
||||
{
|
||||
var s = PKX.GetG1Char(0x5D, Japanese);
|
||||
var s = StringConverter.GetG1Char(0x5D, Japanese);
|
||||
pk7.OT_Name = s.Substring(0, 1) + s.Substring(1).ToLower();
|
||||
}
|
||||
pk7.OT_Friendship = pk7.HT_Friendship = PersonalTable.SM[Species].BaseFriendship;
|
||||
|
@ -391,7 +391,7 @@ namespace PKHeX.Core
|
|||
else if (IsNicknamedBank)
|
||||
{
|
||||
pk7.IsNicknamed = true;
|
||||
pk7.Nickname = PKX.GetG1ConvertedString(nick, Japanese);
|
||||
pk7.Nickname = StringConverter.GetG1ConvertedString(nick, Japanese);
|
||||
}
|
||||
|
||||
pk7.TradeMemory(Bank:true); // oh no, memories on gen7 pkm
|
||||
|
@ -512,7 +512,7 @@ namespace PKHeX.Core
|
|||
Count = Capacity;
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
Data[1 + i] = (byte)PKX.SetG1Species(Pokemon[i].Species);
|
||||
Data[1 + i] = (byte)SpeciesConverter.SetG1Species(Pokemon[i].Species);
|
||||
Array.Copy(Pokemon[i].Data, 0, Data, 2 + Capacity + Entry_Size * i, Entry_Size);
|
||||
Array.Copy(Pokemon[i].OT_Name_Raw, 0, Data, 2 + Capacity + Capacity * Entry_Size + StringLength * i, StringLength);
|
||||
Array.Copy(Pokemon[i].Nickname_Raw, 0, Data, 2 + Capacity + Capacity * Entry_Size + StringLength * Capacity + StringLength * i, StringLength);
|
||||
|
|
|
@ -21,8 +21,8 @@ namespace PKHeX.Core
|
|||
internal const int STRLEN_U = 11;
|
||||
private int StringLength => Japanese ? STRLEN_J : STRLEN_U;
|
||||
|
||||
public override string GetString(int Offset, int Count) => PKX.GetString1(Data, Offset, Count, Japanese);
|
||||
public override byte[] SetString(string value, int maxLength) => PKX.SetString1(value, maxLength, Japanese);
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetString1(Data, Offset, Count, Japanese);
|
||||
public override byte[] SetString(string value, int maxLength) => StringConverter.SetString1(value, maxLength, Japanese);
|
||||
|
||||
// Trash Bytes
|
||||
public override byte[] Nickname_Trash { get => nick; set { if (value?.Length == nick.Length) nick = value; } }
|
||||
|
@ -64,7 +64,7 @@ namespace PKHeX.Core
|
|||
}
|
||||
public override string Nickname
|
||||
{
|
||||
get => PKX.GetString1(nick, 0, nick.Length, Japanese);
|
||||
get => StringConverter.GetString1(nick, 0, nick.Length, Japanese);
|
||||
set
|
||||
{
|
||||
byte[] strdata = SetString(value, StringLength);
|
||||
|
@ -82,7 +82,7 @@ namespace PKHeX.Core
|
|||
|
||||
public override string OT_Name
|
||||
{
|
||||
get => PKX.GetString1(otname, 0, otname.Length, Japanese);
|
||||
get => StringConverter.GetString1(otname, 0, otname.Length, Japanese);
|
||||
set
|
||||
{
|
||||
byte[] strdata = SetString(value, StringLength);
|
||||
|
@ -134,7 +134,7 @@ namespace PKHeX.Core
|
|||
get => Data[0];
|
||||
set => Data[0] = (byte)value;
|
||||
}
|
||||
public override int SpriteItem => PKX.GetG4Item((byte)HeldItem);
|
||||
public override int SpriteItem => ItemConverter.GetG4Item((byte)HeldItem);
|
||||
public override int HeldItem { get => Data[0x1]; set => Data[0x1] = (byte)value; }
|
||||
public override int Move1 { get => Data[2]; set => Data[2] = (byte)value; }
|
||||
public override int Move2 { get => Data[3]; set => Data[3] = (byte)value; }
|
||||
|
@ -396,7 +396,7 @@ namespace PKHeX.Core
|
|||
Move4_PP = Move4_PP,
|
||||
Met_Location = 30004,
|
||||
Gender = PersonalTable.SM[Species].RandomGender,
|
||||
OT_Name = PKX.GetG1ConvertedString(otname, Japanese),
|
||||
OT_Name = StringConverter.GetG1ConvertedString(otname, Japanese),
|
||||
IsNicknamed = false,
|
||||
|
||||
Country = PKMConverter.Country,
|
||||
|
@ -412,7 +412,7 @@ namespace PKHeX.Core
|
|||
pk7.Nickname = PKX.GetSpeciesNameGeneration(pk7.Species, pk7.Language, pk7.Format);
|
||||
if (otname[0] == 0x5D) // Ingame Trade
|
||||
{
|
||||
var s = PKX.GetG1Char(0x5D, Japanese);
|
||||
var s = StringConverter.GetG1Char(0x5D, Japanese);
|
||||
pk7.OT_Name = s.Substring(0, 1) + s.Substring(1).ToLower();
|
||||
}
|
||||
pk7.OT_Friendship = pk7.HT_Friendship = PersonalTable.SM[Species].BaseFriendship;
|
||||
|
@ -440,7 +440,7 @@ namespace PKHeX.Core
|
|||
else if (IsNicknamed)
|
||||
{
|
||||
pk7.IsNicknamed = true;
|
||||
pk7.Nickname = PKX.GetG1ConvertedString(nick, Japanese);
|
||||
pk7.Nickname = StringConverter.GetG1ConvertedString(nick, Japanese);
|
||||
}
|
||||
|
||||
pk7.TradeMemory(Bank: true); // oh no, memories on gen7 pkm
|
||||
|
|
|
@ -24,8 +24,8 @@ namespace PKHeX.Core
|
|||
}
|
||||
public override PKM Clone() { return new PK3(Data); }
|
||||
|
||||
public override string GetString(int Offset, int Count) => PKX.GetString3(Data, Offset, Count, Japanese);
|
||||
public override byte[] SetString(string value, int maxLength) => PKX.SetString3(value, maxLength, Japanese);
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetString3(Data, Offset, Count, Japanese);
|
||||
public override byte[] SetString(string value, int maxLength) => StringConverter.SetString3(value, maxLength, Japanese);
|
||||
|
||||
// Trash Bytes
|
||||
public override byte[] Nickname_Trash { get => GetData(0x08, 10); set { if (value?.Length == 10) value.CopyTo(Data, 0x08); } }
|
||||
|
@ -56,8 +56,8 @@ namespace PKHeX.Core
|
|||
public override ushort Sanity { get => BitConverter.ToUInt16(Data, 0x1E); set => BitConverter.GetBytes(value).CopyTo(Data, 0x1E); }
|
||||
|
||||
#region Block A
|
||||
public override int Species { get => PKX.GetG4Species(BitConverter.ToUInt16(Data, 0x20)); set => BitConverter.GetBytes((ushort)PKX.GetG3Species(value)).CopyTo(Data, 0x20); }
|
||||
public override int SpriteItem => PKX.GetG4Item((ushort)HeldItem);
|
||||
public override int Species { get => SpeciesConverter.GetG4Species(BitConverter.ToUInt16(Data, 0x20)); set => BitConverter.GetBytes((ushort)SpeciesConverter.GetG3Species(value)).CopyTo(Data, 0x20); }
|
||||
public override int SpriteItem => ItemConverter.GetG4Item((ushort)HeldItem);
|
||||
public override int HeldItem { get => BitConverter.ToUInt16(Data, 0x22); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x22); }
|
||||
|
||||
public override uint EXP { get => BitConverter.ToUInt32(Data, 0x24); set => BitConverter.GetBytes(value).CopyTo(Data, 0x24); }
|
||||
|
@ -273,7 +273,7 @@ namespace PKHeX.Core
|
|||
pk4.RibbonG3ToughMaster |= RibbonCountG3Tough > 3;
|
||||
|
||||
// Yay for reusing string buffers!
|
||||
PKX.G4TransferTrashBytes[pk4.Language].CopyTo(pk4.Data, 0x48 + 4);
|
||||
StringConverter.G4TransferTrashBytes[pk4.Language].CopyTo(pk4.Data, 0x48 + 4);
|
||||
pk4.Nickname = IsEgg ? PKX.GetSpeciesNameGeneration(pk4.Species, pk4.Language, pk4.Format) : Nickname;
|
||||
Array.Copy(pk4.Data, 0x48, pk4.Data, 0x68, 0x10);
|
||||
pk4.OT_Name = OT_Name;
|
||||
|
@ -288,8 +288,8 @@ namespace PKHeX.Core
|
|||
|
||||
if (HeldItem > 0)
|
||||
{
|
||||
ushort item = PKX.GetG4Item((ushort)HeldItem);
|
||||
if (PKX.IsItemTransferrable34(item))
|
||||
ushort item = ItemConverter.GetG4Item((ushort)HeldItem);
|
||||
if (ItemConverter.IsItemTransferrable34(item))
|
||||
pk4.HeldItem = item;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@ namespace PKHeX.Core
|
|||
}
|
||||
public override PKM Clone() { return new PK4(Data); }
|
||||
|
||||
public override string GetString(int Offset, int Count) => PKX.GetString4(Data, Offset, Count);
|
||||
public override byte[] SetString(string value, int maxLength) => PKX.SetString4(value, maxLength);
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetString4(Data, Offset, Count);
|
||||
public override byte[] SetString(string value, int maxLength) => StringConverter.SetString4(value, maxLength);
|
||||
|
||||
// Trash Bytes
|
||||
public override byte[] Nickname_Trash { get => GetData(0x48, 22); set { if (value?.Length == 22) value.CopyTo(Data, 0x48); } }
|
||||
|
|
|
@ -24,8 +24,8 @@ namespace PKHeX.Core
|
|||
}
|
||||
public override PKM Clone() { return new PK5(Data); }
|
||||
|
||||
public override string GetString(int Offset, int Count) => PKX.GetString5(Data, Offset, Count);
|
||||
public override byte[] SetString(string value, int maxLength) => PKX.SetString5(value, maxLength);
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetString5(Data, Offset, Count);
|
||||
public override byte[] SetString(string value, int maxLength) => StringConverter.SetString5(value, maxLength);
|
||||
|
||||
// Trash Bytes
|
||||
public override byte[] Nickname_Trash { get => GetData(0x48, 22); set { if (value?.Length == 22) value.CopyTo(Data, 0x48); } }
|
||||
|
|
|
@ -25,8 +25,8 @@ namespace PKHeX.Core
|
|||
}
|
||||
public override PKM Clone() { return new PK6(Data); }
|
||||
|
||||
public override string GetString(int Offset, int Count) => PKX.GetString6(Data, Offset, Count);
|
||||
public override byte[] SetString(string value, int maxLength) => PKX.SetString6(value, maxLength);
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetString6(Data, Offset, Count);
|
||||
public override byte[] SetString(string value, int maxLength) => StringConverter.SetString6(value, maxLength);
|
||||
|
||||
// Trash Bytes
|
||||
public override byte[] Nickname_Trash { get => GetData(0x40, 24); set { if (value?.Length == 24) value.CopyTo(Data, 0x40); } }
|
||||
|
|
|
@ -26,8 +26,8 @@ namespace PKHeX.Core
|
|||
}
|
||||
public override PKM Clone() { return new PK7(Data); }
|
||||
|
||||
public override string GetString(int Offset, int Count) => PKX.GetString7(Data, Offset, Count);
|
||||
public override byte[] SetString(string value, int maxLength) => PKX.SetString7(value, maxLength, Language);
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetString7(Data, Offset, Count);
|
||||
public override byte[] SetString(string value, int maxLength) => StringConverter.SetString7(value, maxLength, Language);
|
||||
|
||||
// Trash Bytes
|
||||
public override byte[] Nickname_Trash { get => GetData(0x40, 24); set { if (value?.Length == 24) value.CopyTo(Data, 0x40); } }
|
||||
|
|
File diff suppressed because it is too large
Load diff
70
PKHeX.Core/PKM/SpeciesConverter.cs
Normal file
70
PKHeX.Core/PKM/SpeciesConverter.cs
Normal file
|
@ -0,0 +1,70 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
internal static class SpeciesConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts Generation 1 species ID to National Dex ID.
|
||||
/// </summary>
|
||||
/// <param name="raw_id">Generation 1 species ID.</param>
|
||||
/// <returns>National Dex ID.</returns>
|
||||
public static int GetG1Species(int raw_id) => table1_National[raw_id];
|
||||
|
||||
/// <summary>
|
||||
/// Converts a National Dex ID to Generation 1 species ID.
|
||||
/// </summary>
|
||||
/// <param name="dex_id">National Dex ID.</param>
|
||||
/// <returns>Generation 1 species ID.</returns>
|
||||
public static int SetG1Species(int dex_id) => table1_Internal[dex_id];
|
||||
|
||||
/// <summary>
|
||||
/// Converts a National Dex ID to Generation 3 species ID.
|
||||
/// </summary>
|
||||
/// <param name="g4index">National Dex ID</param>
|
||||
/// <returns>Generation 3 species ID.</returns>
|
||||
public static int GetG3Species(int g4index) => Dict3Values.TryGetValue(g4index, out int value) ? value : 0;
|
||||
|
||||
/// <summary>
|
||||
/// Converts Generation 3 species ID to National Dex ID.
|
||||
/// </summary>
|
||||
/// <param name="g3index">Generation 3 species ID.</param>
|
||||
/// <returns>National Dex ID.</returns>
|
||||
public static int GetG4Species(int g3index) => Dict4Values.TryGetValue(g3index, out int value) ? value : 0;
|
||||
|
||||
private static readonly int[] table1_Internal = { 0x00, 0x99, 0x09, 0x9A, 0xB0, 0xB2, 0xB4, 0xB1, 0xB3, 0x1C, 0x7B, 0x7C, 0x7D, 0x70, 0x71, 0x72, 0x24, 0x96, 0x97, 0xA5, 0xA6, 0x05, 0x23, 0x6C, 0x2D, 0x54, 0x55, 0x60, 0x61, 0x0F, 0xA8, 0x10, 0x03, 0xA7, 0x07, 0x04, 0x8E, 0x52, 0x53, 0x64, 0x65, 0x6B, 0x82, 0xB9, 0xBA, 0xBB, 0x6D, 0x2E, 0x41, 0x77, 0x3B, 0x76, 0x4D, 0x90, 0x2F, 0x80, 0x39, 0x75, 0x21, 0x14, 0x47, 0x6E, 0x6F, 0x94, 0x26, 0x95, 0x6A, 0x29, 0x7E, 0xBC, 0xBD, 0xBE, 0x18, 0x9B, 0xA9, 0x27, 0x31, 0xA3, 0xA4, 0x25, 0x08, 0xAD, 0x36, 0x40, 0x46, 0x74, 0x3A, 0x78, 0x0D, 0x88, 0x17, 0x8B, 0x19, 0x93, 0x0E, 0x22, 0x30, 0x81, 0x4E, 0x8A, 0x06, 0x8D, 0x0C, 0x0A, 0x11, 0x91, 0x2B, 0x2C, 0x0B, 0x37, 0x8F, 0x12, 0x01, 0x28, 0x1E, 0x02, 0x5C, 0x5D, 0x9D, 0x9E, 0x1B, 0x98, 0x2A, 0x1A, 0x48, 0x35, 0x33, 0x1D, 0x3C, 0x85, 0x16, 0x13, 0x4C, 0x66, 0x69, 0x68, 0x67, 0xAA, 0x62, 0x63, 0x5A, 0x5B, 0xAB, 0x84, 0x4A, 0x4B, 0x49, 0x58, 0x59, 0x42, 0x83, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
private static readonly int[] table1_National = { 0x00, 0x70, 0x73, 0x20, 0x23, 0x15, 0x64, 0x22, 0x50, 0x02, 0x67, 0x6C, 0x66, 0x58, 0x5E, 0x1D, 0x1F, 0x68, 0x6F, 0x83, 0x3B, 0x97, 0x82, 0x5A, 0x48, 0x5C, 0x7B, 0x78, 0x09, 0x7F, 0x72, 0x00, 0x00, 0x3A, 0x5F, 0x16, 0x10, 0x4F, 0x40, 0x4B, 0x71, 0x43, 0x7A, 0x6A, 0x6B, 0x18, 0x2F, 0x36, 0x60, 0x4C, 0x00, 0x7E, 0x00, 0x7D, 0x52, 0x6D, 0x00, 0x38, 0x56, 0x32, 0x80, 0x00, 0x00, 0x00, 0x53, 0x30, 0x95, 0x00, 0x00, 0x00, 0x54, 0x3C, 0x7C, 0x92, 0x90, 0x91, 0x84, 0x34, 0x62, 0x00, 0x00, 0x00, 0x25, 0x26, 0x19, 0x1A, 0x00, 0x00, 0x93, 0x94, 0x8C, 0x8D, 0x74, 0x75, 0x00, 0x00, 0x1B, 0x1C, 0x8A, 0x8B, 0x27, 0x28, 0x85, 0x88, 0x87, 0x86, 0x42, 0x29, 0x17, 0x2E, 0x3D, 0x3E, 0x0D, 0x0E, 0x0F, 0x00, 0x55, 0x39, 0x33, 0x31, 0x57, 0x00, 0x00, 0x0A, 0x0B, 0x0C, 0x44, 0x00, 0x37, 0x61, 0x2A, 0x96, 0x8F, 0x81, 0x00, 0x00, 0x59, 0x00, 0x63, 0x5B, 0x00, 0x65, 0x24, 0x6E, 0x35, 0x69, 0x00, 0x5D, 0x3F, 0x41, 0x11, 0x12, 0x79, 0x01, 0x03, 0x49, 0x00, 0x76, 0x77, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x4E, 0x13, 0x14, 0x21, 0x1E, 0x4A, 0x89, 0x8E, 0x00, 0x51, 0x00, 0x00, 0x04, 0x07, 0x05, 0x08, 0x06, 0x00, 0x00, 0x00, 0x00, 0x2B, 0x2C, 0x2D, 0x45, 0x46, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
/// <summary>
|
||||
/// Gen3 Species IDs ordered by National Dex ID
|
||||
/// </summary>
|
||||
private static readonly int[] oldIndex =
|
||||
{
|
||||
000, 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 017, 018, 019,
|
||||
020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033, 034, 035, 036, 037, 038, 039,
|
||||
040, 041, 042, 043, 044, 045, 046, 047, 048, 049, 050, 051, 052, 053, 054, 055, 056, 057, 058, 059,
|
||||
060, 061, 062, 063, 064, 065, 066, 067, 068, 069, 070, 071, 072, 073, 074, 075, 076, 077, 078, 079,
|
||||
080, 081, 082, 083, 084, 085, 086, 087, 088, 089, 090, 091, 092, 093, 094, 095, 096, 097, 098, 099,
|
||||
100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
|
||||
120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
|
||||
140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
|
||||
160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
|
||||
180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199,
|
||||
200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
|
||||
220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
|
||||
240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 277, 278, 279, 280, 281, 282, 283, 284,
|
||||
285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 304, 305, 309, 310,
|
||||
392, 393, 394, 311, 312, 306, 307, 364, 365, 366, 301, 302, 303, 370, 371, 372, 335, 336, 350, 320,
|
||||
315, 316, 322, 355, 382, 383, 384, 356, 357, 337, 338, 353, 354, 386, 387, 363, 367, 368, 330, 331,
|
||||
313, 314, 339, 340, 321, 351, 352, 308, 332, 333, 334, 344, 345, 358, 359, 380, 379, 348, 349, 323,
|
||||
324, 326, 327, 318, 319, 388, 389, 390, 391, 328, 329, 385, 317, 377, 378, 361, 362, 369, 411, 376,
|
||||
360, 346, 347, 341, 342, 343, 373, 374, 375, 381, 325, 395, 396, 397, 398, 399, 400, 401, 402, 403,
|
||||
407, 408, 404, 405, 406, 409, 410
|
||||
};
|
||||
private static readonly Dictionary<int, int> Dict3Values = oldIndex.Select((v, i) => new { Key = i, Value = v })
|
||||
.ToDictionary(o => o.Key, o => o.Value);
|
||||
private static readonly Dictionary<int, int> Dict4Values = oldIndex.Select((v, i) => new { Key = v, Value = i })
|
||||
.ToDictionary(o => o.Key, o => o.Value);
|
||||
}
|
||||
}
|
1504
PKHeX.Core/PKM/StringConverter.cs
Normal file
1504
PKHeX.Core/PKM/StringConverter.cs
Normal file
File diff suppressed because it is too large
Load diff
|
@ -25,8 +25,8 @@ namespace PKHeX.Core
|
|||
}
|
||||
public override PKM Clone() { return new XK3(Data) {Purification = Purification}; }
|
||||
|
||||
public override string GetString(int Offset, int Count) => PKX.GetBEString3(Data, Offset, Count);
|
||||
public override byte[] SetString(string value, int maxLength) => PKX.SetBEString3(value, maxLength);
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetBEString3(Data, Offset, Count);
|
||||
public override byte[] SetString(string value, int maxLength) => StringConverter.SetBEString3(value, maxLength);
|
||||
|
||||
// Trash Bytes
|
||||
public override byte[] Nickname_Trash { get => GetData(0x4E, 20); set { if (value?.Length == 20) value.CopyTo(Data, 0x4E); } }
|
||||
|
@ -50,8 +50,8 @@ namespace PKHeX.Core
|
|||
public override ushort Checksum { get => SaveUtil.CRC16_CCITT(Data); set { } } // totally false, just a way to get a 'random' ident for the pkm.
|
||||
public override bool ChecksumValid => Valid;
|
||||
|
||||
public override int Species { get => PKX.GetG4Species(BigEndian.ToUInt16(Data, 0x00)); set => BigEndian.GetBytes((ushort)PKX.GetG3Species(value)).CopyTo(Data, 0x00); }
|
||||
public override int SpriteItem => PKX.GetG4Item((ushort)HeldItem);
|
||||
public override int Species { get => SpeciesConverter.GetG4Species(BigEndian.ToUInt16(Data, 0x00)); set => BigEndian.GetBytes((ushort)SpeciesConverter.GetG3Species(value)).CopyTo(Data, 0x00); }
|
||||
public override int SpriteItem => ItemConverter.GetG4Item((ushort)HeldItem);
|
||||
public override int HeldItem { get => BigEndian.ToUInt16(Data, 0x02); set => BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x02); }
|
||||
public override int Stat_HPCurrent { get => BigEndian.ToUInt16(Data, 0x04); set => BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x04); }
|
||||
public override int OT_Friendship { get => Data[0x06]; set => Data[0x06] = (byte)value; }
|
||||
|
|
|
@ -483,12 +483,12 @@ namespace PKHeX.Core
|
|||
return (Data[PokedexCaughtOffset + ofs] & bitval) != 0;
|
||||
}
|
||||
|
||||
public override string GetString(int Offset, int Count) => PKX.GetString1(Data, Offset, Count, Japanese);
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetString1(Data, Offset, Count, Japanese);
|
||||
public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0)
|
||||
{
|
||||
if (PadToSize == 0)
|
||||
PadToSize = maxLength + 1;
|
||||
return PKX.SetString1(value, maxLength, Japanese, PadToSize, PadWith);
|
||||
return StringConverter.SetString1(value, maxLength, Japanese, PadToSize, PadWith);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -496,7 +496,7 @@ namespace PKHeX.Core
|
|||
}
|
||||
public override string GetBoxName(int box)
|
||||
{
|
||||
return PKX.GetString1(Data, BoxNamesOffset + box*9, 9, Japanese);
|
||||
return StringConverter.GetString1(Data, BoxNamesOffset + box*9, 9, Japanese);
|
||||
}
|
||||
public override void SetBoxName(int box, string value)
|
||||
{
|
||||
|
@ -584,7 +584,7 @@ namespace PKHeX.Core
|
|||
return (Data[PokedexCaughtOffset + ofs] & bitval) != 0;
|
||||
}
|
||||
|
||||
public override string GetString(int Offset, int Count) => PKX.GetString1(Data, Offset, Count, Japanese);
|
||||
public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0) => PKX.SetString1(value, maxLength, Japanese);
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetString1(Data, Offset, Count, Japanese);
|
||||
public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0) => StringConverter.SetString1(value, maxLength, Japanese);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -484,7 +484,7 @@ namespace PKHeX.Core
|
|||
public override string GetBoxName(int box)
|
||||
{
|
||||
int offset = GetBoxOffset(BoxCount);
|
||||
return PKX.GetString3(Data, offset + box * 9, 9, Japanese);
|
||||
return StringConverter.GetString3(Data, offset + box * 9, 9, Japanese);
|
||||
}
|
||||
public override void SetBoxName(int box, string value)
|
||||
{
|
||||
|
@ -618,12 +618,12 @@ namespace PKHeX.Core
|
|||
}
|
||||
}
|
||||
}
|
||||
public override string GetString(int Offset, int Count) => PKX.GetString3(Data, Offset, Count, Japanese);
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetString3(Data, Offset, Count, Japanese);
|
||||
public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0)
|
||||
{
|
||||
if (PadToSize == 0)
|
||||
PadToSize = maxLength + 1;
|
||||
return PKX.SetString3(value, maxLength, Japanese, PadToSize, PadWith);
|
||||
return StringConverter.SetString3(value, maxLength, Japanese, PadToSize, PadWith);
|
||||
}
|
||||
|
||||
#region eBerry
|
||||
|
@ -641,7 +641,7 @@ namespace PKHeX.Core
|
|||
{
|
||||
if (!GameVersion.RS.Contains(Version) || !IsEBerryChecksumValid)
|
||||
return string.Empty;
|
||||
return PKX.GetString3(Data, BlockOfs[4] + OFFSET_EBERRY, 7, Japanese).Trim();
|
||||
return StringConverter.GetString3(Data, BlockOfs[4] + OFFSET_EBERRY, 7, Japanese).Trim();
|
||||
}
|
||||
}
|
||||
public override bool IsEBerryIsEnigma => string.IsNullOrEmpty(EBerryName.Trim());
|
||||
|
|
|
@ -393,12 +393,12 @@ namespace PKHeX.Core
|
|||
public override void SetDaycareEXP(int loc, int slot, uint EXP) { }
|
||||
public override void SetDaycareOccupied(int loc, int slot, bool occupied) { }
|
||||
|
||||
public override string GetString(int Offset, int Count) => PKX.GetBEString3(Data, Offset, Count);
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetBEString3(Data, Offset, Count);
|
||||
public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0)
|
||||
{
|
||||
if (PadToSize == 0)
|
||||
PadToSize = maxLength + 1;
|
||||
return PKX.SetBEString3(value, maxLength, PadToSize, PadWith);
|
||||
return StringConverter.SetBEString3(value, maxLength, PadToSize, PadWith);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,12 +202,12 @@ namespace PKHeX.Core
|
|||
Edited = true;
|
||||
}
|
||||
|
||||
public override string GetString(int Offset, int Count) => PKX.GetString3(Data, Offset, Count, Japanese);
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetString3(Data, Offset, Count, Japanese);
|
||||
public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0)
|
||||
{
|
||||
if (PadToSize == 0)
|
||||
PadToSize = maxLength + 1;
|
||||
return PKX.SetString3(value, maxLength, Japanese, PadToSize, PadWith);
|
||||
return StringConverter.SetString3(value, maxLength, Japanese, PadToSize, PadWith);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -359,12 +359,12 @@ namespace PKHeX.Core
|
|||
public override void SetDaycareEXP(int loc, int slot, uint EXP) { }
|
||||
public override void SetDaycareOccupied(int loc, int slot, bool occupied) { }
|
||||
|
||||
public override string GetString(int Offset, int Count) => PKX.GetBEString3(Data, Offset, Count);
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetBEString3(Data, Offset, Count);
|
||||
public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0)
|
||||
{
|
||||
if (PadToSize == 0)
|
||||
PadToSize = maxLength + 1;
|
||||
return PKX.SetBEString3(value, maxLength, PadToSize, PadWith);
|
||||
return StringConverter.SetBEString3(value, maxLength, PadToSize, PadWith);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1121,12 +1121,12 @@ namespace PKHeX.Core
|
|||
}
|
||||
}
|
||||
|
||||
public override string GetString(int Offset, int Count) => PKX.GetString4(Data, Offset, Count);
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetString4(Data, Offset, Count);
|
||||
public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0)
|
||||
{
|
||||
if (PadToSize == 0)
|
||||
PadToSize = maxLength + 1;
|
||||
return PKX.SetString4(value, maxLength, PadToSize, PadWith);
|
||||
return StringConverter.SetString4(value, maxLength, PadToSize, PadWith);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -248,12 +248,12 @@ namespace PKHeX.Core
|
|||
}
|
||||
}
|
||||
|
||||
public override string GetString(int Offset, int Count) => PKX.GetBEString4(Data, Offset, Count);
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetBEString4(Data, Offset, Count);
|
||||
public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0)
|
||||
{
|
||||
if (PadToSize == 0)
|
||||
PadToSize = maxLength + 1;
|
||||
return PKX.SetBEString4(value, maxLength, PadToSize, PadWith);
|
||||
return StringConverter.SetBEString4(value, maxLength, PadToSize, PadWith);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -448,7 +448,7 @@ namespace PKHeX.Core
|
|||
{
|
||||
if (box >= BoxCount)
|
||||
return "";
|
||||
return PKX.TrimFromFFFF(Encoding.Unicode.GetString(Data, PCLayout + 0x28 * box + 4, 0x28));
|
||||
return StringConverter.TrimFromFFFF(Encoding.Unicode.GetString(Data, PCLayout + 0x28 * box + 4, 0x28));
|
||||
}
|
||||
public override void SetBoxName(int box, string val)
|
||||
{
|
||||
|
@ -696,12 +696,12 @@ namespace PKHeX.Core
|
|||
return false;
|
||||
}
|
||||
|
||||
public override string GetString(int Offset, int Count) => PKX.GetString5(Data, Offset, Count);
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetString5(Data, Offset, Count);
|
||||
public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0)
|
||||
{
|
||||
if (PadToSize == 0)
|
||||
PadToSize = maxLength + 1;
|
||||
return PKX.SetString5(value, maxLength, PadToSize, PadWith);
|
||||
return StringConverter.SetString5(value, maxLength, PadToSize, PadWith);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1033,12 +1033,12 @@ namespace PKHeX.Core
|
|||
$"{b.ID:00}: {b.Offset:X5}-{b.Offset + b.Length:X5}, {b.Length:X5}{Environment.NewLine}");
|
||||
}
|
||||
|
||||
public override string GetString(int Offset, int Count) => PKX.GetString6(Data, Offset, Count);
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetString6(Data, Offset, Count);
|
||||
public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0)
|
||||
{
|
||||
if (PadToSize == 0)
|
||||
PadToSize = maxLength + 1;
|
||||
return PKX.SetString6(value, maxLength, PadToSize, PadWith);
|
||||
return StringConverter.SetString6(value, maxLength, PadToSize, PadWith);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1312,12 +1312,12 @@ namespace PKHeX.Core
|
|||
|
||||
public override bool RequiresMemeCrypto => true;
|
||||
|
||||
public override string GetString(int Offset, int Count) => PKX.GetString7(Data, Offset, Count);
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetString7(Data, Offset, Count);
|
||||
public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0)
|
||||
{
|
||||
if (PadToSize == 0)
|
||||
PadToSize = maxLength + 1;
|
||||
return PKX.SetString7(value, maxLength, PadToSize, PadWith);
|
||||
return StringConverter.SetString7(value, maxLength, PadToSize, PadWith);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,11 +54,11 @@ namespace PKHeX.Core
|
|||
get
|
||||
{
|
||||
int val = BigEndian.ToUInt16(Data, 0) & 0x1FF;
|
||||
return PKX.GetG4Species(val);
|
||||
return SpeciesConverter.GetG4Species(val);
|
||||
}
|
||||
set
|
||||
{
|
||||
value = PKX.GetG3Species(value);
|
||||
value = SpeciesConverter.GetG3Species(value);
|
||||
int cval = BigEndian.ToUInt16(Data, 0);
|
||||
cval &= 0xE00; value &= 0x1FF; cval |= value;
|
||||
BigEndian.GetBytes((ushort)cval).CopyTo(Data, 0);
|
||||
|
|
|
@ -128,7 +128,7 @@ namespace PKHeX.WinForms
|
|||
int index = Bytes.IndexOf(nud);
|
||||
Raw[index] = (byte)nud.Value;
|
||||
|
||||
string str = PKX.GetString(Raw, SAV.Generation, SAV.Japanese, bigendian, Raw.Length);
|
||||
string str = StringConverter.GetString(Raw, SAV.Generation, SAV.Japanese, bigendian, Raw.Length);
|
||||
TB_Text.Text = str;
|
||||
editing = false;
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ namespace PKHeX.WinForms
|
|||
return;
|
||||
editing = true;
|
||||
// build bytes
|
||||
byte[] data = PKX.SetString(TB_Text.Text, SAV.Generation, SAV.Japanese, bigendian, Raw.Length, SAV.Language);
|
||||
byte[] data = StringConverter.SetString(TB_Text.Text, SAV.Generation, SAV.Japanese, bigendian, Raw.Length, SAV.Language);
|
||||
Array.Copy(data, Raw, Math.Min(data.Length, Raw.Length));
|
||||
for (int i = 0; i < Raw.Length; i++)
|
||||
Bytes[i].Value = Raw[i];
|
||||
|
@ -152,8 +152,8 @@ namespace PKHeX.WinForms
|
|||
if (species == "") // no result
|
||||
species = CB_Species.Text;
|
||||
|
||||
byte[] current = PKX.SetString(TB_Text.Text, SAV.Generation, SAV.Japanese, bigendian, Raw.Length, SAV.Language);
|
||||
byte[] data = PKX.SetString(species, SAV.Generation, SAV.Japanese, bigendian, Raw.Length, SAV.Language);
|
||||
byte[] current = StringConverter.SetString(TB_Text.Text, SAV.Generation, SAV.Japanese, bigendian, Raw.Length, SAV.Language);
|
||||
byte[] data = StringConverter.SetString(species, SAV.Generation, SAV.Japanese, bigendian, Raw.Length, SAV.Language);
|
||||
if (data.Length <= current.Length)
|
||||
{
|
||||
WinFormsUtil.Alert("Trash byte layer is hidden by current text.",
|
||||
|
@ -170,7 +170,7 @@ namespace PKHeX.WinForms
|
|||
}
|
||||
private void B_ClearTrash_Click(object sender, EventArgs e)
|
||||
{
|
||||
byte[] current = PKX.SetString(TB_Text.Text, SAV.Generation, SAV.Japanese, bigendian, Raw.Length, SAV.Language);
|
||||
byte[] current = StringConverter.SetString(TB_Text.Text, SAV.Generation, SAV.Japanese, bigendian, Raw.Length, SAV.Language);
|
||||
for (int i = current.Length; i < Bytes.Count; i++)
|
||||
Bytes[i].Value = 0;
|
||||
}
|
||||
|
|
|
@ -34,9 +34,9 @@ namespace PKHeX.WinForms
|
|||
|
||||
if (SAV.FRLG)
|
||||
{
|
||||
TB_OTName.Text = PKX.GetString3(SAV.Data, SAV.GetBlockOffset(4) + 0xBCC, 8, SAV.Japanese);
|
||||
ComboBox[] cba = new[] { CB_TCM1, CB_TCM2, CB_TCM3, CB_TCM4, CB_TCM5, CB_TCM6 };
|
||||
int[] HoennListMixed = new[] {
|
||||
TB_OTName.Text = StringConverter.GetString3(SAV.Data, SAV.GetBlockOffset(4) + 0xBCC, 8, SAV.Japanese);
|
||||
ComboBox[] cba = { CB_TCM1, CB_TCM2, CB_TCM3, CB_TCM4, CB_TCM5, CB_TCM6 };
|
||||
int[] HoennListMixed = {
|
||||
277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,
|
||||
304,305,309,310,392,393,394,311,312,306,307,364,365,366,301,302,303,370,371,372,335,336,350,320,315,316,
|
||||
322,355,382,383,384,356,357,337,338,353,354,386,387,363,367,368,330,331,313,314,
|
||||
|
|
Loading…
Reference in a new issue