comparison scripts/pytouhou @ 565:5f7f859a72f9

Move CLI options to their own module.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 18 Jun 2014 22:39:11 +0200
parents bafe6361c0af
children 04ae31809dc7
comparison
equal deleted inserted replaced
564:a0fa01cd9f70 565:5f7f859a72f9
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of 11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ## GNU General Public License for more details. 13 ## GNU General Public License for more details.
14 ## 14 ##
15 15
16 import argparse 16 from os.path import pathsep
17 import os
18
19
20 pathsep = os.path.pathsep
21 default_data = (pathsep.join(('CM.DAT', 'th06*_CM.DAT', '*CM.DAT', '*cm.dat')), 17 default_data = (pathsep.join(('CM.DAT', 'th06*_CM.DAT', '*CM.DAT', '*cm.dat')),
22 pathsep.join(('ST.DAT', 'th6*ST.DAT', '*ST.DAT', '*st.dat')), 18 pathsep.join(('ST.DAT', 'th6*ST.DAT', '*ST.DAT', '*st.dat')),
23 pathsep.join(('IN.DAT', 'th6*IN.DAT', '*IN.DAT', '*in.dat')), 19 pathsep.join(('IN.DAT', 'th6*IN.DAT', '*IN.DAT', '*in.dat')),
24 pathsep.join(('MD.DAT', 'th6*MD.DAT', '*MD.DAT', '*md.dat')), 20 pathsep.join(('MD.DAT', 'th6*MD.DAT', '*MD.DAT', '*md.dat')),
25 pathsep.join(('102h.exe', '102*.exe', '東方紅魔郷.exe', '*.exe'))) 21 pathsep.join(('102h.exe', '102*.exe', '東方紅魔郷.exe', '*.exe')))
26 22
27 23 defaults = {'data': default_data}
28 parser = argparse.ArgumentParser(description='Libre reimplementation of the Touhou 6 engine.') 24
29 25 from pytouhou.options import parse_arguments
30 parser.add_argument('data', metavar='DAT', default=default_data, nargs='*', help='Game’s data files') 26 args = parse_arguments(defaults)
31 parser.add_argument('-p', '--path', metavar='DIRECTORY', default='.', help='Game directory path.')
32 parser.add_argument('--debug', action='store_true', help='Set unlimited continues, and perhaps other debug features.')
33 parser.add_argument('--verbosity', metavar='VERBOSITY', choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], help='Select the wanted logging level.')
34
35 game_group = parser.add_argument_group('Game options')
36 game_group.add_argument('-s', '--stage', metavar='STAGE', type=int, default=None, help='Stage, 1 to 7 (Extra), nothing means story mode.')
37 game_group.add_argument('-r', '--rank', metavar='RANK', type=int, default=0, help='Rank, from 0 (Easy, default) to 3 (Lunatic).')
38 game_group.add_argument('-c', '--character', metavar='CHARACTER', type=int, default=0, help='Select the character to use, from 0 (ReimuA, default) to 3 (MarisaB).')
39 game_group.add_argument('-b', '--boss-rush', action='store_true', help='Fight only bosses.')
40 game_group.add_argument('--game', metavar='GAME', choices=['EoSD'], default='EoSD', help='Select the game engine to use.')
41 game_group.add_argument('--interface', metavar='INTERFACE', choices=['EoSD', 'Sample'], default='EoSD', help='Select the interface to use.')
42 game_group.add_argument('--hints', metavar='HINTS', default=None, help='Hints file, to display text while playing.')
43
44 replay_group = parser.add_argument_group('Replay options')
45 replay_group.add_argument('--replay', metavar='REPLAY', help='Select a file to replay.')
46 replay_group.add_argument('--save-replay', metavar='REPLAY', help='Save the upcoming game into a replay file.')
47 replay_group.add_argument('--skip-replay', action='store_true', help='Skip the replay and start to play when it’s finished.')
48
49 netplay_group = parser.add_argument_group('Netplay options')
50 netplay_group.add_argument('--port', metavar='PORT', type=int, default=0, help='Local port to use.')
51 netplay_group.add_argument('--remote', metavar='REMOTE', default=None, help='Remote address.')
52 netplay_group.add_argument('--friendly-fire', action='store_true', help='Allow friendly-fire during netplay.')
53
54 graphics_group = parser.add_argument_group('Graphics options')
55 graphics_group.add_argument('--backend', metavar='BACKEND', choices=['opengl', 'sdl'], default=['opengl', 'sdl'], nargs='*', help='Which backend to use (opengl or sdl).')
56 graphics_group.add_argument('--fps-limit', metavar='FPS', default=-1, type=int, help='Set fps limit. A value of 0 disables fps limiting, while a negative value limits to 60 fps if and only if vsync doesn’t work.')
57 graphics_group.add_argument('--no-background', action='store_false', help='Disable background display (huge performance boost on slow systems).')
58 graphics_group.add_argument('--no-particles', action='store_false', help='Disable particles handling (huge performance boost on slow systems).')
59 graphics_group.add_argument('--no-sound', action='store_false', help='Disable music and sound effects.')
60
61 opengl_group = parser.add_argument_group('OpenGL backend options')
62 opengl_group.add_argument('--gl-flavor', choices=['core', 'es', 'compatibility', 'legacy'], default='compatibility', help='OpenGL profile to use.')
63 opengl_group.add_argument('--gl-version', default=2.1, type=float, help='OpenGL version to use.')
64
65 double_buffer = opengl_group.add_mutually_exclusive_group()
66 double_buffer.add_argument('--double-buffer', dest='double_buffer', action='store_true', default=None, help='Enable double buffering.')
67 double_buffer.add_argument('--single-buffer', dest='double_buffer', action='store_false', default=None, help='Disable double buffering.')
68
69 args = parser.parse_args()
70
71 27
72 import sys 28 import sys
73 import logging 29 import logging
74 from pytouhou.utils.helpers import get_logger 30 from pytouhou.utils.helpers import get_logger
75 31