mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-22 16:32:13 -07:00
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]
This commit is contained in:
20
osx.m
20
osx.m
@ -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;
|
||||
|
Reference in New Issue
Block a user