예제 #1
0
        public static void ImportNPCTexts(Mod mod, string path)
        {
            using (var fs = new FileStream(Path.Combine(path, "NPCs.json"), FileMode.Open))
            {
                using (var sr = new StreamReader(fs))
                {
                    var npcs = JsonConvert.DeserializeObject <TextFile.NPCFile>(sr.ReadToEnd());

                    foreach (var npc in npcs.NPCs)
                    {
                        var modnpc = mod.GetNPC(npc.Key);

                        if (modnpc == null)
                        {
                            continue;
                        }

                        if (!string.IsNullOrWhiteSpace(npc.Value.NameTranslation))
                        {
                            TranslateTool.AddNpcNameTranslation(modnpc, npc.Value.NameTranslation, GameCulture.Chinese);
                        }
                    }
                }
            }
        }
예제 #2
0
파일: Test.cs 프로젝트: XiaoRr/LocalizerMod
 public static void TestAddNPCTranslation()
 {
     try
     {
         var type = ModLoader.GetMod("Bluemagic").NPCType("Phantom");
         if (type > 0)
         {
             TranslateTool.AddNpcNameTranslation(NPCLoader.GetNPC(type), "测试npc名字", GameCulture.Chinese);
         }
     }
     catch (Exception ex)
     {
         ErrorLogger.Log(ex.ToString());
     }
 }