-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathanimtool.py
48 lines (32 loc) · 1.27 KB
/
animtool.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
import argparse
import os
from formats import anim
from util import bulkrw
def archive(args):
pass
def extract(args):
# Normalize paths.
args.directory = os.path.abspath(args.directory)
args.anim = os.path.abspath(args.anim)
print(f'Extracting "{args.anim}" into directory "{args.directory}"')
entries = anim.read(args.anim)
named_entries = []
for i in range(len(entries)):
name = os.path.basename(args.anim)
name = os.path.splitext(name)[0]
named_entries.append((f'{name}_{i}.DELT', entries[i]))
bulkrw.write_files(args.directory, named_entries, False)
def main():
parser = argparse.ArgumentParser(prog='animtool', description='Tool for Star Wars: Dark Forces ANIM graphics.')
subparsers = parser.add_subparsers(dest='cmd', required=True, help='the operation to perform')
# Extract command subparser.
extract_parser = subparsers.add_parser('extract', help='extract from an LFD')
extract_parser.set_defaults(func=extract)
extract_parser.add_argument('anim', help='ANIM to extract from')
extract_parser.add_argument('directory', help='directory to extract into')
# Parse arguments.
args = parser.parse_args()
# Dispatch command.
args.func(args)
if __name__ == '__main__':
main()