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