From ab131bdf52ff97af3dc13abda188881a033f5425 Mon Sep 17 00:00:00 2001 From: sir-wilhelm Date: Fri, 17 Apr 2020 13:07:23 -0500 Subject: [PATCH] Adding better custom language support. Note: Flipping from custom -> en-US while running won't work. --- SmartHunter/Core/Config/ConfigContainer.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SmartHunter/Core/Config/ConfigContainer.cs b/SmartHunter/Core/Config/ConfigContainer.cs index c5c6462c..333a71ed 100644 --- a/SmartHunter/Core/Config/ConfigContainer.cs +++ b/SmartHunter/Core/Config/ConfigContainer.cs @@ -3,6 +3,7 @@ using System.IO; using Newtonsoft.Json; using Newtonsoft.Json.Converters; +using SmartHunter.Config; using SmartHunter.Game.Helpers; using ErrorEventArgs = Newtonsoft.Json.Serialization.ErrorEventArgs; @@ -44,8 +45,9 @@ private void Load() contents = reader.ReadToEnd(); } + var customLanguage = typeof(T).Equals(typeof(LocalizationConfig)) && !FileName.Equals("en-US.json"); var fileContentsEqualsAutoGen = contents == GetAutoGenerateedJson(); - if (!fileContentsEqualsAutoGen && FileName != "Config.json") + if (!fileContentsEqualsAutoGen && FileName != "Config.json" && !customLanguage) { Log.WriteWarning($"Warning: {FileName} differs from autogenerated version."); } @@ -65,7 +67,7 @@ private void Load() settings.Converters.Add(new StringEnumConverter()); settings.Converters.Add(new StringFloatConverter()); - if (FileName.Equals("Config.json") || fileContentsEqualsAutoGen || ConfigHelper.Main.Values.UseCustomData) + if (FileName.Equals("Config.json") || fileContentsEqualsAutoGen || ConfigHelper.Main.Values.UseCustomData || customLanguage) { JsonConvert.PopulateObject(contents, Values, settings); Log.WriteLine($"{FileName} loaded");