diff options
author | Ignacio Rodriguez <ignacio@sugarlabs.org> | 2013-12-24 11:53:37 (GMT) |
---|---|---|
committer | Ignacio Rodriguez <ignacio@sugarlabs.org> | 2013-12-24 11:53:37 (GMT) |
commit | 343d8a4912102b9f16b8929817542e1f0cbb5d46 (patch) | |
tree | 91c9cd8771ff619d350140f6051ffbd4c24a68c5 | |
parent | 35eb71d4ae54238bea0b8b45f87c890487f46743 (diff) |
fixes, now the collaborations works and the activity works
-rw-r--r-- | .gitignore | 2 | ||||
-rwxr-xr-x | activity.py | 7 | ||||
-rw-r--r-- | game.py | 17 | ||||
-rw-r--r-- | sugargame/mesh.py | 14 |
4 files changed, 29 insertions, 11 deletions
@@ -1 +1 @@ -*.py[co~] +*.py[co] diff --git a/activity.py b/activity.py index 916569c..cbc7025 100755 --- a/activity.py +++ b/activity.py @@ -38,10 +38,13 @@ class MazeActivity(activity.Activity): if self.get_shared(): joined_cb() - self.game = game.MazeGame() - self._canvas.run_pygame(self.game.run) + self.game = game.MazeGame(self._pygamecanvas) + self._pygamecanvas.run_pygame(self.game.run) self._pygamecanvas.grab_focus() + def get_preview(self): + return self._pygamecanvas.get_preview() + def build_toolbar(self): """Build our Activity toolbar for the Sugar system.""" @@ -73,6 +73,9 @@ class MazeGame: GOAL_COLOR = (0x00, 0xff, 0x00) WIN_COLOR = (0xff, 0xff, 0x00) + def __init__(self, canvas=None): + self.canvas = canvas + def first_run(self): # note what time it was when we first launched self.game_start_time = time.time() @@ -180,7 +183,10 @@ class MazeGame: as well as multiplayer events from the mesh.""" if event.type == pygame.QUIT: self.running = False + pygame.quit() elif event.type == pygame.KEYDOWN: + if self.canvas is not None: + self.canvas.grab_focus() if event.key in (pygame.K_PLUS, pygame.K_EQUALS): self.harder() elif event.key == pygame.K_MINUS: @@ -207,8 +213,12 @@ class MazeGame: player.direction[0], player.direction[1])) elif event.type == pygame.KEYUP: + if self.canvas is not None: + self.canvas.grab_focus() pass elif event.type == pygame.MOUSEMOTION: + if self.canvas is not None: + self.canvas.grab_focus() pass elif event.type == pygame.MOUSEBUTTONDOWN: self.mouse_in_use = 1 @@ -457,8 +467,12 @@ class MazeGame: my_cursor = os.path.join(get_bundle_path(), 'my_cursor.xbm') my_cursor_mask = os.path.join(get_bundle_path(), 'my_cursor_mask.xbm') + if self.canvas is not None: + self.canvas.grab_focus() + while self.running: - clock.tick(120) + while Gtk.events_pending(): + Gtk.main_iteration() a, b, c, d = pygame.cursors.load_xbm(my_cursor, my_cursor_mask) @@ -471,6 +485,7 @@ class MazeGame: self.draw() pygame.display.update() + clock.tick(30) def harder(self): diff --git a/sugargame/mesh.py b/sugargame/mesh.py index 58436aa..3cb3ab5 100644 --- a/sugargame/mesh.py +++ b/sugargame/mesh.py @@ -103,8 +103,8 @@ def _getConn(activity): if conn: return conn else: - if hasattr(activity._shared_activity, 'telepathy_conn'): - conn = activity._shared_activity.telepathy_conn + if hasattr(activity.shared_activity, 'telepathy_conn'): + conn = activity.shared_activity.telepathy_conn else: pservice = _get_presence_service() name, path = pservice.get_preferred_connection() @@ -123,14 +123,14 @@ setup(sugar.activity.Activity, telepathy.client.Connection)''' if not activity.get_shared(): raise "Failure" - if hasattr(activity._shared_activity, 'telepathy_tubes_chan'): + if hasattr(activity.shared_activity, 'telepathy_tubes_chan'): _getConn(activity) - conn = activity._shared_activity.telepathy_conn - tubes_chan = activity._shared_activity.telepathy_tubes_chan - text_chan = activity._shared_activity.telepathy_text_chan + conn = activity.shared_activity.telepathy_conn + tubes_chan = activity.shared_activity.telepathy_tubes_chan + text_chan = activity.shared_activity.telepathy_text_chan else: bus_name, conn_path, channel_paths = \ - activity._shared_activity.get_channels() + activity.shared_activity.get_channels() _getConn(activity) # Work out what our room is called and whether we have Tubes already |