From ba94ae247957c929ce04455d59d4801516d28079 Mon Sep 17 00:00:00 2001 From: meancoot Date: Sun, 7 Jul 2013 14:46:16 -0400 Subject: [PATCH] (Apple) More OSX UI wiring --- apple/OSX/en.lproj/MainMenu.xib | 151 +++++++++++++++++++++++++++----- apple/RetroArch/RAGameView.m | 12 ++- apple/RetroArch/main.m | 33 ++++--- apple/RetroArch/utility.m | 9 ++ 4 files changed, 172 insertions(+), 33 deletions(-) diff --git a/apple/OSX/en.lproj/MainMenu.xib b/apple/OSX/en.lproj/MainMenu.xib index d78c9a06b6..078d9b3e79 100644 --- a/apple/OSX/en.lproj/MainMenu.xib +++ b/apple/OSX/en.lproj/MainMenu.xib @@ -240,6 +240,56 @@ + + + Core + + 2147483647 + + + submenuAction: + + Core + + + + Reset + + 2147483647 + + + 1 + + + + Load State + + 2147483647 + + + 2 + + + + Save State + + 2147483647 + + + 3 + + + + Unload + + 2147483647 + + + 4 + + + + Window @@ -336,6 +386,7 @@ {480, 360} + {{0, 0}, {2560, 1418}} {10000000000000, 10000000000000} @@ -344,9 +395,6 @@ RetroArch_OSX - - NSFontManager - @@ -462,6 +510,38 @@ 532 + + + basicEvent: + + + + 548 + + + + basicEvent: + + + + 550 + + + + basicEvent: + + + + 552 + + + + basicEvent: + + + + 556 + @@ -497,6 +577,7 @@ + @@ -696,11 +777,6 @@ - - 420 - - - 490 @@ -727,6 +803,45 @@ + + 545 + + + + + + + + 546 + + + + + + + + + + + 547 + + + + + 549 + + + + + 551 + + + + + 555 + + + @@ -756,12 +871,17 @@ {{380, 496}, {480, 360}} com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -776,24 +896,13 @@ - 535 + 556 RetroArch_OSX NSObject - - window - NSWindow - - - window - - window - NSWindow - - IBProjectSource ./Classes/RetroArch_OSX.h diff --git a/apple/RetroArch/RAGameView.m b/apple/RetroArch/RAGameView.m index f350bf7c01..8f05fee13a 100644 --- a/apple/RetroArch/RAGameView.m +++ b/apple/RetroArch/RAGameView.m @@ -76,6 +76,11 @@ static float g_screen_scale = 1.0f; [self.openGLContext flushBuffer]; } +- (void)bindDrawable +{ + glBindFramebuffer(GL_FRAMEBUFFER, 0); +} + #elif defined(IOS) // < iOS Pause menu and lifecycle - (id)init { @@ -191,21 +196,24 @@ bool apple_init_game_view() void apple_destroy_game_view() { -#ifdef IOS dispatch_sync(dispatch_get_main_queue(), ^{ // Clear the view, otherwise the last frame form this game will be displayed // briefly on the next game. [g_view bindDrawable]; + glClearColor(0, 0, 0, 1); glClear(GL_COLOR_BUFFER_BIT); [g_view display]; glFinish(); - + +#ifdef IOS g_view.context = nil; [EAGLContext setCurrentContext:nil]; g_context = nil; +#endif }); +#ifdef IOS [EAGLContext setCurrentContext:nil]; #else [NSOpenGLContext clearCurrentContext]; diff --git a/apple/RetroArch/main.m b/apple/RetroArch/main.m index a558bb9b6f..26eca01877 100644 --- a/apple/RetroArch/main.m +++ b/apple/RetroArch/main.m @@ -128,7 +128,6 @@ void apple_run_core(RAModuleInfo* core, const char* file) } pthread_detach(apple_retro_thread); -// [self refreshSystemConfig]; } } @@ -487,7 +486,9 @@ int main(int argc, char *argv[]) - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { apple_platform = self; - + + [window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; + window.backgroundColor = [NSColor blackColor]; [window.contentView setAutoresizesSubviews:YES]; @@ -502,35 +503,47 @@ int main(int argc, char *argv[]) - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename { - apple_run_core(nil, filename.UTF8String); + if (filename) + apple_run_core(nil, filename.UTF8String); return YES; } --(void)application:(NSApplication *)sender openFiles:(NSArray *)filenames +- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames { - if (filenames.count == 1) + if (filenames.count == 1 && filenames[0]) apple_run_core(nil, [filenames[0] UTF8String]); else apple_display_alert(@"Cannot open multiple files", @"RetroArch"); } --(void)openDocument:(id)sender +- (void)openDocument:(id)sender { NSOpenPanel* panel = [NSOpenPanel openPanel]; - - if ([panel runModal] == NSOKButton && panel.URL) - apple_run_core(nil, panel.URL.path.UTF8String); + [panel beginSheetModalForWindow:window completionHandler:^(NSInteger result) + { + if (result == NSOKButton && panel.URL) + apple_run_core(nil, panel.URL.path.UTF8String); + }]; } #pragma mark RetroArch_Platform - (void)loadingCore:(RAModuleInfo*)core withFile:(const char*)file { + if (file) + [NSDocumentController.sharedDocumentController noteNewRecentDocumentURL:[NSURL fileURLWithPath:[NSString stringWithUTF8String:file]]]; } - (void)unloadingCore:(RAModuleInfo*)core { } +#pragma mark Menus +- (IBAction)basicEvent:(id)sender +{ + if (apple_is_running) + apple_frontend_post_event(&event_basic_command, (void*)((NSMenuItem*)sender).tag); +} + @end int main(int argc, char *argv[]) @@ -538,4 +551,4 @@ int main(int argc, char *argv[]) return NSApplicationMain(argc, (const char **) argv); } -#endif \ No newline at end of file +#endif diff --git a/apple/RetroArch/utility.m b/apple/RetroArch/utility.m index be0a44297f..a56806e69a 100644 --- a/apple/RetroArch/utility.m +++ b/apple/RetroArch/utility.m @@ -29,6 +29,15 @@ void apple_display_alert(NSString* message, NSString* title) cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; +#else + NSAlert* alert = [NSAlert new]; + alert.messageText = title ? title : @"RetroArch"; + alert.informativeText = message; + alert.alertStyle = NSInformationalAlertStyle; + [alert beginSheetModalForWindow:NSApplication.sharedApplication.mainWindow + modalDelegate:nil + didEndSelector:nil + contextInfo:nil]; #endif }