From 6c4a4ff4ec00f86059b24fc1a08ad15a6000bbd3 Mon Sep 17 00:00:00 2001 From: wwwwwwzx Date: Thu, 14 Dec 2017 19:30:59 -0800 Subject: [PATCH] Fix chinese language ID check Some species have the same unicode name in CHS and in CHT, so it will lose language info after converting from a in-game string to textbox (The game will use different fonts to distinguish them, bad GF) This change will give CHT encoding a higher priorty if the pkm is in CHT, although it's possible to get CHS encoding default species name with CHT language ID. Also fixed previous editing error --- PKHeX.Core/PKM/PK7.cs | 2 +- PKHeX.Core/PKM/PKX.cs | 6 +++++- PKHeX.Core/Resources/text/script/const_usum_zh.txt | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/PKHeX.Core/PKM/PK7.cs b/PKHeX.Core/PKM/PK7.cs index 6eae60609..a35399698 100644 --- a/PKHeX.Core/PKM/PK7.cs +++ b/PKHeX.Core/PKM/PK7.cs @@ -226,7 +226,7 @@ public override string Nickname { if (!IsNicknamed) { - int lang = PKX.GetSpeciesNameLanguage(Species, value, 7); + int lang = PKX.GetSpeciesNameLanguage(Species, value, 7, Language); if (lang == 9 || lang == 10) { StringConverter.SetString7(value, 12, lang, chinese: true).CopyTo(Data, 0x40); diff --git a/PKHeX.Core/PKM/PKX.cs b/PKHeX.Core/PKM/PKX.cs index cc52c53c5..488f5240e 100644 --- a/PKHeX.Core/PKM/PKX.cs +++ b/PKHeX.Core/PKM/PKX.cs @@ -266,11 +266,15 @@ private static IEnumerable GetAvailableGameLanguages(int generation) /// National Dex number of the Pokémon. Should be 0 if an egg. /// Current name /// Generation specific formatting option + /// Language ID with a higher priority /// Language ID if it does not match any language name, -1 if no matches - public static int GetSpeciesNameLanguage(int species, string nick, int generation) + public static int GetSpeciesNameLanguage(int species, string nick, int generation, int priorlang = -1) { var langs = GetAvailableGameLanguages(generation); + if (langs.Contains(priorlang) && GetSpeciesNameGeneration(species, priorlang, generation) == nick) + return priorlang; + foreach (var lang in langs) if (GetSpeciesNameGeneration(species, lang, generation) == nick) return lang; diff --git a/PKHeX.Core/Resources/text/script/const_usum_zh.txt b/PKHeX.Core/Resources/text/script/const_usum_zh.txt index 3f40a2901..f0a1ed1da 100644 --- a/PKHeX.Core/Resources/text/script/const_usum_zh.txt +++ b/PKHeX.Core/Resources/text/script/const_usum_zh.txt @@ -3,5 +3,5 @@ 433 卡璞蝶蝶 01:可对战,02:已击倒,03:已捕获 434 卡璞哞哞 01:可对战,02:已击倒,03:已捕获 404 卡璞鳍鳍 03:可对战,04:已击倒,05:已捕获 -755 基格尔德 01:可对战,02:已击倒,03:已捕获 +755 基格尔德 01:可对战,02:已击倒,05:已捕获 867 霸主礼物 00:未领取,01:领取了1只,02:领取了2只,03:领取了3只,04:领取了4只,05:领取了5只,06:已全部领取 \ No newline at end of file