comparison pytouhou/options.py @ 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
children b2269b9c6119
comparison
equal deleted inserted replaced
564:a0fa01cd9f70 565:5f7f859a72f9
1 # -*- encoding: utf-8 -*-
2 ##
3 ## Copyright (C) 2014 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
4 ##
5 ## This program is free software; you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published
7 ## by the Free Software Foundation; version 3 only.
8 ##
9 ## This program is distributed in the hope that it will be useful,
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ## GNU General Public License for more details.
13 ##
14
15 from argparse import ArgumentParser
16
17
18 def parse_arguments(defaults):
19 parser = ArgumentParser(description='Libre reimplementation of the Touhou 6 engine.')
20
21 parser.add_argument('data', metavar='DAT', default=defaults['data'], nargs='*', help='Game’s data files')
22 parser.add_argument('-p', '--path', metavar='DIRECTORY', default='.', help='Game directory path.')
23 parser.add_argument('--debug', action='store_true', help='Set unlimited continues, and perhaps other debug features.')
24 parser.add_argument('--verbosity', metavar='VERBOSITY', choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], help='Select the wanted logging level.')
25
26 game_group = parser.add_argument_group('Game options')
27 game_group.add_argument('-s', '--stage', metavar='STAGE', type=int, default=None, help='Stage, 1 to 7 (Extra), nothing means story mode.')
28 game_group.add_argument('-r', '--rank', metavar='RANK', type=int, default=0, help='Rank, from 0 (Easy, default) to 3 (Lunatic).')
29 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).')
30 game_group.add_argument('-b', '--boss-rush', action='store_true', help='Fight only bosses.')
31 game_group.add_argument('--game', metavar='GAME', choices=['EoSD'], default='EoSD', help='Select the game engine to use.')
32 game_group.add_argument('--interface', metavar='INTERFACE', choices=['EoSD', 'Sample'], default='EoSD', help='Select the interface to use.')
33 game_group.add_argument('--hints', metavar='HINTS', default=None, help='Hints file, to display text while playing.')
34
35 replay_group = parser.add_argument_group('Replay options')
36 replay_group.add_argument('--replay', metavar='REPLAY', help='Select a file to replay.')
37 replay_group.add_argument('--save-replay', metavar='REPLAY', help='Save the upcoming game into a replay file.')
38 replay_group.add_argument('--skip-replay', action='store_true', help='Skip the replay and start to play when it’s finished.')
39
40 netplay_group = parser.add_argument_group('Netplay options')
41 netplay_group.add_argument('--port', metavar='PORT', type=int, default=0, help='Local port to use.')
42 netplay_group.add_argument('--remote', metavar='REMOTE', default=None, help='Remote address.')
43 netplay_group.add_argument('--friendly-fire', action='store_true', help='Allow friendly-fire during netplay.')
44
45 graphics_group = parser.add_argument_group('Graphics options')
46 graphics_group.add_argument('--backend', metavar='BACKEND', choices=['opengl', 'sdl'], default=['opengl', 'sdl'], nargs='*', help='Which backend to use (opengl or sdl).')
47 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.')
48 graphics_group.add_argument('--no-background', action='store_false', help='Disable background display (huge performance boost on slow systems).')
49 graphics_group.add_argument('--no-particles', action='store_false', help='Disable particles handling (huge performance boost on slow systems).')
50 graphics_group.add_argument('--no-sound', action='store_false', help='Disable music and sound effects.')
51
52 opengl_group = parser.add_argument_group('OpenGL backend options')
53 opengl_group.add_argument('--gl-flavor', choices=['core', 'es', 'compatibility', 'legacy'], default='compatibility', help='OpenGL profile to use.')
54 opengl_group.add_argument('--gl-version', default=2.1, type=float, help='OpenGL version to use.')
55
56 double_buffer = opengl_group.add_mutually_exclusive_group()
57 double_buffer.add_argument('--double-buffer', dest='double_buffer', action='store_true', default=None, help='Enable double buffering.')
58 double_buffer.add_argument('--single-buffer', dest='double_buffer', action='store_false', default=None, help='Disable double buffering.')
59
60 return parser.parse_args()