mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-14 00:07:15 +00:00
Add flexibility for SK2 imports
Check language character table for English vs Japanese when loading for a destination
This commit is contained in:
parent
f8de9fe1bf
commit
09c6359e3a
5 changed files with 9 additions and 10 deletions
|
@ -175,5 +175,7 @@ namespace PKHeX.Core
|
|||
}
|
||||
|
||||
private static bool IsJapanese(byte[] data) => StringConverter12.GetIsG1Japanese(data, 0x24, StringLength) && StringConverter12.GetIsG1Japanese(data, 0x30, StringLength);
|
||||
private static bool IsEnglish(byte[] data) => StringConverter12.GetIsG1English(data, 0x24, StringLength) && StringConverter12.GetIsG1English(data, 0x30, StringLength);
|
||||
public bool IsPossible(bool japanese) => japanese ? IsJapanese(Data) : IsEnglish(Data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,13 +11,10 @@ namespace PKHeX.Core
|
|||
{
|
||||
public static bool GetIsG1Japanese(string str) => AllCharsInDictionary(str, U2RBY_J);
|
||||
public static bool GetIsG1English(string str) => AllCharsInDictionary(str, U2RBY_U);
|
||||
private static bool AllCharsInDictionary(IEnumerable<char> c, IReadOnlyDictionary<char, byte> d) => c.All(d.ContainsKey);
|
||||
public static bool GetIsG1Japanese(byte[] data, int start, int length) => AllCharsInDictionary(data, start, length, RBY2U_J);
|
||||
public static bool GetIsG1English(byte[] data, int start, int length) => AllCharsInDictionary(data, start, length, RBY2U_U);
|
||||
|
||||
public static bool GetIsG1Japanese(byte[] data, int start, int length)
|
||||
{
|
||||
var d = RBY2U_J;
|
||||
return AllCharsInDictionary(data, start, length, d);
|
||||
}
|
||||
private static bool AllCharsInDictionary(IEnumerable<char> c, IReadOnlyDictionary<char, byte> d) => c.All(d.ContainsKey);
|
||||
|
||||
private static bool AllCharsInDictionary(IReadOnlyList<byte> data, int start, int length, IReadOnlyDictionary<byte, char> d)
|
||||
{
|
||||
|
|
|
@ -408,7 +408,7 @@ namespace PKHeX.Core
|
|||
if (!AllowIncompatibleConversion)
|
||||
return false;
|
||||
}
|
||||
if (IsIncompatibleGB(target.Format, target.Japanese, pk.Japanese))
|
||||
if (IsIncompatibleGB(target, target.Japanese, pk.Japanese))
|
||||
{
|
||||
pkm = target;
|
||||
c = GetIncompatibleGBMessage(pk, target.Japanese);
|
||||
|
@ -433,7 +433,7 @@ namespace PKHeX.Core
|
|||
return string.Format(MsgPKMConvertIncompatible, src, pk.GetType().Name, dest);
|
||||
}
|
||||
|
||||
public static bool IsIncompatibleGB(int format, bool destJapanese, bool srcJapanese) => format <= 2 && destJapanese != srcJapanese;
|
||||
public static bool IsIncompatibleGB(PKM pk, bool destJapanese, bool srcJapanese) => pk.Format <= 2 && destJapanese != srcJapanese && !(pk is SK2 sk2 && sk2.IsPossible(srcJapanese));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a Blank <see cref="PKM"/> object of the specified type.
|
||||
|
|
|
@ -165,7 +165,7 @@ namespace PKHeX.Core
|
|||
continue;
|
||||
}
|
||||
|
||||
if (sav is ILangDeviantSave il && PKMConverter.IsIncompatibleGB(pk.Format, il.Japanese, pk.Japanese))
|
||||
if (sav is ILangDeviantSave il && PKMConverter.IsIncompatibleGB(pk, il.Japanese, pk.Japanese))
|
||||
{
|
||||
c = PKMConverter.GetIncompatibleGBMessage(pk, il.Japanese);
|
||||
Debug.WriteLine(c);
|
||||
|
|
|
@ -286,7 +286,7 @@ namespace PKHeX.WinForms.Controls
|
|||
if (badDest && (pk.Species == 0 || pk.IsEgg))
|
||||
return false;
|
||||
|
||||
if (sav is ILangDeviantSave il && PKMConverter.IsIncompatibleGB(pk.Format, il.Japanese, pk.Japanese))
|
||||
if (sav is ILangDeviantSave il && PKMConverter.IsIncompatibleGB(pk, il.Japanese, pk.Japanese))
|
||||
{
|
||||
c = PKMConverter.GetIncompatibleGBMessage(pk, il.Japanese);
|
||||
WinFormsUtil.Error(c);
|
||||
|
|
Loading…
Reference in a new issue