-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
68 lines (58 loc) · 3.55 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from AJTTools import plugins, REPak, build_pak_from_dir
import argparse
from pathlib import Path
info = {}
lines = open("path_init.txt",'r',encoding='utf-8').readlines()
for line in lines:
key, value = line.split('=')
info[key] = value.replace('\n','')
def main():
parser = argparse.ArgumentParser(
prog = "AJT Tools",
description = "REEngine modding tools",
)
mode = parser.add_mutually_exclusive_group()
mode.add_argument("-e", "--exportf", action="store_true", help="Batch export files")
mode.add_argument("-i", "--importf", action="store_true", help="Batch import files")
for command, plugin in plugins.items():
parser.add_argument(command, help=plugin.help, action='store_true')
args = parser.parse_args()
options = vars(args)
if args.exportf:
assert not Path(info["extracted_dir"]).exists(), "Delete the extraction folder before exporting files again. This is intended to be a security feature."
pak = REPak(Path(info["pak_path"]))
pak.unpack(Path(info["extracted_dir"]), Path(info["release_list_path"]))
root_dir = list((Path(info["extracted_dir"]) / 'natives').iterdir())[0]
output_mes = ""
for name in options:
if options[name] and name not in ['exportf','importf']:
plugin = plugins[f"-{name}"]
if name == 'script':
if (root_dir / 'gamedesign' / 'gs4' / 'scriptbinary').exists(): #AJT
output_mes += plugin.batch_export_file(root_dir / 'gamedesign' / 'gs4' / 'scriptbinary', Path(plugin.extract_dir_name) / 'gs4' / 'scriptbinary', info["language"])
plugin.script_code = "aa56"
output_mes += plugin.batch_export_file(root_dir / 'gamedesign' / 'gs5' / 'scriptdata', Path(plugin.extract_dir_name) / 'gs5' / 'scriptdata', info["language"])
output_mes += plugin.batch_export_file(root_dir / 'gamedesign' / 'gs6' / 'scriptdata', Path(plugin.extract_dir_name) / 'gs6' / 'scriptdata', info["language"])
else:
output_mes += plugin.batch_export_file(root_dir, Path(plugin.extract_dir_name), info["language"])
print(output_mes)
elif args.importf:
root_dir = list((Path(info["extracted_dir"]) / 'natives').iterdir())[0]
plat_code = root_dir.name
mod_dir = Path(info["mod_dir"])
output_mes = ""
for name in options:
if options[name] and name not in ['exportf','importf']:
plugin = plugins[f"-{name}"]
if name == 'script':
if (root_dir / 'gamedesign' / 'gs4' / 'scriptbinary').exists(): #AJT
output_mes += plugin.batch_import_file(root_dir / 'gamedesign' , mod_dir / 'natives' / plat_code / 'gamedesign' , Path(plugin.extract_dir_name) / 'gs4' / 'scriptbinary')
plugin.script_code = "aa56"
output_mes += plugin.batch_import_file(root_dir / 'gamedesign' , mod_dir / 'natives' / plat_code / 'gamedesign' , Path(plugin.extract_dir_name) / 'gs5' / 'scriptdata')
output_mes += plugin.batch_import_file(root_dir / 'gamedesign' , mod_dir / 'natives' / plat_code / 'gamedesign' , Path(plugin.extract_dir_name) / 'gs6' / 'scriptdata')
else:
output_mes += plugin.batch_import_file(root_dir, mod_dir / 'natives' / plat_code, Path(plugin.extract_dir_name))
build_pak_from_dir(mod_dir, Path(info["patch_pak_path"]))
print(output_mes)
if __name__ == '__main__':
main()