From d919497e432d44a2c78f67fbf74d9e6f9648b5d9 Mon Sep 17 00:00:00 2001 From: Sinai Date: Tue, 23 Mar 2021 04:47:55 +1100 Subject: [PATCH] Config: use en-us culture, fix recursive exception --- src/Core/Config/ExplorerConfig.cs | 28 +++++++++++++++++++++------- src/ExplorerCore.cs | 2 +- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/Core/Config/ExplorerConfig.cs b/src/Core/Config/ExplorerConfig.cs index c62a999..d8b87df 100644 --- a/src/Core/Config/ExplorerConfig.cs +++ b/src/Core/Config/ExplorerConfig.cs @@ -4,6 +4,7 @@ using UnityEngine; using IniParser; using IniParser.Parser; using UnityExplorer.UI; +using System.Globalization; namespace UnityExplorer.Core.Config { @@ -14,6 +15,8 @@ namespace UnityExplorer.Core.Config internal static readonly IniDataParser _parser = new IniDataParser(); internal static readonly string INI_PATH = Path.Combine(ExplorerCore.Loader.ConfigFolder, "config.ini"); + internal static CultureInfo _enCulture = new CultureInfo("en-US"); + static ExplorerConfig() { _parser.Configuration.CommentString = "#"; @@ -30,7 +33,7 @@ namespace UnityExplorer.Core.Config public bool Hide_On_Startup = false; public string Window_Anchors = DEFAULT_WINDOW_ANCHORS; - private const string DEFAULT_WINDOW_ANCHORS = "0.25,0.1,0.78,0.95"; + private const string DEFAULT_WINDOW_ANCHORS = "0.25,0.10,0.78,0.95"; public static event Action OnConfigChanged; @@ -123,17 +126,22 @@ namespace UnityExplorer.Core.Config try { var split = Window_Anchors.Split(','); + + if (split.Length != 4) + throw new Exception(); + Vector4 ret = Vector4.zero; - ret.x = float.Parse(split[0]); - ret.y = float.Parse(split[1]); - ret.z = float.Parse(split[2]); - ret.w = float.Parse(split[3]); + ret.x = float.Parse(split[0], _enCulture); + ret.y = float.Parse(split[1], _enCulture); + ret.z = float.Parse(split[2], _enCulture); + ret.w = float.Parse(split[3], _enCulture); + return ret; } catch { Window_Anchors = DEFAULT_WINDOW_ANCHORS; - return GetWindowAnchorsVector(); + return new Vector4(0.25f, 0.1f, 0.78f, 0.95f); } } @@ -142,7 +150,13 @@ namespace UnityExplorer.Core.Config try { var rect = PanelDragger.Instance.Panel; - return $"{rect.anchorMin.x},{rect.anchorMin.y},{rect.anchorMax.x},{rect.anchorMax.y}"; + return string.Format(_enCulture, "{0},{1},{2},{3}", new object[] + { + rect.anchorMin.x, + rect.anchorMax.y, + rect.anchorMax.x, + rect.anchorMax.y + }); } catch { diff --git a/src/ExplorerCore.cs b/src/ExplorerCore.cs index 6dac742..2509b3a 100644 --- a/src/ExplorerCore.cs +++ b/src/ExplorerCore.cs @@ -17,7 +17,7 @@ namespace UnityExplorer public class ExplorerCore { public const string NAME = "UnityExplorer"; - public const string VERSION = "3.2.5"; + public const string VERSION = "3.2.6"; public const string AUTHOR = "Sinai"; public const string GUID = "com.sinai.unityexplorer";