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 /osx.m | |
| 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 'osx.m')
| -rw-r--r-- | osx.m | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -581,10 +581,28 @@ struct frontend { NSBeep(); } +- (void)solveGame:(id)sender +{ + char *msg; + NSAlert *alert; + + msg = midend_solve(me); + + if (msg) { + alert = [[[NSAlert alloc] init] autorelease]; + [alert addButtonWithTitle:@"Bah"]; + [alert setInformativeText:[NSString stringWithCString:msg]]; + [alert beginSheetModalForWindow:self modalDelegate:nil + didEndSelector:nil contextInfo:nil]; + } +} + - (BOOL)validateMenuItem:(NSMenuItem *)item { if ([item action] == @selector(copy:)) return (ourgame->can_format_as_text ? YES : NO); + else if ([item action] == @selector(solveGame:)) + return (ourgame->can_solve ? YES : NO); else return [super validateMenuItem:item]; } @@ -1239,6 +1257,8 @@ int main(int argc, char **argv) item = newitem(menu, "Cut", "x", NULL, @selector(cut:)); item = newitem(menu, "Copy", "c", NULL, @selector(copy:)); item = newitem(menu, "Paste", "v", NULL, @selector(paste:)); + [menu addItem:[NSMenuItem separatorItem]]; + item = newitem(menu, "Solve", "S-s", NULL, @selector(solveGame:)); menu = newsubmenu([NSApp mainMenu], "Type"); typemenu = menu; |