diff options
| author | Simon Tatham <anakin@pobox.com> | 2005-05-02 13:17:10 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2005-05-02 13:17:10 +0000 |
| commit | 4f7b65de2e5f6387a819dd3767f5459b06f5db11 (patch) | |
| tree | cae01c5919854fcbbffae43de6032fc50ae5c031 /gtk.c | |
| parent | aea7b6181580df2f0b28d027832dee8d9abccd73 (diff) | |
| download | puzzles-4f7b65de2e5f6387a819dd3767f5459b06f5db11.zip puzzles-4f7b65de2e5f6387a819dd3767f5459b06f5db11.tar.gz puzzles-4f7b65de2e5f6387a819dd3767f5459b06f5db11.tar.bz2 puzzles-4f7b65de2e5f6387a819dd3767f5459b06f5db11.tar.xz | |
Added an automatic `Solve' feature to most games. This is useful for
various things:
- if you haven't fully understood what a game is about, it gives
you an immediate example of a puzzle plus its solution so you can
understand it
- in some games it's useful to compare your solution with the real
one and see where you made a mistake
- in the rearrangement games (Fifteen, Sixteen, Twiddle) it's handy
to be able to get your hands on a pristine grid quickly so you
can practise or experiment with manoeuvres on it
- it provides a good way of debugging the games if you think you've
encountered an unsolvable grid!
[originally from svn r5731]
Diffstat (limited to 'gtk.c')
| -rw-r--r-- | gtk.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -913,6 +913,17 @@ static void menu_copy_event(GtkMenuItem *menuitem, gpointer data) } } +static void menu_solve_event(GtkMenuItem *menuitem, gpointer data) +{ + frontend *fe = (frontend *)data; + char *msg; + + msg = midend_solve(fe->me); + + if (msg) + error_box(fe->window, msg); +} + static void menu_config_event(GtkMenuItem *menuitem, gpointer data) { frontend *fe = (frontend *)data; @@ -1050,6 +1061,14 @@ static frontend *new_window(char *game_id, char **error) GTK_SIGNAL_FUNC(menu_copy_event), fe); gtk_widget_show(menuitem); } + if (thegame.can_solve) { + add_menu_separator(GTK_CONTAINER(menu)); + menuitem = gtk_menu_item_new_with_label("Solve"); + gtk_container_add(GTK_CONTAINER(menu), menuitem); + gtk_signal_connect(GTK_OBJECT(menuitem), "activate", + GTK_SIGNAL_FUNC(menu_solve_event), fe); + gtk_widget_show(menuitem); + } add_menu_separator(GTK_CONTAINER(menu)); add_menu_item_with_key(fe, GTK_CONTAINER(menu), "Exit", 'q'); |