From abe109aeea2ed3c68b3d669a2ff7b8d6b77c4ac5 Mon Sep 17 00:00:00 2001 From: mrkelly Date: Mon, 8 Aug 2016 14:43:02 +0800 Subject: [PATCH] =?UTF-8?q?GameConfig=E9=85=8D=E7=BD=AE=EF=BC=8C=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E7=A7=BB=E5=8A=A8=E5=88=B0GameConfig=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=EF=BC=8C=E6=96=87=E4=BB=B6=E5=90=8D=E7=9B=B4=E6=8E=A5?= =?UTF-8?q?=E4=BB=A5+=E5=BC=80=E5=A4=B4=EF=BC=8C=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=9A=84=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- KEngine | 2 +- KSFramework/Assets/AppSettings.cs | 94 +++++++++--------- .../KSFramework/Editor/KSFrameworkEditor.cs | 33 +++++- .../+Base.bytes} | 3 +- .../+TSV.bytes} | 0 .../+Base.xlsx} | Bin .../+TSV.tsv} | 0 7 files changed, 82 insertions(+), 50 deletions(-) rename KSFramework/Product/Setting/{GameConfig+Base.bytes => GameConfig/+Base.bytes} (52%) rename KSFramework/Product/Setting/{GameConfig+TSV.bytes => GameConfig/+TSV.bytes} (100%) rename KSFramework/Product/SettingSource/{GameConfig+Base.xlsx => GameConfig/+Base.xlsx} (100%) rename KSFramework/Product/SettingSource/{GameConfig+TSV.tsv => GameConfig/+TSV.tsv} (100%) diff --git a/KEngine b/KEngine index 6f036bb4..86970068 160000 --- a/KEngine +++ b/KEngine @@ -1 +1 @@ -Subproject commit 6f036bb401d3336ef96de2e72ab6663193c2cf08 +Subproject commit 86970068e0e730bc40dfd4237948e0adc38db5eb diff --git a/KSFramework/Assets/AppSettings.cs b/KSFramework/Assets/AppSettings.cs index c86cfc42..92847215 100644 --- a/KSFramework/Assets/AppSettings.cs +++ b/KSFramework/Assets/AppSettings.cs @@ -47,8 +47,8 @@ public static IReloadableSettings[] SettingsList { _settingsList = new IReloadableSettings[] { - GameConfigSettings.GetInstance(), TestSettings.GetInstance(), + GameConfigSettings.GetInstance(), }; } return _settingsList; @@ -74,17 +74,17 @@ public static void AllSettingsReload() /// - /// Auto Generate for Tab File: "GameConfig+Base.bytes", "GameConfig+TSV.bytes" + /// Auto Generate for Tab File: "Test.bytes" /// No use of generic and reflection, for better performance, less IL code generating /// > - public partial class GameConfigSettings : IReloadableSettings + public partial class TestSettings : IReloadableSettings { public static readonly string[] TabFilePaths = { - "GameConfig+Base.bytes", "GameConfig+TSV.bytes" + "Test.bytes" }; - static GameConfigSettings _instance; - Dictionary _dict = new Dictionary(); + static TestSettings _instance; + Dictionary _dict = new Dictionary(); /// /// Trigger delegate when reload the Settings @@ -95,7 +95,7 @@ public partial class GameConfigSettings : IReloadableSettings /// Constructor, just reload(init) /// When Unity Editor mode, will watch the file modification and auto reload /// - private GameConfigSettings() + private TestSettings() { } @@ -103,11 +103,11 @@ private GameConfigSettings() /// Get the singleton /// /// - public static GameConfigSettings GetInstance() + public static TestSettings GetInstance() { if (_instance == null) { - _instance = new GameConfigSettings(); + _instance = new TestSettings(); _instance._ReloadAll(true); #if UNITY_EDITOR @@ -141,7 +141,7 @@ public int Count } /// - /// Do reload the setting file: GameConfig, no exception when duplicate primary key + /// Do reload the setting file: Test, no exception when duplicate primary key /// public void ReloadAll() { @@ -149,7 +149,7 @@ public void ReloadAll() } /// - /// Do reload the setting file: GameConfig + /// Do reload the setting file: Test /// void _ReloadAll(bool throwWhenDuplicatePrimaryKey) { @@ -160,11 +160,11 @@ void _ReloadAll(bool throwWhenDuplicatePrimaryKey) { foreach (var row in tableFile) { - var pk = GameConfigSetting.ParsePrimaryKey(row); - GameConfigSetting setting; + var pk = TestSetting.ParsePrimaryKey(row); + TestSetting setting; if (!_dict.TryGetValue(pk, out setting)) { - setting = new GameConfigSetting(row); + setting = new TestSetting(row); _dict[setting.Id] = setting; } else @@ -183,7 +183,7 @@ void _ReloadAll(bool throwWhenDuplicatePrimaryKey) } /// - /// foreachable enumerable: GameConfig + /// foreachable enumerable: Test /// public static IEnumerable GetAll() { @@ -194,7 +194,7 @@ public static IEnumerable GetAll() } /// - /// GetEnumerator for `MoveNext`: GameConfig + /// GetEnumerator for `MoveNext`: Test /// public static IEnumerator GetEnumerator() { @@ -202,11 +202,11 @@ public static IEnumerator GetEnumerator() } /// - /// Get class by primary key: GameConfig + /// Get class by primary key: Test /// - public static GameConfigSetting Get(string primaryKey) + public static TestSetting Get(string primaryKey) { - GameConfigSetting setting; + TestSetting setting; if (GetInstance()._dict.TryGetValue(primaryKey, out setting)) return setting; return null; } @@ -217,10 +217,10 @@ public static GameConfigSetting Get(string primaryKey) } /// - /// Auto Generate for Tab File: "GameConfig+Base.bytes", "GameConfig+TSV.bytes" + /// Auto Generate for Tab File: "Test.bytes" /// Singleton class for less memory use /// - public partial class GameConfigSetting : TableRowParser + public partial class TestSetting : TableRowParser { /// @@ -231,10 +231,10 @@ public partial class GameConfigSetting : TableRowParser /// /// Name/名字 /// - public string Value { get; private set;} + public I18N Value { get; private set;} - internal GameConfigSetting(TableRow row) + internal TestSetting(TableRow row) { Reload(row); } @@ -242,7 +242,7 @@ internal GameConfigSetting(TableRow row) internal void Reload(TableRow row) { Id = row.Get_string(row.Values[0], ""); - Value = row.Get_string(row.Values[1], ""); + Value = row.Get_I18N(row.Values[1], ""); } /// @@ -258,17 +258,17 @@ public static string ParsePrimaryKey(TableRow row) } /// - /// Auto Generate for Tab File: "Test.bytes" + /// Auto Generate for Tab File: "GameConfig/+Base.bytes", "GameConfig/+TSV.bytes" /// No use of generic and reflection, for better performance, less IL code generating /// > - public partial class TestSettings : IReloadableSettings + public partial class GameConfigSettings : IReloadableSettings { public static readonly string[] TabFilePaths = { - "Test.bytes" + "GameConfig/+Base.bytes", "GameConfig/+TSV.bytes" }; - static TestSettings _instance; - Dictionary _dict = new Dictionary(); + static GameConfigSettings _instance; + Dictionary _dict = new Dictionary(); /// /// Trigger delegate when reload the Settings @@ -279,7 +279,7 @@ public partial class TestSettings : IReloadableSettings /// Constructor, just reload(init) /// When Unity Editor mode, will watch the file modification and auto reload /// - private TestSettings() + private GameConfigSettings() { } @@ -287,11 +287,11 @@ private TestSettings() /// Get the singleton /// /// - public static TestSettings GetInstance() + public static GameConfigSettings GetInstance() { if (_instance == null) { - _instance = new TestSettings(); + _instance = new GameConfigSettings(); _instance._ReloadAll(true); #if UNITY_EDITOR @@ -325,7 +325,7 @@ public int Count } /// - /// Do reload the setting file: Test, no exception when duplicate primary key + /// Do reload the setting file: GameConfig, no exception when duplicate primary key /// public void ReloadAll() { @@ -333,7 +333,7 @@ public void ReloadAll() } /// - /// Do reload the setting file: Test + /// Do reload the setting file: GameConfig /// void _ReloadAll(bool throwWhenDuplicatePrimaryKey) { @@ -344,11 +344,11 @@ void _ReloadAll(bool throwWhenDuplicatePrimaryKey) { foreach (var row in tableFile) { - var pk = TestSetting.ParsePrimaryKey(row); - TestSetting setting; + var pk = GameConfigSetting.ParsePrimaryKey(row); + GameConfigSetting setting; if (!_dict.TryGetValue(pk, out setting)) { - setting = new TestSetting(row); + setting = new GameConfigSetting(row); _dict[setting.Id] = setting; } else @@ -367,7 +367,7 @@ void _ReloadAll(bool throwWhenDuplicatePrimaryKey) } /// - /// foreachable enumerable: Test + /// foreachable enumerable: GameConfig /// public static IEnumerable GetAll() { @@ -378,7 +378,7 @@ public static IEnumerable GetAll() } /// - /// GetEnumerator for `MoveNext`: Test + /// GetEnumerator for `MoveNext`: GameConfig /// public static IEnumerator GetEnumerator() { @@ -386,11 +386,11 @@ public static IEnumerator GetEnumerator() } /// - /// Get class by primary key: Test + /// Get class by primary key: GameConfig /// - public static TestSetting Get(string primaryKey) + public static GameConfigSetting Get(string primaryKey) { - TestSetting setting; + GameConfigSetting setting; if (GetInstance()._dict.TryGetValue(primaryKey, out setting)) return setting; return null; } @@ -401,10 +401,10 @@ public static TestSetting Get(string primaryKey) } /// - /// Auto Generate for Tab File: "Test.bytes" + /// Auto Generate for Tab File: "GameConfig/+Base.bytes", "GameConfig/+TSV.bytes" /// Singleton class for less memory use /// - public partial class TestSetting : TableRowParser + public partial class GameConfigSetting : TableRowParser { /// @@ -415,10 +415,10 @@ public partial class TestSetting : TableRowParser /// /// Name/名字 /// - public I18N Value { get; private set;} + public string Value { get; private set;} - internal TestSetting(TableRow row) + internal GameConfigSetting(TableRow row) { Reload(row); } @@ -426,7 +426,7 @@ internal TestSetting(TableRow row) internal void Reload(TableRow row) { Id = row.Get_string(row.Values[0], ""); - Value = row.Get_I18N(row.Values[1], ""); + Value = row.Get_string(row.Values[1], ""); } /// diff --git a/KSFramework/Assets/Plugins/KSFramework/Editor/KSFrameworkEditor.cs b/KSFramework/Assets/Plugins/KSFramework/Editor/KSFrameworkEditor.cs index 87cc360e..2afda063 100644 --- a/KSFramework/Assets/Plugins/KSFramework/Editor/KSFrameworkEditor.cs +++ b/KSFramework/Assets/Plugins/KSFramework/Editor/KSFrameworkEditor.cs @@ -173,12 +173,43 @@ public static void ReloadLuaCache() } } } + + [MenuItem("KSFramework/UI/Reload Lua + Reload UI AssetBundle")] + public static void ReloadUI() + { + if (!EditorApplication.isPlaying) + { + Log.LogError("Reload UI only when your editor is playing!"); + return; + } + foreach (var kv in UIModule.Instance.UIWindows) + { + var luaController = kv.Value.UIWindow as LuaUIController; + if (luaController) // 只处理LuaUIController + { + var inOpenState = UIModule.Instance.IsOpen(kv.Key); + if (inOpenState) + UIModule.Instance.CloseWindow(kv.Key); + + luaController.ReloadLua(); + Log.LogWarning("Reload Lua - {0}", kv.Key); + + UIModule.Instance.ReloadWindow(kv.Key, (args, err) => + { + if (inOpenState) + UIModule.Instance.OpenWindow(kv.Key, luaController.LastOnOpenArgs); + }); + + } + } + + } /// /// 找到所有的LuaUIController被进行Reload /// 如果Reload时,UI正在打开,将对其进行关闭,并再次打开,来立刻看到效果 /// [MenuItem("KSFramework/UI/Reload Lua + ReOpen UI #%&r")] - public static void ReloadUI() + public static void ReloadUILua() { if (!EditorApplication.isPlaying) { diff --git a/KSFramework/Product/Setting/GameConfig+Base.bytes b/KSFramework/Product/Setting/GameConfig/+Base.bytes similarity index 52% rename from KSFramework/Product/Setting/GameConfig+Base.bytes rename to KSFramework/Product/Setting/GameConfig/+Base.bytes index 90d44885..88ccd05b 100644 --- a/KSFramework/Product/Setting/GameConfig+Base.bytes +++ b/KSFramework/Product/Setting/GameConfig/+Base.bytes @@ -1,4 +1,5 @@ Id Value string string TestKey TestValue -I18NKey I am zh_CN \ No newline at end of file +I18NKey I am zh_CN +I18NKey I am zh_TW \ No newline at end of file diff --git a/KSFramework/Product/Setting/GameConfig+TSV.bytes b/KSFramework/Product/Setting/GameConfig/+TSV.bytes similarity index 100% rename from KSFramework/Product/Setting/GameConfig+TSV.bytes rename to KSFramework/Product/Setting/GameConfig/+TSV.bytes diff --git a/KSFramework/Product/SettingSource/GameConfig+Base.xlsx b/KSFramework/Product/SettingSource/GameConfig/+Base.xlsx similarity index 100% rename from KSFramework/Product/SettingSource/GameConfig+Base.xlsx rename to KSFramework/Product/SettingSource/GameConfig/+Base.xlsx diff --git a/KSFramework/Product/SettingSource/GameConfig+TSV.tsv b/KSFramework/Product/SettingSource/GameConfig/+TSV.tsv similarity index 100% rename from KSFramework/Product/SettingSource/GameConfig+TSV.tsv rename to KSFramework/Product/SettingSource/GameConfig/+TSV.tsv