|
@@ -44,7 +44,7 @@ public class GameLanguageCfg
|
|
|
|
|
|
|
|
public class LocalizedTextureCfgMgr : Singleton<LocalizedTextureCfgMgr>
|
|
public class LocalizedTextureCfgMgr : Singleton<LocalizedTextureCfgMgr>
|
|
|
{
|
|
{
|
|
|
- public static string baseName = "LocalizeTextureCfg";
|
|
|
|
|
|
|
+ public static string baseName = "LocalizeTextureCfg";
|
|
|
private static bool isOpen = false;
|
|
private static bool isOpen = false;
|
|
|
public static bool IsOpen { get => isOpen; }
|
|
public static bool IsOpen { get => isOpen; }
|
|
|
|
|
|
|
@@ -62,7 +62,7 @@ public class LocalizedTextureCfgMgr : Singleton<LocalizedTextureCfgMgr>
|
|
|
|
|
|
|
|
if (!isOpen)
|
|
if (!isOpen)
|
|
|
{
|
|
{
|
|
|
- return ;
|
|
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
//SetLanguageLocalSetting("_tw");
|
|
//SetLanguageLocalSetting("_tw");
|
|
|
string defaultlg = GetLanguageLocalSetting();
|
|
string defaultlg = GetLanguageLocalSetting();
|
|
@@ -89,14 +89,19 @@ public class LocalizedTextureCfgMgr : Singleton<LocalizedTextureCfgMgr>
|
|
|
|
|
|
|
|
private void ReadConfig()
|
|
private void ReadConfig()
|
|
|
{
|
|
{
|
|
|
- string cfgname = GetLanguageCfgName(curLanguageKey);
|
|
|
|
|
|
|
+ curCfg = AddCfgByCfgName(curLanguageKey);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if (!cfgs.ContainsKey(curLanguageKey))
|
|
|
|
|
|
|
+ private Dictionary<string, LocalizedSpriteCfg> AddCfgByCfgName(string name)
|
|
|
|
|
+ {
|
|
|
|
|
+ string cfgname = GetLanguageCfgName(name);
|
|
|
|
|
+
|
|
|
|
|
+ if (!cfgs.ContainsKey(name))
|
|
|
{
|
|
{
|
|
|
Dictionary<string, Dictionary<string, string>> cfgdata = ConfigMgr.Instance.getTable(cfgname);
|
|
Dictionary<string, Dictionary<string, string>> cfgdata = ConfigMgr.Instance.getTable(cfgname);
|
|
|
if (cfgdata == null)
|
|
if (cfgdata == null)
|
|
|
{
|
|
{
|
|
|
- return;
|
|
|
|
|
|
|
+ return null;
|
|
|
}
|
|
}
|
|
|
Dictionary<string, LocalizedSpriteCfg> cfg = new Dictionary<string, LocalizedSpriteCfg>();
|
|
Dictionary<string, LocalizedSpriteCfg> cfg = new Dictionary<string, LocalizedSpriteCfg>();
|
|
|
foreach (var item in cfgdata)
|
|
foreach (var item in cfgdata)
|
|
@@ -110,22 +115,17 @@ public class LocalizedTextureCfgMgr : Singleton<LocalizedTextureCfgMgr>
|
|
|
localizedSpriteCfg.SetNativeSize = _value["SetNativeSize"];
|
|
localizedSpriteCfg.SetNativeSize = _value["SetNativeSize"];
|
|
|
cfg.Add(item.Key, localizedSpriteCfg);
|
|
cfg.Add(item.Key, localizedSpriteCfg);
|
|
|
}
|
|
}
|
|
|
- cfgs.Add(curLanguageKey, cfg);
|
|
|
|
|
- curCfg = cfg;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- curCfg = cfgs[curLanguageKey];
|
|
|
|
|
|
|
+ cfgs.Add(name, cfg);
|
|
|
|
|
+ return cfg;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ return cfgs[name];
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
public void SetLanguage(string language)
|
|
public void SetLanguage(string language)
|
|
|
{
|
|
{
|
|
|
if (!string.IsNullOrEmpty(language) && language != curLanguageKey)
|
|
if (!string.IsNullOrEmpty(language) && language != curLanguageKey)
|
|
|
{
|
|
{
|
|
|
oldLanguageKey = curLanguageKey;
|
|
oldLanguageKey = curLanguageKey;
|
|
|
- curLanguageKey = language;
|
|
|
|
|
|
|
+ curLanguageKey = language;
|
|
|
ReadConfig();
|
|
ReadConfig();
|
|
|
ConfigMgr.CurLangKey = language;
|
|
ConfigMgr.CurLangKey = language;
|
|
|
EventMgr.DispatchEvent(new CoreEvent<int>(ECoreEventType.EID_LANGUAGE_CHANGE, 1));
|
|
EventMgr.DispatchEvent(new CoreEvent<int>(ECoreEventType.EID_LANGUAGE_CHANGE, 1));
|
|
@@ -145,11 +145,9 @@ public class LocalizedTextureCfgMgr : Singleton<LocalizedTextureCfgMgr>
|
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
|
public LocalizedSpriteCfg GetLocalizedSpriteCfg(string key, bool notbase = true)
|
|
public LocalizedSpriteCfg GetLocalizedSpriteCfg(string key, bool notbase = true)
|
|
|
{
|
|
{
|
|
|
- if (!isOpen)
|
|
|
|
|
- {
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
- if (notbase && (curLanguageKey == oldLanguageKey || curLanguageKey == baseKey))
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (!isOpen ||
|
|
|
|
|
+ (notbase && curLanguageKey == oldLanguageKey))
|
|
|
{
|
|
{
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
@@ -171,20 +169,27 @@ public class LocalizedTextureCfgMgr : Singleton<LocalizedTextureCfgMgr>
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- public LocalizedSpriteCfg GetCfgByLgkey(string lgKey,string key,bool def = true)
|
|
|
|
|
|
|
+ public LocalizedSpriteCfg GetCfgByLgkey(string lgKey, string key, bool def = true)
|
|
|
{
|
|
{
|
|
|
if (!isOpen)
|
|
if (!isOpen)
|
|
|
{
|
|
{
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
- if (cfgs.ContainsKey(lgKey)&&cfgs[lgKey].ContainsKey(key))
|
|
|
|
|
|
|
+ Dictionary<string, LocalizedSpriteCfg> tcfg = AddCfgByCfgName(lgKey);
|
|
|
|
|
+
|
|
|
|
|
+ if (tcfg != null && tcfg.ContainsKey(key))
|
|
|
{
|
|
{
|
|
|
- return cfgs[lgKey][key];
|
|
|
|
|
|
|
+ return tcfg[key];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (def && cfgs[baseKey].ContainsKey(key))
|
|
|
|
|
|
|
+ if (def)
|
|
|
{
|
|
{
|
|
|
- return cfgs[baseKey][key];
|
|
|
|
|
|
|
+ tcfg = AddCfgByCfgName(baseKey);
|
|
|
|
|
+
|
|
|
|
|
+ if (tcfg != null && tcfg.ContainsKey(key))
|
|
|
|
|
+ {
|
|
|
|
|
+ return tcfg[key];
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
return null;
|
|
@@ -230,7 +235,7 @@ public class LocalizedTextureCfgMgr : Singleton<LocalizedTextureCfgMgr>
|
|
|
GameLanguageCfg cfg = new GameLanguageCfg();
|
|
GameLanguageCfg cfg = new GameLanguageCfg();
|
|
|
cfg.key = item.Key;
|
|
cfg.key = item.Key;
|
|
|
cfg.language = item.Value["Language"];
|
|
cfg.language = item.Value["Language"];
|
|
|
- gameLanguageCfgs.Add(cfg.key,cfg);
|
|
|
|
|
|
|
+ gameLanguageCfgs.Add(cfg.key, cfg);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
isOpen = FileHelper.CheckStringIsTrue(GetLanguageCfgByKey("openSetting"));
|
|
isOpen = FileHelper.CheckStringIsTrue(GetLanguageCfgByKey("openSetting"));
|
|
@@ -283,7 +288,7 @@ public class LocalizedTextureCfgMgr : Singleton<LocalizedTextureCfgMgr>
|
|
|
ret = LanguageFileEx.English;
|
|
ret = LanguageFileEx.English;
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
case UnityEngine.SystemLanguage.Chinese:
|
|
case UnityEngine.SystemLanguage.Chinese:
|
|
|
case UnityEngine.SystemLanguage.ChineseSimplified:
|
|
case UnityEngine.SystemLanguage.ChineseSimplified:
|
|
|
case UnityEngine.SystemLanguage.ChineseTraditional:
|
|
case UnityEngine.SystemLanguage.ChineseTraditional:
|
|
@@ -318,7 +323,7 @@ public class LocalizedTextureCfgMgr : Singleton<LocalizedTextureCfgMgr>
|
|
|
|
|
|
|
|
public static string GetLanguageLocalSetting()
|
|
public static string GetLanguageLocalSetting()
|
|
|
{
|
|
{
|
|
|
- return UnityEngine.PlayerPrefs.GetString("LanguageLocalSetting",string.Empty);
|
|
|
|
|
|
|
+ return UnityEngine.PlayerPrefs.GetString("LanguageLocalSetting", string.Empty);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static void SetLanguageLocalSetting(string key)
|
|
public static void SetLanguageLocalSetting(string key)
|