Mercurial > touhou
annotate scripts/anmviewer @ 612:73f134f84c7f
Request a RGB888 context, since SDL2’s default of RGB332 sucks.
On X11/GLX, it will select the first config available, that is the best
one, while on EGL it will iterate over them to select the one closest
to what the application requested.
Of course, anything lower than RGB888 looks bad and we really don’t
want that.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Thu, 26 Mar 2015 20:20:37 +0100 |
parents | e15672733c93 |
children |
rev | line source |
---|---|
590
e15672733c93
Switch to Python 3.x instead of 2.7.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
546
diff
changeset
|
1 #!/usr/bin/env python3 |
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 |
425
1104dc2553ee
Make the anmviewer use the new architecture.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
414
diff
changeset
|
19 from pytouhou.ui.window import Window |
237
cbe9dbd80dfb
Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
20 from pytouhou.resource.loader import Loader |
cbe9dbd80dfb
Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
21 from pytouhou.ui.anmrenderer import ANMRenderer |
cbe9dbd80dfb
Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
22 |
cbe9dbd80dfb
Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
23 |
430
c9433188ffdb
Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
425
diff
changeset
|
24 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
|
25 resource_loader = Loader() |
cbe9dbd80dfb
Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
26 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
|
27 |
425
1104dc2553ee
Make the anmviewer use the new architecture.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
414
diff
changeset
|
28 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
|
29 |
237
cbe9dbd80dfb
Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
30 # Get out animation |
430
c9433188ffdb
Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
425
diff
changeset
|
31 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
|
32 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
|
33 window.set_runner(renderer) |
425
1104dc2553ee
Make the anmviewer use the new architecture.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
414
diff
changeset
|
34 window.run() |
237
cbe9dbd80dfb
Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
35 |
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 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
|
38 |
cbe9dbd80dfb
Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
39 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
|
40 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
|
41 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
|
42 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
|
43 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
|
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 |
430
c9433188ffdb
Remove AnmWrapper, since ANMs are lists of entries now.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
425
diff
changeset
|
49 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
|
50 args.fixed_pipeline) |