From 5ccc917de04369b5a78ccc3e0791a326b863b26d Mon Sep 17 00:00:00 2001 From: "qingqing.zhao" Date: Tue, 30 Mar 2021 22:44:22 +0800 Subject: [PATCH] =?UTF-8?q?setting=E7=9A=84=E8=B7=AF=E5=BE=84=E5=9C=A8?= =?UTF-8?q?=E5=AE=89=E5=8D=93=E4=B8=8A=E7=9A=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../KEngine/CoreModules/SettingModule.cs | 43 +++---------------- .../Assets/KSFramework/Modules/I18N/I18N.cs | 2 +- 2 files changed, 6 insertions(+), 39 deletions(-) diff --git a/KSFramework/Assets/KSFramework/KEngine/KEngine/CoreModules/SettingModule.cs b/KSFramework/Assets/KSFramework/KEngine/KEngine/CoreModules/SettingModule.cs index 9cf90f20..b572659e 100644 --- a/KSFramework/Assets/KSFramework/KEngine/KEngine/CoreModules/SettingModule.cs +++ b/KSFramework/Assets/KSFramework/KEngine/KEngine/CoreModules/SettingModule.cs @@ -38,19 +38,6 @@ namespace KEngine.Modules /// public class SettingModule : SettingModuleBase { - public delegate byte[] LoadSettingFuncDelegate(string filePath); - public delegate byte[] SettingBytesFilterDelegate(byte[] bytes); - - /// - /// Filter the loaded bytes, which settings file may be encrypted, so you can manipulate the bytes - /// - public static SettingBytesFilterDelegate SettingBytesFilter; - - /// - /// Override the default load file strategy - /// - public static LoadSettingFuncDelegate CustomLoadSetting; - private static readonly bool IsEditor; static SettingModule() { @@ -63,9 +50,8 @@ static SettingModule() internal SettingModule() { } - - - + + /// /// Singleton /// @@ -91,35 +77,16 @@ public static TableFile Get(string path, bool useCache = true) /// protected override string LoadSetting(string path) { - byte[] fileContent = CustomLoadSetting != null ? CustomLoadSetting(path) : DefaultLoadSetting(path); + byte[] fileContent = KResourceModule.LoadAssetsSync(GetSettingFilePath(path)); return Encoding.UTF8.GetString(fileContent); } - - /// - /// Default load setting strategry, - /// - /// - /// - public static byte[] DefaultLoadSetting(string path) - { - string fullUrl ; - var getResPathType = KResourceModule.GetResourceFullPath(GetTextFilePath(path), false, out fullUrl); - if (getResPathType == KResourceModule.GetResourceFullPathType.Invalid) - { - Log.Error("can not find file: {0}", fullUrl); - return null; - } - var bytes = File.ReadAllBytes(fullUrl); - bytes = SettingBytesFilter != null ? SettingBytesFilter(bytes) : bytes; - return bytes; - } - + /// /// 获取配置表的路径,都在Settings目录下 /// /// /// - public static string GetTextFilePath(string path) + public static string GetSettingFilePath(string path) { return AppConfig.SettingResourcesPath + "/" + path; } diff --git a/KSFramework/Assets/KSFramework/Modules/I18N/I18N.cs b/KSFramework/Assets/KSFramework/Modules/I18N/I18N.cs index b5f2e10d..6169ce05 100644 --- a/KSFramework/Assets/KSFramework/Modules/I18N/I18N.cs +++ b/KSFramework/Assets/KSFramework/Modules/I18N/I18N.cs @@ -57,7 +57,7 @@ public static void Init() Strs.Clear(); //读取语言包 var lang_file = $"I18N/lang{AppConfig.LangFileFlag}.txt"; - var bytes = SettingModule.DefaultLoadSetting(lang_file); + var bytes = KResourceModule.LoadAssetsSync(SettingModule.GetSettingFilePath(lang_file)); var fileContent = Encoding.UTF8.GetString(bytes); TextParser.ParseText(fileContent,Strs);