From da16945d78bd8b7b9f30e7f41d4207521f82a8c0 Mon Sep 17 00:00:00 2001 From: gaoxin Date: Sat, 26 Jun 2021 19:52:08 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=B7=A5=E5=85=B7=E3=80=91=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E6=88=98=E6=96=97=E6=A0=A1=E9=AA=8C=E6=9C=8D=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=B7=BB=E5=8A=A0=EF=BC=8C=E6=8F=90=E4=BA=A4=E9=9C=80?= =?UTF-8?q?svn=E5=91=BD=E4=BB=A4=E8=A1=8C=E5=B7=A5=E5=85=B7=20https://www.?= =?UTF-8?q?visualsvn.com/files/Apache-Subversion-1.14.1.zip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ExcelTool/DataConfig/DataConfigWindow.cs | 104 +++++++++++++++--- 1 file changed, 89 insertions(+), 15 deletions(-) diff --git a/Assets/Scripts/Editor/ExcelTool/DataConfig/DataConfigWindow.cs b/Assets/Scripts/Editor/ExcelTool/DataConfig/DataConfigWindow.cs index 7b6355c7de..3b502e9154 100644 --- a/Assets/Scripts/Editor/ExcelTool/DataConfig/DataConfigWindow.cs +++ b/Assets/Scripts/Editor/ExcelTool/DataConfig/DataConfigWindow.cs @@ -1,7 +1,10 @@ using GameCore; +using GameEditor.Util; +using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Linq; using System.Threading; using UnityEditor; using UnityEngine; @@ -13,18 +16,36 @@ namespace GameEditor.Core.DataConfig { static string m_ExcelPath; static string m_BattleConfigPath; + static string m_BattleConfigRootPath; static string m_Bench; static string[] m_Files; static bool[] m_Choose; static string shellPath; + static string m_CurGitBench; + static string m_CurServerBattlePath; + + static Dictionary ServerBattleConfig = new Dictionary(); + //{ + // new string[]{ "china/test", "master_zh_test"}, + // new string[]{ "china/zf_test", "master_zh_online_special"}, + //}; [MenuItem("Data Config/Export")] private static void ShowConfigWin() { + ServerBattleConfig.Clear(); + ServerBattleConfig.Add("china/dev", "test"); + ServerBattleConfig.Add("china/test", "master_zh_test"); + ServerBattleConfig.Add("china/zf_test", "master_zh_online_special"); + m_CurGitBench = GitUtil.GetCurBenchName(); + ServerBattleConfig.TryGetValue(m_CurGitBench, out m_CurServerBattlePath); + m_ExcelPath = EditorPrefs.GetString("m_ExcelPath"); m_BattleConfigPath = EditorPrefs.GetString("m_BattleConfigPath"); + m_BattleConfigRootPath = EditorPrefs.GetString("m_BattleConfigRootPath"); m_Bench = EditorPrefs.GetString("m_Bench"); + LoadDic(); var win = GetWindow(); @@ -67,11 +88,10 @@ namespace GameEditor.Core.DataConfig // 保存数据 EditorPrefs.SetString("m_ExcelPath", m_ExcelPath); EditorPrefs.SetString("m_BattleConfigPath", m_BattleConfigPath); + EditorPrefs.SetString("m_BattleConfigRootPath",m_BattleConfigRootPath); EditorPrefs.SetString("m_Bench", m_Bench); } - - public static void OpenDirectory(string path) { if (string.IsNullOrEmpty(path)) return; @@ -114,13 +134,13 @@ namespace GameEditor.Core.DataConfig p.Close(); } - private string[] battleConfigList = new string[] + private static string[] battleConfigList = new string[] { "PassiveSkillLogicConfig", "HardStage", "HardStageCondition", }; - + public static bool isUpDateOnline = false; private void OnGUI() { @@ -168,25 +188,73 @@ namespace GameEditor.Core.DataConfig // 导表 DataConfigWindow.excelALLConfig(true, m_Bench + "/base_data"); } + if(m_CurServerBattlePath!= null) + { + EditorGUILayout.LabelField("战斗数据表同步根路径:"); + m_BattleConfigRootPath = EditorGUILayout.TextField("", m_BattleConfigRootPath); + EditorGUILayout.LabelField("目标战斗校验服文件夹为:"+m_CurServerBattlePath); + if (GUILayout.Button("同步到战斗校验服并提交", GUILayout.Height(40f))) + { + UpdateSVNBattleData(); + SaveLocalConfig(); + // 导表 + //isUpDateOnline = true; + //DataConfigWindow.excelALLConfig(false, m_Bench + "/base_data"); + + } + } EditorGUILayout.LabelField("战斗数据表同步路径:"); m_BattleConfigPath = EditorGUILayout.TextField("", m_BattleConfigPath); + + if (GUILayout.Button("同步战斗数据表", GUILayout.Height(40f))) { - string sourcePath = Application.dataPath + "/ManagedResources/~lua/Config/Data/"; - for(int i = 0; i < battleConfigList.Length; i++) - { - string luaFile = sourcePath + battleConfigList[i] + ".lua"; - string targetPath = m_BattleConfigPath +"/"+ battleConfigList[i] + ".lua"; - UnityEngine.Debug.Log(battleConfigList[i]); - File.Copy(luaFile, targetPath, true); - } - // 同步 - UnityEngine.Debug.Log("同步成功"); + CopyBattleFiles(m_BattleConfigPath); // 保存数据 SaveLocalConfig(); } } + + void UpdateSVNBattleData() + { + string targetPath = Path.Combine(m_BattleConfigRootPath, m_CurServerBattlePath); + string svnPath = targetPath + "\\Modules"; + // 拉取一次 + ProcessUtil.ProcessCommand(svnPath, "svn update"); + // + CopyBattleFiles(targetPath + "/Modules/Battle/Config/Data"); + // + string PackTime = DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss"); + string commitMsg = string.Format("{0}同步数据表{1}", m_CurServerBattlePath, PackTime); + // 重写Readme文件 + string readMePath = svnPath + "/Battle/Readme.txt"; + string[] flines = File.ReadAllLines(readMePath, System.Text.Encoding.UTF8); + List wlines = flines.ToList(); + wlines.Insert(0, commitMsg); + File.WriteAllLines(readMePath, wlines.ToArray(), System.Text.Encoding.UTF8); + + // 提交到SVN + //ProcessUtil.ProcessCommand(svnPath, "svn add . --force"); + ProcessUtil.ProcessCommand(svnPath, "svn commit -m " + commitMsg); + UnityEngine.Debug.Log("同步SVN完成!"); + } + + // 将战斗相关数据表文件同步到目标文件夹 + void CopyBattleFiles(string targetPath) + { + UnityEngine.Debug.Log("同步战斗文件到目标路径:"+ targetPath); + string sourcePath = Application.dataPath + "/ManagedResources/~lua/Config/Data/"; + for (int i = 0; i < battleConfigList.Length; i++) + { + string luaFile = sourcePath + battleConfigList[i] + ".lua"; + string path = targetPath + "/" + battleConfigList[i] + ".lua"; + UnityEngine.Debug.Log(battleConfigList[i]); + File.Copy(luaFile, path, true); + } + // 同步 + UnityEngine.Debug.Log("同步完成!"); + } } @@ -287,6 +355,12 @@ namespace GameEditor.Core.DataConfig UnityEngine.Debug.LogError("耗时:" + time.ElapsedMilliseconds); EditorUtil.ShowSureDialog("配置表数据导入完毕!"); + //if (ConfigExportWindow.isUpDateOnline) + //{ + // ConfigExportWindow.UpdateSVNBattleData(); + // ConfigExportWindow.isUpDateOnline = false; + //} + } }; @@ -347,7 +421,7 @@ namespace GameEditor.Core.DataConfig { excelALLConfig(true, DataConfigSetting.execlDir); } - + private static void exportSheet(DataConfigSetting setting, string path, bool isIncrement) { string fileExt = Path.GetExtension(path).ToLower();