diff pytouhou/ui/gamerunner.py @ 373:6deab6ad8be8

Add the ability to save a replay.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 05 Aug 2012 16:37:26 +0200
parents 74471afbac37
children 6a63fd3deb76
line wrap: on
line diff
--- a/pytouhou/ui/gamerunner.py
+++ b/pytouhou/ui/gamerunner.py
@@ -61,7 +61,7 @@ class GameRunner(pyglet.window.Window, G
         self.clock = pyglet.clock.get_default()
 
 
-    def load_game(self, game=None, background=None, bgms=None, replay=None):
+    def load_game(self, game=None, background=None, bgms=None, replay=None, save_keystates=None):
         GameRenderer.load_game(self, game, background)
         self.replay_level = None
         if not replay or not replay.levels[game.stage-1]:
@@ -75,6 +75,8 @@ class GameRunner(pyglet.window.Window, G
             game.players[0].state.bombs = self.replay_level.bombs
             game.difficulty = self.replay_level.difficulty
 
+        self.save_keystates = save_keystates
+
         game.music = MusicPlayer(game.resource_loader, bgms)
         game.music.play(0)
 
@@ -166,6 +168,9 @@ class GameRunner(pyglet.window.Window, G
                     else:
                         keystate = _keystate
 
+            if self.save_keystates is not None:
+                self.save_keystates.append(keystate)
+
             self.game.run_iter(keystate)