mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
69 lines
2.4 KiB
C#
69 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace NewHorizons.External.Configs
|
|
{
|
|
[JsonObject]
|
|
public class TranslationConfig
|
|
{
|
|
/// <summary>
|
|
/// Translation table for dialogue
|
|
/// </summary>
|
|
public Dictionary<string, string> DialogueDictionary;
|
|
|
|
/// <summary>
|
|
/// Translation table for Ship Log (entries, facts, etc)
|
|
/// </summary>
|
|
public Dictionary<string, string> ShipLogDictionary;
|
|
|
|
/// <summary>
|
|
/// Translation table for UI elements
|
|
/// </summary>
|
|
public Dictionary<string, string> UIDictionary;
|
|
|
|
#region Achievements+
|
|
// This only exists for schema generation, Achievements+ handles the parsing
|
|
#pragma warning disable 0169
|
|
/// <summary>
|
|
/// Translation table for achievements. The key is the unique ID of the achievement
|
|
/// </summary>
|
|
private readonly Dictionary<string, AchievementTranslationInfo> AchievementTranslations;
|
|
|
|
[JsonObject]
|
|
public class AchievementTranslationInfo
|
|
{
|
|
/// <summary>
|
|
/// The name of the achievement.
|
|
/// </summary>
|
|
private string Name;
|
|
|
|
/// <summary>
|
|
/// The short description for this achievement.
|
|
/// </summary>
|
|
private readonly string Description;
|
|
}
|
|
#pragma warning restore 0169
|
|
#endregion
|
|
|
|
public TranslationConfig(string filename)
|
|
{
|
|
var dict = JObject.Parse(File.ReadAllText(filename)).ToObject<Dictionary<string, object>>();
|
|
|
|
if (dict.ContainsKey(nameof(DialogueDictionary)))
|
|
DialogueDictionary =
|
|
(Dictionary<string, string>) (dict[nameof(DialogueDictionary)] as JObject).ToObject(
|
|
typeof(Dictionary<string, string>));
|
|
if (dict.ContainsKey(nameof(ShipLogDictionary)))
|
|
ShipLogDictionary =
|
|
(Dictionary<string, string>) (dict[nameof(ShipLogDictionary)] as JObject).ToObject(
|
|
typeof(Dictionary<string, string>));
|
|
if (dict.ContainsKey(nameof(UIDictionary)))
|
|
UIDictionary =
|
|
(Dictionary<string, string>) (dict[nameof(UIDictionary)] as JObject).ToObject(
|
|
typeof(Dictionary<string, string>));
|
|
}
|
|
}
|
|
} |