Преглед на файлове

Merge branch 'localizetexture' of ssh://192.168.0.8:29418/xianjing into hy_dny_localized

# Conflicts:
#	Assets/Editor/CsvToLua/CsvToLua.cs
#	Assets/Src/ExtendComponents/UILocalizeTexture.cs
gdl_123 преди 3 месеца
родител
ревизия
229c5d3047

+ 2 - 2
Assets/Editor/CsvToLua/CsvToLua.cs

@@ -924,7 +924,7 @@ return aaa";
                         if (isCheck&& !path.Contains(metastr))
                         {
                             checkList.Add(path+"\r\n");
-                            if (copyqsFile && File.Exists(path))
+                            if (copyqsFile&& File.Exists(path))
                             {
                                 File.Copy(path, fileOutputPath, true);
                             }
@@ -1112,7 +1112,7 @@ return aaa";
                     string basepath = copycfg.RawGet<string, string>("basepath");
                     string path = copycfg.RawGet<string, string>("path");
                     string fileName = copycfg.RawGet<string, string>("fileName");
-                    if (fileName.Contains(".png"))
+                    if (fileName.Contains(".png")&& File.Exists(fileroot + fileName))
                     {
                         string opp = output + basepath + path + fileName;
                         File.Copy(fileroot + fileName, opp, true);

+ 19 - 0
Assets/Src/Core/Config/LocalizedTextureCfgMgr.cs

@@ -170,6 +170,25 @@ public class LocalizedTextureCfgMgr : Singleton<LocalizedTextureCfgMgr>
     }
 
 
+    public LocalizedSpriteCfg GetCfgByLgkey(string lgKey,string key,bool def = true)
+    {
+        if (!isOpen)
+        {
+            return null;
+        }
+        if (cfgs.ContainsKey(lgKey)&&cfgs[lgKey].ContainsKey(key))
+        {
+            return cfgs[lgKey][key];
+        }
+
+        if (def && cfgs[baseKey].ContainsKey(key))
+        {
+            return cfgs[baseKey][key];
+        }
+
+        return null;
+    }
+
     public string GetLocalize(string key, bool notbase = false)
     {
         if (!isOpen)

+ 9 - 2
Assets/Src/ExtendComponents/UILocalizeTexture.cs

@@ -6,7 +6,7 @@ using UnityEngine.UI;
 
 public class UILocalizeTexture : MonoBehaviour
 {
-
+    public string lgKey;
     public string key;
 
     private Image mImage;
@@ -53,7 +53,14 @@ public class UILocalizeTexture : MonoBehaviour
         if (string.IsNullOrEmpty(key) || mImage == null)
             return;
 
-        spriteCfg = LocalizedTextureCfgMgr.Instance.GetLocalizedSpriteCfg(key,false);
+        if (string.IsNullOrEmpty(lgKey))
+        {
+            spriteCfg = LocalizedTextureCfgMgr.Instance.GetLocalizedSpriteCfg(key);
+        }
+        else
+        {
+            spriteCfg = LocalizedTextureCfgMgr.Instance.GetCfgByLgkey(lgKey,key);
+        }
         if (spriteCfg == null || oldname == spriteCfg.Language)
         {
             return;

+ 38 - 0
Assets/ToLua/Source/Generate/LocalizedTextureCfgMgrWrap.cs

@@ -10,6 +10,7 @@ public class LocalizedTextureCfgMgrWrap
 		L.RegFunction("Init", Init);
 		L.RegFunction("SetLanguage", SetLanguage);
 		L.RegFunction("GetLocalizedSpriteCfg", GetLocalizedSpriteCfg);
+		L.RegFunction("GetCfgByLgkey", GetCfgByLgkey);
 		L.RegFunction("GetLocalize", GetLocalize);
 		L.RegFunction("SetLanguageByKey", SetLanguageByKey);
 		L.RegFunction("GetLanguageCfgByKey", GetLanguageCfgByKey);
@@ -117,6 +118,43 @@ public class LocalizedTextureCfgMgrWrap
 		}
 	}
 
+	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
+	static int GetCfgByLgkey(IntPtr L)
+	{
+		try
+		{
+			int count = LuaDLL.lua_gettop(L);
+
+			if (count == 3)
+			{
+				LocalizedTextureCfgMgr obj = (LocalizedTextureCfgMgr)ToLua.CheckObject<LocalizedTextureCfgMgr>(L, 1);
+				string arg0 = ToLua.CheckString(L, 2);
+				string arg1 = ToLua.CheckString(L, 3);
+				LocalizedSpriteCfg o = obj.GetCfgByLgkey(arg0, arg1);
+				ToLua.PushObject(L, o);
+				return 1;
+			}
+			else if (count == 4)
+			{
+				LocalizedTextureCfgMgr obj = (LocalizedTextureCfgMgr)ToLua.CheckObject<LocalizedTextureCfgMgr>(L, 1);
+				string arg0 = ToLua.CheckString(L, 2);
+				string arg1 = ToLua.CheckString(L, 3);
+				bool arg2 = LuaDLL.luaL_checkboolean(L, 4);
+				LocalizedSpriteCfg o = obj.GetCfgByLgkey(arg0, arg1, arg2);
+				ToLua.PushObject(L, o);
+				return 1;
+			}
+			else
+			{
+				return LuaDLL.luaL_throw(L, "invalid arguments to method: LocalizedTextureCfgMgr.GetCfgByLgkey");
+			}
+		}
+		catch (Exception e)
+		{
+			return LuaDLL.toluaL_exception(L, e);
+		}
+	}
+
 	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
 	static int GetLocalize(IntPtr L)
 	{

+ 39 - 0
Assets/ToLua/Source/Generate/UILocalizeTextureWrap.cs

@@ -12,6 +12,7 @@ public class UILocalizeTextureWrap
 		L.RegFunction("Dispose", Dispose);
 		L.RegFunction("__eq", op_Equality);
 		L.RegFunction("__tostring", ToLua.op_ToString);
+		L.RegVar("lgKey", get_lgKey, set_lgKey);
 		L.RegVar("key", get_key, set_key);
 		L.EndClass();
 	}
@@ -83,6 +84,25 @@ public class UILocalizeTextureWrap
 		}
 	}
 
+	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
+	static int get_lgKey(IntPtr L)
+	{
+		object o = null;
+
+		try
+		{
+			o = ToLua.ToObject(L, 1);
+			UILocalizeTexture obj = (UILocalizeTexture)o;
+			string ret = obj.lgKey;
+			LuaDLL.lua_pushstring(L, ret);
+			return 1;
+		}
+		catch(Exception e)
+		{
+			return LuaDLL.toluaL_exception(L, e, o, "attempt to index lgKey on a nil value");
+		}
+	}
+
 	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
 	static int get_key(IntPtr L)
 	{
@@ -102,6 +122,25 @@ public class UILocalizeTextureWrap
 		}
 	}
 
+	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
+	static int set_lgKey(IntPtr L)
+	{
+		object o = null;
+
+		try
+		{
+			o = ToLua.ToObject(L, 1);
+			UILocalizeTexture obj = (UILocalizeTexture)o;
+			string arg0 = ToLua.CheckString(L, 2);
+			obj.lgKey = arg0;
+			return 0;
+		}
+		catch(Exception e)
+		{
+			return LuaDLL.toluaL_exception(L, e, o, "attempt to index lgKey on a nil value");
+		}
+	}
+
 	[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
 	static int set_key(IntPtr L)
 	{