[gnome-games/sudoku-tube] Calculate the difficulty only once
- From: Zhang Sen <zhangsen src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-games/sudoku-tube] Calculate the difficulty only once
- Date: Tue, 21 Jul 2009 10:44:07 +0000 (UTC)
commit a6e7551b35bc4a1e62558407da76777cbef5a0d4
Author: Zhang Sen <zh jesse gmail com>
Date: Tue Jul 21 17:05:43 2009 +0800
Calculate the difficulty only once
gnome-sudoku/src/lib/main.py | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/gnome-sudoku/src/lib/main.py b/gnome-sudoku/src/lib/main.py
index 049462f..73760fa 100644
--- a/gnome-sudoku/src/lib/main.py
+++ b/gnome-sudoku/src/lib/main.py
@@ -158,9 +158,15 @@ class UI (gconf_wrapper.GConfWrapper):
"""Properly do the setup after entering game
Like show highlight, update hints, start timer, etc."""
- self.timer.start_timing()
- self.update_statusbar()
+ self._calc_difficulty()
self.setup_toggles()
+ self.update_statusbar()
+
+ self.timer.start_timing()
+
+ def _calc_difficulty(self):
+ puzzle = self._main_model.grid.virgin.to_string()
+ self._difficulty = self.sudoku_maker.get_difficulty(puzzle)
def _run_background_generator (self):
"""Generate puzzles in background"""
@@ -527,7 +533,7 @@ class UI (gconf_wrapper.GConfWrapper):
self.set_statusbar_value(" ")
return True
- puzzle_diff = self._get_difficulty()
+ puzzle_diff = self._difficulty
tot_string = _("Playing %(difficulty)s puzzle.") % {'difficulty':puzzle_diff.value_string()}
tot_string += " " + "(%1.2f)" % puzzle_diff.value
@@ -537,10 +543,6 @@ class UI (gconf_wrapper.GConfWrapper):
def toggle_highlight_cb (self, widg):
self._main_grid_vew.toggle_highlight(widg.get_active())
- def _get_difficulty(self):
- puzzle = self._main_model.grid.virgin.to_string()
- return self.sudoku_maker.get_difficulty(puzzle)
-
def show_info_cb (self, *args):
if not self._main_model.grid:
dialog_extras.show_message(parent = self.w,
@@ -548,7 +550,7 @@ class UI (gconf_wrapper.GConfWrapper):
label = _("There is no current puzzle.")
)
return
- diff = self._get_difficulty()
+ diff = self._difficulty
information = _("Calculated difficulty: ")
information += diff.value_string()
information += " (%1.2f)" % diff.value
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]