diff --git a/projectfiles/xcode/Emulator/AppDelegate.h b/projectfiles/xcode/Emulator/AppDelegate.h index 449823bb8..f25be029c 100644 --- a/projectfiles/xcode/Emulator/AppDelegate.h +++ b/projectfiles/xcode/Emulator/AppDelegate.h @@ -17,6 +17,7 @@ @interface AppDelegate : NSObject { IBOutlet FBScreenView *screen; + IBOutlet NSView *spinner; } + (AppDelegate *) sharedInstance; diff --git a/projectfiles/xcode/Emulator/AppDelegate.m b/projectfiles/xcode/Emulator/AppDelegate.m index f2607114a..f535a942b 100644 --- a/projectfiles/xcode/Emulator/AppDelegate.m +++ b/projectfiles/xcode/Emulator/AppDelegate.m @@ -11,7 +11,7 @@ // FIXME: errors during load // FIXME: starting without ROM selected // FIXME: dropping file into window -// FIXME: sound when load fails +// FIXME: focus on visibility toggle @interface AppDelegate () @property (weak) IBOutlet NSWindow *window; @@ -27,6 +27,7 @@ static AppDelegate *sharedInstance = nil; { FBMainThread *main; BOOL _cursorVisible; + NSTitlebarAccessoryViewController *tbAccessory; } - (void) dealloc @@ -39,14 +40,19 @@ static AppDelegate *sharedInstance = nil; - (void) awakeFromNib { sharedInstance = self; - _video = [FBVideo new]; - _input = [FBInput new]; - main = [FBMainThread new]; + _input = [FBInput new]; _cursorVisible = YES; + + tbAccessory = [NSTitlebarAccessoryViewController new]; + tbAccessory.view = spinner; + tbAccessory.layoutAttribute = NSLayoutAttributeRight; + + main = [FBMainThread new]; main.delegate = self; - screen.delegate = self; + _video = [FBVideo new]; _video.delegate = screen; + screen.delegate = self; } - (void) applicationDidFinishLaunching:(NSNotification *)aNotification { @@ -138,11 +144,26 @@ static AppDelegate *sharedInstance = nil; if (screenSize.width != 0 && screenSize.height != 0) [self resizeFrame:NSMakeSize(screenSize.width * 2, screenSize.height * 2) animate:NO]; + + screen.hidden = NO; } - (void) gameSessionDidEnd { NSLog(@"gameSessionDidEnd"); + screen.hidden = YES; +} + +- (void) driverInitDidStart +{ + [spinner.subviews.firstObject startAnimation:self]; + [_window addTitlebarAccessoryViewController:tbAccessory]; +} + +- (void) driverInitDidEnd:(BOOL) success +{ + [spinner.subviews.firstObject stopAnimation:self]; + [tbAccessory removeFromParentViewController]; } #pragma mark - Actions diff --git a/projectfiles/xcode/Emulator/Base.lproj/MainMenu.xib b/projectfiles/xcode/Emulator/Base.lproj/MainMenu.xib index fbc1ee52a..82adbba2f 100644 --- a/projectfiles/xcode/Emulator/Base.lproj/MainMenu.xib +++ b/projectfiles/xcode/Emulator/Base.lproj/MainMenu.xib @@ -16,6 +16,7 @@ + @@ -181,5 +182,16 @@ + + + + + + + + + + + diff --git a/src/burner/macos/FBMainThread.h b/src/burner/macos/FBMainThread.h index cde90215a..cac1a354c 100644 --- a/src/burner/macos/FBMainThread.h +++ b/src/burner/macos/FBMainThread.h @@ -10,7 +10,9 @@ @protocol FBMainThreadDelegate -- (void) gameSessionDidStart: (NSString *) name; +- (void) driverInitDidStart; +- (void) driverInitDidEnd:(BOOL) success; +- (void) gameSessionDidStart:(NSString *) name; - (void) gameSessionDidEnd; @end diff --git a/src/burner/macos/FBMainThread.mm b/src/burner/macos/FBMainThread.mm index 9c977ed34..0b6aefd88 100644 --- a/src/burner/macos/FBMainThread.mm +++ b/src/burner/macos/FBMainThread.mm @@ -44,9 +44,24 @@ extern int MainEnd(); NSString *setPath = [[pathToLoad stringByDeletingLastPathComponent] stringByAppendingString:@"/"]; NSString *setName = [[pathToLoad lastPathComponent] stringByDeletingPathExtension]; + { + id del = _delegate; + dispatch_async(dispatch_get_main_queue(), ^{ + [del driverInitDidStart]; + }); + } + if (!MainInit([setPath cStringUsingEncoding:NSUTF8StringEncoding], [setName cStringUsingEncoding:NSUTF8StringEncoding])) { pathToLoad = nil; + + { + id del = _delegate; + dispatch_async(dispatch_get_main_queue(), ^{ + [del driverInitDidEnd:NO]; + }); + } + continue; } @@ -56,6 +71,7 @@ extern int MainEnd(); { id del = _delegate; dispatch_async(dispatch_get_main_queue(), ^{ + [del driverInitDidEnd:YES]; [del gameSessionDidStart:setName]; }); } diff --git a/src/burner/macos/main.cpp b/src/burner/macos/main.cpp index 0ad7f5ca4..d4138726d 100644 --- a/src/burner/macos/main.cpp +++ b/src/burner/macos/main.cpp @@ -33,9 +33,10 @@ int MainInit(const char *path, const char *setname) } bCheatsAllowed = false; - sprintf(szAppRomPaths[0], path); - DrvInit(i, 0); + + if (DrvInit(i, 0)) + return 0; MediaInit(); RunInit();