From e1bccd2cdbc1bd74c6fd4bd8b1fc30838f0c66ee Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Sun, 13 Mar 2011 15:58:47 +0000 Subject: disable moving remote turtles --- diff --git a/TurtleArt/tacollaboration.py b/TurtleArt/tacollaboration.py index 3a5bd17..4a4d1fe 100644 --- a/TurtleArt/tacollaboration.py +++ b/TurtleArt/tacollaboration.py @@ -49,6 +49,7 @@ class Collaboration(): """ A simplistic sharing model: the sharer is the master """ self._tw = tw self._tw.send_event = self.send_event + self._tw.turtle_dictionary = {} self._activity = activity self._setup_dispatch_table() @@ -96,7 +97,7 @@ class Collaboration(): self.initiating = True self.waiting_for_turtles = False - self.turtle_dictionary = self._get_dictionary() + self._tw.turtle_dictionary = self._get_dictionary() debug_output('I am sharing...', self._tw.running_sugar) @@ -211,24 +212,24 @@ class Collaboration(): [nick, colors] = data_from_string(payload) if nick != self._tw.nick: # There may not be a turtle dictionary. - if hasattr(self, 'turtle_dictionary'): - self.turtle_dictionary[nick] = colors + if hasattr(self._tw, 'turtle_dictionary'): + self._tw.turtle_dictionary[nick] = colors else: - self.turtle_dictionary = {nick: colors} + self._tw.turtle_dictionary = {nick: colors} # Add new turtle for the joiner. self._tw.canvas.set_turtle(nick, colors) # Sharer should send turtle dictionary. if self.initiating: - event_payload = data_to_string(self.turtle_dictionary) + event_payload = data_to_string(self._tw.turtle_dictionary) self.send_event('T|' + event_payload) def _receive_turtle_dict(self, payload): if self.waiting_for_turtles: if len(payload) > 0: - self.turtle_dictionary = data_from_string(payload) - for nick in self.turtle_dictionary: + self._tw.turtle_dictionary = data_from_string(payload) + for nick in self._tw.turtle_dictionary: if nick != self._tw.nick: - colors = self.turtle_dictionary[nick] + colors = self._tw.turtle_dictionary[nick] # add new turtle for the joiner self._tw.canvas.set_turtle(nick, colors) self.waiting_for_turtles = False diff --git a/TurtleArt/taturtle.py b/TurtleArt/taturtle.py index a4bd2f4..8a70638 100644 --- a/TurtleArt/taturtle.py +++ b/TurtleArt/taturtle.py @@ -229,6 +229,10 @@ class Turtle: self.spr.move(pos) return(self.x, self.y) + def get_name(self): + ''' return turtle name (key) ''' + return self.name + def get_xy(self): """ Return the turtle's x, y coordinates. """ return(self.x, self.y) diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py index b5d083f..7068dc0 100644 --- a/TurtleArt/tawindow.py +++ b/TurtleArt/tawindow.py @@ -211,10 +211,10 @@ class TurtleArtWindow(): self.sprite_list = None self.turtles = Turtles(self.sprite_list) - if mynick is None: + if self.nick is None: self.default_turtle_name = DEFAULT_TURTLE else: - self.default_turtle_name = mynick + self.default_turtle_name = self.nick if mycolors is None: Turtle(self.turtles, self.default_turtle_name) else: @@ -927,6 +927,11 @@ class TurtleArtWindow(): # Next, look for a turtle t = self.turtles.spr_to_turtle(spr) if t is not None: + # If turtle is shared, ignore click + if hasattr(self, 'turtle_dictionary'): + if t.get_name() in self.turtle_dictionary and \ + t.get_name() != self.nick: + return True self.selected_turtle = t self.canvas.set_turtle(self.turtles.get_turtle_key(t)) self._turtle_pressed(x, y) -- cgit v0.9.1