gdl_123 3 ヶ月 前
コミット
d1f439a5cd

+ 40 - 1
Assets/Editor/CsvToLua/CsvToLua.cs

@@ -170,6 +170,11 @@ return aaa";
         {
             B2T("D:/项目/其他/Language15000-19000.csv", "D:/项目/其他/111.csv",Encoding.UTF8);
         }
+
+        if (GUILayout.Button("复制luacfg文件"))
+        {
+            CopyFleByLuaCfg("Assets\\Editor\\CsvToLua\\LuaCfg.lua","", "D:/项目/图/仙境/cn/","_cn");
+        }
     }
 
     public static string GetFilePath()
@@ -708,7 +713,7 @@ return aaa";
 
                     string field = fieldValue.RawGet<string, string>("field");
                     string value = fieldValue.RawGet<string, string>("value");
-
+                    
                     SetLuaLine(rowDatas,id,field,value.ToString(),"{0},");
                     
                 }
@@ -720,6 +725,40 @@ return aaa";
         File.WriteAllLines(outputPath, rowDatas);
     }
 
+    private static void CopyFleByLuaCfg(string luacfgpath, string fileRootPath,string outputPath,string output)
+    {
+
+        using (LuaState runTime = new LuaState())
+        {
+            runTime.Start();
+            LuaTable luaTable = runTime.DoFile<LuaTable>(luacfgpath);
+
+            LuaFunction init_fun = luaTable.GetLuaFunction("Init");
+            LuaFunction SetOutput_fun = luaTable.GetLuaFunction("SetOutput");
+            LuaFunction GetNextCfg_fun = luaTable.GetLuaFunction("GetNextCfg");
+
+
+            init_fun.Call<LuaTable>(luaTable);
+            SetOutput_fun.Call<LuaTable, string>(luaTable, output);
+
+            while (true)
+            {
+                LuaTable cfg = GetNextCfg_fun.Invoke<LuaTable>();
+                //{result = false,path = path,outputPath = outputPath}
+                bool result = cfg.RawGet<string, bool>("result");
+                if (result)
+                {
+                    string path = cfg.RawGet<string, string>("path");
+                    string _outputPath = cfg.RawGet<string, string>("outputPath");
+                    File.Copy(fileRootPath+path,outputPath+_outputPath,true);
+                }
+                else
+                {
+                    break;
+                }
+            }
+        }
+    }
     struct lgInfo 
     {
        public int index;

+ 34 - 0
Assets/Editor/CsvToLua/luaCopyFileCfg.lua

@@ -0,0 +1,34 @@
+local luaCopyFileCfg= {}
+-- basepath  基础路径
+-- path      文件上层路径   
+-- outputDis  输出后的文件上层路径
+-- fileName  文件名
+luaCopyFileCfg.FileCfg ={
+
+}
+
+
+
+
+function luaCopyFileCfg:Init()
+    self.curindex = 1
+    self.MaxIndex = #self.FileCfg
+    self.curOutput = "_cn"
+end 
+
+function luaCopyFileCfg:SetOutput(output)
+    self.curOutput = output
+end
+
+function luaCopyFileCfg:GetNextCfg()
+    if self.curindex >= self.MaxIndex then
+        return {result = false}
+    end
+    local curCfg = self.FileCfg[self.curindex]
+    self.curindex = self.curindex + 1
+    local path = curCfg.basepath..curCfg.path..curCfg.fileName
+    local outputPath = curCfg.basepath..curCfg.path..self.curOutput..'/'..curCfg.fileName
+    return {result = true,path = path,outputPath = outputPath}
+end
+
+return luaCopyFileCfg

+ 7 - 0
Assets/Editor/CsvToLua/luaCopyFileCfg.lua.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 10a3e2ba675ae4941bbfb8e067ea23ca
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: