[gnome-games/sudoku-tube] Read more attributes from saved file



commit d69919db9e0b47aaf83093fb7c7eee22ffe6a2b5
Author: Zhang Sen <zh jesse gmail com>
Date:   Tue Jul 21 19:48:25 2009 +0800

    Read more attributes from saved file

 gnome-sudoku/src/lib/gsudoku.py |   12 +++++++++++-
 gnome-sudoku/src/lib/main.py    |   14 +++++++++++---
 2 files changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/gnome-sudoku/src/lib/gsudoku.py b/gnome-sudoku/src/lib/gsudoku.py
index a1d91b8..586ae2f 100644
--- a/gnome-sudoku/src/lib/gsudoku.py
+++ b/gnome-sudoku/src/lib/gsudoku.py
@@ -412,6 +412,9 @@ class NotesModel:
     def _increase_hints_count(self):
         self._hints_count += 1
 
+    def set_hints_count(self, count):
+        self._hints_count = count
+
     def get_hints_count(self):
         return self._hints_count
 
@@ -422,7 +425,7 @@ class NotesModel:
 class SudokuModel:
 
     def __init__ (self, virgin_grid, group_size, initial_grid=None):
-        self.auto_fills = 0
+        self.autofill_count = 0
         self.show_impossible_implications = False
         self.impossible_hints = 0
         self.impossibilities = []
@@ -535,7 +538,14 @@ class SudokuModel:
         if self.grid.check_for_completeness():
             self._signal_completeness()
 
+    def set_autofill_count(self, count):
+        self.autofill_count = count
+
+    def get_autofill_count(self):
+        return self.autofill_count
+
     def auto_fill (self):
+        self.autofill_count += 1
         result = []
 
         changed = set(self.grid.auto_fill()) # there are duplicate?
diff --git a/gnome-sudoku/src/lib/main.py b/gnome-sudoku/src/lib/main.py
index 42670d8..d6fcb67 100644
--- a/gnome-sudoku/src/lib/main.py
+++ b/gnome-sudoku/src/lib/main.py
@@ -131,9 +131,16 @@ class UI (gconf_wrapper.GConfWrapper):
     def _open_saved_game(self, jar):
         virgin, in_prog = jar["game"].split('\n')
         self._main_model = gsudoku.SudokuModel(virgin, 9, in_prog)
+        self._main_model.set_autofill_count(jar["gsd.auto_fills"])
+
         self._notes_model = gsudoku.NotesModel(self._main_model, group_size=9)
+        self._notes_model.set_hints_count(jar["gsd.hints"])
         for (x, y, top, bottom) in jar["notes"]:
             self._notes_model.set_notes(x, y, top, bottom)
+
+        self.timer.__absolute_start_time__ = jar["timer.__absolute_start_time__"]
+        self.timer.active_time = jar["timer.active_time"]
+        self.timer.total_time = jar["timer.total_time"]
         return
 
         # this is a bit easily breakable... we take advantage of the fact
@@ -377,11 +384,12 @@ class UI (gconf_wrapper.GConfWrapper):
                                  self._main_model.impossible_hints) % {
                                          'n': self._main_model.impossible_hints}
             sublabel += "\n"
-        if self._main_model.auto_fills:
+        autofill_count = self._main_model.get_autofill_count()
+        if autofill_count:
             sublabel += ngettext("You used the auto-fill %(n)s time",
                                  "You used the auto-fill %(n)s times",
-                                 self._main_model.auto_fills) % {
-                                         'n':self._main_model.auto_fills}
+                                 autofill_count) % {
+                                         'n': autofill_count}
         import dancer
         self.dancer = dancer.GridDancer(self._main_grid_vew, self._main_model)
         self.dancer.start_dancing()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]