X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/puzzles/blobdiff_plain/9b4b03d31e30089e9f45f6ea166561c4c0c25a9c..4b24f58222c549b383d23ed86a958c9656218c48:/osx.m diff --git a/osx.m b/osx.m index 28af613..a27c840 100644 --- a/osx.m +++ b/osx.m @@ -60,13 +60,9 @@ * nested sheet. On the other hand I think there are good * practical reasons for wanting it that way. Uncertain. * - * - User feedback suggests we should have `File' and `Edit' menus - * like everyone else, so some menu reorg is probably required, - * along with some documentation rewording. - * - * - User feedback also dislikes nothing happening when you start - * the app; they suggest a finder-like window containing an icon - * for each puzzle type, enabling you to start one easily. Needs + * - User feedback dislikes nothing happening when you start the + * app; they suggest a finder-like window containing an icon for + * each puzzle type, enabling you to start one easily. Needs * thought. * * Grotty implementation details that could probably be improved: @@ -585,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]; } @@ -1151,12 +1165,12 @@ void status_bar(frontend *fe, char *text) @interface AppController : NSObject { } -- (void)newGame:(id)sender; +- (void)newGameWindow:(id)sender; @end @implementation AppController -- (void)newGame:(id)sender +- (void)newGameWindow:(id)sender { const game *g = [sender getPayload]; id win; @@ -1175,7 +1189,7 @@ void status_bar(frontend *fe, char *text) id item = initnewitem([DataMenuItem allocWithZone:[NSMenu menuZone]], menu, gamelist[i]->name, "", self, - @selector(newGame:)); + @selector(newGameWindow:)); [item setPayload:(void *)gamelist[i]]; } } @@ -1216,30 +1230,35 @@ int main(int argc, char **argv) item = newitem(menu, "Quit", "q", NSApp, @selector(terminate:)); [NSApp setAppleMenu: menu]; - menu = newsubmenu([NSApp mainMenu], "Open"); + menu = newsubmenu([NSApp mainMenu], "File"); + item = newitem(menu, "New Game", "n", NULL, @selector(newGame:)); + item = newitem(menu, "Restart Game", "r", NULL, @selector(restartGame:)); + item = newitem(menu, "Specific Game", "", NULL, @selector(specificGame:)); + [menu addItem:[NSMenuItem separatorItem]]; { + NSMenu *submenu = newsubmenu(menu, "New Window"); int i; for (i = 0; i < gamecount; i++) { id item = initnewitem([DataMenuItem allocWithZone:[NSMenu menuZone]], - menu, gamelist[i]->name, "", controller, - @selector(newGame:)); + submenu, gamelist[i]->name, "", controller, + @selector(newGameWindow:)); [item setPayload:(void *)gamelist[i]]; } } - - menu = newsubmenu([NSApp mainMenu], "Game"); - item = newitem(menu, "New", "n", NULL, @selector(newGame:)); - item = newitem(menu, "Restart", "r", NULL, @selector(restartGame:)); - item = newitem(menu, "Specific", "", NULL, @selector(specificGame:)); [menu addItem:[NSMenuItem separatorItem]]; + item = newitem(menu, "Close", "w", NULL, @selector(performClose:)); + + menu = newsubmenu([NSApp mainMenu], "Edit"); item = newitem(menu, "Undo", "z", NULL, @selector(undoMove:)); item = newitem(menu, "Redo", "S-z", NULL, @selector(redoMove:)); [menu addItem:[NSMenuItem separatorItem]]; + 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, "Close", "w", NULL, @selector(performClose:)); + item = newitem(menu, "Solve", "S-s", NULL, @selector(solveGame:)); menu = newsubmenu([NSApp mainMenu], "Type"); typemenu = menu;