Relocate gui-only text files to WinForms project

Split up the DataUtil method to load text files so that the caching
functionality can be reused
This commit is contained in:
Kurt
2020-01-03 15:53:48 -08:00
parent 10b2120b93
commit 852bd2af20
13 changed files with 281 additions and 33 deletions

View File

@@ -131,7 +131,6 @@
<None Remove="Resources\byte\wc7full.pkl" />
<None Remove="Resources\byte\wb7full.pkl" />
<None Remove="Resources\byte\wc8.pkl" />
<None Remove="Resources\text\de\lang_de.txt" />
<None Remove="Resources\text\de\LegalityCheckStrings_de.txt" />
<None Remove="Resources\text\de\MessageStrings_en.txt" />
<None Remove="Resources\text\de\text_Abilities_de.txt" />
@@ -186,7 +185,6 @@
<None Remove="Resources\text\de\text_xy_30000_de.txt" />
<None Remove="Resources\text\de\text_xy_40000_de.txt" />
<None Remove="Resources\text\de\text_xy_60000_de.txt" />
<None Remove="Resources\text\en\lang_en.txt" />
<None Remove="Resources\text\en\LegalityCheckStrings_en.txt" />
<None Remove="Resources\text\en\MessageStrings_en.txt" />
<None Remove="Resources\text\en\text_Abilities_en.txt" />
@@ -241,7 +239,6 @@
<None Remove="Resources\text\en\text_xy_30000_en.txt" />
<None Remove="Resources\text\en\text_xy_40000_en.txt" />
<None Remove="Resources\text\en\text_xy_60000_en.txt" />
<None Remove="Resources\text\es\lang_es.txt" />
<None Remove="Resources\text\es\LegalityCheckStrings_es.txt" />
<None Remove="Resources\text\es\MessageStrings_es.txt" />
<None Remove="Resources\text\es\text_Abilities_es.txt" />
@@ -296,7 +293,6 @@
<None Remove="Resources\text\es\text_xy_30000_es.txt" />
<None Remove="Resources\text\es\text_xy_40000_es.txt" />
<None Remove="Resources\text\es\text_xy_60000_es.txt" />
<None Remove="Resources\text\fr\lang_fr.txt" />
<None Remove="Resources\text\fr\LegalityCheckStrings_fr.txt" />
<None Remove="Resources\text\fr\MessageStrings_fr.txt" />
<None Remove="Resources\text\fr\text_Abilities_fr.txt" />
@@ -375,7 +371,6 @@
<None Remove="Resources\text\gen3\text_rsefrlg_00000_en.txt" />
<None Remove="Resources\text\gen3\text_rsefrlg_00000_es.txt" />
<None Remove="Resources\text\gen3\text_rsefrlg_00000_zh.txt" />
<None Remove="Resources\text\it\lang_it.txt" />
<None Remove="Resources\text\it\LegalityCheckStrings_it.txt" />
<None Remove="Resources\text\it\MessageStrings_it.txt" />
<None Remove="Resources\text\it\text_Abilities_it.txt" />
@@ -430,7 +425,6 @@
<None Remove="Resources\text\it\text_xy_30000_it.txt" />
<None Remove="Resources\text\it\text_xy_40000_it.txt" />
<None Remove="Resources\text\it\text_xy_60000_it.txt" />
<None Remove="Resources\text\ja\lang_ja.txt" />
<None Remove="Resources\text\ja\LegalityCheckStrings_ja.txt" />
<None Remove="Resources\text\ja\MessageStrings_ja.txt" />
<None Remove="Resources\text\ja\text_Abilities_ja.txt" />
@@ -485,7 +479,6 @@
<None Remove="Resources\text\ja\text_xy_30000_ja.txt" />
<None Remove="Resources\text\ja\text_xy_40000_ja.txt" />
<None Remove="Resources\text\ja\text_xy_60000_ja.txt" />
<None Remove="Resources\text\ko\lang_ko.txt" />
<None Remove="Resources\text\ko\LegalityCheckStrings_ko.txt" />
<None Remove="Resources\text\ko\MessageStrings_ko.txt" />
<None Remove="Resources\text\ko\text_Abilities_ko.txt" />
@@ -755,7 +748,6 @@
<None Remove="Resources\text\script\flags_gs_en.txt" />
<None Remove="Resources\text\script\flags_gs_ja.txt" />
<None Remove="Resources\text\script\flags_gs_zh.txt" />
<None Remove="Resources\text\zh\lang_zh.txt" />
<None Remove="Resources\text\zh\LegalityCheckStrings_zh.txt" />
<None Remove="Resources\text\zh\MessageStrings_zh.txt" />
<None Remove="Resources\text\zh\text_Abilities_zh.txt" />
@@ -923,7 +915,6 @@
<EmbeddedResource Include="Resources\byte\wc7full.pkl" />
<EmbeddedResource Include="Resources\byte\wb7full.pkl" />
<EmbeddedResource Include="Resources\byte\wc8.pkl" />
<EmbeddedResource Include="Resources\text\de\lang_de.txt" />
<EmbeddedResource Include="Resources\text\de\LegalityCheckStrings_de.txt" />
<EmbeddedResource Include="Resources\text\de\MessageStrings_de.txt" />
<EmbeddedResource Include="Resources\text\de\text_Abilities_de.txt" />
@@ -978,7 +969,6 @@
<EmbeddedResource Include="Resources\text\de\text_xy_30000_de.txt" />
<EmbeddedResource Include="Resources\text\de\text_xy_40000_de.txt" />
<EmbeddedResource Include="Resources\text\de\text_xy_60000_de.txt" />
<EmbeddedResource Include="Resources\text\en\lang_en.txt" />
<EmbeddedResource Include="Resources\text\en\LegalityCheckStrings_en.txt" />
<EmbeddedResource Include="Resources\text\en\MessageStrings_en.txt" />
<EmbeddedResource Include="Resources\text\en\text_Abilities_en.txt" />
@@ -1033,8 +1023,6 @@
<EmbeddedResource Include="Resources\text\en\text_xy_30000_en.txt" />
<EmbeddedResource Include="Resources\text\en\text_xy_40000_en.txt" />
<EmbeddedResource Include="Resources\text\en\text_xy_60000_en.txt" />
<EmbeddedResource Include="Resources\text\es\lang_es.txt" />
<EmbeddedResource Include="Resources\text\es\LegalityCheckStrings_es.txt" />
<EmbeddedResource Include="Resources\text\es\MessageStrings_es.txt" />
<EmbeddedResource Include="Resources\text\es\text_Abilities_es.txt" />
<EmbeddedResource Include="Resources\text\es\text_bw2_00000_es.txt" />
@@ -1088,7 +1076,6 @@
<EmbeddedResource Include="Resources\text\es\text_xy_30000_es.txt" />
<EmbeddedResource Include="Resources\text\es\text_xy_40000_es.txt" />
<EmbeddedResource Include="Resources\text\es\text_xy_60000_es.txt" />
<EmbeddedResource Include="Resources\text\fr\lang_fr.txt" />
<EmbeddedResource Include="Resources\text\fr\LegalityCheckStrings_fr.txt" />
<EmbeddedResource Include="Resources\text\fr\MessageStrings_fr.txt" />
<EmbeddedResource Include="Resources\text\fr\text_Abilities_fr.txt" />
@@ -1167,7 +1154,6 @@
<EmbeddedResource Include="Resources\text\gen3\text_rsefrlg_00000_en.txt" />
<EmbeddedResource Include="Resources\text\gen3\text_rsefrlg_00000_es.txt" />
<EmbeddedResource Include="Resources\text\gen3\text_rsefrlg_00000_zh.txt" />
<EmbeddedResource Include="Resources\text\it\lang_it.txt" />
<EmbeddedResource Include="Resources\text\it\LegalityCheckStrings_it.txt" />
<EmbeddedResource Include="Resources\text\it\MessageStrings_it.txt" />
<EmbeddedResource Include="Resources\text\it\text_Abilities_it.txt" />
@@ -1222,7 +1208,6 @@
<EmbeddedResource Include="Resources\text\it\text_xy_30000_it.txt" />
<EmbeddedResource Include="Resources\text\it\text_xy_40000_it.txt" />
<EmbeddedResource Include="Resources\text\it\text_xy_60000_it.txt" />
<EmbeddedResource Include="Resources\text\ja\lang_ja.txt" />
<EmbeddedResource Include="Resources\text\ja\LegalityCheckStrings_ja.txt" />
<EmbeddedResource Include="Resources\text\ja\MessageStrings_ja.txt" />
<EmbeddedResource Include="Resources\text\ja\text_Abilities_ja.txt" />
@@ -1277,7 +1262,6 @@
<EmbeddedResource Include="Resources\text\ja\text_xy_30000_ja.txt" />
<EmbeddedResource Include="Resources\text\ja\text_xy_40000_ja.txt" />
<EmbeddedResource Include="Resources\text\ja\text_xy_60000_ja.txt" />
<EmbeddedResource Include="Resources\text\ko\lang_ko.txt" />
<EmbeddedResource Include="Resources\text\ko\LegalityCheckStrings_ko.txt" />
<EmbeddedResource Include="Resources\text\ko\MessageStrings_ko.txt" />
<EmbeddedResource Include="Resources\text\ko\text_Abilities_ko.txt" />
@@ -1547,7 +1531,6 @@
<EmbeddedResource Include="Resources\text\script\flags_gs_en.txt" />
<EmbeddedResource Include="Resources\text\script\flags_gs_ja.txt" />
<EmbeddedResource Include="Resources\text\script\flags_gs_zh.txt" />
<EmbeddedResource Include="Resources\text\zh\lang_zh.txt" />
<EmbeddedResource Include="Resources\text\zh\LegalityCheckStrings_zh.txt" />
<EmbeddedResource Include="Resources\text\zh\MessageStrings_zh.txt" />
<EmbeddedResource Include="Resources\text\zh\text_Abilities_zh.txt" />

View File

@@ -126,15 +126,22 @@ public static string[][] GetLanguageStrings10(string fileName)
#endregion
public static string[] GetStringList(string f)
public static string[] GetStringList(string fileName)
{
if (IsStringListCached(fileName, out var result))
return result;
var txt = GetStringResource(fileName); // Fetch File, \n to list.
return LoadStringList(fileName, txt);
}
public static bool IsStringListCached(string fileName, out string[] result)
{
lock (getStringListLoadLock) // Make sure only one thread can read the cache
{
if (stringListCache.TryGetValue(f, out var result))
return (string[])result.Clone();
}
return stringListCache.TryGetValue(fileName, out result);
}
var txt = GetStringResource(f); // Fetch File, \n to list.
public static string[] LoadStringList(string file, string? txt)
{
if (txt == null)
return Array.Empty<string>();
string[] rawlist = txt.Split('\n');
@@ -143,14 +150,14 @@ public static string[] GetStringList(string f)
lock (getStringListLoadLock) // Make sure only one thread can write to the cache
{
if (!stringListCache.ContainsKey(f)) // Check cache again in case of race condition
stringListCache.Add(f, rawlist);
if (!stringListCache.ContainsKey(file)) // Check cache again in case of race condition
stringListCache.Add(file, rawlist);
}
return (string[])rawlist.Clone();
}
public static string[] GetStringList(string f, string l, string type = "text") => GetStringList($"{type}_{f}_{l}");
public static string[] GetStringList(string fileName, string lang2char, string type = "text") => GetStringList($"{type}_{fileName}_{lang2char}");
public static byte[] GetBinaryResource(string name)
{

View File

@@ -214,12 +214,13 @@ public class Resources {
/// Looks up a localized string similar to PKHeX - By Kaphotics
///http://projectpokemon.org/pkhex/
///
///19/11/15 - New Update:
/// - Introducing Sword/Shield support! Thanks @SciresM and @sora10pls for troubleshooting prior to release!
/// - - Initial Legality Checking is provided. Please refer to the forums when reporting legality issues for Generation 8 parsing.
/// - - Bag editing, Pokédex, and Trainer Info editing is provided.
/// - Changed: PKHeX.Core.dll is now merged in with the main executable.
/// - Changed: PKHeX.WinForms spriting has now been split in [rest of string was truncated]&quot;;.
///19/12/26 - New Update:
/// - Legality:
/// - - Added: PP Count verification, Egg TR/StatNature checks, etc.
/// - - Added: More static encounter locations.
/// - - Added: Handling for downleveled raid content, and location crossover comparisons for wild encounters.
/// - - Changed: Encounter yielding pattern for Gen8 is now slightly different from the one used for Gen5-7 (now yields more).
/// - - Fixed: EvolutionTree regressions have been resolved. Please repor [rest of string was truncated]&quot;;.
/// </summary>
public static string changelog {
get {
@@ -507,6 +508,236 @@ public class Resources {
}
}
/// <summary>
/// Looks up a localized string similar to About=About
///BatchEditor=Batch Editor
///ErrorWindow=Error
///KChart=KChart
///Main=PKHeX
///MemoryAmie=Memory / Amie Editor
///RibbonEditor=Ribbon Editor
///SAV_Apricorn=Apricorn Editor
///SAV_BerryField=Berry Field Viewer
///SAV_BoxLayout=Box Layout Editor
///SAV_BoxList=Storage Viewer
///SAV_CGearSkin=C-Gear Skin
///SAV_Database=Database
///SAV_Encounters=Database
///SAV_EventFlags=Event Flag Editor
///SAV_EventReset1=Event Resetter
///SAV_EventWork=Event Flag Editor
///SAV_FolderList=Folder List
///SAV_GameSelect=Game Selection
///SAV_Hal [rest of string was truncated]&quot;;.
/// </summary>
public static string lang_de {
get {
return ResourceManager.GetString("lang_de", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to About=About
///BatchEditor=Batch Editor
///ErrorWindow=Error
///KChart=KChart
///Main=PKHeX
///MemoryAmie=Memory / Amie Editor
///RibbonEditor=Ribbon Editor
///SAV_Apricorn=Apricorn Editor
///SAV_BerryField=Berry Field Viewer
///SAV_BoxLayout=Box Layout Editor
///SAV_BoxList=Storage Viewer
///SAV_CGearSkin=C-Gear Skin
///SAV_Database=Database
///SAV_Encounters=Database
///SAV_EventFlags=Event Flag Editor
///SAV_EventReset1=Event Resetter
///SAV_EventWork=Event Flag Editor
///SAV_FolderList=Folder List
///SAV_GameSelect=Game Selection
///SAV_Hal [rest of string was truncated]&quot;;.
/// </summary>
public static string lang_en {
get {
return ResourceManager.GetString("lang_en", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to About=Acerca de
///BatchEditor=Editor por lotes
///ErrorWindow=Error
///KChart=KChart
///Main=PKHeX
///MemoryAmie=Editor de memorias / Poké Recreo
///RibbonEditor=Editor de cintas
///SAV_Apricorn=Editor de Bonguri
///SAV_BerryField=Visor de campos de bayas
///SAV_BoxLayout=Editor de fondos de cajas
///SAV_BoxList=Visor de almacenamiento
///SAV_CGearSkin=Editor de la apariencia C-Gear
///SAV_Database=Base de datos
///SAV_Encounters=Base de datos
///SAV_EventFlags=Editor de marca de eventos
///SAV_EventReset1=Reiniciador de eventos
///SAV_E [rest of string was truncated]&quot;;.
/// </summary>
public static string lang_es {
get {
return ResourceManager.GetString("lang_es", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to About=À propos
///BatchEditor=Batch Editor
///ErrorWindow=Erreur
///KChart=KChart
///Main=PKHeX
///MemoryAmie=Memory / Amie Editor
///RibbonEditor=Rubans
///SAV_Apricorn=Noigrumes
///SAV_BerryField=Champs de Baies
///SAV_BoxLayout=Fonds de Boîtes
///SAV_BoxList=Storage Viewer
///SAV_CGearSkin=Fonds C-Gear
///SAV_Database=Base de Données
///SAV_Encounters=Database
///SAV_EventFlags=Événements dans le Jeu
///SAV_EventReset1=Réinitialisateur d&apos;événements
///SAV_EventWork=Event Flag Editor
///SAV_FolderList=Liste Dossiers
///SAV_GameSelect=Choix [rest of string was truncated]&quot;;.
/// </summary>
public static string lang_fr {
get {
return ResourceManager.GetString("lang_fr", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to About=About
///BatchEditor=Batch Editor
///ErrorWindow=Error
///KChart=KChart
///Main=PKHeX
///MemoryAmie=Memory / Amie Editor
///RibbonEditor=Ribbon Editor
///SAV_Apricorn=Apricorn Editor
///SAV_BerryField=Berry Field Viewer
///SAV_BoxLayout=Box Layout Editor
///SAV_BoxList=Storage Viewer
///SAV_CGearSkin=C-Gear Skin
///SAV_Database=Database
///SAV_Encounters=Database
///SAV_EventFlags=Event Flag Editor
///SAV_EventReset1=Event Resetter
///SAV_EventWork=Event Flag Editor
///SAV_FolderList=Folder List
///SAV_GameSelect=Game Selection
///SAV_Hal [rest of string was truncated]&quot;;.
/// </summary>
public static string lang_it {
get {
return ResourceManager.GetString("lang_it", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to About=About
///BatchEditor=バッチエディタ
///ErrorWindow=エラー
///KChart=KChart
///Main=PKHeX
///MemoryAmie=おもいで
///RibbonEditor=取得リボン
///SAV_Apricorn=ぼんぐり
///SAV_BerryField=きのみ畑
///SAV_BoxLayout=ボックスレイアウト
///SAV_BoxList=ボックスリスト
///SAV_CGearSkin=Cギア スキン
///SAV_Database=データベース
///SAV_Encounters=Database
///SAV_EventFlags=イベントフラグ
///SAV_EventReset1=イベントリセット
///SAV_EventWork=Event Flag Editor
///SAV_FolderList=フォルダリスト
///SAV_GameSelect=ゲームバーション
///SAV_HallOfFame=殿堂入りデータ
///SAV_HallOfFame7=殿堂入りデータ参照
///SAV_HoneyTree=あまいかおりのするき
///SAV_Inventory=アイテム
///SAV_Link6=ポケモ [rest of string was truncated]&quot;;.
/// </summary>
public static string lang_ja {
get {
return ResourceManager.GetString("lang_ja", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to About=About
///BatchEditor=Batch Editor
///ErrorWindow=Error
///KChart=KChart
///Main=PKHeX
///MemoryAmie=Memory / Amie Editor
///RibbonEditor=Ribbon Editor
///SAV_Apricorn=Apricorn Editor
///SAV_BerryField=Berry Field Viewer
///SAV_BoxLayout=Box Layout Editor
///SAV_BoxList=Storage Viewer
///SAV_CGearSkin=C-Gear Skin
///SAV_Database=Database
///SAV_Encounters=Database
///SAV_EventFlags=Event Flag Editor
///SAV_EventReset1=Event Resetter
///SAV_EventWork=Event Flag Editor
///SAV_FolderList=Folder List
///SAV_GameSelect=Game Selection
///SAV_Hal [rest of string was truncated]&quot;;.
/// </summary>
public static string lang_ko {
get {
return ResourceManager.GetString("lang_ko", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to About=About
///BatchEditor=批量编辑器
///ErrorWindow=错误
///KChart=信息列表
///Main=PKHeX
///MemoryAmie=回忆/清爽乐
///RibbonEditor=奖章
///SAV_Apricorn=球果编辑
///SAV_BerryField=树果田查看器
///SAV_BoxLayout=盒子外观
///SAV_BoxList=寄放系统
///SAV_CGearSkin=C-装置皮肤
///SAV_Database=数据库
///SAV_Encounters=Database
///SAV_EventFlags=事件旗标编辑
///SAV_EventReset1=事件重置
///SAV_EventWork=Event Flag Editor
///SAV_FolderList=文件夹列表
///SAV_GameSelect=游戏选择
///SAV_HallOfFame=名人堂
///SAV_HallOfFame7=名人堂
///SAV_HoneyTree=甜甜蜜树编辑
///SAV_Inventory=物品栏
///SAV_Link6=宝可梦连接工具
///SAV_MailBox=邮箱编辑
///SAV_Misc3=训练家数据编辑 /// [rest of string was truncated]&quot;;.
/// </summary>
public static string lang_zh {
get {
return ResourceManager.GetString("lang_zh", resourceCulture);
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View File

@@ -346,4 +346,28 @@
<data name="rare_icon_2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\img\markings\rare_icon_2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="lang_de" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\text\lang_de.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="lang_en" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\text\lang_en.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="lang_es" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\text\lang_es.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="lang_fr" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\text\lang_fr.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="lang_it" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\text\lang_it.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="lang_ja" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\text\lang_ja.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="lang_ko" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\text\lang_ko.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="lang_zh" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\text\lang_zh.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
</root>

View File

@@ -63,7 +63,10 @@ private static IEnumerable<string> GetTranslationFile(string lang)
catch { /* In use? Just return the internal resource. */ }
}
return Util.GetStringList(file);
if (Util.IsStringListCached(file, out var result))
return result;
var txt = (string)Properties.Resources.ResourceManager.GetObject(file);
return Util.LoadStringList(file, txt);
}
private static IEnumerable<object> GetTranslatableControls(Control f)