mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-10 06:34:19 +00:00
PK1/2 edit: Use save language when detecting lang
GBPKM allow spa/ita lang as fallback (so that nicknamed species just use fallback) SK2 GetNonNickname reuse the passed language ID instead of recomputing
This commit is contained in:
parent
417231a67c
commit
da51291364
4 changed files with 15 additions and 6 deletions
|
@ -137,7 +137,7 @@ public sealed class SK2 : GBPKM, ICaughtData2
|
||||||
protected override void GetNonNickname(int language, Span<byte> data)
|
protected override void GetNonNickname(int language, Span<byte> data)
|
||||||
{
|
{
|
||||||
var name = SpeciesName.GetSpeciesNameGeneration(Species, language, 2);
|
var name = SpeciesName.GetSpeciesNameGeneration(Species, language, 2);
|
||||||
StringConverter2.SetString(data, name, data.Length, Language, StringConverterOption.Clear50);
|
StringConverter2.SetString(data, name, data.Length, language, StringConverterOption.Clear50);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SetNotNicknamed(int language) => GetNonNickname(language, NicknameTrash);
|
public override void SetNotNicknamed(int language) => GetNonNickname(language, NicknameTrash);
|
||||||
|
|
|
@ -187,12 +187,20 @@ public abstract class GBPKM : PKM
|
||||||
public void SetNotNicknamed() => SetNotNicknamed(GuessedLanguage());
|
public void SetNotNicknamed() => SetNotNicknamed(GuessedLanguage());
|
||||||
public abstract void SetNotNicknamed(int language);
|
public abstract void SetNotNicknamed(int language);
|
||||||
|
|
||||||
|
public bool IsSpeciesNameMatch(int language)
|
||||||
|
{
|
||||||
|
var expect = SpeciesName.GetSpeciesNameGeneration(Species, language, 2);
|
||||||
|
Span<char> current = stackalloc char[TrashCharCountNickname];
|
||||||
|
int len = LoadString(NicknameTrash, current);
|
||||||
|
return current[..len].SequenceEqual(expect);
|
||||||
|
}
|
||||||
|
|
||||||
public int GuessedLanguage(int fallback = (int)LanguageID.English)
|
public int GuessedLanguage(int fallback = (int)LanguageID.English)
|
||||||
{
|
{
|
||||||
int lang = Language;
|
int lang = Language;
|
||||||
if (lang > 0)
|
if (lang > 0)
|
||||||
return lang;
|
return lang;
|
||||||
if (fallback is (int)LanguageID.French or (int)LanguageID.German) // only other permitted besides English
|
if (fallback is (int)LanguageID.French or (int)LanguageID.German or (int)LanguageID.Italian or (int)LanguageID.Spanish) // only other permitted besides English
|
||||||
return fallback;
|
return fallback;
|
||||||
return (int)LanguageID.English;
|
return (int)LanguageID.English;
|
||||||
}
|
}
|
||||||
|
@ -205,8 +213,7 @@ public abstract class GBPKM : PKM
|
||||||
protected int TransferLanguage(int destLanguage)
|
protected int TransferLanguage(int destLanguage)
|
||||||
{
|
{
|
||||||
// if the Species name of the destination language matches the current nickname, transfer with that language.
|
// if the Species name of the destination language matches the current nickname, transfer with that language.
|
||||||
var expect = SpeciesName.GetSpeciesNameGeneration(Species, destLanguage, 2);
|
if (IsSpeciesNameMatch(destLanguage))
|
||||||
if (Nickname == expect)
|
|
||||||
return destLanguage;
|
return destLanguage;
|
||||||
return GuessedLanguage(destLanguage);
|
return GuessedLanguage(destLanguage);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,8 @@ public partial class PKMEditor
|
||||||
CR_PK1.LoadPK1(pk1);
|
CR_PK1.LoadPK1(pk1);
|
||||||
|
|
||||||
// Attempt to detect language
|
// Attempt to detect language
|
||||||
CB_Language.SelectedValue = pk1.GuessedLanguage();
|
var language = RequestSaveFile.Language;
|
||||||
|
CB_Language.SelectedValue = pk1.IsSpeciesNameMatch(language) ? language : pk1.GuessedLanguage(language);
|
||||||
|
|
||||||
LoadPartyStats(pk1);
|
LoadPartyStats(pk1);
|
||||||
UpdateStats();
|
UpdateStats();
|
||||||
|
|
|
@ -24,7 +24,8 @@ public partial class PKMEditor
|
||||||
CB_MetTimeOfDay.SelectedIndex = c2.MetTimeOfDay;
|
CB_MetTimeOfDay.SelectedIndex = c2.MetTimeOfDay;
|
||||||
|
|
||||||
// Attempt to detect language
|
// Attempt to detect language
|
||||||
CB_Language.SelectedValue = pk2.GuessedLanguage();
|
var language = RequestSaveFile.Language;
|
||||||
|
CB_Language.SelectedValue = pk2.IsSpeciesNameMatch(language) ? language : pk2.GuessedLanguage(language);
|
||||||
|
|
||||||
LoadPartyStats(pk2);
|
LoadPartyStats(pk2);
|
||||||
UpdateStats();
|
UpdateStats();
|
||||||
|
|
Loading…
Reference in a new issue