From d3a1cba41cf7796fb5e488c1f76aedd9709574d6 Mon Sep 17 00:00:00 2001 From: gaoxin Date: Thu, 4 Mar 2021 19:29:15 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=AE=A1=E7=90=86=E3=80=91=E5=8C=85?= =?UTF-8?q?=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);