[gnome-mahjongg] Do not allow shuffling if it's guaranteed to fail



commit dcdb6193ced9e021c645616dafb2a65f37a3a60e
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sun Aug 17 14:23:08 2014 -0500

    Do not allow shuffling if it's guaranteed to fail
    
    https://bugzilla.gnome.org/show_bug.cgi?id=732225

 src/gnome-mahjongg.vala |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/src/gnome-mahjongg.vala b/src/gnome-mahjongg.vala
index 5f16ce8..41370f0 100644
--- a/src/gnome-mahjongg.vala
+++ b/src/gnome-mahjongg.vala
@@ -383,15 +383,19 @@ public class Mahjongg : Gtk.Application
         }
         else if (!game_view.game.can_move)
         {
+            bool allow_shuffle = game_view.game.number_of_movable_tiles () > 1;
+
             var dialog = new Gtk.MessageDialog (window, Gtk.DialogFlags.MODAL | 
Gtk.DialogFlags.DESTROY_WITH_PARENT,
                                                 Gtk.MessageType.INFO,
                                                 Gtk.ButtonsType.NONE,
                                                 "%s", _("There are no more moves."));
-            dialog.format_secondary_text (_("Each puzzle has at least one solution.  You can undo your moves 
and try and find the solution, restart this game, or start a new one. You can also try to reshuffle the game, 
but this does not guarantee a solution."));
+            dialog.format_secondary_text ("%s%s%s".printf (_("Each puzzle has at least one solution.  You 
can undo your moves and try and find the solution, restart this game, or start a new one."),
+                                                           allow_shuffle ? " " : "",
+                                                           allow_shuffle ? _("You can also try to reshuffle 
the game, but this does not guarantee a solution.") : ""));
             dialog.add_buttons (_("_Undo"), NoMovesDialogResponse.UNDO,
                                 _("_Restart"), NoMovesDialogResponse.RESTART,
                                 _("_New game"), NoMovesDialogResponse.NEW_GAME,
-                                _("_Shuffle"), NoMovesDialogResponse.SHUFFLE);
+                                allow_shuffle ? _("_Shuffle") : null, NoMovesDialogResponse.SHUFFLE);
 
             var result = dialog.run ();
             /* Shuffling may cause the dialog to appear again immediately,


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