(Apple) More OSX UI wiring

This commit is contained in:
meancoot 2013-07-07 14:46:16 -04:00
parent e709784b70
commit ba94ae2479
4 changed files with 172 additions and 33 deletions

View File

@ -240,6 +240,56 @@
</array>
</object>
</object>
<object class="NSMenuItem" id="265357942">
<reference key="NSMenu" ref="649796088"/>
<string key="NSTitle">Core</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
<string key="NSAction">submenuAction:</string>
<object class="NSMenu" key="NSSubmenu" id="604031057">
<string key="NSTitle">Core</string>
<array class="NSMutableArray" key="NSMenuItems">
<object class="NSMenuItem" id="768774843">
<reference key="NSMenu" ref="604031057"/>
<string key="NSTitle">Reset</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
<int key="NSTag">1</int>
</object>
<object class="NSMenuItem" id="354494807">
<reference key="NSMenu" ref="604031057"/>
<string key="NSTitle">Load State</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
<int key="NSTag">2</int>
</object>
<object class="NSMenuItem" id="870739926">
<reference key="NSMenu" ref="604031057"/>
<string key="NSTitle">Save State</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
<int key="NSTag">3</int>
</object>
<object class="NSMenuItem" id="555841229">
<reference key="NSMenu" ref="604031057"/>
<string key="NSTitle">Unload</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
<int key="NSTag">4</int>
</object>
</array>
</object>
</object>
<object class="NSMenuItem" id="713487014">
<reference key="NSMenu" ref="649796088"/>
<string key="NSTitle">Window</string>
@ -336,6 +386,7 @@
<string key="NSFrameSize">{480, 360}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
</object>
<string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string>
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
@ -344,9 +395,6 @@
<object class="NSCustomObject" id="976324537">
<string key="NSClassName">RetroArch_OSX</string>
</object>
<object class="NSCustomObject" id="755631768">
<string key="NSClassName">NSFontManager</string>
</object>
</array>
<object class="IBObjectContainer" key="IBDocument.Objects">
<array class="NSMutableArray" key="connectionRecords">
@ -462,6 +510,38 @@
</object>
<int key="connectionID">532</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">basicEvent:</string>
<reference key="source" ref="976324537"/>
<reference key="destination" ref="768774843"/>
</object>
<int key="connectionID">548</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">basicEvent:</string>
<reference key="source" ref="976324537"/>
<reference key="destination" ref="354494807"/>
</object>
<int key="connectionID">550</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">basicEvent:</string>
<reference key="source" ref="976324537"/>
<reference key="destination" ref="870739926"/>
</object>
<int key="connectionID">552</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">basicEvent:</string>
<reference key="source" ref="976324537"/>
<reference key="destination" ref="555841229"/>
</object>
<int key="connectionID">556</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
@ -497,6 +577,7 @@
<reference ref="694149608"/>
<reference ref="379814623"/>
<reference ref="448692316"/>
<reference ref="265357942"/>
</array>
<reference key="parent" ref="0"/>
</object>
@ -696,11 +777,6 @@
<reference key="object" ref="439893737"/>
<reference key="parent" ref="972006081"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">420</int>
<reference key="object" ref="755631768"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">490</int>
<reference key="object" ref="448692316"/>
@ -727,6 +803,45 @@
<reference key="object" ref="976324537"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">545</int>
<reference key="object" ref="265357942"/>
<array class="NSMutableArray" key="children">
<reference ref="604031057"/>
</array>
<reference key="parent" ref="649796088"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">546</int>
<reference key="object" ref="604031057"/>
<array class="NSMutableArray" key="children">
<reference ref="768774843"/>
<reference ref="354494807"/>
<reference ref="870739926"/>
<reference ref="555841229"/>
</array>
<reference key="parent" ref="265357942"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">547</int>
<reference key="object" ref="768774843"/>
<reference key="parent" ref="604031057"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">549</int>
<reference key="object" ref="354494807"/>
<reference key="parent" ref="604031057"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">551</int>
<reference key="object" ref="870739926"/>
<reference key="parent" ref="604031057"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">555</int>
<reference key="object" ref="555841229"/>
<reference key="parent" ref="604031057"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
@ -756,12 +871,17 @@
<string key="371.IBWindowTemplateEditedContentRect">{{380, 496}, {480, 360}}</string>
<integer value="1" key="371.NSWindowTemplate.visibleAtLaunch"/>
<string key="372.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="420.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="490.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="491.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="492.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="494.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="5.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="545.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="546.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="547.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="549.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="551.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="555.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="56.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="57.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="58.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
@ -776,24 +896,13 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">535</int>
<int key="maxID">556</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">RetroArch_OSX</string>
<string key="superclassName">NSObject</string>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">window</string>
<string key="NS.object.0">NSWindow</string>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<string key="NS.key.0">window</string>
<object class="IBToOneOutletInfo" key="NS.object.0">
<string key="name">window</string>
<string key="candidateClassName">NSWindow</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/RetroArch_OSX.h</string>

View File

@ -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];

View File

@ -128,7 +128,6 @@ void apple_run_core(RAModuleInfo* core, const char* file)
}
pthread_detach(apple_retro_thread);
// [self refreshSystemConfig];
}
}
@ -488,6 +487,8 @@ int main(int argc, char *argv[])
{
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[])

View File

@ -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
}