-
Notifications
You must be signed in to change notification settings - Fork 1
/
Tales_Exe.py
265 lines (214 loc) · 6.79 KB
/
Tales_Exe.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
import argparse
from pathlib import Path
from pythonlib.games import ToolsNDX, ToolsTOR
SCRIPT_VERSION = "0.0.3"
def get_arguments(argv=None):
# Init argument parser
parser = argparse.ArgumentParser()
parser.add_argument(
"-g",
"--game",
choices=["TOR", "NDX"],
required=True,
metavar="game",
help="Options: TOR, NDX",
)
parser.add_argument(
"-p",
"--project",
required=True,
type=Path,
metavar="project",
help="project.json file path",
)
sp = parser.add_subparsers(title="Available actions", required=False, dest="action")
# Extract commands
sp_extract = sp.add_parser(
"extract",
description="Extract the content of the files",
help="Extract the content of the files",
formatter_class=argparse.RawTextHelpFormatter,
)
sp_extract.add_argument(
"-ft",
"--file_type",
choices=["Iso", "Main", "Menu", "Story", "Minigame", "Skits"],
required=True,
metavar="file_type",
help="(Required) - Options: Iso, Init, Main, Menu, Story, Minigame, Skits",
)
sp_extract.add_argument(
"-i",
"--iso",
required=False,
default="../b-topndxj.iso",
metavar="iso",
help="(Optional) - Only for extract Iso command",
)
sp_extract.add_argument(
"-r",
"--replace",
required=False,
metavar="replace",
default=False,
help="(Optional) - Boolean to uses translations from the Repo to overwrite the one in the Data folder",
)
sp_extract.add_argument(
"--only-changed",
required=False,
action="store_true",
help="(Optional) - Insert only changed files not yet commited",
)
sp_extract.add_argument(
"--update-battle-subs",
required=False,
dest="update_subs",
action="store_true",
help="(Deprecated)",
)
sp_extract.add_argument(
"--update-subs",
required=False,
action="store_true",
help="(Optional) - Update Battle and Fmv Subs",
)
sp_extract.add_argument(
"--single-build",
required=False,
action="store_true",
help="(Optional) - Create just a single iso instead",
)
sp_insert = sp.add_parser(
"insert",
help="Take the new texts and recreate the files",
)
sp_insert.add_argument(
"-ft",
"--file_type",
choices=["Iso", "Main", "Menu", "Story", "Skits", "Minigame", "All", "Asm"],
required=True,
metavar="file_type",
help="(Required) - Options: Iso, Init, Main, Elf, Story, Skits, Minigame, All, Asm",
)
sp_insert.add_argument(
"-i",
"--iso",
required=False,
default="",
metavar="iso",
help="(Deprecated) - No longer in use for insertion",
)
sp_insert.add_argument(
"--with-proofreading",
required=False,
action="store_const",
const="Proofreading",
default="",
help="(Optional) - Insert lines in 'Proofreading' status",
)
sp_insert.add_argument(
"--with-editing",
required=False,
action="store_const",
const="Editing",
default="",
help="(Optional) - Insert lines in 'Editing' status",
)
sp_insert.add_argument(
"--with-problematic",
required=False,
action="store_const",
const="Problematic",
default="",
help="(Optional) - Insert lines in 'Problematic' status",
)
sp_insert.add_argument(
"--only-changed",
required=False,
action="store_true",
help="(Optional) - Insert only changed files not yet commited",
)
sp_insert.add_argument(
"--update-battle-subs",
required=False,
dest="update_subs",
action="store_true",
help="(Deprecated)",
)
sp_insert.add_argument(
"--update-subs",
required=False,
action="store_true",
help="(Optional) - Update Battle and Fmv Subs",
)
sp_insert.add_argument(
"--single-build",
required=False,
action="store_true",
help="(Optional) - Create just a single iso instead",
)
args = parser.parse_args()
return args
def getTalesInstance(args, game_name):
if game_name == "TOR":
if args.action == "insert":
insert_mask = [
args.with_proofreading,
args.with_editing,
args.with_problematic,
]
else:
insert_mask = []
talesInstance = ToolsTOR.ToolsTOR(
args.project.resolve(), insert_mask, args.only_changed
)
talesInstance.single_build = args.single_build
talesInstance.make_btl_subs = args.update_subs
elif game_name == "NDX":
talesInstance = ToolsNDX.ToolsNDX("TBL_All.json")
else:
raise ValueError("Unkown game name")
return talesInstance
if __name__ == "__main__":
args = get_arguments()
game_name = args.game
tales_instance = getTalesInstance(args, game_name)
if args.action == "insert":
if args.update_subs:
tales_instance.create_fmv_subs()
tales_instance.create_btl_subs()
if args.file_type == "Main":
tales_instance.pack_main_archive()
elif args.file_type == "Story":
tales_instance.pack_all_story()
elif args.file_type == "Minigame":
tales_instance.pack_all_minigame()
elif args.file_type == "Iso":
tales_instance.make_iso()
elif args.file_type == "Skits":
tales_instance.pack_all_skits()
elif args.file_type == "Menu":
tales_instance.pack_all_menu()
elif args.file_type == "Asm":
tales_instance.patch_binaries()
elif args.file_type == "All":
tales_instance.pack_all_story()
tales_instance.pack_all_skits()
tales_instance.pack_all_menu()
tales_instance.pack_all_minigame()
tales_instance.patch_binaries()
tales_instance.make_iso()
if args.action == "extract":
if args.file_type == "Iso":
tales_instance.extract_Iso(Path(args.iso))
tales_instance.extract_main_archive()
if args.file_type == "Main":
tales_instance.extract_main_archive()
if args.file_type == "Menu":
tales_instance.extract_all_menu()
if args.file_type == "Story":
tales_instance.extract_all_story()
if args.file_type == "Minigame":
tales_instance.extract_all_minigame()
if args.file_type == "Skits":
tales_instance.extract_all_skits(args.replace)