Browse Source

配置表数据优化

guodong 1 year ago
parent
commit
e1ed1a253e

+ 13 - 8
GameClient/Assets/Editor/Excel/CodeBuilder.cs

@@ -1,13 +1,8 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Data;
+using System.Collections.Generic;
 using System.IO;
 using System.IO;
 using System.Text;
 using System.Text;
 using UnityEngine;
 using UnityEngine;
 using GFGGame;
 using GFGGame;
-using System.Text.RegularExpressions;
-using static Google.Protobuf.Reflection.GeneratedCodeInfo.Types;
 using OfficeOpenXml;
 using OfficeOpenXml;
 
 
 namespace GFGEditor
 namespace GFGEditor
@@ -168,7 +163,7 @@ namespace GFGEditor
                     string functionName = string.Format("GetCfgsBy{0}", string.Join("And", groupNames[key]));
                     string functionName = string.Format("GetCfgsBy{0}", string.Join("And", groupNames[key]));
                     string cfgsGroupDicName = string.Format("_cfgsGroupDic{0}", index0);
                     string cfgsGroupDicName = string.Format("_cfgsGroupDic{0}", index0);
                     groupFunction = groupFunction + HandleGroupFunction("groupKey_" + key, groupNames[key], groupTypes[key], functionName, cfgsGroupDicName, configArrayStr, configArrayName);
                     groupFunction = groupFunction + HandleGroupFunction("groupKey_" + key, groupNames[key], groupTypes[key], functionName, cfgsGroupDicName, configArrayStr, configArrayName);
-                    strDispose = string.Format("{0}\t\t\t{1}.Clear();", strDispose, cfgsGroupDicName);
+                    strDispose = string.Format("{0}\n\t\t\t{1}.Clear();", strDispose, cfgsGroupDicName);
                     index0++;
                     index0++;
                 }
                 }
             }
             }
@@ -205,6 +200,16 @@ namespace GFGEditor
             }
             }
             string singleStrs = string.Join("\n", singleStrArry);
             string singleStrs = string.Join("\n", singleStrArry);
 
 
+            if(string.IsNullOrEmpty(singleStrs))
+            {
+                configArrayStr = configArrayStr.Replace("{SingleHandleBlock}", "");
+            }
+            else
+            {
+                //添加
+                configArrayStr = configArrayStr.Replace("{SingleHandleBlock}", singleStrs);
+            }
+
             List<string> groupStrArry = new List<string>();
             List<string> groupStrArry = new List<string>();
             int index1 = 0;
             int index1 = 0;
             foreach (string key in groupNames.Keys)
             foreach (string key in groupNames.Keys)
@@ -219,7 +224,7 @@ namespace GFGEditor
             }
             }
             string groupStrs = string.Join("\n", groupStrArry);
             string groupStrs = string.Join("\n", groupStrArry);
 
 
-            configArrayStr = configArrayStr.Replace("{FunctionAllBlock}", singleStrs + "\n" + groupStrs);
+            configArrayStr = configArrayStr.Replace("{FunctionAllBlock}", groupStrs);
 
 
             // foreach()
             // foreach()
             //名称处理
             //名称处理

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

@@ -9,6 +9,13 @@ namespace GFGGame
 
 
 {Dispose}
 {Dispose}
 
 
+
+        private void HandleCfg({CfgName} cfg)
+        {
+{SingleHandleBlock}
+        }
+
+
 {singleFunction}
 {singleFunction}
 
 
 {groupFunction}
 {groupFunction}

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

@@ -1,6 +1,7 @@
 
 
         private void HandleCfgInAll({CfgName} cfg)
         private void HandleCfgInAll({CfgName} cfg)
         {
         {
+            HandleCfg(cfg);
 {FunctionAllBlock}
 {FunctionAllBlock}
         }
         }
 
 

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

@@ -4,6 +4,6 @@
         {
         {
             var colNames = new string[] { {colNames}};
             var colNames = new string[] { {colNames}};
             var colValues = new string[] { {colValues} };
             var colValues = new string[] { {colValues} };
-            return ConfigUtil.GetCfgs<{CfgName}>("{CfgArrayName}", colNames, colValues, {cfgsGroupDicName});
+            return ConfigUtil.GetCfgs<{CfgName}>("{CfgArrayName}", colNames, colValues, {cfgsGroupDicName}, HandleCfg);
         }
         }
         
         

+ 2 - 0
GameClient/Assets/Editor/Excel/Template/FunctionSingle.txt

@@ -5,4 +5,6 @@
             var colValues = new string[] { {colValues} };
             var colValues = new string[] { {colValues} };
             return ConfigUtil.GetCfg<{CfgName}>("{CfgArrayName}", colNames, colValues, {cfgsDicName});
             return ConfigUtil.GetCfg<{CfgName}>("{CfgArrayName}", colNames, colValues, {cfgsDicName});
         }
         }
+
+