annotate anmviewer @ 423:d8630c086926

Replace Pyglet with our own Cython OpenGL wrapper.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 16 Jul 2013 21:07:15 +0200
parents b0b8825296d0
children 1104dc2553ee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
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
405
402e96a0baeb Make the anmviewer use the programmable pipeline too.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 241
diff changeset
28 def main(path, data, name, script, sprites, fixed_pipeline):
237
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(','))
405
402e96a0baeb Make the anmviewer use the programmable pipeline too.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 241
diff changeset
34 anm = ANMRenderer(resource_loader, anm_wrapper, script, sprites, fixed_pipeline)
237
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.')
405
402e96a0baeb Make the anmviewer use the programmable pipeline too.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 241
diff changeset
45 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
46
cbe9dbd80dfb Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
47 args = parser.parse_args()
cbe9dbd80dfb Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
48
405
402e96a0baeb Make the anmviewer use the programmable pipeline too.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 241
diff changeset
49 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
50 args.fixed_pipeline)