Skip to content

Commit

Permalink
setting的路径在安卓上的调整
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoqingqing committed Mar 30, 2021
1 parent 1cd2867 commit 5ccc917
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,6 @@ namespace KEngine.Modules
/// </summary>
public class SettingModule : SettingModuleBase
{
public delegate byte[] LoadSettingFuncDelegate(string filePath);
public delegate byte[] SettingBytesFilterDelegate(byte[] bytes);

/// <summary>
/// Filter the loaded bytes, which settings file may be encrypted, so you can manipulate the bytes
/// </summary>
public static SettingBytesFilterDelegate SettingBytesFilter;

/// <summary>
/// Override the default load file strategy
/// </summary>
public static LoadSettingFuncDelegate CustomLoadSetting;

private static readonly bool IsEditor;
static SettingModule()
{
Expand All @@ -63,9 +50,8 @@ static SettingModule()
internal SettingModule()
{
}





/// <summary>
/// Singleton
/// </summary>
Expand All @@ -91,35 +77,16 @@ public static TableFile Get(string path, bool useCache = true)
/// <returns></returns>
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);
}

/// <summary>
/// Default load setting strategry,
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
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;
}


/// <summary>
/// 获取配置表的路径,都在Settings目录下
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public static string GetTextFilePath(string path)
public static string GetSettingFilePath(string path)
{
return AppConfig.SettingResourcesPath + "/" + path;
}
Expand Down
2 changes: 1 addition & 1 deletion KSFramework/Assets/KSFramework/Modules/I18N/I18N.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 5ccc917

Please sign in to comment.