Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2012-04-04 20:31:27 (GMT)
committer Walter Bender <walter.bender@gmail.com>2012-04-04 20:31:27 (GMT)
commit767424c452b470ab24092330c05f17d81fd54072 (patch)
treeddbda7b12b01bcab5fd36227086d65515cb1ae3a
parent7c1b9abf0d2b9a76d84aacb74d72c66e80c6751b (diff)
save/restore dot position in Journal
-rw-r--r--XOEditorActivity.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/XOEditorActivity.py b/XOEditorActivity.py
index 8322049..3358872 100644
--- a/XOEditorActivity.py
+++ b/XOEditorActivity.py
@@ -27,6 +27,7 @@ if _have_toolbox:
from sugar.activity.widgets import StopButton
from sugar.graphics.objectchooser import ObjectChooser
from sugar.graphics.alert import ConfirmationAlert, NotifyAlert
+from sugar.graphics.xocolor import colors
from toolbar_utils import button_factory, radio_factory, separator_factory
@@ -68,6 +69,15 @@ class XOEditorActivity(activity.Activity):
self._game = Game(canvas, parent=self, mycolors=self.colors)
+ # Read the dot positions from the Journal
+ for i in range(len(colors)):
+ if 'x%d' % (i) in self.metadata and 'y%d' % (i) in self.metadata:
+ self._game.move_dot(i, int(self.metadata['x%d' % (i)]),
+ int(self.metadata['y%d' % (i)]))
+ if 'xox' in self.metadata and 'xoy' in self.metadata:
+ self._game.move_xo_man(int(self.metadata['xox']),
+ int(self.metadata['xoy']))
+
def _setup_toolbars(self, have_toolbox):
""" Setup the toolbars. """
@@ -153,3 +163,13 @@ class XOEditorActivity(activity.Activity):
def _rotate_cb(self, button=None):
self._game.rotate()
+
+ def write_file(self, file_path):
+ for i in range(len(colors)):
+ x, y = self._game.get_dot_xy(i)
+ self.metadata['x%d' % (i)] = str(x)
+ self.metadata['y%d' % (i)] = str(y)
+
+ x, y = self._game.get_xo_man_xy()
+ self.metadata['xox'] = str(x)
+ self.metadata['xoy'] = str(y)