zhaoyang 3 ani în urmă
părinte
comite
fe1c282f0e

+ 1 - 1
GameClient/Assets/Editor/Excel/CodeBuilder.cs

@@ -171,7 +171,7 @@ namespace GFGEditor
             //处理全部数据函数
             string FunctionAllStr = CodeTemplateFactory.FunctionAllTemplate;
             configArrayStr = configArrayStr.Replace("{allFunction}", FunctionAllStr);
-            configArrayStr = configArrayStr.Replace("{Constructor}", CodeTemplateFactory.ConstructorTemplate);
+            configArrayStr = configArrayStr.Replace("{Init}", CodeTemplateFactory.InitTemplate);
             configArrayStr = configArrayStr.Replace("{Dispose}", CodeTemplateFactory.DisposeTemplate);
             configArrayStr = configArrayStr.Replace("{StrDiapose}", strDiapose);
 

+ 18 - 3
GameClient/Assets/Editor/Excel/CodeTemplateFactory.cs

@@ -9,7 +9,7 @@ namespace GFGEditor
 
         public static string ConfigTemplate { get; private set; }
         public static string ConfigArrayTemplate { get; private set; }
-        public static string ConstructorTemplate { get; private set; }
+        public static string InitTemplate { get; private set; }
         public static string DisposeTemplate { get; private set; }
         public static string FunctionSingleTemplate { get; private set; }
         public static string FunctionGroupTemplate { get; private set; }
@@ -19,6 +19,9 @@ namespace GFGEditor
         public static string DisposeAllCfgsCacheTemplate { get; private set; }
         public static string FunctionDisposeTemplate { get; private set; }
         public static string StrCfgArrayDisposeTemplate { get; private set; }
+        public static string InitAllCfgsCacheTemplate { get; private set; }
+        public static string FunctionInitTemplate { get; private set; }
+        public static string StrCfgArrayInitTemplate { get; private set; }
         //public static string ConfigTemplateEditor { get => _configTemplateEditor; }
         //public static string ConfigArrayTemplateEditor { get => _configArrayTemplateEditor; }
 
@@ -33,9 +36,9 @@ namespace GFGEditor
             {
                 ConfigArrayTemplate = sr.ReadToEnd();
             }
-            using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "Constructor.txt"))
+            using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "Init.txt"))
             {
-                ConstructorTemplate = sr.ReadToEnd();
+                InitTemplate = sr.ReadToEnd();
             }
             using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "Dispose.txt"))
             {
@@ -74,6 +77,18 @@ namespace GFGEditor
             {
                 StrCfgArrayDisposeTemplate = sr.ReadToEnd();
             }
+            using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "InitAllCfgsCache.txt"))
+            {
+                InitAllCfgsCacheTemplate = sr.ReadToEnd();
+            }
+            using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "FunctionInit.txt"))
+            {
+                FunctionInitTemplate = sr.ReadToEnd();
+            }
+            using (StreamReader sr = new StreamReader(ExcelConfig.templatePath + "StrCfgArrayInitBlock.txt"))
+            {
+                StrCfgArrayInitTemplate = sr.ReadToEnd();
+            }
         }
 
     }

+ 2 - 2
GameClient/Assets/Editor/Excel/ExcelConfig.cs

@@ -26,9 +26,9 @@ namespace GFGEditor
         public const string configArrayCodePath = "Assets/Game/CSShare/GFG//HotUpdate/ExcelConfig/GenCode/Array/";
 
         /// <summary>
-        /// 存放数据Dispose文件的文件夹路径
+        /// 存放数据Dispose、Init文件的文件夹路径
         /// </summary>
-        public const string configDataDisposePath = "Assets/Game/CSShare/GFG//HotUpdate/ExcelConfig/GenCode/";
+        public const string handleAllCfgsCache = "Assets/Game/CSShare/GFG//HotUpdate/ExcelConfig/GenCode/";
 
 
         /// <summary>

+ 19 - 6
GameClient/Assets/Editor/Excel/ExcelReader.cs

@@ -16,6 +16,7 @@ namespace GFGEditor
             string[] files = Directory.GetFiles(ExcelConfig.excelsFolderPath);
             int totalCount = files.Length;
             string strCfgArrayDispose = "";
+            string strCfgArrayInit = "";
             for (int i = 0; i < totalCount; i++)
             {
                 string filePath = files[i];
@@ -28,31 +29,43 @@ namespace GFGEditor
                     //IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
                     //DataSet result = excelReader.AsDataSet();
 
-                    HandleTableCollection(excelPackage.Workbook.Worksheets, rowCollectionHandler, out string dispose);
+                    HandleTableCollection(excelPackage.Workbook.Worksheets, rowCollectionHandler, out string dispose, out string init);
                     strCfgArrayDispose = strCfgArrayDispose + dispose;
+                    strCfgArrayInit = strCfgArrayInit + init;
                 }
             }
             string functionDispose = CodeTemplateFactory.FunctionDisposeTemplate;
             functionDispose = functionDispose.Replace("{StrCfgArrayDispose}", strCfgArrayDispose);
             string disposeAllCfgsCache = CodeTemplateFactory.DisposeAllCfgsCacheTemplate;
             disposeAllCfgsCache = disposeAllCfgsCache.Replace("{FunctionDispose}", functionDispose);
-            //创建管理类代码
-            using (StreamWriter sw = new StreamWriter(ExcelConfig.configDataDisposePath + "DisposeAllCfgsCache.cs"))
+            using (StreamWriter sw = new StreamWriter(ExcelConfig.handleAllCfgsCache + "DisposeAllCfgsCache.cs"))
             {
                 sw.Write(disposeAllCfgsCache);
             }
+
+            string functionInit = CodeTemplateFactory.FunctionInitTemplate;
+            functionInit = functionInit.Replace("{StrCfgArrayInit}", strCfgArrayInit);
+            string initAllCfgsCache = CodeTemplateFactory.InitAllCfgsCacheTemplate;
+            initAllCfgsCache = initAllCfgsCache.Replace("{FunctionInit}", functionInit);
+            using (StreamWriter sw = new StreamWriter(ExcelConfig.handleAllCfgsCache + "InitAllCfgsCache.cs"))
+            {
+                sw.Write(initAllCfgsCache);
+            }
         }
 
-        private static void HandleTableCollection(ExcelWorksheets Worksheets, RowCollectionHandler rowCollectionHandler, out string strCfgArrayDispose)
+        private static void HandleTableCollection(ExcelWorksheets Worksheets, RowCollectionHandler rowCollectionHandler, out string strDispose, out string strInit)
         {
-            strCfgArrayDispose = "";
+            strDispose = "";
+            strInit = "";
             for (int i = 1; i <= Worksheets.Count; i++)
             {
                 ExcelWorksheet worksheet = Worksheets[i];
                 string configArrayName = HandleTable(worksheet, rowCollectionHandler);
                 if (string.IsNullOrEmpty(configArrayName)) continue;
                 string dispose = CodeTemplateFactory.StrCfgArrayDisposeTemplate.Replace("{configArrayName}", configArrayName);
-                strCfgArrayDispose = strCfgArrayDispose + "\n" + dispose;
+                strDispose = strDispose + "\n" + dispose;
+                string init = CodeTemplateFactory.StrCfgArrayInitTemplate.Replace("{configArrayName}", configArrayName);
+                strInit = strInit + "\n" + init;
             }
         }
 

+ 1 - 1
GameClient/Assets/Editor/Excel/Template/ConfigArray.txt

@@ -4,7 +4,7 @@ namespace GFGGame
 {
     public partial class {CfgArrayName} : SingletonBase<{CfgArrayName}>
     {
-{Constructor}
+{Init}
 
 {Dispose}
 

+ 4 - 0
GameClient/Assets/Editor/Excel/Template/FunctionInit.txt

@@ -0,0 +1,4 @@
+        public void InitAll()
+        {
+	        {StrCfgArrayInit}
+        }

+ 1 - 1
GameClient/Assets/Editor/Excel/Template/Constructor.txt.meta → GameClient/Assets/Editor/Excel/Template/FunctionInit.txt.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 1688b80d9c8e8954785c935d67d58893
+guid: 40d762977efb06642950b31e87200eb3
 TextScriptImporter:
   externalObjects: {}
   userData: 

+ 1 - 1
GameClient/Assets/Editor/Excel/Template/Constructor.txt → GameClient/Assets/Editor/Excel/Template/Init.txt

@@ -1,4 +1,4 @@
-		public {CfgArrayName} ()
+		public void Init ()
 		{ 
 			{CfgName}[] dataArray =this.dataArray;
 		}

+ 7 - 0
GameClient/Assets/Editor/Excel/Template/Init.txt.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: b08b89f4f801d914a8cd0ad234bb4448
+TextScriptImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 7 - 0
GameClient/Assets/Editor/Excel/Template/InitAllCfgsCache.txt

@@ -0,0 +1,7 @@
+namespace GFGGame
+{
+    public partial class InitAllCfgsCache : SingletonBase<InitAllCfgsCache>
+    {
+{FunctionInit}
+    }
+}

+ 7 - 0
GameClient/Assets/Editor/Excel/Template/InitAllCfgsCache.txt.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: ca08be5ced251ce468ff9be0411031b4
+TextScriptImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 1 - 0
GameClient/Assets/Editor/Excel/Template/StrCfgArrayInitBlock.txt

@@ -0,0 +1 @@
+			{configArrayName}.Instance.Init();

+ 7 - 0
GameClient/Assets/Editor/Excel/Template/StrCfgArrayInitBlock.txt.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: c2d607553dd0051459c04ea7a11c1dbb
+TextScriptImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

BIN
GameClient/Assets/ResIn/Config/excelConfig.sqlite.bytes