扩充道具系统并统一图标命名规范
- 为 20 个道具赋予中文名称(铁护腕、狂战士药剂等)
- 移除数据表 IconAssetName 列,改为按 `类型_{id}_icon`
的命名约定自动推导图标路径
- 清理旧图标资源(Almighty_Icon、172 系列)
- 同步更新各数据表 Excel 源文件
This commit is contained in:
+23
-36
@@ -1,51 +1,38 @@
|
||||
import pandas as pd
|
||||
import pandas as pd
|
||||
import os
|
||||
def format_cell(value):
|
||||
if value is None:
|
||||
return ''
|
||||
return str(value)
|
||||
|
||||
def convert_excel_to_txt(folder_path='.'):
|
||||
# 计数器,用于最后汇总
|
||||
count = 0
|
||||
# 固定从脚本所在目录读取,避免受运行时工作目录影响
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
scan_dir = script_dir if folder_path in ('.', '') else os.path.abspath(folder_path)
|
||||
target_dir = os.path.join(os.path.dirname(__file__), '../Assets/GameMain/DataTables')
|
||||
target_dir = os.path.abspath(target_dir)
|
||||
|
||||
# 确保目标目录存在
|
||||
os.makedirs(target_dir, exist_ok=True)
|
||||
|
||||
for root, _, files in os.walk(scan_dir):
|
||||
for file_name in files:
|
||||
# 跳过 Excel 打开时生成的临时锁文件
|
||||
if file_name.startswith('~$'):
|
||||
for dirpath, _, filenames in os.walk(folder_path):
|
||||
for file_name in filenames:
|
||||
if not file_name.endswith(('.xlsx', '.xls')):
|
||||
continue
|
||||
if file_name.endswith(('.xlsx', '.xls')):
|
||||
file_path = os.path.join(root, file_name)
|
||||
base_name = os.path.splitext(file_name)[0]
|
||||
output_file = os.path.join(target_dir, f"{base_name}.txt")
|
||||
|
||||
print(f"正在处理: {file_path}...")
|
||||
|
||||
try:
|
||||
# 读取 Excel
|
||||
df = pd.read_excel(
|
||||
file_path,
|
||||
header=None,
|
||||
keep_default_na=False,
|
||||
)
|
||||
file_path = os.path.join(dirpath, file_name)
|
||||
txt_name = os.path.splitext(file_name)[0] + '.txt'
|
||||
target_file = os.path.join(target_dir, txt_name)
|
||||
|
||||
with open(output_file, 'w', encoding='utf-8', newline='') as f:
|
||||
for row in df.itertuples(index=False, name=None):
|
||||
f.write('\t'.join(format_cell(cell) for cell in row) + '\n')
|
||||
|
||||
print(f"成功转换 -> {output_file}")
|
||||
count += 1
|
||||
|
||||
except Exception as e:
|
||||
print(f"处理 {file_path} 时出错: {e}")
|
||||
print(f"正在处理: {file_name}...")
|
||||
|
||||
try:
|
||||
df = pd.read_excel(file_path, header=None, keep_default_na=False)
|
||||
|
||||
with open(target_file, 'w', encoding='utf-8', newline='') as f:
|
||||
for row in df.itertuples(index=False):
|
||||
line = '\t'.join('' if cell is None else str(cell) for cell in row)
|
||||
f.write(line + '\n')
|
||||
|
||||
print(f"成功转换 -> {target_file}")
|
||||
count += 1
|
||||
|
||||
except Exception as e:
|
||||
print(f"处理 {file_name} 时出错: {e}")
|
||||
|
||||
print(f"\n任务完成!共转换了 {count} 个文件。")
|
||||
|
||||
@@ -54,4 +41,4 @@ if __name__ == "__main__":
|
||||
|
||||
# --- 关键修改:在这里添加暂停 ---
|
||||
print("\n" + "="*30)
|
||||
input("按回车键(Enter)退出程序...")
|
||||
input("按回车键(Enter)退出程序...")
|
||||
Reference in New Issue
Block a user