[gnome-sudoku] Do not guess user's desired difficulty level
- From: Parin Porecha <parinporecha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sudoku] Do not guess user's desired difficulty level
- Date: Sun, 17 Aug 2014 22:14:39 +0000 (UTC)
commit a3190e8b07cde3be208940986f8a29d6046b2a72
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Tue Aug 12 21:13:46 2014 -0500
Do not guess user's desired difficulty level
If the user has never played GNOME Sudoku before, or just has no games
in progress, show the new game screen when starting Sudoku rather than
badly guessing which difficulty level he might want to play.
Usually a game will be saved and launching Sudoku will take you straight
to a puzzle, but if not, one click is not a big deal.
Lastly, it'd be better to present the new game screen than an empty
puzzle, so stop saving those.
https://bugzilla.gnome.org/show_bug.cgi?id=734699
src/gnome-sudoku.vala | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/src/gnome-sudoku.vala b/src/gnome-sudoku.vala
index bb5ceeb..2b7e860 100644
--- a/src/gnome-sudoku.vala
+++ b/src/gnome-sudoku.vala
@@ -165,15 +165,12 @@ public class Sudoku : Gtk.Application
if (savegame != null)
start_game (savegame.board);
else
- {
- var random_difficulty = (DifficultyCategory) Random.int_range (0, 4);
- start_game (SudokuGenerator.generate_board (random_difficulty));
- }
+ show_new_game_screen ();
window.show ();
window.delete_event.connect ((event) => {
- if (!game.board.complete)
+ if (game != null && !game.board.is_empty () && !game.board.complete)
saver.save_game (game);
return false;
@@ -277,7 +274,7 @@ public class Sudoku : Gtk.Application
});
}
- private void new_game_cb ()
+ private void show_new_game_screen ()
{
main_stack.set_visible_child_name ("start_box");
back_button.visible = true;
@@ -287,6 +284,11 @@ public class Sudoku : Gtk.Application
print_action.set_enabled (false);
}
+ private void new_game_cb ()
+ {
+ show_new_game_screen ();
+ }
+
private void start_game_cb (SimpleAction action, Variant? difficulty)
{
// Since we cannot have enums in .ui file, the 'action-target' property
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]