From 37f84be660cc111911f9bf03396d5cc329c58aa0 Mon Sep 17 00:00:00 2001 From: Kurt Date: Wed, 30 Sep 2020 15:10:55 -0700 Subject: [PATCH] Add localization for forgery, none, and manual insertion of internal indexes --- NHSE.Parsing/GameMSBTDumper.cs | 78 +++++++++++++++++++++++++++--- NHSE.Parsing/GameMSBTDumperNHSE.cs | 2 +- 2 files changed, 71 insertions(+), 9 deletions(-) diff --git a/NHSE.Parsing/GameMSBTDumper.cs b/NHSE.Parsing/GameMSBTDumper.cs index c6405aa..2d97b5f 100644 --- a/NHSE.Parsing/GameMSBTDumper.cs +++ b/NHSE.Parsing/GameMSBTDumper.cs @@ -8,9 +8,9 @@ namespace NHSE.Parsing { public static class GameMSBTDumper { - public static string[] GetItemListResource(string msgPath) + public static string[] GetItemListResource(string msgPath, string language) { - var list = GetItemList(msgPath); + var list = GetItemList(msgPath, language); var max = list.Max(z => z.Key); var result = new string?[max + 1]; @@ -19,11 +19,18 @@ public static string[] GetItemListResource(string msgPath) for (int i = 0; i < result.Length; i++) result[i] ??= string.Empty; - result[0] = "(None)"; - result[5794] = "DIY recipe"; + FinalizeItemList(language, result!); return result!; } + private static void FinalizeItemList(string language, string[] result) + { + result[0] = $"({GetNoneName(language)})"; + result[5794] = $"({GetDIYRecipeName(language)})"; + foreach (var internalItem in InternalItemList) + result[internalItem.Key] = internalItem.Value; + } + public static string[] GetArtList(string msgPath) { var file = Path.Combine(msgPath, "Item", "STR_ItemName_01_Art.msbt"); @@ -57,19 +64,21 @@ public static string[] GetVillagerListResource(string msgPath) return normal.Concat(special).ToArray(); } - public static Dictionary GetItemList(string msgPath) + public static Dictionary GetItemList(string msgPath, string language) { var result = new Dictionary(); - AddRegularItems(result, msgPath); + AddRegularItems(result, msgPath, language); AddColoredItems(result, msgPath); return result; } - private static void AddRegularItems(IDictionary result, string msgPath) + private static void AddRegularItems(IDictionary result, string msgPath, string language) { var pitem = Path.Combine(msgPath, "Item"); var fitem = Directory.EnumerateFiles(pitem); var regularItemList = GetLabelList(fitem); // (itemID, itemName) + + var forgery = GetForgerySuffix(language); foreach (var (label, text) in regularItemList) { if (label.EndsWith("_pl")) @@ -81,12 +90,65 @@ private static void AddRegularItems(IDictionary result, string m var itemText = text; if (label.StartsWith("PictureFake") || label.StartsWith("SculptureFake")) - itemText = $"{itemText} (forgery)"; + itemText = $"{itemText} ({forgery})"; result.Add(itemID, itemText); } } + private static string GetNoneName(string language) + { + return language switch + { + "de" => "Leer", + "es" => "Ningun", + "fr" => "Aucun", + "it" => "Nessuna", + "ko" => "없음", + "ja" => "無し", + "chs" => "没有", + "cht" => "沒有", + _ => "None", + }; + } + + private static string GetDIYRecipeName(string language) + { + return language switch + { + "de" => "Leer", + "es" => "Ningun", + "fr" => "Aucun", + "it" => "Nessuna", + "ko" => "없음", + "ja" => "無し", + "chs" => "没有", + "cht" => "沒有", + _ => "DIY recipe", + }; + } + + private static string GetForgerySuffix(string language) + { + return language switch + { + "de" => "fälschung", + "es" => "falsificación", + "fr" => "falsification", + "it" => "falsificazione", + "ko" => "위조", + "ja" => "偽造", + "chs" => "伪造", + "cht" => "偽造", + _ => "forgery", + }; + } + + private static readonly Dictionary InternalItemList = new Dictionary + { + {4200, "k.k. slider's guitar (internal)"}, + }; + private static void AddColoredItems(IDictionary result, string msgPath) { var pgname = Path.Combine(msgPath, "Outfit", "GroupName"); // (baseItemName, groupID) diff --git a/NHSE.Parsing/GameMSBTDumperNHSE.cs b/NHSE.Parsing/GameMSBTDumperNHSE.cs index ae9ac1d..67efcfe 100644 --- a/NHSE.Parsing/GameMSBTDumperNHSE.cs +++ b/NHSE.Parsing/GameMSBTDumperNHSE.cs @@ -59,7 +59,7 @@ private static void DumpItem(string corePath, string langID, string msbtFolder, { var dest = Path.Combine(corePath, langID, $"text_item_{langID}.txt"); var file = string.Format(msbtFolder, langFolderCode); - var items = GameMSBTDumper.GetItemListResource(file); + var items = GameMSBTDumper.GetItemListResource(file, langID); File.WriteAllLines(dest, items); }