Mercurial > touhou
comparison anmviewer @ 237:cbe9dbd80dfb
Add an anmviewer script.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sun, 01 Jan 2012 19:51:34 +0100 |
parents | |
children | dd2bd7283bec |
comparison
equal
deleted
inserted
replaced
236:741860192b56 | 237:cbe9dbd80dfb |
---|---|
1 #!/usr/bin/env python | |
2 # -*- encoding: utf-8 -*- | |
3 ## | |
4 ## Copyright (C) 2011 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | |
5 ## | |
6 ## This program is free software; you can redistribute it and/or modify | |
7 ## it under the terms of the GNU General Public License as published | |
8 ## by the Free Software Foundation; version 3 only. | |
9 ## | |
10 ## This program is distributed in the hope that it will be useful, | |
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 ## GNU General Public License for more details. | |
14 ## | |
15 | |
16 import argparse | |
17 import os | |
18 | |
19 import pyximport | |
20 pyximport.install() | |
21 | |
22 from pytouhou.resource.loader import Loader | |
23 from pytouhou.game.sprite import Sprite | |
24 from pytouhou.vm.anmrunner import ANMRunner | |
25 from pytouhou.ui.anmrenderer import ANMRenderer | |
26 | |
27 | |
28 def main(path, data, name, script, sprites): | |
29 resource_loader = Loader() | |
30 resource_loader.scan_archives(os.path.join(path, name) for name in data) | |
31 | |
32 # Get out animation | |
33 anm_wrapper = resource_loader.get_anm_wrapper((name,)) | |
34 anm = ANMRenderer(resource_loader, anm_wrapper, script, sprites) | |
35 anm.start() | |
36 | |
37 | |
38 parser = argparse.ArgumentParser(description='Viewer of ANM files, archives containing animations used in Touhou games.') | |
39 | |
40 parser.add_argument('data', metavar='DAT', default=('CM.DAT', 'ST.DAT'), nargs='*', help='Game’s .DAT data files') | |
41 parser.add_argument('-p', '--path', metavar='DIRECTORY', default='.', help='Game directory path.') | |
42 parser.add_argument('--anm', metavar='ANM', required=True, help='Select an ANM') | |
43 parser.add_argument('--script', metavar='SCRIPT', type=int, default=0, help='First script to play') | |
44 parser.add_argument('--sprites', action='store_true', default=False, help='Display sprites instead of scripts.') | |
45 | |
46 args = parser.parse_args() | |
47 | |
48 main(args.path, tuple(args.data), args.anm, args.script, args.sprites) |