Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
Adding better custom language support.
Browse files Browse the repository at this point in the history
Note: Flipping from custom -> en-US while running won't work.
  • Loading branch information
sir-wilhelm committed Apr 17, 2020
1 parent 478dbad commit ab131bd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions SmartHunter/Core/Config/ConfigContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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.");
}
Expand All @@ -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");
Expand Down

0 comments on commit ab131bd

Please sign in to comment.