comparison eclviewer.py @ 213:9bdf116bb2a5

Add a distutils setup and don’t hardcode DAT list.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 27 Nov 2011 15:13:31 +0100
parents ee6dfd14a785
children
comparison
equal deleted inserted replaced
212:78e9957ad344 213:9bdf116bb2a5
25 from pytouhou.games.eosd import EoSDGame 25 from pytouhou.games.eosd import EoSDGame
26 from pytouhou.game.player import PlayerState 26 from pytouhou.game.player import PlayerState
27 from pytouhou.formats.t6rp import T6RP 27 from pytouhou.formats.t6rp import T6RP
28 28
29 29
30 def main(path, stage_num, rank, character, replay): 30 def main(path, stage_num, rank, character, replay, data):
31 if replay: 31 if replay:
32 with open(replay, 'rb') as file: 32 with open(replay, 'rb') as file:
33 replay = T6RP.read(file) 33 replay = T6RP.read(file)
34 rank = replay.rank 34 rank = replay.rank
35 character = replay.character 35 character = replay.character
40 else: 40 else:
41 prng = None 41 prng = None
42 42
43 resource_loader = Loader() 43 resource_loader = Loader()
44 resource_loader.scan_archives(os.path.join(path, name) 44 resource_loader.scan_archives(os.path.join(path, name)
45 for name in ('CM.DAT', 'ST.DAT')) 45 for name in data)
46 game = EoSDGame(resource_loader, [PlayerState(character=character)], stage_num, rank, 16, 46 game = EoSDGame(resource_loader, [PlayerState(character=character)], stage_num, rank, 16,
47 prng=prng) 47 prng=prng)
48 48
49 # Load stage data 49 # Load stage data
50 stage = resource_loader.get_stage('stage%d.std' % stage_num) 50 stage = resource_loader.get_stage('stage%d.std' % stage_num)
60 runner.start() 60 runner.start()
61 61
62 62
63 parser = argparse.ArgumentParser(description='Libre reimplementation of the Touhou 6 engine.') 63 parser = argparse.ArgumentParser(description='Libre reimplementation of the Touhou 6 engine.')
64 64
65 parser.add_argument('data', metavar='DAT', default=('CM.DAT', 'ST.DAT'), nargs='*', help='Game’s .DAT data files')
65 parser.add_argument('-p', '--path', metavar='DIRECTORY', default='.', help='Game directory path.') 66 parser.add_argument('-p', '--path', metavar='DIRECTORY', default='.', help='Game directory path.')
66 parser.add_argument('-s', '--stage', metavar='STAGE', type=int, required=True, help='Stage, 1 to 7 (Extra).') 67 parser.add_argument('-s', '--stage', metavar='STAGE', type=int, required=True, help='Stage, 1 to 7 (Extra).')
67 parser.add_argument('-r', '--rank', metavar='RANK', type=int, default=0, help='Rank, from 0 (Easy, default) to 3 (Lunatic).') 68 parser.add_argument('-r', '--rank', metavar='RANK', type=int, default=0, help='Rank, from 0 (Easy, default) to 3 (Lunatic).')
68 parser.add_argument('-c', '--character', metavar='CHARACTER', type=int, default=0, help='Select the character to use, from 0 (ReimuA, default) to 3 (MarisaB).') 69 parser.add_argument('-c', '--character', metavar='CHARACTER', type=int, default=0, help='Select the character to use, from 0 (ReimuA, default) to 3 (MarisaB).')
69 parser.add_argument('--replay', metavar='REPLAY', help='Select a replay') 70 parser.add_argument('--replay', metavar='REPLAY', help='Select a replay')
70 71
71 args = parser.parse_args() 72 args = parser.parse_args()
72 73
73 main(args.path, args.stage, args.rank, args.character, args.replay) 74 main(args.path, args.stage, args.rank, args.character, args.replay, tuple(args.data))