using System; using System.Collections.Generic; using System.IO; using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace NewHorizons.External.Configs { [JsonObject] 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; #region Achievements+ // This only exists for schema generation, Achievements+ handles the parsing #pragma warning disable 0169 /// /// Translation table for achievements. The key is the unique ID of the achievement /// private readonly Dictionary AchievementTranslations; [JsonObject] public class AchievementTranslationInfo { /// /// The name of the achievement. /// private string Name; /// /// The short description for this achievement. /// private readonly string Description; } #pragma warning restore 0169 #endregion 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)); } } }