Import Cryville.Culture in favor of ScriptUtils.
This commit is contained in:
@@ -5,6 +5,7 @@ using Cryville.Common.Logging;
|
||||
using Cryville.Common.Unity;
|
||||
using Cryville.Common.Unity.UI;
|
||||
using Cryville.Crtr.UI;
|
||||
using Cryville.Culture;
|
||||
using Cryville.Input;
|
||||
using Cryville.Input.Unity;
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
@@ -18,6 +19,9 @@ using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using UnityEngine;
|
||||
using Logger = Cryville.Common.Logging.Logger;
|
||||
using unity = UnityEngine;
|
||||
@@ -61,7 +65,7 @@ namespace Cryville.Crtr {
|
||||
Logger.Log("main", 1, "Game", "Culture: {0}, UI = {1}, System = {2}, Unity = {3}", CultureInfo.CurrentCulture, CultureInfo.CurrentUICulture, CultureInfo.InstalledUICulture, Application.systemLanguage);
|
||||
|
||||
if (_bcflag) Logger.Log("main", 2, "Game", "Reset all settings");
|
||||
|
||||
|
||||
GameDataPath = Settings.Default.GameDataPath;
|
||||
UnityDataPath = Application.dataPath;
|
||||
|
||||
@@ -153,7 +157,13 @@ namespace Cryville.Crtr {
|
||||
Settings.Default.Save();
|
||||
|
||||
Logger.Log("main", 1, "UI", "Initializing font manager");
|
||||
TMPAutoFont.FontMatcher = new FallbackListFontMatcher(PlatformConfig.FontManager) {
|
||||
foreach (var res in Resources.LoadAll<TextAsset>("cldr/common/validity")) {
|
||||
IdValidity.Load(LoadXmlDocument(res));
|
||||
}
|
||||
var metadata = new SupplementalMetadata(LoadXmlDocument("cldr/common/supplemental/supplementalMetadata"));
|
||||
var subtags = new LikelySubtags(LoadXmlDocument("cldr/common/supplemental/likelySubtags"), metadata);
|
||||
var matcher = new LanguageMatching(LoadXmlDocument("cldr/common/supplemental/languageInfo"), subtags);
|
||||
TMPAutoFont.FontMatcher = new FallbackListFontMatcher(matcher, PlatformConfig.FontManager) {
|
||||
MapScriptToTypefaces = PlatformConfig.ScriptFontMap
|
||||
};
|
||||
TMPAutoFont.DefaultShader = Resources.Load<Shader>(PlatformConfig.TextShader);
|
||||
@@ -161,6 +171,21 @@ namespace Cryville.Crtr {
|
||||
Logger.Log("main", 1, "Game", "Initialized");
|
||||
}
|
||||
|
||||
static readonly Encoding _encoding = new UTF8Encoding(false, true);
|
||||
static readonly XmlReaderSettings _xmlSettings = new XmlReaderSettings {
|
||||
DtdProcessing = DtdProcessing.Ignore,
|
||||
};
|
||||
static XDocument LoadXmlDocument(string path) {
|
||||
return LoadXmlDocument(Resources.Load<TextAsset>(path));
|
||||
}
|
||||
static XDocument LoadXmlDocument(TextAsset asset) {
|
||||
using (var stream = new MemoryStream(_encoding.GetBytes(asset.text))) {
|
||||
using (var reader = XmlReader.Create(stream, _xmlSettings)) {
|
||||
return XDocument.Load(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool _shutdown;
|
||||
public static void Shutdown() {
|
||||
if (_shutdown) return;
|
||||
|
Reference in New Issue
Block a user