From 4f7b65de2e5f6387a819dd3767f5459b06f5db11 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Mon, 2 May 2005 13:17:10 +0000 Subject: 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] --- windows.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'windows.c') diff --git a/windows.c b/windows.c index c570b29..4df9175 100644 --- a/windows.c +++ b/windows.c @@ -28,11 +28,12 @@ #define IDM_UNDO 0x0030 #define IDM_REDO 0x0040 #define IDM_COPY 0x0050 -#define IDM_QUIT 0x0060 -#define IDM_CONFIG 0x0070 -#define IDM_SEED 0x0080 -#define IDM_HELPC 0x0090 -#define IDM_GAMEHELP 0x00A0 +#define IDM_SOLVE 0x0060 +#define IDM_QUIT 0x0070 +#define IDM_CONFIG 0x0080 +#define IDM_SEED 0x0090 +#define IDM_HELPC 0x00A0 +#define IDM_GAMEHELP 0x00B0 #define IDM_PRESETS 0x0100 #define HELP_FILE_NAME "puzzles.hlp" @@ -487,6 +488,10 @@ static frontend *new_window(HINSTANCE inst, char *game_id, char **error) AppendMenu(menu, MF_SEPARATOR, 0, 0); AppendMenu(menu, MF_ENABLED, IDM_COPY, "Copy"); } + if (thegame.can_solve) { + AppendMenu(menu, MF_SEPARATOR, 0, 0); + AppendMenu(menu, MF_ENABLED, IDM_SOLVE, "Solve"); + } AppendMenu(menu, MF_SEPARATOR, 0, 0); AppendMenu(menu, MF_ENABLED, IDM_QUIT, "Exit"); if (fe->help_path) { @@ -930,6 +935,14 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, MessageBeep(MB_ICONWARNING); } break; + case IDM_SOLVE: + { + char *msg = midend_solve(fe->me); + if (msg) + MessageBox(hwnd, msg, "Unable to solve", + MB_ICONERROR | MB_OK); + } + break; case IDM_QUIT: if (!midend_process_key(fe->me, 0, 0, 'q')) PostQuitMessage(0); -- cgit v1.1