Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2014-06-12 19:27:10 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2014-06-16 15:26:38 (GMT)
commit7de726b052795cef0076e8d010492f7e502c3f7f (patch)
treebb2718d6f0e917d7dc423563eed852ea385ef150
parenta1d9c0a8f60ac8813aa5d388c42d21c07ded04e2 (diff)
Notify other players when show/hide trail
-rwxr-xr-xactivity.py13
-rw-r--r--game.py14
2 files changed, 18 insertions, 9 deletions
diff --git a/activity.py b/activity.py
index 6c0d782..8d0879d 100755
--- a/activity.py
+++ b/activity.py
@@ -81,11 +81,11 @@ class MazeActivity(activity.Activity):
toolbar_box.toolbar.insert(separator, -1)
separator.show()
- show_trail_button = ToggleToolButton('show-trail')
- show_trail_button.set_tooltip(_('Show trail'))
- show_trail_button.set_active(True)
- show_trail_button.connect('toggled', self._toggled_show_trail_cb)
- toolbar_box.toolbar.insert(show_trail_button, -1)
+ self.show_trail_button = ToggleToolButton('show-trail')
+ self.show_trail_button.set_tooltip(_('Show trail'))
+ self.show_trail_button.set_active(True)
+ self.show_trail_button.connect('toggled', self._toggled_show_trail_cb)
+ toolbar_box.toolbar.insert(self.show_trail_button, -1)
separator = Gtk.SeparatorToolItem()
separator.props.draw = False
@@ -110,7 +110,8 @@ class MazeActivity(activity.Activity):
self.game.harder()
def _toggled_show_trail_cb(self, button):
- self.game.set_show_trail(button.get_active())
+ if self.game.set_show_trail(button.get_active()):
+ self.broadcast_msg('show_trail:%s' % str(button.get_active()))
def _shared_cb(self, activity):
logging.debug('Maze was shared')
diff --git a/game.py b/game.py
index aa507e7..07a5f19 100644
--- a/game.py
+++ b/game.py
@@ -271,8 +271,12 @@ class MazeGame(Gtk.DrawingArea):
# self.dirtyPoints = []
def set_show_trail(self, show_trail):
- self._show_trail = show_trail
- self.queue_draw()
+ if self._show_trail != show_trail:
+ self._show_trail = show_trail
+ self.queue_draw()
+ return True
+ else:
+ return False
def markRectDirty(self, rect):
"""Mark an area that needs to be redrawn. This lets us
@@ -523,6 +527,8 @@ class MazeGame(Gtk.DrawingArea):
step: x, y, dx, dy
A player move using the accelerator, move a single step
+ show_trail: True/False
+
finish: elapsed
A player has finished the maze
"""
@@ -575,7 +581,9 @@ class MazeGame(Gtk.DrawingArea):
player.elapsed = float(elapsed)
self.show_finish_window()
-
+ elif message.startswith("show_trail:"):
+ show_trail = message.endswith('True')
+ self._activity.show_trail_button.set_active(show_trail)
else:
# it was something I don't recognize...
logging.debug("Message from %s: %s", player.nick, message)