Mercurial > touhou
annotate anmviewer @ 425:1104dc2553ee
Make the anmviewer use the new architecture.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Tue, 16 Jul 2013 21:07:15 +0200 |
parents | b0b8825296d0 |
children | c9433188ffdb |
rev | line source |
---|---|
414
b0b8825296d0
Follow the PEP-0394 guidelines, migrating from python to python2.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
405
diff
changeset
|
1 #!/usr/bin/env python2 |
237
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 |
425
1104dc2553ee
Make the anmviewer use the new architecture.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
414
diff
changeset
|
22 from pytouhou.ui.window import Window |
237
cbe9dbd80dfb
Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
23 from pytouhou.resource.loader import Loader |
cbe9dbd80dfb
Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
24 from pytouhou.ui.anmrenderer import ANMRenderer |
cbe9dbd80dfb
Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
25 |
cbe9dbd80dfb
Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
26 |
405
402e96a0baeb
Make the anmviewer use the programmable pipeline too.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
241
diff
changeset
|
27 def main(path, data, name, script, sprites, fixed_pipeline): |
237
cbe9dbd80dfb
Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
28 resource_loader = Loader() |
cbe9dbd80dfb
Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
29 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
|
30 |
425
1104dc2553ee
Make the anmviewer use the new architecture.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
414
diff
changeset
|
31 window = Window((384, 448), fixed_pipeline=fixed_pipeline, sound=False) |
1104dc2553ee
Make the anmviewer use the new architecture.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
414
diff
changeset
|
32 |
237
cbe9dbd80dfb
Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
33 # 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
|
34 anm_wrapper = resource_loader.get_anm_wrapper(name.split(',')) |
425
1104dc2553ee
Make the anmviewer use the new architecture.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
414
diff
changeset
|
35 anm = ANMRenderer(window, resource_loader, anm_wrapper, script, sprites) |
1104dc2553ee
Make the anmviewer use the new architecture.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
414
diff
changeset
|
36 window.set_runner(anm) |
1104dc2553ee
Make the anmviewer use the new architecture.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
414
diff
changeset
|
37 window.run() |
237
cbe9dbd80dfb
Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
38 |
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 = 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
|
41 |
cbe9dbd80dfb
Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
42 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
|
43 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
|
44 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
|
45 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
|
46 parser.add_argument('--sprites', action='store_true', default=False, help='Display sprites instead of scripts.') |
405
402e96a0baeb
Make the anmviewer use the programmable pipeline too.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
241
diff
changeset
|
47 parser.add_argument('--fixed-pipeline', action='store_true', help='Use the fixed pipeline instead of the new programmable one.') |
237
cbe9dbd80dfb
Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
48 |
cbe9dbd80dfb
Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
49 args = parser.parse_args() |
cbe9dbd80dfb
Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
50 |
405
402e96a0baeb
Make the anmviewer use the programmable pipeline too.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
241
diff
changeset
|
51 main(args.path, tuple(args.data), args.anm, args.script, args.sprites, |
402e96a0baeb
Make the anmviewer use the programmable pipeline too.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
241
diff
changeset
|
52 args.fixed_pipeline) |