chiark / gitweb /
After much thought, I've decided that `Restart' on r is not a
authorSimon Tatham <anakin@pobox.com>
Tue, 17 May 2005 17:20:08 +0000 (17:20 +0000)
committerSimon Tatham <anakin@pobox.com>
Tue, 17 May 2005 17:20:08 +0000 (17:20 +0000)
particularly useful keypress, particularly given how easy it is to
confuse it with `Redo'. So both r and ^R are now Redo, and Restart
is relegated to being a menu-only option.

[originally from svn r5796]

gtk.c
midend.c
osx.m
windows.c

diff --git a/gtk.c b/gtk.c
index 24b2ccad794c17cfeabdb1d3a36ad7862d55634d..6de9fcf288b42046c910cc835d0ca06cc7c9619e 100644 (file)
--- a/gtk.c
+++ b/gtk.c
@@ -937,6 +937,13 @@ static void menu_solve_event(GtkMenuItem *menuitem, gpointer data)
        error_box(fe->window, msg);
 }
 
+static void menu_restart_event(GtkMenuItem *menuitem, gpointer data)
+{
+    frontend *fe = (frontend *)data;
+
+    midend_restart_game(fe->me);
+}
+
 static void menu_config_event(GtkMenuItem *menuitem, gpointer data)
 {
     frontend *fe = (frontend *)data;
@@ -1032,7 +1039,12 @@ static frontend *new_window(char *game_id, char **error)
     gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu);
 
     add_menu_item_with_key(fe, GTK_CONTAINER(menu), "New", 'n');
-    add_menu_item_with_key(fe, GTK_CONTAINER(menu), "Restart", 'r');
+
+    menuitem = gtk_menu_item_new_with_label("Restart");
+    gtk_container_add(GTK_CONTAINER(menu), menuitem);
+    gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
+                      GTK_SIGNAL_FUNC(menu_restart_event), fe);
+    gtk_widget_show(menuitem);
 
     menuitem = gtk_menu_item_new_with_label("Specific...");
     gtk_object_set_data(GTK_OBJECT(menuitem), "user-data",
index 0c914918fca752d0eb50254615c867c1c0e64214..d35ad7cd80a72a8e032b48b83616c6eab4c3eefa 100644 (file)
--- a/midend.c
+++ b/midend.c
@@ -2,7 +2,7 @@
  * midend.c: general middle fragment sitting between the
  * platform-specific front end and game-specific back end.
  * Maintains a move list, takes care of Undo and Redo commands, and
- * processes standard keystrokes for undo/redo/new/restart/quit.
+ * processes standard keystrokes for undo/redo/new/quit.
  */
 
 #include <stdio.h>
@@ -238,6 +238,8 @@ void midend_restart_game(midend_data *me)
 {
     game_state *s;
 
+    midend_stop_anim(me);
+
     assert(me->statepos >= 1);
     if (me->statepos == 1)
         return;                        /* no point doing anything at all! */
@@ -272,11 +274,6 @@ static int midend_really_process_key(midend_data *me, int x, int y, int button)
        midend_new_game(me);
         midend_redraw(me);
         return 1;                      /* never animate */
-    } else if (button == 'r' || button == 'R') {
-       midend_stop_anim(me);
-       midend_restart_game(me);
-        midend_redraw(me);
-        return 1;                      /* never animate */
     } else if (button == 'u' || button == 'u' ||
                button == '\x1A' || button == '\x1F') {
        midend_stop_anim(me);
@@ -284,7 +281,8 @@ static int midend_really_process_key(midend_data *me, int x, int y, int button)
         gotspecial = TRUE;
        if (!midend_undo(me))
             return 1;
-    } else if (button == '\x12') {
+    } else if (button == 'r' || button == 'R' ||
+               button == '\x12') {
        midend_stop_anim(me);
        if (!midend_redo(me))
             return 1;
diff --git a/osx.m b/osx.m
index 337748d2ef198554092f28606c484cf19a74fb40..dfed94c329d33bb7f4adc35f1475738795a46a8c 100644 (file)
--- a/osx.m
+++ b/osx.m
@@ -651,7 +651,7 @@ struct frontend {
 }
 - (void)restartGame:(id)sender
 {
-    [self processButton:'r' x:-1 y:-1];
+    midend_restart_game(me);
 }
 - (void)undoMove:(id)sender
 {
index da324b13386ad952cb557ae0f858d2836d758d00..45ec69c79f62f4516bbd1a62c9e5b7ed79b136c1 100644 (file)
--- a/windows.c
+++ b/windows.c
@@ -1120,8 +1120,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
                PostQuitMessage(0);
            break;
          case IDM_RESTART:
-           if (!midend_process_key(fe->me, 0, 0, 'r'))
-               PostQuitMessage(0);
+           midend_restart_game(fe->me);
            break;
          case IDM_UNDO:
            if (!midend_process_key(fe->me, 0, 0, 'u'))