From 1dafda4b442ed5c0efe75eb3b52f1ddbd0e7ec97 Mon Sep 17 00:00:00 2001 From: gaoxin Date: Fri, 22 Jan 2021 14:17:08 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E3=80=90=E7=83=AD=E6=9B=B4=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E3=80=91=E7=BB=93=E6=9E=84=E6=90=AD=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AssetBundles/config.txt | 4 + AssetBundles/version.txt | 2 +- .../Scripts/ConstDefine/AppConst.cs | 5 +- Assets/LuaFramework/Scripts/Framework/App.cs | 11 ++ .../Scripts/Manager/ConfigManager.cs | 153 ++++++++++++++++++ .../Scripts/Manager/ConfigManager.cs.meta | 11 ++ Assets/Resources/config.txt | 4 + Assets/Resources/config.txt.meta | 7 + .../Manager/ResourcesUpdateManager.cs | 21 ++- 9 files changed, 214 insertions(+), 4 deletions(-) create mode 100644 AssetBundles/config.txt create mode 100644 Assets/LuaFramework/Scripts/Manager/ConfigManager.cs create mode 100644 Assets/LuaFramework/Scripts/Manager/ConfigManager.cs.meta create mode 100644 Assets/Resources/config.txt create mode 100644 Assets/Resources/config.txt.meta diff --git a/AssetBundles/config.txt b/AssetBundles/config.txt new file mode 100644 index 0000000000..a9c5b7f715 --- /dev/null +++ b/AssetBundles/config.txt @@ -0,0 +1,4 @@ +{"subChannel":"1", +"buglyId":"261348dcd3", +"channel":"pc", +"serverUrl":"http://60.1.1.23:8080/"} \ No newline at end of file diff --git a/AssetBundles/version.txt b/AssetBundles/version.txt index d252578df2..e7e73835a5 100644 --- a/AssetBundles/version.txt +++ b/AssetBundles/version.txt @@ -1 +1 @@ -{"buglyId":"261348dcd3", "channel":"pc", "resUrl":"http://60.1.1.12/jieling_dl/dev/assetBundles/subChannal094-test/", "packageVersion":"0.2", "subChannel":"1", "version":"0.15.0", "serverUrl":"http://60.1.1.23:8080/"} \ No newline at end of file +{"subChannel":"1", "buglyId":"261348dcd3", "channel":"pc", "resUrl":"http://60.1.1.12/jieling_dl/dev/assetBundles/subChannal094-test/", "packageVersion":"0.2", "version":"0.15.0", "serverUrl":"http://60.1.1.23:8080/"} \ No newline at end of file diff --git a/Assets/LuaFramework/Scripts/ConstDefine/AppConst.cs b/Assets/LuaFramework/Scripts/ConstDefine/AppConst.cs index cc239a6a3c..d05cf15bff 100644 --- a/Assets/LuaFramework/Scripts/ConstDefine/AppConst.cs +++ b/Assets/LuaFramework/Scripts/ConstDefine/AppConst.cs @@ -164,8 +164,9 @@ namespace GameLogic public static string LaQi_JoinRoom_Url = string.Empty; //拉起应用链接 - public const string LoadingMD5Flie = "files.txt"; //加载界面更新MD5文件 - public const string GameVersionFile = "version.txt"; //游戏版本号文件 + public const string LoadingMD5Flie = "files.txt"; //加载界面更新MD5文件 + public const string GameVersionFile = "version.txt"; //游戏版本号文件 + public const string GameConfigFile = "config.txt"; //游戏版本号文件 public static int UserId; //用户ID public static int Token; //用户Token diff --git a/Assets/LuaFramework/Scripts/Framework/App.cs b/Assets/LuaFramework/Scripts/Framework/App.cs index 343bc0ecfc..f5b47afc24 100644 --- a/Assets/LuaFramework/Scripts/Framework/App.cs +++ b/Assets/LuaFramework/Scripts/Framework/App.cs @@ -180,12 +180,23 @@ public class App : UnitySingleton return VersionManager.Instance; } } + /// + /// 配置数据管理器管理器 + /// + public static ConfigManager ConfigMgr + { + get + { + return ConfigManager.Instance; + } + } /// /// 初始化 /// public void Initialize() { + ConfigMgr.Init(); VersionMgr.Initialize(); } diff --git a/Assets/LuaFramework/Scripts/Manager/ConfigManager.cs b/Assets/LuaFramework/Scripts/Manager/ConfigManager.cs new file mode 100644 index 0000000000..e2c83228e2 --- /dev/null +++ b/Assets/LuaFramework/Scripts/Manager/ConfigManager.cs @@ -0,0 +1,153 @@ +using UnityEngine; +using UnityEditor; +using GameCore; +using System.Collections; +using System.IO; +using System; + +namespace GameLogic +{ + public class MConfig + { + Hashtable info; + + public MConfig(string json) + { + info = MiniJSON.jsonDecode(json) as Hashtable; + } + + public string ToJson() + { + return MiniJSON.jsonEncode(info); + } + + public string GetInfo(string key) + { + if (info.ContainsKey(key)) + { + return info[key] as string; + } + return null; + } + + public void RemoveInfo(string key) + { + if (info.ContainsKey(key)) + { + info.Remove(key); + } + } + + public void SetInfo(string key, string value) + { + info[key] = value; + } + } + public class ConfigManager : Singleton + { + + /// + /// 版本号文件 + /// + const string configFile = "config"; + /// + /// 版本文件路径 + /// + string configFilePath + { + get + { + return AppConst.PersistentDataPath + configFile + ".txt"; + } + } + + MConfig StreamingInfo; + MConfig PersistentInfo; + MConfig NetInfo; + // 初始化 获取本地的数据 + public void Init() + { + try + { + if (File.Exists(configFilePath)) + { + PersistentInfo = new MConfig(File.ReadAllText(configFilePath, System.Text.Encoding.UTF8)); + } + } + catch (Exception e) + { + Debug.LogError(e); + } + + try + { + StreamingInfo = new MConfig(Resources.Load(configFile).text); + } + catch (Exception e) + { + Debug.LogError(e); + } + } + + public void SetNetInfo(string info) + { + + try + { + NetInfo = new MConfig(info); + SaveToFiles(); + } + catch (Exception e) + { + Debug.LogError(e); + } + } + + /// + /// 保存到文件 + /// + void SaveToFiles() + { + PersistentInfo = NetInfo; + string directoryPath = Path.GetDirectoryName(configFilePath); + if (!Directory.Exists(directoryPath)) Directory.CreateDirectory(directoryPath); + File.WriteAllText(configFilePath, PersistentInfo.ToJson(), System.Text.Encoding.UTF8); + } + + /// + /// + /// + /// + /// + public string GetConfigInfo(string key) + { + string v = GetConfigNetInfo(key); + if (v != null) return v; + v = GetConfigPersistentInfo(key); + if (v != null) return v; + v = GetConfigStreamingInfo(key); + if (v != null) return v; + return null; + } + public string GetConfigNetInfo(string key) + { + if (NetInfo == null) return null; + string v = NetInfo.GetInfo(key); + return v; + } + public string GetConfigPersistentInfo(string key) + { + if (PersistentInfo == null) return null; + string v = PersistentInfo.GetInfo(key); + return v; + } + public string GetConfigStreamingInfo(string key) + { + if (StreamingInfo == null) return null; + string v = StreamingInfo.GetInfo(key); + return v; + } + + + } +} diff --git a/Assets/LuaFramework/Scripts/Manager/ConfigManager.cs.meta b/Assets/LuaFramework/Scripts/Manager/ConfigManager.cs.meta new file mode 100644 index 0000000000..690450a906 --- /dev/null +++ b/Assets/LuaFramework/Scripts/Manager/ConfigManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 252b072fc95a44740976d9126b5b4626 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/config.txt b/Assets/Resources/config.txt new file mode 100644 index 0000000000..a9c5b7f715 --- /dev/null +++ b/Assets/Resources/config.txt @@ -0,0 +1,4 @@ +{"subChannel":"1", +"buglyId":"261348dcd3", +"channel":"pc", +"serverUrl":"http://60.1.1.23:8080/"} \ No newline at end of file diff --git a/Assets/Resources/config.txt.meta b/Assets/Resources/config.txt.meta new file mode 100644 index 0000000000..64e1d3c3a3 --- /dev/null +++ b/Assets/Resources/config.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 343cc3bd6dddfa64381bbe4c53e06a87 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Core/ResUpdate/Manager/ResourcesUpdateManager.cs b/Assets/Scripts/Core/ResUpdate/Manager/ResourcesUpdateManager.cs index a766fd97f5..ac15104c01 100644 --- a/Assets/Scripts/Core/ResUpdate/Manager/ResourcesUpdateManager.cs +++ b/Assets/Scripts/Core/ResUpdate/Manager/ResourcesUpdateManager.cs @@ -314,6 +314,25 @@ namespace ResUpdate } downLoadURL = VersionManager.Instance.GetVersionInfo("resUrl") + AppConst.PlatformPath + "/"; + + // 获取config + string conUrl = downLoadURL + AppConst.GameConfigFile; + Debug.Log("Download_Resouces_Url:" + conUrl); + UnityWebRequest request0 = UnityWebRequest.Get(conUrl); + request0.certificateHandler = new AcceptAllCertificatesSignedWithASpecificPublicKey(); + yield return request0.SendWebRequest(); + if (request0.isNetworkError) + { + SetResourcesUpdateState(true, ResourcesUpdateState.GetGameConfigsFailed); + yield break; + } + else + { + Debug.Log("www.text.config:" + request0.downloadHandler.text); + ConfigManager.Instance.SetNetInfo(request0.downloadHandler.text); + } + + // 获取version string resUrl = downLoadURL + AppConst.GameVersionFile; Debug.Log("Download_Resouces_Url:" + resUrl); @@ -327,7 +346,7 @@ namespace ResUpdate } else { - Debug.Log("www.text:" + request.downloadHandler.text); + Debug.Log("www.text.version:" + request.downloadHandler.text); Hashtable table = MiniJSON.jsonDecode(request.downloadHandler.text) as Hashtable; if (table == null) From ab0a82f9817dec31f1b7f972085eb5fcf6eca61d Mon Sep 17 00:00:00 2001 From: gaoxin Date: Tue, 26 Jan 2021 10:38:48 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E3=80=90=E7=83=AD=E6=9B=B4=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E3=80=91=E5=BA=94=E7=94=A8=E5=88=B0lua=E5=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ManagedResources/~Lua/Common/define.lua | 1 + .../~Lua/Framework/Framework.lua | 2 + .../Framework/Manager/ServerConfigManager.lua | 34 ++++ .../Manager/ServerConfigManager.lua.meta | 7 + .../Scripts/Editor/Custom/CustomSettings.cs | 1 + Assets/Source/Generate/AppWrap.cs | 15 ++ ...e_Singleton_GameLogic_ConfigManagerWrap.cs | 29 ++++ ...gleton_GameLogic_ConfigManagerWrap.cs.meta | 11 ++ .../Source/Generate/GameLogic_AppConstWrap.cs | 15 ++ .../Generate/GameLogic_ConfigManagerWrap.cs | 150 ++++++++++++++++++ .../GameLogic_ConfigManagerWrap.cs.meta | 11 ++ Assets/Source/Generate/LuaBinder.cs | 2 + 12 files changed, 278 insertions(+) create mode 100644 Assets/ManagedResources/~Lua/Framework/Manager/ServerConfigManager.lua create mode 100644 Assets/ManagedResources/~Lua/Framework/Manager/ServerConfigManager.lua.meta create mode 100644 Assets/Source/Generate/GameCore_Singleton_GameLogic_ConfigManagerWrap.cs create mode 100644 Assets/Source/Generate/GameCore_Singleton_GameLogic_ConfigManagerWrap.cs.meta create mode 100644 Assets/Source/Generate/GameLogic_ConfigManagerWrap.cs create mode 100644 Assets/Source/Generate/GameLogic_ConfigManagerWrap.cs.meta diff --git a/Assets/ManagedResources/~Lua/Common/define.lua b/Assets/ManagedResources/~Lua/Common/define.lua index 090f3edff7..44fda27d4f 100644 --- a/Assets/ManagedResources/~Lua/Common/define.lua +++ b/Assets/ManagedResources/~Lua/Common/define.lua @@ -21,6 +21,7 @@ RRenderMgr = App.RRenderMgr --shareSDKMgr = App.ShareSDKMgr SDKMgr = App.SDKMgr VersionManager=App.VersionMgr +ConfigMgr=App.ConfigMgr --umengsdk=App.UmengSdkMgr imageDownloadMgr = App.ImageDownloadMgr --BuglySdkManager=App.BuglySdkMgr diff --git a/Assets/ManagedResources/~Lua/Framework/Framework.lua b/Assets/ManagedResources/~Lua/Framework/Framework.lua index 408e10f8bd..985d91bd23 100644 --- a/Assets/ManagedResources/~Lua/Framework/Framework.lua +++ b/Assets/ManagedResources/~Lua/Framework/Framework.lua @@ -8,6 +8,7 @@ require "Framework/Manager/PoolManager" require "Framework/Manager/SoundManager" require "Framework/Manager/CardRendererManager" require "Framework/Manager/RoleRenderManager" +require "Framework/Manager/ServerConfigManager" require "Data/UIData" require "Data/SoundData" require "Data/ConfigData" @@ -89,6 +90,7 @@ function Framework.Initialize() UIManager.Initialize() poolManager = PoolManager:new() CardRendererManager.Initialize() + ServerConfigManager.Initialize() UpdateBeat:Add(update, Framework) end diff --git a/Assets/ManagedResources/~Lua/Framework/Manager/ServerConfigManager.lua b/Assets/ManagedResources/~Lua/Framework/Manager/ServerConfigManager.lua new file mode 100644 index 0000000000..a3b6f3d081 --- /dev/null +++ b/Assets/ManagedResources/~Lua/Framework/Manager/ServerConfigManager.lua @@ -0,0 +1,34 @@ + +ServerConfigManager = { } + + +function ServerConfigManager.Initialize() + +end + +-- 判断是否有 +function ServerConfigManager.IsConfig() + if AndroidDeviceInfo.Instance:GetVersionCode() > 24 then + + end +end + +function ServerConfigManager.GetConfigInfo(key) + local s = ConfigMgr:GetConfigInfo(key) + return s +end +function ServerConfigManager.GetConfigNetInfo(key) + local s = ConfigMgr:GetConfigNetInfo(key) + return s + +end +function ServerConfigManager.GetConfigPersistentInfo(key) + local s = ConfigMgr:GetConfigPersistentInfo(key) + return s + +end +function ServerConfigManager.GetConfigStreamingInfo(key) + local s = ConfigMgr:GetConfigStreamingInfo(key) + return s + +end \ No newline at end of file diff --git a/Assets/ManagedResources/~Lua/Framework/Manager/ServerConfigManager.lua.meta b/Assets/ManagedResources/~Lua/Framework/Manager/ServerConfigManager.lua.meta new file mode 100644 index 0000000000..f059a5f32c --- /dev/null +++ b/Assets/ManagedResources/~Lua/Framework/Manager/ServerConfigManager.lua.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 587696ae067d4004ba3b5b8c40e674e9 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Editor/Custom/CustomSettings.cs b/Assets/Scripts/Editor/Custom/CustomSettings.cs index fb7d4593cc..1b0ee34f60 100644 --- a/Assets/Scripts/Editor/Custom/CustomSettings.cs +++ b/Assets/Scripts/Editor/Custom/CustomSettings.cs @@ -247,6 +247,7 @@ public static class CustomSettings _GT(typeof(ResourcesUpdateState)), _GT(typeof(ImageDownloadManager)), _GT(typeof(VersionManager)), + _GT(typeof(ConfigManager)), _GT(typeof(UpdateManager)), _GT(typeof(SetInternetPic)), _GT(typeof(SkeletonGraphic)), diff --git a/Assets/Source/Generate/AppWrap.cs b/Assets/Source/Generate/AppWrap.cs index 9da6bbf3fc..9943d28622 100644 --- a/Assets/Source/Generate/AppWrap.cs +++ b/Assets/Source/Generate/AppWrap.cs @@ -29,6 +29,7 @@ public class AppWrap L.RegVar("SDKMgr", get_SDKMgr, null); L.RegVar("RRenderMgr", get_RRenderMgr, null); L.RegVar("VersionMgr", get_VersionMgr, null); + L.RegVar("ConfigMgr", get_ConfigMgr, null); L.EndClass(); } @@ -341,5 +342,19 @@ public class AppWrap return LuaDLL.toluaL_exception(L, e); } } + + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] + static int get_ConfigMgr(IntPtr L) + { + try + { + ToLua.PushObject(L, App.ConfigMgr); + return 1; + } + catch (Exception e) + { + return LuaDLL.toluaL_exception(L, e); + } + } } diff --git a/Assets/Source/Generate/GameCore_Singleton_GameLogic_ConfigManagerWrap.cs b/Assets/Source/Generate/GameCore_Singleton_GameLogic_ConfigManagerWrap.cs new file mode 100644 index 0000000000..fcc3459e5c --- /dev/null +++ b/Assets/Source/Generate/GameCore_Singleton_GameLogic_ConfigManagerWrap.cs @@ -0,0 +1,29 @@ +//this source code was auto-generated by tolua#, do not modify it +using System; +using LuaInterface; + +public class GameCore_Singleton_GameLogic_ConfigManagerWrap +{ + public static void Register(LuaState L) + { + L.BeginClass(typeof(GameCore.Singleton), typeof(System.Object), "Singleton_GameLogic_ConfigManager"); + L.RegFunction("__tostring", ToLua.op_ToString); + L.RegVar("Instance", get_Instance, null); + L.EndClass(); + } + + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] + static int get_Instance(IntPtr L) + { + try + { + ToLua.PushObject(L, GameCore.Singleton.Instance); + return 1; + } + catch (Exception e) + { + return LuaDLL.toluaL_exception(L, e); + } + } +} + diff --git a/Assets/Source/Generate/GameCore_Singleton_GameLogic_ConfigManagerWrap.cs.meta b/Assets/Source/Generate/GameCore_Singleton_GameLogic_ConfigManagerWrap.cs.meta new file mode 100644 index 0000000000..39e8c8d924 --- /dev/null +++ b/Assets/Source/Generate/GameCore_Singleton_GameLogic_ConfigManagerWrap.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 67952d9124f8ab5498b0ac978bcbdea7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Source/Generate/GameLogic_AppConstWrap.cs b/Assets/Source/Generate/GameLogic_AppConstWrap.cs index 803338e272..2c0f9ca8c4 100644 --- a/Assets/Source/Generate/GameLogic_AppConstWrap.cs +++ b/Assets/Source/Generate/GameLogic_AppConstWrap.cs @@ -53,6 +53,7 @@ public class GameLogic_AppConstWrap L.RegVar("LaQi_JoinRoom_Url", get_LaQi_JoinRoom_Url, set_LaQi_JoinRoom_Url); L.RegVar("LoadingMD5Flie", get_LoadingMD5Flie, null); L.RegVar("GameVersionFile", get_GameVersionFile, null); + L.RegVar("GameConfigFile", get_GameConfigFile, null); L.RegVar("UserId", get_UserId, set_UserId); L.RegVar("Token", get_Token, set_Token); L.RegVar("SdkId", get_SdkId, set_SdkId); @@ -730,6 +731,20 @@ public class GameLogic_AppConstWrap } } + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] + static int get_GameConfigFile(IntPtr L) + { + try + { + LuaDLL.lua_pushstring(L, GameLogic.AppConst.GameConfigFile); + return 1; + } + catch (Exception e) + { + return LuaDLL.toluaL_exception(L, e); + } + } + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_UserId(IntPtr L) { diff --git a/Assets/Source/Generate/GameLogic_ConfigManagerWrap.cs b/Assets/Source/Generate/GameLogic_ConfigManagerWrap.cs new file mode 100644 index 0000000000..0d48ae02cc --- /dev/null +++ b/Assets/Source/Generate/GameLogic_ConfigManagerWrap.cs @@ -0,0 +1,150 @@ +//this source code was auto-generated by tolua#, do not modify it +using System; +using LuaInterface; + +public class GameLogic_ConfigManagerWrap +{ + public static void Register(LuaState L) + { + L.BeginClass(typeof(GameLogic.ConfigManager), typeof(GameCore.Singleton)); + L.RegFunction("Init", Init); + L.RegFunction("SetNetInfo", SetNetInfo); + L.RegFunction("GetConfigInfo", GetConfigInfo); + L.RegFunction("GetConfigNetInfo", GetConfigNetInfo); + L.RegFunction("GetConfigPersistentInfo", GetConfigPersistentInfo); + L.RegFunction("GetConfigStreamingInfo", GetConfigStreamingInfo); + L.RegFunction("New", _CreateGameLogic_ConfigManager); + L.RegFunction("__tostring", ToLua.op_ToString); + L.EndClass(); + } + + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] + static int _CreateGameLogic_ConfigManager(IntPtr L) + { + try + { + int count = LuaDLL.lua_gettop(L); + + if (count == 0) + { + GameLogic.ConfigManager obj = new GameLogic.ConfigManager(); + ToLua.PushObject(L, obj); + return 1; + } + else + { + return LuaDLL.luaL_throw(L, "invalid arguments to ctor method: GameLogic.ConfigManager.New"); + } + } + catch (Exception e) + { + return LuaDLL.toluaL_exception(L, e); + } + } + + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] + static int Init(IntPtr L) + { + try + { + ToLua.CheckArgsCount(L, 1); + GameLogic.ConfigManager obj = (GameLogic.ConfigManager)ToLua.CheckObject(L, 1); + obj.Init(); + return 0; + } + catch (Exception e) + { + return LuaDLL.toluaL_exception(L, e); + } + } + + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] + static int SetNetInfo(IntPtr L) + { + try + { + ToLua.CheckArgsCount(L, 2); + GameLogic.ConfigManager obj = (GameLogic.ConfigManager)ToLua.CheckObject(L, 1); + string arg0 = ToLua.CheckString(L, 2); + obj.SetNetInfo(arg0); + return 0; + } + catch (Exception e) + { + return LuaDLL.toluaL_exception(L, e); + } + } + + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] + static int GetConfigInfo(IntPtr L) + { + try + { + ToLua.CheckArgsCount(L, 2); + GameLogic.ConfigManager obj = (GameLogic.ConfigManager)ToLua.CheckObject(L, 1); + string arg0 = ToLua.CheckString(L, 2); + string o = obj.GetConfigInfo(arg0); + LuaDLL.lua_pushstring(L, o); + return 1; + } + catch (Exception e) + { + return LuaDLL.toluaL_exception(L, e); + } + } + + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] + static int GetConfigNetInfo(IntPtr L) + { + try + { + ToLua.CheckArgsCount(L, 2); + GameLogic.ConfigManager obj = (GameLogic.ConfigManager)ToLua.CheckObject(L, 1); + string arg0 = ToLua.CheckString(L, 2); + string o = obj.GetConfigNetInfo(arg0); + LuaDLL.lua_pushstring(L, o); + return 1; + } + catch (Exception e) + { + return LuaDLL.toluaL_exception(L, e); + } + } + + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] + static int GetConfigPersistentInfo(IntPtr L) + { + try + { + ToLua.CheckArgsCount(L, 2); + GameLogic.ConfigManager obj = (GameLogic.ConfigManager)ToLua.CheckObject(L, 1); + string arg0 = ToLua.CheckString(L, 2); + string o = obj.GetConfigPersistentInfo(arg0); + LuaDLL.lua_pushstring(L, o); + return 1; + } + catch (Exception e) + { + return LuaDLL.toluaL_exception(L, e); + } + } + + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] + static int GetConfigStreamingInfo(IntPtr L) + { + try + { + ToLua.CheckArgsCount(L, 2); + GameLogic.ConfigManager obj = (GameLogic.ConfigManager)ToLua.CheckObject(L, 1); + string arg0 = ToLua.CheckString(L, 2); + string o = obj.GetConfigStreamingInfo(arg0); + LuaDLL.lua_pushstring(L, o); + return 1; + } + catch (Exception e) + { + return LuaDLL.toluaL_exception(L, e); + } + } +} + diff --git a/Assets/Source/Generate/GameLogic_ConfigManagerWrap.cs.meta b/Assets/Source/Generate/GameLogic_ConfigManagerWrap.cs.meta new file mode 100644 index 0000000000..39821fc84e --- /dev/null +++ b/Assets/Source/Generate/GameLogic_ConfigManagerWrap.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 467effe90bc1d524a8830982f9034e0f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Source/Generate/LuaBinder.cs b/Assets/Source/Generate/LuaBinder.cs index affca7f33b..6e96c13b19 100644 --- a/Assets/Source/Generate/LuaBinder.cs +++ b/Assets/Source/Generate/LuaBinder.cs @@ -50,6 +50,7 @@ public static class LuaBinder GameCore_UnitySingleton_SDK_SDKManagerWrap.Register(L); GameCore_UnitySingleton_GameLogic_ImageDownloadManagerWrap.Register(L); GameCore_Singleton_GameLogic_VersionManagerWrap.Register(L); + GameCore_Singleton_GameLogic_ConfigManagerWrap.Register(L); GameCore_Singleton_GameLogic_UpdateManagerWrap.Register(L); GameCore_UnitySingleton_GameLogic_PhoneManagerWrap.Register(L); GameCore_UnitySingleton_GameLogic_ObjectPoolManagerWrap.Register(L); @@ -258,6 +259,7 @@ public static class LuaBinder GameLogic_UIDepthAdapterWrap.Register(L); GameLogic_ImageDownloadManagerWrap.Register(L); GameLogic_VersionManagerWrap.Register(L); + GameLogic_ConfigManagerWrap.Register(L); GameLogic_UpdateManagerWrap.Register(L); GameLogic_PhoneManagerWrap.Register(L); GameLogic_EventTriggerListenerWrap.Register(L); From 4dacf3081ec1b177ee5ba2be64fe1e38e7206dd9 Mon Sep 17 00:00:00 2001 From: gaoxin Date: Tue, 23 Feb 2021 16:20:25 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E3=80=90=E5=B7=A5=E7=A8=8B=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E3=80=91=E5=B7=A5=E5=85=B7=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Resources/config.txt | 8 +- .../GameEditor/FrameTool/ConfigWindow.cs | 125 ++++++++++++++++++ .../GameEditor/FrameTool/ConfigWindow.cs.meta | 11 ++ 3 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 Assets/Scripts/Editor/GameEditor/FrameTool/ConfigWindow.cs create mode 100644 Assets/Scripts/Editor/GameEditor/FrameTool/ConfigWindow.cs.meta diff --git a/Assets/Resources/config.txt b/Assets/Resources/config.txt index a9c5b7f715..102f62cff6 100644 --- a/Assets/Resources/config.txt +++ b/Assets/Resources/config.txt @@ -1,4 +1,10 @@ {"subChannel":"1", "buglyId":"261348dcd3", "channel":"pc", -"serverUrl":"http://60.1.1.23:8080/"} \ No newline at end of file +"serverUrl":"http://60.1.1.23:8080/", + +"func":{ +"Func_1":{"desc":"", "versionCode:"", isActive:""} +} + +} \ No newline at end of file diff --git a/Assets/Scripts/Editor/GameEditor/FrameTool/ConfigWindow.cs b/Assets/Scripts/Editor/GameEditor/FrameTool/ConfigWindow.cs new file mode 100644 index 0000000000..f7c8d80dc4 --- /dev/null +++ b/Assets/Scripts/Editor/GameEditor/FrameTool/ConfigWindow.cs @@ -0,0 +1,125 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +using System.IO; +using System.Linq; +using GameEditor.Core; +using GameEditor.GameEditor.PlayerBuilder; +using GameLogic; +using System.Diagnostics; +using ResUpdate; +using System.Threading; + +namespace GameEditor.FrameTool { + public class ConfigWindow : EditorWindow + { + + string m_ExcelPath = EditorPrefs.GetString("m_ExcelPath"); + + // Add menu named "My Window" to the Window menu + [MenuItem("Build/Config")] + static void Init() + { + + // Get existing open window or if none, make a new one: + ConfigWindow window = (ConfigWindow)EditorWindow.GetWindow(typeof(ConfigWindow)); + window.Show(); + window.InitWindow(); + + } + + void InitWindow() + { + InitSize(); + InitGames(); + } + + /// + /// 初始化大小 + /// + void InitSize() + { + minSize = new Vector2(300, 400); + maxSize = new Vector2(300, 650); + } + + + /// + /// 初始化游戏 + /// + void InitGames() + { + } + + void OnGUI() + { + + + EditorGUILayout.BeginVertical(); + EditorGUILayout.Space(); + EditorGUILayout.LabelField("Config文件路径:"); + + EditorGUILayout.BeginHorizontal(); + m_ExcelPath = EditorGUILayout.TextField("", m_ExcelPath); + if (GUILayout.Button("加载", GUILayout.Width(60f))) + { + } + if (GUILayout.Button("打开目录", GUILayout.Width(60f))) + { + OpenDirectory(m_ExcelPath); + } + EditorGUILayout.EndHorizontal(); + + + //if (excelArr != null && excelArr.Length > 0) + //{ + // excelIndex = EditorGUILayout.Popup("选择excel文件:", excelIndex, excelArr); + //} + + } + + static string shellPath; + public static void OpenDirectory(string path) + { + if (string.IsNullOrEmpty(path)) return; + + if (!Directory.Exists(path)) + { + UnityEngine.Debug.LogError("No Directory: " + path); + return; + } + + //Application.dataPath 只能在主线程中获取 + int lastIndex = Application.dataPath.LastIndexOf("/"); + shellPath = Application.dataPath.Substring(0, lastIndex) + "/Shell/"; + + // 新开线程防止锁死 + Thread newThread = new Thread(new ParameterizedThreadStart(CmdOpenDirectory)); + newThread.Start(path); + } + private static void CmdOpenDirectory(object obj) + { + Process p = new Process(); +#if UNITY_EDITOR_WIN + p.StartInfo.FileName = "cmd.exe"; + p.StartInfo.Arguments = "/c start " + obj.ToString(); +#elif UNITY_EDITOR_OSX + p.StartInfo.FileName = "bash"; + string shPath = shellPath + "openDir.sh"; + p.StartInfo.Arguments = shPath + " " + obj.ToString(); +#endif + //UnityEngine.Debug.Log(p.StartInfo.Arguments); + p.StartInfo.UseShellExecute = false; + p.StartInfo.RedirectStandardInput = true; + p.StartInfo.RedirectStandardOutput = true; + p.StartInfo.RedirectStandardError = true; + p.StartInfo.CreateNoWindow = true; + p.Start(); + + p.WaitForExit(); + p.Close(); + } + } + +} diff --git a/Assets/Scripts/Editor/GameEditor/FrameTool/ConfigWindow.cs.meta b/Assets/Scripts/Editor/GameEditor/FrameTool/ConfigWindow.cs.meta new file mode 100644 index 0000000000..f3b8be4529 --- /dev/null +++ b/Assets/Scripts/Editor/GameEditor/FrameTool/ConfigWindow.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 430a2ef9ef9800c4d8bff3f5edc235e1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From cd4a1e8c8997682972eaa5fdffa7ff1c98a4f4e8 Mon Sep 17 00:00:00 2001 From: gaoxin Date: Wed, 24 Feb 2021 13:53:11 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scripts/Manager/ConfigManager.cs | 59 +++++++++++++++++-- Assets/Resources/config.txt | 3 +- 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/Assets/LuaFramework/Scripts/Manager/ConfigManager.cs b/Assets/LuaFramework/Scripts/Manager/ConfigManager.cs index e2c83228e2..7a9fd21226 100644 --- a/Assets/LuaFramework/Scripts/Manager/ConfigManager.cs +++ b/Assets/LuaFramework/Scripts/Manager/ConfigManager.cs @@ -23,24 +23,73 @@ namespace GameLogic public string GetInfo(string key) { - if (info.ContainsKey(key)) + string[] ks = key.Split('.'); + Hashtable ins = info; + for (int i = 0; i < ks.Length; i++) { - return info[key] as string; + string k = ks[i]; + if (!ins.ContainsKey(k)) + { + break; + } + // 没有下一个值直接返回 + if (i + 1 == ks.Length) + { + return ins[k] as string; + } + else + { + ins = ins[k] as Hashtable; + } } + return null; } public void RemoveInfo(string key) { - if (info.ContainsKey(key)) + string[] ks = key.Split('.'); + Hashtable ins = info; + for (int i = 0; i < ks.Length; i++) { - info.Remove(key); + string k = ks[i]; + if (!ins.ContainsKey(k)) + { + break; + } + // + if (i + 1 == ks.Length) + { + ins.Remove(k); + } + else + { + ins = ins[k] as Hashtable; + } } } public void SetInfo(string key, string value) { - info[key] = value; + string[] ks = key.Split('.'); + Hashtable ins = info; + for (int i = 0; i < ks.Length; i++) + { + string k = ks[i]; + if (!ins.ContainsKey(k)) + { + break; + } + // + if (i + 1 == ks.Length) + { + ins[k] = value; + } + else + { + ins = ins[k] as Hashtable; + } + } } } public class ConfigManager : Singleton diff --git a/Assets/Resources/config.txt b/Assets/Resources/config.txt index 102f62cff6..1edcd25f8e 100644 --- a/Assets/Resources/config.txt +++ b/Assets/Resources/config.txt @@ -2,9 +2,8 @@ "buglyId":"261348dcd3", "channel":"pc", "serverUrl":"http://60.1.1.23:8080/", - "func":{ -"Func_1":{"desc":"", "versionCode:"", isActive:""} + "Func_1":{"desc":"test", "versionCode":"123", "isActive":"1"} } } \ No newline at end of file From 16ea6c16de213c1b37e17a71dff262025f462994 Mon Sep 17 00:00:00 2001 From: gaoxin Date: Thu, 25 Feb 2021 14:19:00 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E3=80=90=E9=85=8D=E7=BD=AE=E3=80=91?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E9=85=8D=E7=BD=AE=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../~Lua/Framework/Manager/ServerConfigManager.lua | 2 +- Assets/Resources/config.txt | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Assets/ManagedResources/~Lua/Framework/Manager/ServerConfigManager.lua b/Assets/ManagedResources/~Lua/Framework/Manager/ServerConfigManager.lua index a3b6f3d081..04524d9095 100644 --- a/Assets/ManagedResources/~Lua/Framework/Manager/ServerConfigManager.lua +++ b/Assets/ManagedResources/~Lua/Framework/Manager/ServerConfigManager.lua @@ -3,7 +3,7 @@ ServerConfigManager = { } function ServerConfigManager.Initialize() - + LogError(ServerConfigManager.GetConfigInfo("func.Func_1.desc")) end -- 判断是否有 diff --git a/Assets/Resources/config.txt b/Assets/Resources/config.txt index 1edcd25f8e..025c8cf04e 100644 --- a/Assets/Resources/config.txt +++ b/Assets/Resources/config.txt @@ -3,7 +3,9 @@ "channel":"pc", "serverUrl":"http://60.1.1.23:8080/", "func":{ - "Func_1":{"desc":"test", "versionCode":"123", "isActive":"1"} + "ThinkAnalysis_GetDeviceID":{"desc":"数数获取DeviceID方法", "PackageVersionCode":"24", "isActive":"1"}, + "LayoutBuilderWrap":{"desc":"强制刷新layout组建大小的方法修改到lua中调用", "PackageVersionCode":"25", "isActive":"1"}, + "LanguagePackager":{"desc":"本地化处理", "PackageVersionCode":"25", "isActive":"1"}, } } \ No newline at end of file From d124d59f1b62edb7c647f4d153879f7e345d0ba3 Mon Sep 17 00:00:00 2001 From: gaoxin Date: Tue, 2 Mar 2021 15:18:06 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E3=80=90=E9=85=8D=E7=BD=AE=E3=80=91?= =?UTF-8?q?=E5=AE=8C=E5=96=84=E9=80=BB=E8=BE=91=E5=B9=B6=E5=BA=94=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../~Lua/Common/GlobalDefine.lua | 1 - .../Framework/Manager/ServerConfigManager.lua | 49 ++++++++++++++++--- .../ThinkingAnalyticsManager.lua | 2 +- .../~Lua/Modules/Login/LoginManager.lua | 2 +- .../~Lua/Modules/Login/LoginPanel.lua | 12 ++--- .../~Lua/Modules/Login/NoticePopup.lua | 2 +- .../GameEditor/FrameTool/ConfigWindow.cs | 6 ++- 7 files changed, 57 insertions(+), 17 deletions(-) diff --git a/Assets/ManagedResources/~Lua/Common/GlobalDefine.lua b/Assets/ManagedResources/~Lua/Common/GlobalDefine.lua index 79c3b33874..4aedbb4b0e 100644 --- a/Assets/ManagedResources/~Lua/Common/GlobalDefine.lua +++ b/Assets/ManagedResources/~Lua/Common/GlobalDefine.lua @@ -5,7 +5,6 @@ * @Created by MagicianJoker --]] -SERVER_VERSION = 0 -- 0 正式服 1 提审服 -- 启用功能引导 ENABLE_FUNC_GUIDE = 1 --0关闭1开启 RECHARGEABLE = true --false不可充值 true可充值 diff --git a/Assets/ManagedResources/~Lua/Framework/Manager/ServerConfigManager.lua b/Assets/ManagedResources/~Lua/Framework/Manager/ServerConfigManager.lua index 04524d9095..d990475b11 100644 --- a/Assets/ManagedResources/~Lua/Framework/Manager/ServerConfigManager.lua +++ b/Assets/ManagedResources/~Lua/Framework/Manager/ServerConfigManager.lua @@ -1,18 +1,56 @@ ServerConfigManager = { } +local _ActiveCode = 0 -- 激活版本 + +ServerConfigManager.SettingConfig = { + ServerVersion = "ServerVersion", -- 用于切换正式服和提审服 + ThinkAnalysis_GetDeviceID = "ThinkAnalysis_GetDeviceID", -- 数数获取DeviceID方法 + LayoutBuilderWrap = "LayoutBuilderWrap", -- 强制刷新layout组件大小的方法修改到lua中调用 + LanguagePackager = "LanguagePackager", -- 本地化处理 +} function ServerConfigManager.Initialize() - LogError(ServerConfigManager.GetConfigInfo("func.Func_1.desc")) + end --- 判断是否有 -function ServerConfigManager.IsConfig() - if AndroidDeviceInfo.Instance:GetVersionCode() > 24 then - +-- 判断设置是否激活 +function ServerConfigManager.IsSettingActive(settingType) + local s_isActive = "Setting."..settingType..".isActive" + local s_versionCode = "Setting."..settingType..".versionCode" + local isActive = ServerConfigManager.GetConfigInfo(s_isActive) == "1" + if isActive then -- 激活 + local vc = AndroidDeviceInfo.Instance:GetVersionCode() + if vc >= tonumber(ServerConfigManager.GetConfigInfo(s_versionCode)) then --符合包版本 + return true + end + end + return false +end +function ServerConfigManager.GetSettingValue(settingType) + if ServerConfigManager.IsSettingActive(settingType) then + local s_value = "Setting."..settingType..".value" + local value = ServerConfigManager.GetConfigInfo(s_value) + LogError(s_value .. "| ".. value) + return value end end +-- 获取version信息(老版本信息,新版中用于获取版本号,包版本号,) +function ServerConfigManager.GetVersionInfo(key) + -- 包版本大于启用的版本使用新的配置 + if AndroidDeviceInfo.Instance:GetVersionCode() >= _ActiveCode then + local v = ServerConfigManager.GetConfigInfo(key) + if not v then + v = VersionManager:GetVersionInfo(key) + end + return v + else + return VersionManager:GetVersionInfo(key) + end +end + +-- function ServerConfigManager.GetConfigInfo(key) local s = ConfigMgr:GetConfigInfo(key) return s @@ -30,5 +68,4 @@ end function ServerConfigManager.GetConfigStreamingInfo(key) local s = ConfigMgr:GetConfigStreamingInfo(key) return s - end \ No newline at end of file diff --git a/Assets/ManagedResources/~Lua/Modules/DataCenterService/ThinkingAnalyticsManager.lua b/Assets/ManagedResources/~Lua/Modules/DataCenterService/ThinkingAnalyticsManager.lua index d39ff1e4f4..c6a78d8d63 100644 --- a/Assets/ManagedResources/~Lua/Modules/DataCenterService/ThinkingAnalyticsManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/DataCenterService/ThinkingAnalyticsManager.lua @@ -71,7 +71,7 @@ end -- 获取设备Id function this.GetDeviceId() if AppConst.isSDK then - if AndroidDeviceInfo.Instance:GetVersionCode() > 24 then + if ServerConfigManager.IsSettingActive(ServerConfigManager.SettingConfig.ThinkAnalysis_GetDeviceID) then return App.TAMgr:GetDeviceId() end return AndroidDeviceInfo.Instance:GetDeviceID() diff --git a/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua b/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua index 5f07b19eab..21c93664d9 100644 --- a/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua @@ -7,7 +7,7 @@ this.IsLogin = false this.pt_pId = "" this.pt_gId = "" -local LoginRoot_Url = VersionManager:GetVersionInfo("serverUrl") +local LoginRoot_Url = ServerConfigManager.GetVersionInfo("serverUrl") function this.Initialize() this.IsLogin = false this.GameName='DouDou' diff --git a/Assets/ManagedResources/~Lua/Modules/Login/LoginPanel.lua b/Assets/ManagedResources/~Lua/Modules/Login/LoginPanel.lua index 7bb88fd3b1..f8ccfc1bf2 100644 --- a/Assets/ManagedResources/~Lua/Modules/Login/LoginPanel.lua +++ b/Assets/ManagedResources/~Lua/Modules/Login/LoginPanel.lua @@ -4,7 +4,7 @@ LoginPanel = Inherit(BasePanel) local this = LoginPanel this.LoginWay = { Account = 0, WeChat = 1 } - +SERVER_VERSION = tonumber(ServerConfigManager.GetSettingValue(ServerConfigManager.SettingConfig.ServerVersion) or 0) local ServerVersion = SERVER_VERSION local IsShowNotice = SERVER_VERSION == 0 -- 正式服显示公告 @@ -15,11 +15,11 @@ local openIdkey = "openIdkey" local openIdPw = "openIdPw" local defaultOpenIdkey = Language[11118] local defaultOpenIdPw = "" -local LoginRoot_Url = VersionManager:GetVersionInfo("serverUrl") -local LoginRoot_SubChannel = VersionManager:GetVersionInfo("subChannel") -local LoginRoot_Channel = VersionManager:GetVersionInfo("channel") -local LoginRoot_Version = VersionManager:GetVersionInfo("version") -local LoginRoot_PackageVersion = VersionManager:GetVersionInfo("packageVersion") +local LoginRoot_Url = ServerConfigManager.GetVersionInfo("serverUrl") +local LoginRoot_SubChannel = ServerConfigManager.GetVersionInfo("subChannel") +local LoginRoot_Channel = ServerConfigManager.GetVersionInfo("channel") +local LoginRoot_Version = ServerConfigManager.GetVersionInfo("version") +local LoginRoot_PackageVersion = ServerConfigManager.GetVersionInfo("packageVersion") local orginLayer local timeStamp = Time.realtimeSinceStartup diff --git a/Assets/ManagedResources/~Lua/Modules/Login/NoticePopup.lua b/Assets/ManagedResources/~Lua/Modules/Login/NoticePopup.lua index 48039cd91c..b353e4d5d4 100644 --- a/Assets/ManagedResources/~Lua/Modules/Login/NoticePopup.lua +++ b/Assets/ManagedResources/~Lua/Modules/Login/NoticePopup.lua @@ -1,7 +1,7 @@ require("Base/BasePanel") NoticePopup = Inherit(BasePanel) local this = NoticePopup -local LoginRoot_Url = VersionManager:GetVersionInfo("serverUrl") +local LoginRoot_Url = ServerConfigManager.GetVersionInfo("serverUrl") --初始化组件(用于子类重写) function NoticePopup:InitComponent() diff --git a/Assets/Scripts/Editor/GameEditor/FrameTool/ConfigWindow.cs b/Assets/Scripts/Editor/GameEditor/FrameTool/ConfigWindow.cs index f7c8d80dc4..f744f65112 100644 --- a/Assets/Scripts/Editor/GameEditor/FrameTool/ConfigWindow.cs +++ b/Assets/Scripts/Editor/GameEditor/FrameTool/ConfigWindow.cs @@ -15,7 +15,11 @@ namespace GameEditor.FrameTool { public class ConfigWindow : EditorWindow { - string m_ExcelPath = EditorPrefs.GetString("m_ExcelPath"); + string m_ExcelPath; + private void OnEnable() + { + m_ExcelPath = EditorPrefs.GetString("m_ExcelPath"); + } // Add menu named "My Window" to the Window menu [MenuItem("Build/Config")] From 0ea1263a662d386467ed1b817bdbe0f65526aa5b Mon Sep 17 00:00:00 2001 From: gaoxin Date: Tue, 2 Mar 2021 15:18:49 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E3=80=90=E9=85=8D=E7=BD=AE=E3=80=91?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Resources/config.txt | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Assets/Resources/config.txt b/Assets/Resources/config.txt index 025c8cf04e..9248dd9388 100644 --- a/Assets/Resources/config.txt +++ b/Assets/Resources/config.txt @@ -1,11 +1,11 @@ -{"subChannel":"1", -"buglyId":"261348dcd3", -"channel":"pc", -"serverUrl":"http://60.1.1.23:8080/", -"func":{ - "ThinkAnalysis_GetDeviceID":{"desc":"数数获取DeviceID方法", "PackageVersionCode":"24", "isActive":"1"}, - "LayoutBuilderWrap":{"desc":"强制刷新layout组建大小的方法修改到lua中调用", "PackageVersionCode":"25", "isActive":"1"}, - "LanguagePackager":{"desc":"本地化处理", "PackageVersionCode":"25", "isActive":"1"}, -} - +{ + "subChannel":"1", + "channel":"pc", + "serverUrl":"http://60.1.1.23:8080/", + "Setting":{ + "ServerVersion":{"desc":"用于切换正式服和提审服", "versionCode":"25", "isActive":"1", "value":"1"}, + "ThinkAnalysis_GetDeviceID":{"desc":"数数获取DeviceID方法", "versionCode":"24", "isActive":"1"}, + "LayoutBuilderWrap":{"desc":"强制刷新layout组件大小的方法修改到lua中调用", "versionCode":"25", "isActive":"1"}, + "LanguagePackager":{"desc":"本地化处理", "versionCode":"25", "isActive":"1"}, + } } \ No newline at end of file From d3a1cba41cf7796fb5e488c1f76aedd9709574d6 Mon Sep 17 00:00:00 2001 From: gaoxin Date: Thu, 4 Mar 2021 19:29:15 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E3=80=90=E7=AE=A1=E7=90=86=E3=80=91?= =?UTF-8?q?=E5=8C=85=E9=85=8D=E7=BD=AE=E7=AE=A1=E7=90=86=E5=8A=A0=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AssetBundles/config.txt | 5 +- .../Scripts/Manager/ConfigManager.cs | 36 +--------- .../~Lua/Common/LanguageManager.lua | 3 + .../ManagedResources/~Lua/Common/define.lua | 1 - .../Framework/Manager/ServerConfigManager.lua | 23 ++----- .../~Lua/Modules/Guild/GuildInfoPopup.lua | 10 +-- .../~Lua/Modules/Message/MsgPanel.lua | 4 +- .../Popup/RewardTalismanSingleShowPopup.lua | 4 +- .../~Lua/Modules/Setting/SettingInfo.lua | 68 +++++++++++-------- .../ManagedResources/~Lua/misc/functions.lua | 15 ++-- Assets/Resources/config.txt | 11 --- Assets/Resources/config.txt.meta | 7 -- .../Generate/GameLogic_ConfigManagerWrap.cs | 38 ----------- Assets/Source/Generate/LuaBinder.cs | 1 + 14 files changed, 70 insertions(+), 156 deletions(-) delete mode 100644 Assets/Resources/config.txt delete mode 100644 Assets/Resources/config.txt.meta diff --git a/AssetBundles/config.txt b/AssetBundles/config.txt index a9c5b7f715..c559bb5061 100644 --- a/AssetBundles/config.txt +++ b/AssetBundles/config.txt @@ -1,4 +1 @@ -{"subChannel":"1", -"buglyId":"261348dcd3", -"channel":"pc", -"serverUrl":"http://60.1.1.23:8080/"} \ No newline at end of file +{"channel":"MHT", "Setting":{"LanguagePackager":{"desc":"\u672c\u5730\u5316\u5904\u7406", "versionCode":"26", "isActive":"1"}, "ServerVersion":{"desc":"\u7528\u4e8e\u5207\u6362\u6b63\u5f0f\u670d\u548c\u63d0\u5ba1\u670d", "value":"1", "versionCode":"26", "isActive":"1"}, "ThinkAnalysis_GetDeviceID":{"desc":"\u6570\u6570\u83b7\u53d6DeviceID\u65b9\u6cd5", "versionCode":"24", "isActive":"1"}, "LayoutBuilderWrap":{"desc":"\u5f3a\u5236\u5237\u65b0layout\u7ec4\u4ef6\u5927\u5c0f\u7684\u65b9\u6cd5\u4fee\u6539\u5230lua\u4e2d\u8c03\u7528", "versionCode":"25", "isActive":"1"}}, "subChannel":"2000", "serverUrl":"http://119.28.117.110:8080/"} \ No newline at end of file diff --git a/Assets/LuaFramework/Scripts/Manager/ConfigManager.cs b/Assets/LuaFramework/Scripts/Manager/ConfigManager.cs index 7a9fd21226..d97860d314 100644 --- a/Assets/LuaFramework/Scripts/Manager/ConfigManager.cs +++ b/Assets/LuaFramework/Scripts/Manager/ConfigManager.cs @@ -109,9 +109,7 @@ namespace GameLogic return AppConst.PersistentDataPath + configFile + ".txt"; } } - - MConfig StreamingInfo; - MConfig PersistentInfo; + MConfig NetInfo; // 初始化 获取本地的数据 public void Init() @@ -120,22 +118,13 @@ namespace GameLogic { if (File.Exists(configFilePath)) { - PersistentInfo = new MConfig(File.ReadAllText(configFilePath, System.Text.Encoding.UTF8)); + NetInfo = new MConfig(File.ReadAllText(configFilePath, System.Text.Encoding.UTF8)); } } catch (Exception e) { Debug.LogError(e); } - - try - { - StreamingInfo = new MConfig(Resources.Load(configFile).text); - } - catch (Exception e) - { - Debug.LogError(e); - } } public void SetNetInfo(string info) @@ -157,10 +146,9 @@ namespace GameLogic /// void SaveToFiles() { - PersistentInfo = NetInfo; string directoryPath = Path.GetDirectoryName(configFilePath); if (!Directory.Exists(directoryPath)) Directory.CreateDirectory(directoryPath); - File.WriteAllText(configFilePath, PersistentInfo.ToJson(), System.Text.Encoding.UTF8); + File.WriteAllText(configFilePath, NetInfo.ToJson(), System.Text.Encoding.UTF8); } /// @@ -172,10 +160,6 @@ namespace GameLogic { string v = GetConfigNetInfo(key); if (v != null) return v; - v = GetConfigPersistentInfo(key); - if (v != null) return v; - v = GetConfigStreamingInfo(key); - if (v != null) return v; return null; } public string GetConfigNetInfo(string key) @@ -184,19 +168,5 @@ namespace GameLogic string v = NetInfo.GetInfo(key); return v; } - public string GetConfigPersistentInfo(string key) - { - if (PersistentInfo == null) return null; - string v = PersistentInfo.GetInfo(key); - return v; - } - public string GetConfigStreamingInfo(string key) - { - if (StreamingInfo == null) return null; - string v = StreamingInfo.GetInfo(key); - return v; - } - - } } diff --git a/Assets/ManagedResources/~Lua/Common/LanguageManager.lua b/Assets/ManagedResources/~Lua/Common/LanguageManager.lua index d074bd71d9..8041924813 100644 --- a/Assets/ManagedResources/~Lua/Common/LanguageManager.lua +++ b/Assets/ManagedResources/~Lua/Common/LanguageManager.lua @@ -1,5 +1,7 @@ languageDic={} +IsLanguagePack = ServerConfigManager.IsSettingActive(ServerConfigManager.SettingConfig.LanguagePackager) + function InitLanguageData() local languageData= ConfigManager.GetConfig(ConfigName.Language) for index, config in ConfigPairs(languageData) do @@ -13,4 +15,5 @@ function InitLanguageData() end LogGreen("语言初始化完成:"..tostring(#languageData)) end + InitLanguageData() \ No newline at end of file diff --git a/Assets/ManagedResources/~Lua/Common/define.lua b/Assets/ManagedResources/~Lua/Common/define.lua index af914efbb8..44fda27d4f 100644 --- a/Assets/ManagedResources/~Lua/Common/define.lua +++ b/Assets/ManagedResources/~Lua/Common/define.lua @@ -34,7 +34,6 @@ Input = UnityEngine.Input Screen = UnityEngine.Screen RectTransformUtility = UnityEngine.RectTransformUtility LayoutUtility = UnityEngine.UI.LayoutUtility -LayoutRebuilder = UnityEngine.UI.LayoutRebuilder Tweening = DG.Tweening Ease = DG.Tweening.Ease diff --git a/Assets/ManagedResources/~Lua/Framework/Manager/ServerConfigManager.lua b/Assets/ManagedResources/~Lua/Framework/Manager/ServerConfigManager.lua index d990475b11..9fe44ba1c7 100644 --- a/Assets/ManagedResources/~Lua/Framework/Manager/ServerConfigManager.lua +++ b/Assets/ManagedResources/~Lua/Framework/Manager/ServerConfigManager.lua @@ -1,6 +1,6 @@ ServerConfigManager = { } -local _ActiveCode = 0 -- 激活版本 +local _ActiveCode = 26 -- 激活版本 ServerConfigManager.SettingConfig = { ServerVersion = "ServerVersion", -- 用于切换正式服和提审服 @@ -20,6 +20,9 @@ function ServerConfigManager.IsSettingActive(settingType) local s_versionCode = "Setting."..settingType..".versionCode" local isActive = ServerConfigManager.GetConfigInfo(s_isActive) == "1" if isActive then -- 激活 + if not AppConst.isSDK then + return true + end local vc = AndroidDeviceInfo.Instance:GetVersionCode() if vc >= tonumber(ServerConfigManager.GetConfigInfo(s_versionCode)) then --符合包版本 return true @@ -31,7 +34,7 @@ function ServerConfigManager.GetSettingValue(settingType) if ServerConfigManager.IsSettingActive(settingType) then local s_value = "Setting."..settingType..".value" local value = ServerConfigManager.GetConfigInfo(s_value) - LogError(s_value .. "| ".. value) + LogGreen(s_value .. " | ".. value) return value end end @@ -39,7 +42,7 @@ end -- 获取version信息(老版本信息,新版中用于获取版本号,包版本号,) function ServerConfigManager.GetVersionInfo(key) -- 包版本大于启用的版本使用新的配置 - if AndroidDeviceInfo.Instance:GetVersionCode() >= _ActiveCode then + if not AppConst.isSDK or AndroidDeviceInfo.Instance:GetVersionCode() >= _ActiveCode then local v = ServerConfigManager.GetConfigInfo(key) if not v then v = VersionManager:GetVersionInfo(key) @@ -54,18 +57,4 @@ end function ServerConfigManager.GetConfigInfo(key) local s = ConfigMgr:GetConfigInfo(key) return s -end -function ServerConfigManager.GetConfigNetInfo(key) - local s = ConfigMgr:GetConfigNetInfo(key) - return s - -end -function ServerConfigManager.GetConfigPersistentInfo(key) - local s = ConfigMgr:GetConfigPersistentInfo(key) - return s - -end -function ServerConfigManager.GetConfigStreamingInfo(key) - local s = ConfigMgr:GetConfigStreamingInfo(key) - return s end \ No newline at end of file diff --git a/Assets/ManagedResources/~Lua/Modules/Guild/GuildInfoPopup.lua b/Assets/ManagedResources/~Lua/Modules/Guild/GuildInfoPopup.lua index 2f5f24973f..e640f7f851 100644 --- a/Assets/ManagedResources/~Lua/Modules/Guild/GuildInfoPopup.lua +++ b/Assets/ManagedResources/~Lua/Modules/Guild/GuildInfoPopup.lua @@ -249,11 +249,11 @@ end --界面打开时调用(用于子类重写) function GuildInfoPopup:OnOpen(...) this.RefreshShow() - LayoutRebuilder.ForceRebuildLayoutImmediate(this.layoutName.transform) - LayoutRebuilder.ForceRebuildLayoutImmediate(this.layoutLevel.transform) - LayoutRebuilder.ForceRebuildLayoutImmediate(this.layoutMaster.transform) - LayoutRebuilder.ForceRebuildLayoutImmediate(this.layoutMember.transform) - LayoutRebuilder.ForceRebuildLayoutImmediate(this.layoutDeclaration.transform) + ForceRebuildLayout(this.layoutName.transform) + ForceRebuildLayout(this.layoutLevel.transform) + ForceRebuildLayout(this.layoutMaster.transform) + ForceRebuildLayout(this.layoutMember.transform) + ForceRebuildLayout(this.layoutDeclaration.transform) end --界面打开或者重新打开后,界面刷新时调用(用于子类重写) diff --git a/Assets/ManagedResources/~Lua/Modules/Message/MsgPanel.lua b/Assets/ManagedResources/~Lua/Modules/Message/MsgPanel.lua index f7bbb200df..d373df13a0 100644 --- a/Assets/ManagedResources/~Lua/Modules/Message/MsgPanel.lua +++ b/Assets/ManagedResources/~Lua/Modules/Message/MsgPanel.lua @@ -64,7 +64,7 @@ function MsgPanel.ShowOne(msg, action, text, title) MsgPanel.btn_Left.gameObject:SetActive(true) MsgPanel.btn_Right.gameObject:SetActive(false) MsgPanel._toggle.gameObject:SetActive(false) - LayoutRebuilder.ForceRebuildLayoutImmediate(MsgPanel._toggle.transform) + ForceRebuildLayout(MsgPanel._toggle.transform) end --展示两个按钮 @@ -88,7 +88,7 @@ function MsgPanel.ShowTwo(msg, leftAction, rightAction, leftText, rightText, tit else MsgPanel._toggle.gameObject:SetActive(false) end - LayoutRebuilder.ForceRebuildLayoutImmediate(MsgPanel._toggle.transform) + ForceRebuildLayout(MsgPanel._toggle.transform) end function MsgPanel.Hide() diff --git a/Assets/ManagedResources/~Lua/Modules/Popup/RewardTalismanSingleShowPopup.lua b/Assets/ManagedResources/~Lua/Modules/Popup/RewardTalismanSingleShowPopup.lua index 5b8e72efa8..0a93c6bd00 100644 --- a/Assets/ManagedResources/~Lua/Modules/Popup/RewardTalismanSingleShowPopup.lua +++ b/Assets/ManagedResources/~Lua/Modules/Popup/RewardTalismanSingleShowPopup.lua @@ -110,8 +110,8 @@ function RewardTalismanSingleShowPopup:OnShow() self.btnSure:SetActive(false) end self:OnShowPanelData() - LayoutRebuilder.ForceRebuildLayoutImmediate(self.curMainProscroll.transform) - LayoutRebuilder.ForceRebuildLayoutImmediate(self.curotherProscroll.transform) + ForceRebuildLayout(self.curMainProscroll.transform) + ForceRebuildLayout(self.curotherProscroll.transform) end function RewardTalismanSingleShowPopup:OnShowPanelData() local curEquipTreasureFigData = {} diff --git a/Assets/ManagedResources/~Lua/Modules/Setting/SettingInfo.lua b/Assets/ManagedResources/~Lua/Modules/Setting/SettingInfo.lua index bde32a6832..13692a69ab 100644 --- a/Assets/ManagedResources/~Lua/Modules/Setting/SettingInfo.lua +++ b/Assets/ManagedResources/~Lua/Modules/Setting/SettingInfo.lua @@ -40,44 +40,54 @@ function SettingInfo:InitComponent(gameObject, rootPanel) -- this.languageBtn = Util.GetGameObject(gameObject, "other/box/languageBtn") -- this.languageText= Util.GetGameObject(this.languageBtn,"Text"):GetComponent("Text") -- this.languageText.text=GetCurLanguage()==0 and "中文" or "英文" + + if IsLanguagePack then + this.dropDown = Util.GetGameObject(gameObject,"other/box1/Dropdown"):GetComponent("Dropdown") + this.dropDownText = Util.GetGameObject(gameObject,"other/box1/Dropdown/Label"):GetComponent("Text") + this.dropDownTip = Util.GetGameObject(gameObject,"other/box1/tip") + else + this.dropDown = Util.GetGameObject(gameObject,"other/box1/Dropdown") + this.dropDown:SetActive(false) - this.dropDown = Util.GetGameObject(gameObject,"other/box1/Dropdown"):GetComponent("Dropdown") - this.dropDownText = Util.GetGameObject(gameObject,"other/box1/Dropdown/Label"):GetComponent("Text") - this.dropDownTip = Util.GetGameObject(gameObject,"other/box1/tip") + end end function SettingInfo:SetTipShow() - local flag = PlayerPrefs.GetInt("language_flag") - LogGreen("PlayerPrefs:"..flag) - if flag == 0 then - this.dropDownText.text = Language[11854] - elseif flag == 2 then - this.dropDownText.text = "Tiếng Việt" - elseif flag == 1 then - this.dropDownText.text = "English" - end - this.dropDown.value = flag - if GetCurLanguage() ~= flag then - this.dropDownTip.gameObject:SetActive(true) - else - this.dropDownTip.gameObject:SetActive(false) + if IsLanguagePack then + local flag = PlayerPrefs.GetInt("language_flag") + LogGreen("PlayerPrefs:"..flag) + if flag == 0 then + this.dropDownText.text = Language[11854] + elseif flag == 2 then + this.dropDownText.text = "Tiếng Việt" + elseif flag == 1 then + this.dropDownText.text = "English" + end + this.dropDown.value = flag + if GetCurLanguage() ~= flag then + this.dropDownTip.gameObject:SetActive(true) + else + this.dropDownTip.gameObject:SetActive(false) + end end end --绑定事件(用于子类重写) function SettingInfo:BindEvent() - this.dropDown.onValueChanged:AddListener( - function(value) - PlayerPrefs.SetInt("language_flag",value) - this:SetTipShow() - if value == GetCurLanguage() then - return - end - MsgPanel.ShowTwo(Language[11856],function() end,function() - Game.Logout() - end,Language[10731],Language[10732],"",false,"") - end - ) + if IsLanguagePack then + this.dropDown.onValueChanged:AddListener( + function(value) + PlayerPrefs.SetInt("language_flag",value) + this:SetTipShow() + if value == GetCurLanguage() then + return + end + MsgPanel.ShowTwo(Language[11856],function() end,function() + Game.Logout() + end,Language[10731],Language[10732],"",false,"") + end + ) + end --cdKey兑换 Util.AddClick(this.cdKey, function() UIManager.OpenPanel(UIName.CDKeyExchangePanel) diff --git a/Assets/ManagedResources/~Lua/misc/functions.lua b/Assets/ManagedResources/~Lua/misc/functions.lua index 0b1a6ad135..a003de5e3f 100644 --- a/Assets/ManagedResources/~Lua/misc/functions.lua +++ b/Assets/ManagedResources/~Lua/misc/functions.lua @@ -56,20 +56,21 @@ function reimport(name) return require(name) end + function GetPreferredHeight(_transform) - if LayoutRebuilder then - LayoutRebuilder.ForceRebuildLayoutImmediate(_transform) - end + ForceRebuildLayout(_transform) return LayoutUtility.GetPreferredHeight(_transform) end function GetPreferredWidth(_transform) - if LayoutRebuilder then - LayoutRebuilder.ForceRebuildLayoutImmediate(_transform) - end + ForceRebuildLayout(_transform) return LayoutUtility.GetPreferredWidth(_transform) end + function ForceRebuildLayout(_transform) - if LayoutRebuilder then + if ServerConfigManager.IsSettingActive(ServerConfigManager.SettingConfig.LayoutBuilderWrap) then + if not LayoutRebuilder then + LayoutRebuilder = UnityEngine.UI.LayoutRebuilder + end LayoutRebuilder.ForceRebuildLayoutImmediate(_transform) end end \ No newline at end of file diff --git a/Assets/Resources/config.txt b/Assets/Resources/config.txt deleted file mode 100644 index 9248dd9388..0000000000 --- a/Assets/Resources/config.txt +++ /dev/null @@ -1,11 +0,0 @@ -{ - "subChannel":"1", - "channel":"pc", - "serverUrl":"http://60.1.1.23:8080/", - "Setting":{ - "ServerVersion":{"desc":"用于切换正式服和提审服", "versionCode":"25", "isActive":"1", "value":"1"}, - "ThinkAnalysis_GetDeviceID":{"desc":"数数获取DeviceID方法", "versionCode":"24", "isActive":"1"}, - "LayoutBuilderWrap":{"desc":"强制刷新layout组件大小的方法修改到lua中调用", "versionCode":"25", "isActive":"1"}, - "LanguagePackager":{"desc":"本地化处理", "versionCode":"25", "isActive":"1"}, - } -} \ No newline at end of file diff --git a/Assets/Resources/config.txt.meta b/Assets/Resources/config.txt.meta deleted file mode 100644 index 64e1d3c3a3..0000000000 --- a/Assets/Resources/config.txt.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 343cc3bd6dddfa64381bbe4c53e06a87 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Source/Generate/GameLogic_ConfigManagerWrap.cs b/Assets/Source/Generate/GameLogic_ConfigManagerWrap.cs index 0d48ae02cc..31789b96e8 100644 --- a/Assets/Source/Generate/GameLogic_ConfigManagerWrap.cs +++ b/Assets/Source/Generate/GameLogic_ConfigManagerWrap.cs @@ -11,8 +11,6 @@ public class GameLogic_ConfigManagerWrap L.RegFunction("SetNetInfo", SetNetInfo); L.RegFunction("GetConfigInfo", GetConfigInfo); L.RegFunction("GetConfigNetInfo", GetConfigNetInfo); - L.RegFunction("GetConfigPersistentInfo", GetConfigPersistentInfo); - L.RegFunction("GetConfigStreamingInfo", GetConfigStreamingInfo); L.RegFunction("New", _CreateGameLogic_ConfigManager); L.RegFunction("__tostring", ToLua.op_ToString); L.EndClass(); @@ -110,41 +108,5 @@ public class GameLogic_ConfigManagerWrap return LuaDLL.toluaL_exception(L, e); } } - - [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] - static int GetConfigPersistentInfo(IntPtr L) - { - try - { - ToLua.CheckArgsCount(L, 2); - GameLogic.ConfigManager obj = (GameLogic.ConfigManager)ToLua.CheckObject(L, 1); - string arg0 = ToLua.CheckString(L, 2); - string o = obj.GetConfigPersistentInfo(arg0); - LuaDLL.lua_pushstring(L, o); - return 1; - } - catch (Exception e) - { - return LuaDLL.toluaL_exception(L, e); - } - } - - [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] - static int GetConfigStreamingInfo(IntPtr L) - { - try - { - ToLua.CheckArgsCount(L, 2); - GameLogic.ConfigManager obj = (GameLogic.ConfigManager)ToLua.CheckObject(L, 1); - string arg0 = ToLua.CheckString(L, 2); - string o = obj.GetConfigStreamingInfo(arg0); - LuaDLL.lua_pushstring(L, o); - return 1; - } - catch (Exception e) - { - return LuaDLL.toluaL_exception(L, e); - } - } } diff --git a/Assets/Source/Generate/LuaBinder.cs b/Assets/Source/Generate/LuaBinder.cs index 01425c6ffa..f24f1f41ef 100644 --- a/Assets/Source/Generate/LuaBinder.cs +++ b/Assets/Source/Generate/LuaBinder.cs @@ -181,6 +181,7 @@ public static class LuaBinder UnityEngine_UI_VerticalLayoutGroupWrap.Register(L); UnityEngine_UI_LayoutElementWrap.Register(L); UnityEngine_UI_ContentSizeFitterWrap.Register(L); + UnityEngine_UI_SpriteStateWrap.Register(L); UnityEngine_UI_LayoutUtilityWrap.Register(L); UnityEngine_UI_LayoutRebuilderWrap.Register(L); UnityEngine_UI_GraphicWrap.Register(L); From 1c210301fd3e89890676d9975467117faf46de54 Mon Sep 17 00:00:00 2001 From: gaoxin Date: Thu, 4 Mar 2021 19:48:38 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E3=80=90=E6=9C=AC=E5=9C=B0=E5=8C=96?= =?UTF-8?q?=E3=80=91=E5=90=8E=E7=AB=AF=E5=86=99=E6=AD=BB=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E8=A1=A8=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ManagedResources/~Lua/Logic/Network.lua | 54 ++++++++++++------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/Assets/ManagedResources/~Lua/Logic/Network.lua b/Assets/ManagedResources/~Lua/Logic/Network.lua index 4f2be1fde3..49d93be8b3 100644 --- a/Assets/ManagedResources/~Lua/Logic/Network.lua +++ b/Assets/ManagedResources/~Lua/Logic/Network.lua @@ -222,31 +222,47 @@ function Network:ReceiveErrorInfo(buffer) if msg.errCode == -1 then LogError("Network ReceiveErrorInfo errDes:"..msg.errMsg) end - local errorCfg = ConfigManager.TryGetConfigData(ConfigName.ErrorCodeHint, msg.errCode) - if errorCfg then - if errorCfg.ShowType == 1 then --tips - PopupTipPanel.ShowTip(string.format(GetLanguageStrById(errorCfg.Desc), unpack(msg.errParams))) - elseif errorCfg.ShowType == 2 then --弹窗 - local contexts = string.split(GetLanguageStrById(errorCfg.Desc), "#") --标题#内容 - MsgPanel.ShowOne(string.format(contexts[2], unpack(msg.errParams)), nil, nil, contexts[1]) + + local desc, title = self:GetErrorTip(msg) + if msg.errCode == -101 or msg.errCode == -102 or msg.errCode == -103 then + if(Time.time- self.ReconnectTime<10)then + return + end + --被顶号或者被封号 + Game.Logout() + AppConst.Code = desc--TODO:重登会重置所有lua变量信息,用一个不用的C#变量记录,用于记录异常退出信息 + return + end + if desc then + if title then + MsgPanel.ShowOne(desc, nil, nil, title) else - PopupTipPanel.ShowTip(msg.errMsg) + PopupTipPanel.ShowTip(desc) end else - if msg.errCode == -101 or msg.errCode == -102 then - - if(Time.time- self.ReconnectTime<10)then - return - end - --被顶号或者被封号 - Game.Logout() - AppConst.Code = msg.errMsg --TODO:重登会重置所有lua变量信息,用一个不用的C#变量记录,用于记录异常退出信息 - else - PopupTipPanel.ShowTip(msg.errMsg) - end + PopupTipPanel.ShowTip(msg.errMsg) end end +function Network:GetErrorTip(msg) + local errorCfg = ConfigManager.TryGetConfigData(ConfigName.ErrorCodeHint, msg.errCode) + if errorCfg then + local params = {} + for i = 1, #msg.errParams do + table.insert(params, GetLanguageStrById(msg.errParams[i])) + end + if errorCfg.ShowType == 1 then --tips + return string.format(GetLanguageStrById(errorCfg.Desc), unpack(params)) + elseif errorCfg.ShowType == 2 then --弹窗 + local contexts = string.split(GetLanguageStrById(errorCfg.Desc), "#") --标题#内容 + return string.format(contexts[2], unpack(params)), contexts[1] + end + end + return msg.errMsg +end + + + --注册消息模块 function Network:RegisterMessage(nMsgId, pMessageHandle) self.socket:RegistNetMessage(nMsgId, pMessageHandle)