annotate anmviewer @ 430:c9433188ffdb

Remove AnmWrapper, since ANMs are lists of entries now.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 03 Aug 2013 15:49:04 +0200
parents 1104dc2553ee
children 77c0e9a53795
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
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
430
c9433188ffdb Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 425
diff changeset
27 def main(path, data, name, script, entry, 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
430
c9433188ffdb Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 425
diff changeset
34 anm = resource_loader.get_anm(name)
c9433188ffdb Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 425
diff changeset
35 renderer = ANMRenderer(window, resource_loader, anm[entry], script, sprites)
c9433188ffdb Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 425
diff changeset
36 window.set_runner(renderer)
425
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')
430
c9433188ffdb Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 425
diff changeset
46 parser.add_argument('--entry', metavar='ENTRY', type=int, default=0, help='Entry to display, in multi-entries ANMs.')
237
cbe9dbd80dfb Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
47 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
48 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
49
cbe9dbd80dfb Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
50 args = parser.parse_args()
cbe9dbd80dfb Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
51
430
c9433188ffdb Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 425
diff changeset
52 main(args.path, tuple(args.data), args.anm, args.script, args.entry, args.sprites,
405
402e96a0baeb Make the anmviewer use the programmable pipeline too.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 241
diff changeset
53 args.fixed_pipeline)