using System.Collections.Generic; using System.IO; using Newtonsoft.Json.Linq; namespace NewHorizons.External.Configs { public class TranslationConfig { /// /// Translation table for dialogue /// public Dictionary dialogueDictionary; /// /// Translation table for Ship Log (entries, facts, etc) /// public Dictionary shipLogDictionary; /// /// Translation table for UI elements /// public Dictionary uiDictionary; public TranslationConfig(string filename) { var dict = JObject.Parse(File.ReadAllText(filename)).ToObject>(); if (dict.ContainsKey(nameof(dialogueDictionary))) dialogueDictionary = (Dictionary) (dict[nameof(dialogueDictionary)] as JObject).ToObject( typeof(Dictionary)); if (dict.ContainsKey(nameof(shipLogDictionary))) shipLogDictionary = (Dictionary) (dict[nameof(shipLogDictionary)] as JObject).ToObject( typeof(Dictionary)); if (dict.ContainsKey(nameof(uiDictionary))) uiDictionary = (Dictionary) (dict[nameof(uiDictionary)] as JObject).ToObject( typeof(Dictionary)); } } }