简化流程,删除其他表

This commit is contained in:
zhang hongbo 2026-01-15 16:22:02 +08:00
parent fa94321db6
commit 1c9c361f99
88 changed files with 229 additions and 230 deletions

View File

@ -18,7 +18,7 @@ import openpyxl
from datetime import datetime
# 版本号
VERSION = "v2.1.4 (AllConfigs字段名使用PascalCase)"
VERSION = "v2.2.0 (简化路径配置)"
class IntegratedPipeline:
def __init__(self, root):
@ -26,16 +26,17 @@ class IntegratedPipeline:
self.root.title(f"Thrift 完整流程工具 - {VERSION}")
self.root.geometry("1200x950")
# 配置路径
self.cfg_json_path = ""
self.compiler_path = ""
self.thrift_dir = ""
self.csharp_output_dir = ""
self.bytes_output_dir = ""
self.config_dir = "" # xlsx 文件夹
self.unity_csharp_dir = ""
self.unity_bytes_dir = ""
self.dr_output_dir = "" # DR 文件输出路径
# 配置路径 - 只需要两个基础路径
self.docs_path = "" # Docs 项目路径
self.main_project_path = "" # Unity 主项目路径
# 获取当前工具所在的项目根目录thrift-related
if getattr(sys, 'frozen', False):
# exe 模式
self.tool_root = Path(sys.executable).parent.parent.parent
else:
# 开发模式 - 当前文件在 PythonWorkSpace/IntegratedTool/
self.tool_root = Path(__file__).parent.parent.parent
# 获取配置文件路径支持exe模式
if getattr(sys, 'frozen', False):
@ -62,15 +63,8 @@ class IntegratedPipeline:
if self.config_file.exists():
with open(self.config_file, 'r', encoding='utf-8') as f:
config = json.load(f)
self.cfg_json_path = config.get('cfg_json_path', '')
self.compiler_path = config.get('compiler_path', '')
self.thrift_dir = config.get('thrift_dir', '')
self.csharp_output_dir = config.get('csharp_output_dir', '')
self.bytes_output_dir = config.get('bytes_output_dir', '')
self.config_dir = config.get('config_dir', '')
self.unity_csharp_dir = config.get('unity_csharp_dir', '')
self.unity_bytes_dir = config.get('unity_bytes_dir', '')
self.dr_output_dir = config.get('dr_output_dir', '')
self.docs_path = config.get('docs_path', '')
self.main_project_path = config.get('main_project_path', '')
except Exception as e:
print(f"加载配置失败: {e}")
@ -78,20 +72,38 @@ class IntegratedPipeline:
"""保存配置"""
try:
config = {
'cfg_json_path': self.cfg_json_path,
'compiler_path': self.compiler_path,
'thrift_dir': self.thrift_dir,
'csharp_output_dir': self.csharp_output_dir,
'bytes_output_dir': self.bytes_output_dir,
'config_dir': self.config_dir,
'unity_csharp_dir': self.unity_csharp_dir,
'unity_bytes_dir': self.unity_bytes_dir,
'dr_output_dir': self.dr_output_dir
'docs_path': self.docs_path,
'main_project_path': self.main_project_path
}
with open(self.config_file, 'w', encoding='utf-8') as f:
json.dump(config, f, indent=2, ensure_ascii=False)
except Exception as e:
print(f"保存配置失败: {e}")
def get_derived_paths(self) -> Dict[str, str]:
"""根据基础路径获取所有派生路径"""
paths = {}
# Docs 相关路径
if self.docs_path:
docs_root = Path(self.docs_path)
paths['cfg_json'] = str(docs_root / "tool" / "cfg" / "cfg_txt.json")
paths['config_dir'] = str(docs_root / "config")
# thrift-related 相关路径(相对路径)
paths['compiler'] = str(self.tool_root / "compiler" / "exe" / "thrift.exe")
paths['thrift_dir'] = str(self.tool_root / "thrift-files" / "meowment")
paths['csharp_output_dir'] = str(self.tool_root / "compiled_output" / "csharp")
paths['bytes_output_dir'] = str(self.tool_root / "binary_output")
# Unity 主项目相关路径
if self.main_project_path:
main_root = Path(self.main_project_path)
paths['unity_csharp_dir'] = str(main_root / "Assets" / "Scripts" / "thrift" / "gen-netstd")
paths['unity_bytes_dir'] = str(main_root / "Assets" / "Resources" / "ConfigData")
paths['dr_output_dir'] = str(main_root / "Assets" / "GameMain" / "Scripts" / "DR_Generated")
return paths
def setup_ui(self):
"""设置UI界面"""
@ -105,67 +117,46 @@ class IntegratedPipeline:
row = 0
# cfg_txt.json
ttk.Label(main_frame, text="cfg_txt.json:").grid(row=row, column=0, sticky=tk.W, pady=5)
self.cfg_json_var = tk.StringVar(value=self.cfg_json_path)
ttk.Entry(main_frame, textvariable=self.cfg_json_var, width=85).grid(row=row, column=1, sticky=(tk.W, tk.E), pady=5, padx=5)
ttk.Button(main_frame, text="选择", command=lambda: self.select_file('cfg_json', 'cfg_txt.json', [("JSON", "*.json")])).grid(row=row, column=2, pady=5)
# 说明文字
info_label = ttk.Label(main_frame, text="只需配置两个基础路径,其他路径将自动推导",
font=("", 10, "bold"), foreground="darkgreen")
info_label.grid(row=row, column=0, columnspan=3, sticky=tk.W, pady=10)
row += 1
# Thrift 编译器
ttk.Label(main_frame, text="Thrift 编译器:").grid(row=row, column=0, sticky=tk.W, pady=5)
self.compiler_var = tk.StringVar(value=self.compiler_path)
ttk.Entry(main_frame, textvariable=self.compiler_var, width=85).grid(row=row, column=1, sticky=(tk.W, tk.E), pady=5, padx=5)
ttk.Button(main_frame, text="选择", command=lambda: self.select_file('compiler', 'Thrift编译器', [("EXE", "*.exe")])).grid(row=row, column=2, pady=5)
# Docs 项目路径
ttk.Label(main_frame, text="Docs 项目路径:").grid(row=row, column=0, sticky=tk.W, pady=5)
self.docs_path_var = tk.StringVar(value=self.docs_path)
ttk.Entry(main_frame, textvariable=self.docs_path_var, width=85).grid(row=row, column=1, sticky=(tk.W, tk.E), pady=5, padx=5)
ttk.Button(main_frame, text="选择", command=lambda: self.select_directory('docs_path', 'Docs项目路径')).grid(row=row, column=2, pady=5)
row += 1
# Thrift 文件路径
ttk.Label(main_frame, text="Thrift 文件路径:").grid(row=row, column=0, sticky=tk.W, pady=5)
self.thrift_dir_var = tk.StringVar(value=self.thrift_dir)
ttk.Entry(main_frame, textvariable=self.thrift_dir_var, width=85).grid(row=row, column=1, sticky=(tk.W, tk.E), pady=5, padx=5)
ttk.Button(main_frame, text="选择", command=lambda: self.select_directory('thrift_dir', 'Thrift文件路径')).grid(row=row, column=2, pady=5)
# Unity 主项目路径
ttk.Label(main_frame, text="Unity 主项目路径:").grid(row=row, column=0, sticky=tk.W, pady=5)
self.main_project_path_var = tk.StringVar(value=self.main_project_path)
ttk.Entry(main_frame, textvariable=self.main_project_path_var, width=85).grid(row=row, column=1, sticky=(tk.W, tk.E), pady=5, padx=5)
ttk.Button(main_frame, text="选择", command=lambda: self.select_directory('main_project_path', 'Unity主项目路径')).grid(row=row, column=2, pady=5)
row += 1
# C# 输出路径
ttk.Label(main_frame, text="C# 输出路径:").grid(row=row, column=0, sticky=tk.W, pady=5)
self.csharp_output_dir_var = tk.StringVar(value=self.csharp_output_dir)
ttk.Entry(main_frame, textvariable=self.csharp_output_dir_var, width=85).grid(row=row, column=1, sticky=(tk.W, tk.E), pady=5, padx=5)
ttk.Button(main_frame, text="选择", command=lambda: self.select_directory('csharp_output_dir', 'C#输出路径')).grid(row=row, column=2, pady=5)
# 分隔线
separator = ttk.Separator(main_frame, orient='horizontal')
separator.grid(row=row, column=0, columnspan=3, sticky=(tk.W, tk.E), pady=15)
row += 1
# Bytes 输出路径
ttk.Label(main_frame, text="Bytes 输出路径:").grid(row=row, column=0, sticky=tk.W, pady=5)
self.bytes_output_dir_var = tk.StringVar(value=self.bytes_output_dir)
ttk.Entry(main_frame, textvariable=self.bytes_output_dir_var, width=85).grid(row=row, column=1, sticky=(tk.W, tk.E), pady=5, padx=5)
ttk.Button(main_frame, text="选择", command=lambda: self.select_directory('bytes_output_dir', 'Bytes输出路径')).grid(row=row, column=2, pady=5)
# 派生路径预览标题
preview_label = ttk.Label(main_frame, text="派生路径预览(自动生成):",
font=("", 9, "bold"), foreground="navy")
preview_label.grid(row=row, column=0, columnspan=3, sticky=tk.W, pady=5)
row += 1
# Config 路径 (xlsx)
ttk.Label(main_frame, text="Config 路径 (xlsx):").grid(row=row, column=0, sticky=tk.W, pady=5)
self.config_dir_var = tk.StringVar(value=self.config_dir)
ttk.Entry(main_frame, textvariable=self.config_dir_var, width=85).grid(row=row, column=1, sticky=(tk.W, tk.E), pady=5, padx=5)
ttk.Button(main_frame, text="选择", command=lambda: self.select_directory('config_dir', 'Config路径')).grid(row=row, column=2, pady=5)
# 派生路径显示区域
self.preview_text = scrolledtext.ScrolledText(main_frame, width=140, height=10,
wrap=tk.WORD, font=("", 8),
state=tk.DISABLED, bg="#f0f0f0")
self.preview_text.grid(row=row, column=0, columnspan=3, sticky=(tk.W, tk.E), pady=5)
row += 1
# Unity C# 路径
ttk.Label(main_frame, text="Unity C# 路径:").grid(row=row, column=0, sticky=tk.W, pady=5)
self.unity_csharp_dir_var = tk.StringVar(value=self.unity_csharp_dir)
ttk.Entry(main_frame, textvariable=self.unity_csharp_dir_var, width=85).grid(row=row, column=1, sticky=(tk.W, tk.E), pady=5, padx=5)
ttk.Button(main_frame, text="选择", command=lambda: self.select_directory('unity_csharp_dir', 'Unity C#路径')).grid(row=row, column=2, pady=5)
row += 1
# Unity Bytes 路径
ttk.Label(main_frame, text="Unity Bytes 路径:").grid(row=row, column=0, sticky=tk.W, pady=5)
self.unity_bytes_dir_var = tk.StringVar(value=self.unity_bytes_dir)
ttk.Entry(main_frame, textvariable=self.unity_bytes_dir_var, width=85).grid(row=row, column=1, sticky=(tk.W, tk.E), pady=5, padx=5)
ttk.Button(main_frame, text="选择", command=lambda: self.select_directory('unity_bytes_dir', 'Unity Bytes路径')).grid(row=row, column=2, pady=5)
row += 1
# DR 输出路径
ttk.Label(main_frame, text="DR 输出路径:").grid(row=row, column=0, sticky=tk.W, pady=5)
self.dr_output_dir_var = tk.StringVar(value=self.dr_output_dir)
ttk.Entry(main_frame, textvariable=self.dr_output_dir_var, width=85).grid(row=row, column=1, sticky=(tk.W, tk.E), pady=5, padx=5)
ttk.Button(main_frame, text="选择", command=lambda: self.select_directory('dr_output_dir', 'DR输出路径')).grid(row=row, column=2, pady=5)
# 更新预览按钮
ttk.Button(main_frame, text="刷新路径预览", command=self.update_path_preview).grid(row=row, column=0, columnspan=3, pady=10)
row += 1
# 开始按钮
@ -184,17 +175,6 @@ class IntegratedPipeline:
self.log_text = scrolledtext.ScrolledText(main_frame, width=140, height=30, wrap=tk.WORD, font=("Consolas", 9))
self.log_text.grid(row=row, column=0, columnspan=3, sticky=(tk.W, tk.E, tk.N, tk.S), pady=5)
def select_file(self, attr_name: str, title: str, filetypes: List):
"""选择文件"""
current_val = getattr(self, attr_name + '_path')
initialdir = os.path.dirname(current_val) if current_val else None
file_path = filedialog.askopenfilename(title=f"选择{title}", initialdir=initialdir, filetypes=filetypes)
if file_path:
setattr(self, attr_name + '_path', file_path)
getattr(self, attr_name + '_var').set(file_path)
self.save_config()
self.log(f"[OK] 已选择 {title}: {file_path}\n")
def select_directory(self, attr_name: str, title: str):
"""选择目录"""
current_val = getattr(self, attr_name)
@ -205,6 +185,35 @@ class IntegratedPipeline:
getattr(self, attr_name + '_var').set(dir_path)
self.save_config()
self.log(f"[OK] 已选择 {title}: {dir_path}\n")
self.update_path_preview()
def update_path_preview(self):
"""更新路径预览"""
self.preview_text.config(state=tk.NORMAL)
self.preview_text.delete(1.0, tk.END)
paths = self.get_derived_paths()
preview_lines = []
preview_lines.append("📁 Docs 项目相关路径:")
preview_lines.append(f" • cfg_txt.json: {paths.get('cfg_json', '未配置')}")
preview_lines.append(f" • Config 目录 (xlsx): {paths.get('config_dir', '未配置')}")
preview_lines.append("")
preview_lines.append("📁 thrift-related 项目相关路径 (相对路径):")
preview_lines.append(f" • Thrift 编译器: {paths.get('compiler', '')}")
preview_lines.append(f" • Thrift 文件目录: {paths.get('thrift_dir', '')}")
preview_lines.append(f" • C# 输出目录: {paths.get('csharp_output_dir', '')}")
preview_lines.append(f" • Bytes 输出目录: {paths.get('bytes_output_dir', '')}")
preview_lines.append("")
preview_lines.append("📁 Unity 主项目相关路径:")
preview_lines.append(f" • Unity C# 目录: {paths.get('unity_csharp_dir', '未配置')}")
preview_lines.append(f" • Unity Bytes 目录: {paths.get('unity_bytes_dir', '未配置')}")
preview_lines.append(f" • DR 生成目录: {paths.get('dr_output_dir', '未配置')}")
self.preview_text.insert(tk.END, "\n".join(preview_lines))
self.preview_text.config(state=tk.DISABLED)
def log(self, message: str):
"""输出日志"""
@ -369,20 +378,30 @@ class IntegratedPipeline:
report_lines.append("="*100)
report_lines.append(" 配置路径信息")
report_lines.append("="*100)
report_lines.append("📁 输入路径:")
report_lines.append(f" • cfg_txt.json: {self.cfg_json_path}")
report_lines.append(f" • Thrift 编译器: {self.compiler_path}")
report_lines.append(f" • Thrift 文件目录: {self.thrift_dir}")
paths = self.get_derived_paths()
report_lines.append("📁 基础路径:")
report_lines.append(f" • Docs 项目: {self.docs_path}")
report_lines.append(f" • Unity 主项目: {self.main_project_path}")
report_lines.append("")
report_lines.append("📁 生成路径:")
report_lines.append(f" • C# 输出根目录: {self.csharp_output_dir}")
report_lines.append(f"C# 实际目录: {os.path.join(self.csharp_output_dir, 'Byway', 'Thrift', 'Data')}")
report_lines.append(f"Bytes 输出目录: {self.bytes_output_dir}")
report_lines.append("📁 Docs 派生路径:")
report_lines.append(f"cfg_txt.json: {paths.get('cfg_json', '')}")
report_lines.append(f"Config 目录: {paths.get('config_dir', '')}")
report_lines.append("")
report_lines.append("📁 Unity目标路径:")
report_lines.append(f" • Unity C# 根目录: {self.unity_csharp_dir}")
report_lines.append(f" • Unity C# 实际目录: {os.path.join(self.unity_csharp_dir, 'Byway', 'Thrift', 'Data')}")
report_lines.append(f" • Unity Bytes 目录: {self.unity_bytes_dir}")
report_lines.append("📁 thrift-related 派生路径 (相对路径):")
report_lines.append(f" • Thrift 编译器: {paths.get('compiler', '')}")
report_lines.append(f" • Thrift 文件目录: {paths.get('thrift_dir', '')}")
report_lines.append(f" • C# 输出目录: {paths.get('csharp_output_dir', '')}")
report_lines.append(f" • Bytes 输出目录: {paths.get('bytes_output_dir', '')}")
report_lines.append("")
report_lines.append("📁 Unity 派生路径:")
report_lines.append(f" • Unity C# 目录: {paths.get('unity_csharp_dir', '')}")
report_lines.append(f" • Unity Bytes 目录: {paths.get('unity_bytes_dir', '')}")
report_lines.append(f" • DR 生成目录: {paths.get('dr_output_dir', '')}")
report_lines.append("="*100)
return "\n".join(report_lines)
@ -391,32 +410,29 @@ class IntegratedPipeline:
"""验证所有路径"""
errors = []
if not self.cfg_json_path or not os.path.exists(self.cfg_json_path):
errors.append("❌ cfg_txt.json 文件不存在或未选择")
# 验证基础路径
if not self.docs_path:
errors.append("❌ 请选择 Docs 项目路径")
if not self.compiler_path or not os.path.exists(self.compiler_path):
errors.append("Thrift 编译器不存在或未选择")
if not self.main_project_path:
errors.append("请选择 Unity 主项目路径")
if not self.thrift_dir:
errors.append("❌ 请选择 Thrift 文件路径")
# 获取派生路径并验证
paths = self.get_derived_paths()
if not self.csharp_output_dir:
errors.append("❌ 请选择 C# 输出路径")
if self.docs_path:
if 'cfg_json' in paths and not os.path.exists(paths['cfg_json']):
errors.append(f"❌ cfg_txt.json 文件不存在: {paths['cfg_json']}")
if 'config_dir' in paths and not os.path.exists(paths['config_dir']):
errors.append(f"❌ Config 目录不存在: {paths['config_dir']}")
if not self.bytes_output_dir:
errors.append("❌ 请选择 Bytes 输出路径")
# 验证 thrift-related 相关路径
if not os.path.exists(paths.get('compiler', '')):
errors.append(f"❌ Thrift 编译器不存在: {paths.get('compiler', '')}")
if not self.config_dir or not os.path.exists(self.config_dir):
errors.append("❌ Config 路径Excel文件夹不存在或未选择")
if not self.unity_csharp_dir:
errors.append("❌ 请选择 Unity C# 路径")
if not self.unity_bytes_dir:
errors.append("❌ 请选择 Unity Bytes 路径")
if not self.dr_output_dir:
errors.append("❌ 请选择 DR 输出路径")
if not os.path.exists(paths.get('thrift_dir', '')):
errors.append(f"❌ Thrift 文件目录不存在: {paths.get('thrift_dir', '')}")
if errors:
error_msg = "\n".join(errors)
@ -429,6 +445,18 @@ class IntegratedPipeline:
"""执行完整流程"""
if not self.validate_paths():
return
# 获取所有派生路径
paths = self.get_derived_paths()
self.cfg_json_path = paths.get('cfg_json', '')
self.compiler_path = paths.get('compiler', '')
self.thrift_dir = paths.get('thrift_dir', '')
self.csharp_output_dir = paths.get('csharp_output_dir', '')
self.bytes_output_dir = paths.get('bytes_output_dir', '')
self.config_dir = paths.get('config_dir', '')
self.unity_csharp_dir = paths.get('unity_csharp_dir', '')
self.unity_bytes_dir = paths.get('unity_bytes_dir', '')
self.dr_output_dir = paths.get('dr_output_dir', '')
self.clear_log()
self.report = {'start_time': datetime.now().strftime('%Y-%m-%d %H:%M:%S'), 'end_time': None, 'steps': []}
@ -820,6 +848,10 @@ class IntegratedPipeline:
self.log(f" 找到 {len(file_list)} 个配置项\n\n")
# 注意:现在只生成 AllConfigs.bytes不生成单个配置的 bytes 文件
self.log(f" 新策略:只生成 AllConfigs.bytes合并文件跳过单个 bytes 文件生成\n\n")
# 收集所有成功处理的配置名称,用于生成 AllConfigs
for idx, config_item in enumerate(file_list, 1):
in_file = config_item.get('in_file', '')
out_file = config_item.get('out_file', '')
@ -834,11 +866,11 @@ class IntegratedPipeline:
struct_name = out_file.replace('.txt', '')
excel_path = os.path.join(self.config_dir, in_file)
# 原始:显示处理进度
self.log(f" [{idx}/{len(file_list)}] 处理: {in_file} -> {struct_name}\n")
# 原始:显示处理进度只验证配置不生成单个bytes
self.log(f" [{idx}/{len(file_list)}] 验证: {in_file} -> {struct_name}\n")
try:
# 动态导入模块
# 动态导入模块(只验证结构体存在)
module_name = f"{struct_name}.ttypes"
ttypes_module = importlib.import_module(module_name)
item_class = getattr(ttypes_module, f"{struct_name}Item")
@ -964,18 +996,8 @@ class IntegratedPipeline:
setattr(container, f"{struct_name.lower()}s", container_items)
# 序列化
transport = TTransport.TMemoryBuffer()
protocol = TBinaryProtocol.TBinaryProtocol(transport)
container.write(protocol)
binary_data = transport.getvalue()
# 写入文件
bytes_path = os.path.join(self.bytes_output_dir, f"{struct_name}.bytes")
with open(bytes_path, 'wb') as f:
f.write(binary_data)
self.log(f" [OK] {struct_name}.bytes ({len(binary_data)} bytes)\n")
# 不再生成单个 bytes 文件,只验证配置可以成功处理
self.log(f" [OK] {struct_name} 验证通过(数据行数: {len(data_rows)}\n")
success_count += 1
success_list.append(struct_name)
@ -1000,22 +1022,23 @@ class IntegratedPipeline:
for failed in failed_list:
self.log(f" - {failed['name']}: {failed['error'][:100]}\n")
# 生成 AllConfigs.bytes合并所有配置到一个文件)
# 生成 AllConfigs.bytes唯一的 bytes 文件)
self.log(f"\n生成 AllConfigs.bytes合并所有配置...\n")
allconfigs_generated = False
if self.generate_all_configs_bytes(success_list):
self.log(f" [OK] AllConfigs.bytes 生成成功\n")
success_list.append('AllConfigs') # 添加到成功列表
success_count += 1 # 计数+1
allconfigs_generated = True
else:
self.log(f" ⚠ AllConfigs.bytes 生成失败但不影响单独的bytes文件\n")
self.log(f" [FAIL] AllConfigs.bytes 生成失败\n")
# 保存成功生成的列表供步骤6使用必须在AllConfigs添加之后
self.generated_bytes_list = success_list
# 只保存 AllConfigs 到列表供步骤6使用
self.generated_bytes_list = ['AllConfigs'] if allconfigs_generated else []
# 最终统计AllConfigs已包含
self.log(f"\n✅ 生成完成: {success_count} 个 bytes 文件({success_count - 1} 个独立配置 + 1 个合并文件)\n")
# 最终统计
if allconfigs_generated:
self.log(f"\n✅ 生成完成: AllConfigs.bytes包含 {success_count} 个配置)\n")
else:
self.log(f"\n❌ 生成失败\n")
self.add_step_report("生成Bytes文件", "success", {
"success": success_count,
@ -1147,34 +1170,31 @@ class IntegratedPipeline:
self.log(f" 源目录: {self.bytes_output_dir}\n")
self.log(f" 目标目录: {self.unity_bytes_dir}\n")
self.log(f" 预期文件: {len(self.generated_bytes_list)} 个 (步骤3成功生成的)\n\n")
self.log(f" 只复制 AllConfigs.bytes\n\n")
# 只复制步骤3中成功生成的bytes文件
bytes_to_copy = {f"{name}.bytes" for name in self.generated_bytes_list}
# 只复制 AllConfigs.bytes
allconfigs_file = 'AllConfigs.bytes'
allconfigs_src = os.path.join(self.bytes_output_dir, allconfigs_file)
for file in os.listdir(self.bytes_output_dir):
if file.endswith('.bytes'):
if file in bytes_to_copy:
src = os.path.join(self.bytes_output_dir, file)
dst = os.path.join(self.unity_bytes_dir, file)
shutil.copy2(src, dst)
copied_files.append(file)
copied_count += 1
# 标记 AllConfigs
if file == 'AllConfigs.bytes':
self.log(f" [OK] {file} [合并文件-主力]\n")
else:
self.log(f" [OK] {file}\n")
else:
skipped_files.append(file)
self.log(f" → 跳过: {file} (不在成功生成列表中)\n")
if os.path.exists(allconfigs_src):
allconfigs_dst = os.path.join(self.unity_bytes_dir, allconfigs_file)
shutil.copy2(allconfigs_src, allconfigs_dst)
copied_files.append(allconfigs_file)
copied_count = 1
self.log(f" [OK] {allconfigs_file} [唯一的配置文件]\n")
else:
self.log(f" [FAIL] 未找到 {allconfigs_file}\n")
# 列出所有其他 bytes 文件(已废弃)
other_bytes = [f for f in os.listdir(self.bytes_output_dir)
if f.endswith('.bytes') and f != allconfigs_file]
if other_bytes:
self.log(f"\n 发现 {len(other_bytes)} 个其他 bytes 文件(已废弃,不复制):\n")
for f in other_bytes:
self.log(f" - {f}\n")
self.log(f"\n复制完成: {copied_count} 个 bytes 文件\n")
# 验证数量一致性
if copied_count != len(self.generated_bytes_list):
self.log(f" ⚠ 警告: 复制数量({copied_count})与生成数量({len(self.generated_bytes_list)})不一致!\n")
self.add_step_report("复制Bytes到Unity", "success", {
"count": copied_count,
"expected": len(self.generated_bytes_list),

View File

@ -1,11 +1,4 @@
{
"cfg_json_path": "E:/WorkSpace/Docs/tool/cfg/cfg_txt.json",
"compiler_path": "E:/WorkSpace/thrift-related/compiler/exe/thrift.exe",
"thrift_dir": "E:/WorkSpace/thrift-related/thrift-files/meowment",
"csharp_output_dir": "E:/WorkSpace/thrift-related/compiled_output/csharp",
"bytes_output_dir": "E:/WorkSpace/thrift-related/binary_output",
"config_dir": "E:/WorkSpace/Docs/config",
"unity_csharp_dir": "E:/WorkSpace/MeowMent_New/Assets/Scripts/thrift/gen-netstd",
"unity_bytes_dir": "E:/WorkSpace/MeowMent_New/Assets/Resources/ConfigData",
"dr_output_dir": "E:/WorkSpace/MeowMent_New/Assets/GameMain/Scripts/DR_Generated"
"docs_path": "E:/WorkSpace/Docs",
"main_project_path": "E:/WorkSpace/MeowMent_New"
}

View File

@ -4,67 +4,43 @@
**选择完路径后,下次打开工具会默认选择上次选择的位置。**
## 版本更新说明
**v2.2.0 新特性:**
- ✨ 简化路径配置,只需配置两个基础路径
- 🔧 其他路径自动推导,无需手动选择
- 📁 thrift-related 项目路径使用相对路径
## 路径配置说明
请按照以下说明配置各个路径:
### 只需配置两个基础路径
### 1. cfg_txt.json 路径
选择 Docs 项目中的配置文件:
```
Docs/tool/cfg/cfg_txt.json
```
#### 1. Docs 项目路径
选择您的 Docs 项目根目录,工具将自动推导:
- `Docs/tool/cfg/cfg_txt.json` (配置文件)
- `Docs/config` (Excel 配置文件目录)
### 2. Thrift 编译器路径
选择 thrift-related 项目中的编译器
```
thrift-related/compiler/exe/thrift.exe
```
#### 2. Unity 主项目路径
选择您的 Unity 主项目根目录例如MeowMent_New工具将自动推导
- `MeowMent_New/Assets/Scripts/thrift/gen-netstd` (C# 代码目录)
- `MeowMent_New/Assets/Resources/ConfigData` (Bytes 资源目录)
- `MeowMent_New/Assets/GameMain/Scripts/DR_Generated` (DR 生成代码目录)
### 3. Thrift 文件路径
选择 thrift 源文件目录:
```
thrift-related/thrift-files/meowment
```
### 自动推导的路径(无需配置)
### 4. C# 输出路径
选择编译后的 C# 代码输出目录:
```
thrift-related/compiled_output/csharp
```
以下路径由工具自动确定,无需手动选择:
### 5. Bytes 输出路径
选择二进制文件输出目录:
```
thrift-related/binary_output
```
### 6. Config 路径
选择配置文件目录:
```
Docs/config
```
### 7. Unity C# 路径
选择 Unity 主项目中的 C# 代码目录:
```
主项目/Assets/Scripts/thrift/gen-netstd
```
### 8. Unity Bytes 路径
选择 Unity 主项目中的资源数据目录:
```
主项目/Assets/Resources/ConfigData
```
### 9. DR 输出路径
选择 Unity 主项目中的 DR 生成代码目录:
```
主项目/Assets/GameMain/Scripts/DR_Generated
```
#### thrift-related 项目相关(相对路径)
- Thrift 编译器: `thrift-related/compiler/exe/thrift.exe`
- Thrift 文件目录: `thrift-related/thrift-files/meowment`
- C# 输出目录: `thrift-related/compiled_output/csharp`
- Bytes 输出目录: `thrift-related/binary_output`
## 执行流程
配置完所有路径后,点击 **"开始执行完整流程"** 按钮。
配置完两个基础路径后,点击 **"刷新路径预览"** 查看所有派生路径。
确认路径无误后,点击 **"开始执行完整流程"** 按钮。
工具将自动完成以下步骤:
1. 编译 Thrift 文件
@ -75,8 +51,18 @@ Docs/config
## 故障排查
如果执行过程中出现问题,请查看 **错误日志** 获取详细的错误信息。
如果执行过程中出现问题,请查看 **执行日志** 获取详细的错误信息。
### 常见问题
1. **路径不存在错误**
- 检查 Docs 项目路径是否正确
- 确认 Docs 项目内包含 `tool/cfg/cfg_txt.json``config` 目录
2. **Unity 项目路径错误**
- 确认选择的是 Unity 项目根目录(包含 Assets 文件夹的目录)
- 检查项目内是否存在所需的目标目录结构
---
**注意:** 确保所有路径都存在且可访问,否则流程可能会失败。
**注意:** 确保所有派生路径都存在且可访问,否则流程可能会失败。

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.