-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
增加自制模组生成器
- Loading branch information
Showing
20 changed files
with
271 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# dol美化模组自动生成器 | ||
由北极星制作的傻瓜版模组生成器,用于生成可供modloader加载的模组包,仅支持纯美化模组。 | ||
|
||
使用方法: | ||
|
||
1.将美化img文件夹复制到此目录,和目录中的img文件夹合并。 | ||
|
||
2.如果安装有python环境,请双击"dol美化模组自动生成器.py"启动。 | ||
|
||
3.如果没有python环境,请双击"dol美化模组自动生成器.exe"启动。 | ||
|
||
4.按照提示填写你要制作的模组名称和版本号。 | ||
|
||
5.回车,等到看到"模组生成完成"字样就已成功。 | ||
|
||
6.此目录下会生成.zip压缩文件,这就是做好的模组包。 | ||
|
||
ps.制作新模组时,记得删除原有的img文件夹。 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import os | ||
import json | ||
import zipfile | ||
|
||
def zip_files_and_folders(file_paths, zip_name): | ||
with zipfile.ZipFile(zip_name, 'w', zipfile.ZIP_DEFLATED) as zipf: | ||
for file_path in file_paths: | ||
if os.path.isdir(file_path): | ||
for root, dirs, files in os.walk(file_path): | ||
for file in files: | ||
zipf.write(os.path.join(root, file), os.path.relpath(os.path.join(root, file), os.path.dirname(file_path))) | ||
else: | ||
zipf.write(file_path, os.path.basename(file_path)) | ||
|
||
def list_files_and_subdirectories(directory, output_dict): | ||
for root, dirs, files in os.walk(directory): | ||
for file in files: | ||
file_path = os.path.relpath(os.path.join(root, file), directory) | ||
if not file_path.endswith('png') and not file_path.endswith('gif'): | ||
output_dict["additionFile"].append('img/' + file_path.replace("\\", "/")) | ||
else: | ||
output_dict["imgFileList"].append('img/' + file_path.replace("\\", "/")) | ||
|
||
os.makedirs('img', exist_ok=True) | ||
output_dict = {} | ||
output_dict['name'] = input('请输入模组名称:') | ||
output_dict['version'] = input('请输入类似于1.0.0的模组版本号:') | ||
print(f'模组生成中请稍等...') | ||
output_dict['styleFileList'] = [] | ||
output_dict['scriptFileList'] = [] | ||
output_dict['tweeFileList'] = [] | ||
output_dict['additionFile'] = [] | ||
output_dict['imgFileList'] = [] | ||
list_files_and_subdirectories('img', output_dict) | ||
output_dict['addonPlugin'] = [ | ||
{ | ||
"modName": "ModLoader DoL ImageLoaderHook", | ||
"addonName": "ImageLoaderAddon", | ||
"modVersion": "^2.3.0", | ||
"params": [ | ||
] | ||
} | ||
] | ||
output_dict['dependenceInfo'] = [ | ||
{ | ||
"modName": "ModLoader DoL ImageLoaderHook", | ||
"version": "^2.3.0" | ||
} | ||
] | ||
|
||
# 将内容输出到文本文件 | ||
with open('boot.json', 'w', encoding='utf-8') as file: | ||
json.dump(output_dict, file, indent=2, ensure_ascii=False) | ||
|
||
# 要压缩的文件和文件夹路径列表 | ||
file_paths = ['img', 'boot.json'] | ||
# 压缩后的文件名 | ||
zip_name = output_dict['name'] + '.zip' | ||
|
||
zip_files_and_folders(file_paths, zip_name) | ||
os.remove('boot.json') | ||
print(f'模组生成完成: {zip_name}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# dol衣服美化模组自动生成器 | ||
由北极星制作的傻瓜版模组生成器,用于生成可供modloader加载的模组包,支持新增衣物及美化模组。 | ||
|
||
使用方法: | ||
|
||
1.将新衣服的代码,复制粘贴到此目录"clothes"文件夹中,对应种类的json文件中。 | ||
|
||
2.将所需的新img文件夹复制到此目录,和目录中的img文件夹合并。 | ||
|
||
3.如果安装有python环境,请双击"dol衣服美化模组自动生成器.py"启动。 | ||
|
||
4.如果没有python环境,请双击"dol衣服美化模组自动生成器.exe"启动。 | ||
|
||
5.按照提示填写你要制作的模组名称和版本号。 | ||
|
||
6.回车,等到看到"模组生成完成"字样就已成功。 | ||
|
||
7.此目录下会生成.zip压缩文件,这就是做好的模组包。 | ||
|
||
ps.制作新模组时,可以删除clothes文件夹,然后运行生成器可以自动创建初始json文件。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[ | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[ | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[ | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[ | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[ | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[ | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[ | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[ | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[ | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[ | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[ | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[ | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[ | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[ | ||
] |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
import os | ||
import json | ||
import zipfile | ||
|
||
def zip_files_and_folders(file_paths, zip_name): | ||
with zipfile.ZipFile(zip_name, 'w', zipfile.ZIP_DEFLATED) as zipf: | ||
for file_path in file_paths: | ||
if os.path.isdir(file_path): | ||
for root, dirs, files in os.walk(file_path): | ||
for file in files: | ||
zipf.write(os.path.join(root, file), os.path.relpath(os.path.join(root, file), os.path.dirname(file_path))) | ||
else: | ||
zipf.write(file_path, os.path.basename(file_path)) | ||
|
||
def list_files_and_subdirectories(directory, output_dict): | ||
for root, dirs, files in os.walk(directory): | ||
for file in files: | ||
file_path = os.path.relpath(os.path.join(root, file), directory) | ||
if not file_path.endswith('png') and not file_path.endswith('gif'): | ||
output_dict["additionFile"].append('img/' + file_path.replace("\\", "/")) | ||
else: | ||
output_dict["imgFileList"].append('img/' + file_path.replace("\\", "/")) | ||
|
||
def generate_files_with_text(folder_path, file_list): | ||
for filename in file_list: | ||
file_path = os.path.join(folder_path, filename) | ||
with open(file_path, 'w', encoding='utf-8') as file: | ||
file.write('[\n]') | ||
|
||
if not os.path.exists('clothes'): | ||
type_list = ['face.json', 'feet.json', 'genitals.json', 'hands.json', 'head.json', | ||
'legs.json', 'neck.json', 'upper.json', 'lower.json', 'under_upper.json', | ||
'under_lower.json', 'over_upper.json', 'over_lower.json', 'over_head.json'] | ||
os.makedirs('clothes', exist_ok=True) | ||
generate_files_with_text('clothes', type_list) | ||
os.makedirs('img', exist_ok=True) | ||
output_dict = {} | ||
output_dict['name'] = input('请输入模组名称:') | ||
output_dict['version'] = input('请输入类似于1.0.0的模组版本号:') | ||
print(f'模组生成中请稍等...') | ||
output_dict['styleFileList'] = [] | ||
output_dict['scriptFileList'] = [] | ||
output_dict['tweeFileList'] = [] | ||
output_dict['additionFile'] = [] | ||
output_dict['imgFileList'] = [] | ||
list_files_and_subdirectories('img', output_dict) | ||
output_dict['addonPlugin'] = [ | ||
{ | ||
"modName": "ModdedClothesAddon", | ||
"addonName": "ModdedClothesAddon", | ||
"modVersion": "^1.1.0", | ||
"params": { | ||
"clothes": [ | ||
{ | ||
"key": "face", | ||
"filePath": "clothes/face.json" | ||
}, | ||
{ | ||
"key": "feet", | ||
"filePath": "clothes/feet.json" | ||
}, | ||
{ | ||
"key": "genitals", | ||
"filePath": "clothes/genitals.json" | ||
}, | ||
{ | ||
"key": "hands", | ||
"filePath": "clothes/hands.json" | ||
}, | ||
{ | ||
"key": "head", | ||
"filePath": "clothes/head.json" | ||
}, | ||
{ | ||
"key": "legs", | ||
"filePath": "clothes/legs.json" | ||
}, | ||
{ | ||
"key": "neck", | ||
"filePath": "clothes/neck.json" | ||
}, | ||
{ | ||
"key": "upper", | ||
"filePath": "clothes/upper.json" | ||
}, | ||
{ | ||
"key": "lower", | ||
"filePath": "clothes/lower.json" | ||
}, | ||
{ | ||
"key": "under_upper", | ||
"filePath": "clothes/under_upper.json" | ||
}, | ||
{ | ||
"key": "under_lower", | ||
"filePath": "clothes/under_lower.json" | ||
}, | ||
{ | ||
"key": "over_upper", | ||
"filePath": "clothes/over_upper.json" | ||
}, | ||
{ | ||
"key": "over_lower", | ||
"filePath": "clothes/over_lower.json" | ||
}, | ||
{ | ||
"key": "over_head", | ||
"filePath": "clothes/over_head.json" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"modName": "ModLoader DoL ImageLoaderHook", | ||
"addonName": "ImageLoaderAddon", | ||
"modVersion": "^2.3.0", | ||
"params": [ | ||
] | ||
} | ||
] | ||
output_dict['dependenceInfo'] = [ | ||
{ | ||
"modName": "ModdedClothesAddon", | ||
"version": "^1.1.0" | ||
}, | ||
{ | ||
"modName": "ModLoader DoL ImageLoaderHook", | ||
"version": "^2.3.0" | ||
} | ||
] | ||
|
||
# 将内容输出到文本文件 | ||
with open('boot.json', 'w', encoding='utf-8') as file: | ||
json.dump(output_dict, file, indent=2, ensure_ascii=False) | ||
|
||
# 要压缩的文件和文件夹路径列表 | ||
file_paths = ['img', 'boot.json', "clothes"] | ||
# 压缩后的文件名 | ||
zip_name = output_dict['name'] + '.zip' | ||
|
||
zip_files_and_folders(file_paths, zip_name) | ||
os.remove('boot.json') | ||
print(f'模组生成完成: {zip_name}') |