(OSX) Reduce usage of obj-c dot notation to explicit properties.

This commit is contained in:
meancoot 2013-12-14 20:35:47 -05:00
parent b86a2c92e6
commit 4c526585f5
5 changed files with 100 additions and 98 deletions

View File

@ -35,37 +35,39 @@ static void* const associated_core_key = (void*)&associated_core_key;
{ {
[super sendEvent:event]; [super sendEvent:event];
if (event.type == NSKeyDown || event.type == NSKeyUp) NSEventType event_type = [event type];
apple_input_handle_key_event(event.keyCode, event.type == GSEVENT_TYPE_KEYDOWN);
else if (event.type == NSFlagsChanged) if (event_type == NSKeyDown || event_type == NSKeyUp)
apple_input_handle_key_event([event keyCode], event_type == GSEVENT_TYPE_KEYDOWN);
else if (event_type == NSFlagsChanged)
{ {
static uint32_t old_flags = 0; static uint32_t old_flags = 0;
uint32_t new_flags = event.modifierFlags; uint32_t new_flags = [event modifierFlags];
bool down = (new_flags & old_flags) == old_flags; bool down = (new_flags & old_flags) == old_flags;
old_flags = new_flags; old_flags = new_flags;
apple_input_handle_key_event(event.keyCode, down); apple_input_handle_key_event([event keyCode], down);
} }
else if (event.type == NSMouseMoved || event.type == NSLeftMouseDragged || else if (event_type == NSMouseMoved || event_type == NSLeftMouseDragged ||
event.type == NSRightMouseDragged || event.type == NSOtherMouseDragged) event_type == NSRightMouseDragged || event_type == NSOtherMouseDragged)
{ {
// Relative // Relative
g_current_input_data.mouse_delta[0] += event.deltaX; g_current_input_data.mouse_delta[0] += [event deltaX];
g_current_input_data.mouse_delta[1] += event.deltaY; g_current_input_data.mouse_delta[1] += [event deltaY];
// Absolute // Absolute
NSPoint pos = [[RAGameView get] convertPoint:[event locationInWindow] fromView:nil]; NSPoint pos = [[RAGameView get] convertPoint:[event locationInWindow] fromView:nil];
g_current_input_data.touches[0].screen_x = pos.x; g_current_input_data.touches[0].screen_x = pos.x;
g_current_input_data.touches[0].screen_y = pos.y; g_current_input_data.touches[0].screen_y = pos.y;
} }
else if (event.type == NSLeftMouseDown || event.type == NSRightMouseDown || event.type == NSOtherMouseDown) else if (event_type == NSLeftMouseDown || event_type == NSRightMouseDown || event_type == NSOtherMouseDown)
{ {
g_current_input_data.mouse_buttons |= 1 << event.buttonNumber; g_current_input_data.mouse_buttons |= 1 << [event buttonNumber];
g_current_input_data.touch_count = 1; g_current_input_data.touch_count = 1;
} }
else if (event.type == NSLeftMouseUp || event.type == NSRightMouseUp || event.type == NSOtherMouseUp) else if (event_type == NSLeftMouseUp || event_type == NSRightMouseUp || event_type == NSOtherMouseUp)
{ {
g_current_input_data.mouse_buttons &= ~(1 << event.buttonNumber); g_current_input_data.mouse_buttons &= ~(1 << [event buttonNumber]);
g_current_input_data.touch_count = 0; g_current_input_data.touch_count = 0;
} }
} }
@ -116,22 +118,22 @@ static void* const associated_core_key = (void*)&associated_core_key;
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); NSArray* paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
self.configDirectory = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"RetroArch"]; self.configDirectory = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"RetroArch"];
self.globalConfigFile = [NSString stringWithFormat:@"%@/retroarch.cfg", self.configDirectory]; self.globalConfigFile = [NSString stringWithFormat:@"%@/retroarch.cfg", self.configDirectory];
self.coreDirectory = [NSBundle.mainBundle.bundlePath stringByAppendingPathComponent:@"Contents/Resources/modules"]; self.coreDirectory = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"Contents/Resources/modules"];
self.window.acceptsMouseMovedEvents = YES; [self.window setAcceptsMouseMovedEvents: YES];
RAGameView.get.frame = [self.window.contentView bounds]; [[RAGameView get] setFrame: [[self.window contentView] bounds]];
[self.window.contentView setAutoresizesSubviews:YES]; [[self.window contentView] setAutoresizesSubviews:YES];
[self.window.contentView addSubview:RAGameView.get]; [[self.window contentView] addSubview:RAGameView.get];
[self.window makeFirstResponder:RAGameView.get]; [self.window makeFirstResponder:[RAGameView get]];
self.settingsWindow = [[[NSWindowController alloc] initWithWindowNibName:@"Settings"] autorelease]; self.settingsWindow = [[[NSWindowController alloc] initWithWindowNibName:@"Settings"] autorelease];
// Create core select list // Create core select list
NSComboBox* cb = (NSComboBox*)[self.coreSelectSheet.contentView viewWithTag:1]; NSComboBox* cb = (NSComboBox*)[[self.coreSelectSheet contentView] viewWithTag:1];
apple_core_info_set_core_path(self.coreDirectory.UTF8String); apple_core_info_set_core_path([self.coreDirectory UTF8String]);
apple_core_info_set_config_path(self.configDirectory.UTF8String); apple_core_info_set_config_path([self.configDirectory UTF8String]);
const core_info_list_t* cores = apple_core_info_list_get(); const core_info_list_t* cores = apple_core_info_list_get();
for (int i = 0; cores && i != cores->count; i ++) for (int i = 0; cores && i != cores->count; i ++)
{ {
@ -140,7 +142,7 @@ static void* const associated_core_key = (void*)&associated_core_key;
[cb addItemWithObjectValue:desc]; [cb addItemWithObjectValue:desc];
} }
if (cb.numberOfItems) if ([cb numberOfItems])
[cb selectItemAtIndex:0]; [cb selectItemAtIndex:0];
else else
apple_display_alert(@"No libretro cores were found.\nSelect \"Go->Cores Directory\" from the menu and place libretro dylib files there.", @"RetroArch"); apple_display_alert(@"No libretro cores were found.\nSelect \"Go->Cores Directory\" from the menu and place libretro dylib files there.", @"RetroArch");
@ -175,7 +177,7 @@ static void* const associated_core_key = (void*)&associated_core_key;
- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames - (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames
{ {
if (filenames.count == 1 && [filenames objectAtIndex:0]) if ([filenames count] == 1 && [filenames objectAtIndex:0])
{ {
self.file = [filenames objectAtIndex:0]; self.file = [filenames objectAtIndex:0];
@ -198,15 +200,15 @@ static void* const associated_core_key = (void*)&associated_core_key;
NSOpenPanel* panel = [NSOpenPanel openPanel]; NSOpenPanel* panel = [NSOpenPanel openPanel];
[panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) [panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result)
{ {
[NSApplication.sharedApplication stopModal]; [[NSApplication sharedApplication] stopModal];
if (result == NSOKButton && panel.URL) if (result == NSOKButton && [panel URL])
{ {
self.file = panel.URL.path; self.file = [[panel URL] path];
[self performSelector:@selector(chooseCore) withObject:nil afterDelay:.5f]; [self performSelector:@selector(chooseCore) withObject:nil afterDelay:.5f];
} }
}]; }];
[NSApplication.sharedApplication runModalForWindow:panel]; [[NSApplication sharedApplication] runModalForWindow:panel];
} }
// This utility function will queue the self.core and self.file instance values for running. // This utility function will queue the self.core and self.file instance values for running.
@ -216,28 +218,28 @@ static void* const associated_core_key = (void*)&associated_core_key;
_wantReload = apple_is_running; _wantReload = apple_is_running;
if (!apple_is_running) if (!apple_is_running)
apple_run_core(self.core, self.file.UTF8String); apple_run_core(self.core, [self.file UTF8String]);
else else
apple_frontend_post_event(apple_event_basic_command, (void*)QUIT); apple_frontend_post_event(apple_event_basic_command, (void*)QUIT);
} }
- (void)chooseCore - (void)chooseCore
{ {
[NSApplication.sharedApplication beginSheet:self.coreSelectSheet modalForWindow:self.window modalDelegate:nil didEndSelector:nil contextInfo:nil]; [[NSApplication sharedApplication] beginSheet:self.coreSelectSheet modalForWindow:self.window modalDelegate:nil didEndSelector:nil contextInfo:nil];
[NSApplication.sharedApplication runModalForWindow:self.coreSelectSheet]; [[NSApplication sharedApplication] runModalForWindow:self.coreSelectSheet];
} }
- (IBAction)coreWasChosen:(id)sender - (IBAction)coreWasChosen:(id)sender
{ {
[NSApplication.sharedApplication stopModal]; [[NSApplication sharedApplication] stopModal];
[NSApplication.sharedApplication endSheet:self.coreSelectSheet returnCode:0]; [[NSApplication sharedApplication] endSheet:self.coreSelectSheet returnCode:0];
[self.coreSelectSheet orderOut:self]; [self.coreSelectSheet orderOut:self];
if (_isTerminating) if (_isTerminating)
return; return;
NSComboBox* cb = (NSComboBox*)[self.coreSelectSheet.contentView viewWithTag:1]; NSComboBox* cb = (NSComboBox*)[[self.coreSelectSheet contentView] viewWithTag:1];
self.core = objc_getAssociatedObject(cb.objectValueOfSelectedItem, associated_core_key); self.core = objc_getAssociatedObject([cb objectValueOfSelectedItem], associated_core_key);
[self runCore]; [self runCore];
} }
@ -246,20 +248,20 @@ static void* const associated_core_key = (void*)&associated_core_key;
- (void)loadingCore:(const NSString*)core withFile:(const char*)file - (void)loadingCore:(const NSString*)core withFile:(const char*)file
{ {
if (file) if (file)
[NSDocumentController.sharedDocumentController noteNewRecentDocumentURL:[NSURL fileURLWithPath:BOXSTRING(file)]]; [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:[NSURL fileURLWithPath:BOXSTRING(file)]];
} }
- (void)unloadingCore:(const NSString*)core - (void)unloadingCore:(const NSString*)core
{ {
if (_isTerminating) if (_isTerminating)
[NSApplication.sharedApplication terminate:nil]; [[NSApplication sharedApplication] terminate:nil];
if (_wantReload) if (_wantReload)
apple_run_core(self.core, self.file.UTF8String); apple_run_core(self.core, [self.file UTF8String]);
else if(apple_use_tv_mode) else if(apple_use_tv_mode)
apple_run_core(nil, 0); apple_run_core(nil, 0);
else else
[NSApplication.sharedApplication terminate:nil]; [[NSApplication sharedApplication] terminate:nil];
_wantReload = false; _wantReload = false;
} }
@ -272,18 +274,18 @@ static void* const associated_core_key = (void*)&associated_core_key;
- (IBAction)showPreferences:(id)sender - (IBAction)showPreferences:(id)sender
{ {
[NSApp runModalForWindow:self.settingsWindow.window]; [NSApp runModalForWindow:[self.settingsWindow window]];
} }
- (IBAction)basicEvent:(id)sender - (IBAction)basicEvent:(id)sender
{ {
if (apple_is_running) if (apple_is_running)
apple_frontend_post_event(&apple_event_basic_command, (void*)((NSMenuItem*)sender).tag); apple_frontend_post_event(&apple_event_basic_command, (void*)[sender tag]);
} }
- (void)alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo - (void)alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
{ {
[NSApplication.sharedApplication stopModal]; [[NSApplication sharedApplication] stopModal];
} }
@end @end

View File

@ -187,12 +187,12 @@ static void* const associated_name_tag = (void*)&associated_name_tag;
} }
} }
setting_data_load_config_path(setting_data_get_list(), apple_platform.globalConfigFile.UTF8String); setting_data_load_config_path(setting_data_get_list(), [apple_platform.globalConfigFile UTF8String]);
} }
- (void)windowWillClose:(NSNotification *)notification - (void)windowWillClose:(NSNotification *)notification
{ {
setting_data_save_config_path(setting_data_get_list(), apple_platform.globalConfigFile.UTF8String); setting_data_save_config_path(setting_data_get_list(), [apple_platform.globalConfigFile UTF8String]);
apple_exit_stasis(true); apple_exit_stasis(true);
@ -202,7 +202,7 @@ static void* const associated_name_tag = (void*)&associated_name_tag;
#pragma mark Section Table #pragma mark Section Table
- (NSInteger)numberOfRowsInTableView:(NSTableView*)view - (NSInteger)numberOfRowsInTableView:(NSTableView*)view
{ {
return self.settings.count; return [self.settings count];
} }
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
@ -212,14 +212,14 @@ static void* const associated_name_tag = (void*)&associated_name_tag;
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification - (void)tableViewSelectionDidChange:(NSNotification *)aNotification
{ {
self.currentGroup = [self.settings objectAtIndex:self.table.selectedRow]; self.currentGroup = [self.settings objectAtIndex:[self.table selectedRow]];
[self.outline reloadData]; [self.outline reloadData];
} }
#pragma mark Setting Outline #pragma mark Setting Outline
- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item - (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
{ {
return (item == nil) ? self.currentGroup.count : [item count]; return (item == nil) ? [self.currentGroup count] : [item count];
} }
- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item - (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item
@ -244,7 +244,7 @@ static void* const associated_name_tag = (void*)&associated_name_tag;
if ([item isKindOfClass:[NSArray class]]) if ([item isKindOfClass:[NSArray class]])
{ {
if ([tableColumn.identifier isEqualToString:@"left"]) if ([[tableColumn identifier] isEqualToString:@"left"])
return objc_getAssociatedObject(item, associated_name_tag); return objc_getAssociatedObject(item, associated_name_tag);
else else
return @""; return @"";
@ -255,7 +255,7 @@ static void* const associated_name_tag = (void*)&associated_name_tag;
const rarch_setting_t* setting = &setting_data[[item intValue]]; const rarch_setting_t* setting = &setting_data[[item intValue]];
char buffer[PATH_MAX]; char buffer[PATH_MAX];
if ([tableColumn.identifier isEqualToString:@"left"]) if ([[tableColumn identifier] isEqualToString:@"left"])
return BOXSTRING(setting->short_description); return BOXSTRING(setting->short_description);
else else
{ {
@ -274,10 +274,10 @@ static void* const associated_name_tag = (void*)&associated_name_tag;
return nil; return nil;
if ([item isKindOfClass:[NSArray class]]) if ([item isKindOfClass:[NSArray class]])
return tableColumn.dataCell; return [tableColumn dataCell];
if ([tableColumn.identifier isEqualToString:@"left"]) if ([[tableColumn identifier] isEqualToString:@"left"])
return tableColumn.dataCell; return [tableColumn dataCell];
const rarch_setting_t* setting_data = setting_data_get_list(); const rarch_setting_t* setting_data = setting_data_get_list();
const rarch_setting_t* setting = &setting_data[[item intValue]]; const rarch_setting_t* setting = &setting_data[[item intValue]];
@ -286,15 +286,15 @@ static void* const associated_name_tag = (void*)&associated_name_tag;
{ {
case ST_BOOL: return self.booleanCell; case ST_BOOL: return self.booleanCell;
case ST_BIND: return self.binderCell; case ST_BIND: return self.binderCell;
default: return tableColumn.dataCell; default: return [tableColumn dataCell];
} }
} }
- (IBAction)outlineViewClicked:(id)sender - (IBAction)outlineViewClicked:(id)sender
{ {
if (self.outline.clickedColumn == 1) if ([self.outline clickedColumn] == 1)
{ {
id item = [self.outline itemAtRow:self.outline.clickedRow]; id item = [self.outline itemAtRow:[self.outline clickedRow]];
if ([item isKindOfClass:[NSNumber class]]) if ([item isKindOfClass:[NSNumber class]])
{ {
@ -304,7 +304,7 @@ static void* const associated_name_tag = (void*)&associated_name_tag;
switch (setting->type) switch (setting->type)
{ {
case ST_BOOL: *setting->value.boolean = !*setting->value.boolean; return; case ST_BOOL: *setting->value.boolean = !*setting->value.boolean; return;
case ST_BIND: [self.binderWindow runForSetting:setting onWindow:self.outline.window]; return; case ST_BIND: [self.binderWindow runForSetting:setting onWindow:[self.outline window]]; return;
default: return; default: return;
} }
} }
@ -313,18 +313,18 @@ static void* const associated_name_tag = (void*)&associated_name_tag;
- (void)controlTextDidEndEditing:(NSNotification*)notification - (void)controlTextDidEndEditing:(NSNotification*)notification
{ {
if (notification.object == self.outline) if ([notification object] == self.outline)
{ {
NSText* editor = [[notification userInfo] objectForKey:@"NSFieldEditor"]; NSText* editor = [[notification userInfo] objectForKey:@"NSFieldEditor"];
id item = [self.outline itemAtRow:self.outline.selectedRow]; id item = [self.outline itemAtRow:[self.outline selectedRow]];
if ([item isKindOfClass:[NSNumber class]]) if ([item isKindOfClass:[NSNumber class]])
{ {
const rarch_setting_t* setting_data = setting_data_get_list(); const rarch_setting_t* setting_data = setting_data_get_list();
const rarch_setting_t* setting = &setting_data[[item intValue]]; const rarch_setting_t* setting = &setting_data[[item intValue]];
setting_data_set_with_string_representation(setting, editor.string.UTF8String); setting_data_set_with_string_representation(setting, [editor.string UTF8String]);
} }
} }
} }

View File

@ -28,7 +28,7 @@
#include <AVFoundation/AVCaptureInput.h> #include <AVFoundation/AVCaptureInput.h>
#include <AVFoundation/AVMediaFormat.h> #include <AVFoundation/AVMediaFormat.h>
#include <CoreVideo/CVOpenGLESTextureCache.h> #include <CoreVideo/CVOpenGLESTextureCache.h>
#define APP_HAS_FOCUS ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) #define APP_HAS_FOCUS ([[UIApplication sharedApplication] applicationState] == UIApplicationStateActive)
#define GLContextClass EAGLContext #define GLContextClass EAGLContext
#define GLAPIType GFX_CTX_OPENGL_ES_API #define GLAPIType GFX_CTX_OPENGL_ES_API
@ -37,8 +37,8 @@
@interface EAGLContext (OSXCompat) @end @interface EAGLContext (OSXCompat) @end
@implementation EAGLContext (OSXCompat) @implementation EAGLContext (OSXCompat)
+ (void)clearCurrentContext { EAGLContext.currentContext = nil; } + (void)clearCurrentContext { [EAGLContext setCurrentContext:nil]; }
- (void)makeCurrentContext { EAGLContext.currentContext = self; } - (void)makeCurrentContext { [EAGLContext setCurrentContext:self]; }
@end @end
#elif defined(OSX) #elif defined(OSX)
@ -55,7 +55,7 @@
@implementation NSScreen (IOSCompat) @implementation NSScreen (IOSCompat)
- (CGRect)bounds - (CGRect)bounds
{ {
CGRect cgrect = NSRectToCGRect(self.frame); CGRect cgrect = NSRectToCGRect([self frame]);
return CGRectMake(0, 0, CGRectGetWidth(cgrect), CGRectGetHeight(cgrect)); return CGRectMake(0, 0, CGRectGetWidth(cgrect), CGRectGetHeight(cgrect));
} }
- (float) scale { return 1.0f; } - (float) scale { return 1.0f; }
@ -109,7 +109,7 @@ static bool g_is_syncing = true;
- (id)init - (id)init
{ {
self = [super init]; self = [super init];
self.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; [self setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
return self; return self;
} }
@ -324,7 +324,7 @@ static RAScreen* get_chosen_screen()
#ifdef OSX #ifdef OSX
[pool drain]; [pool drain];
#endif #endif
return RAScreen.mainScreen; return [RAScreen mainScreen];
} }
NSArray *screens = [RAScreen screens]; NSArray *screens = [RAScreen screens];
@ -406,7 +406,7 @@ bool apple_gfx_ctx_bind_api(enum gfx_ctx_api api, unsigned major, unsigned minor
g_format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]; g_format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
g_context = [[NSOpenGLContext alloc] initWithFormat:g_format shareContext:nil]; g_context = [[NSOpenGLContext alloc] initWithFormat:g_format shareContext:nil];
g_context.view = g_view; [g_context setView:g_view];
#else #else
g_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; g_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
g_view.context = g_context; g_view.context = g_context;
@ -446,13 +446,13 @@ bool apple_gfx_ctx_set_video_mode(unsigned width, unsigned height, bool fullscre
else if (!fullscreen && g_has_went_fullscreen) else if (!fullscreen && g_has_went_fullscreen)
{ {
[g_view exitFullScreenModeWithOptions:nil]; [g_view exitFullScreenModeWithOptions:nil];
[g_view.window makeFirstResponder:g_view]; [[g_view window] makeFirstResponder:g_view];
[NSCursor unhide]; [NSCursor unhide];
} }
g_has_went_fullscreen = fullscreen; g_has_went_fullscreen = fullscreen;
if (!g_has_went_fullscreen) if (!g_has_went_fullscreen)
[g_view.window setContentSize:NSMakeSize(width, height)]; [[g_view window] setContentSize:NSMakeSize(width, height)];
}); });
#endif #endif
@ -469,18 +469,18 @@ void apple_gfx_ctx_get_video_size(unsigned* width, unsigned* height)
if (g_initialized) if (g_initialized)
{ {
#if defined(OSX) && !defined(MAC_OS_X_VERSION_10_7) #if defined(OSX) && !defined(MAC_OS_X_VERSION_10_7)
CGRect cgrect = NSRectToCGRect(g_view.frame); CGRect cgrect = NSRectToCGRect([g_view frame]);
size = CGRectMake(0, 0, CGRectGetWidth(cgrect), CGRectGetHeight(cgrect)); size = CGRectMake(0, 0, CGRectGetWidth(cgrect), CGRectGetHeight(cgrect));
#else #else
size = g_view.bounds; size = [g_view bounds];
#endif #endif
} }
else else
size = screen.bounds; size = [screen bounds];
*width = CGRectGetWidth(size) * screen.scale; *width = CGRectGetWidth(size) * [screen scale];
*height = CGRectGetHeight(size) * screen.scale; *height = CGRectGetHeight(size) * [screen scale];
} }
void apple_gfx_ctx_update_window_title(void) void apple_gfx_ctx_update_window_title(void)
@ -498,7 +498,7 @@ void apple_gfx_ctx_update_window_title(void)
// If it poses a problem it should be changed to dispatch_sync. // If it poses a problem it should be changed to dispatch_sync.
dispatch_async(dispatch_get_main_queue(), dispatch_async(dispatch_get_main_queue(),
^{ ^{
g_view.window.title = [NSString stringWithCString:text encoding:NSUTF8StringEncoding]; [[g_view window] setTitle:[NSString stringWithCString:text encoding:NSUTF8StringEncoding]];
}); });
} }
#endif #endif

View File

@ -63,17 +63,17 @@ void apple_run_core(NSString* core, const char* file)
if (!apple_argv) if (!apple_argv)
{ {
if (apple_core_info_has_custom_config(apple_core.UTF8String)) if (apple_core_info_has_custom_config([apple_core UTF8String]))
apple_core_info_get_custom_config(apple_core.UTF8String, config_path, sizeof(config_path)); apple_core_info_get_custom_config([apple_core UTF8String], config_path, sizeof(config_path));
else else
strlcpy(config_path, apple_platform.globalConfigFile.UTF8String, sizeof(config_path)); strlcpy(config_path, [apple_platform.globalConfigFile UTF8String], sizeof(config_path));
static const char* const argv_game[] = { "retroarch", "-c", config_path, "-L", core_path, file_path, 0 }; static const char* const argv_game[] = { "retroarch", "-c", config_path, "-L", core_path, file_path, 0 };
static const char* const argv_menu[] = { "retroarch", "-c", config_path, "--menu", 0 }; static const char* const argv_menu[] = { "retroarch", "-c", config_path, "--menu", 0 };
if (file && core) if (file && core)
{ {
strlcpy(core_path, apple_core.UTF8String, sizeof(core_path)); strlcpy(core_path, [apple_core UTF8String], sizeof(core_path));
strlcpy(file_path, file, sizeof(file_path)); strlcpy(file_path, file, sizeof(file_path));
} }

View File

@ -33,14 +33,14 @@ void apple_display_alert(NSString* message, NSString* title)
#else #else
NSAlert* alert = [[NSAlert new] autorelease]; NSAlert* alert = [[NSAlert new] autorelease];
alert.messageText = title ? title : @"RetroArch"; [alert setMessageText:title ? title : @"RetroArch"];
alert.informativeText = message; [alert setInformativeText:message];
alert.alertStyle = NSInformationalAlertStyle; [alert setAlertStyle:NSInformationalAlertStyle];
[alert beginSheetModalForWindow:RetroArch_OSX.get.window [alert beginSheetModalForWindow:[RetroArch_OSX get].window
modalDelegate:apple_platform modalDelegate:apple_platform
didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
contextInfo:nil]; contextInfo:nil];
[[NSApplication sharedApplication] runModalForWindow:alert.window]; [[NSApplication sharedApplication] runModalForWindow:[alert window]];
#endif #endif
} }
@ -65,7 +65,7 @@ NSString *apple_get_core_id(const core_info_t *core)
NSString *apple_get_core_display_name(NSString *core_id) NSString *apple_get_core_display_name(NSString *core_id)
{ {
const core_info_t *core = apple_core_info_list_get_by_id(core_id.UTF8String); const core_info_t *core = apple_core_info_list_get_by_id([core_id UTF8String]);
return core ? BOXSTRING(core->display_name) : core_id; return core ? BOXSTRING(core->display_name) : core_id;
} }
@ -75,29 +75,29 @@ NSString *apple_get_core_display_name(NSString *core_id)
{ {
if ((self = [super init])) if ((self = [super init]))
{ {
self.allowsFloats = (setting->type == ST_FLOAT); [self setAllowsFloats:(setting->type == ST_FLOAT)];
if (setting->min != setting->max) if (setting->min != setting->max)
{ {
self.minimum = BOXFLOAT(setting->min); [self setMinimum:BOXFLOAT(setting->min)];
self.maximum = BOXFLOAT(setting->max); [self setMaximum:BOXFLOAT(setting->max)];
} }
else else
{ {
if (setting->type == ST_INT) if (setting->type == ST_INT)
{ {
self.minimum = BOXINT(INT_MIN); [self setMinimum:BOXINT(INT_MIN)];
self.maximum = BOXINT(INT_MAX); [self setMaximum:BOXINT(INT_MAX)];
} }
else if (setting->type == ST_UINT) else if (setting->type == ST_UINT)
{ {
self.minimum = BOXUINT(0); [self setMinimum:BOXUINT(0)];
self.maximum = BOXUINT(UINT_MAX); [self setMaximum:BOXUINT(UINT_MAX)];
} }
else if (setting->type == ST_FLOAT) else if (setting->type == ST_FLOAT)
{ {
self.minimum = BOXFLOAT(FLT_MIN); [self setMinimum:BOXFLOAT(FLT_MIN)];
self.maximum = BOXFLOAT(FLT_MAX); [self setMaximum:BOXFLOAT(FLT_MAX)];
} }
} }
} }
@ -109,14 +109,14 @@ NSString *apple_get_core_display_name(NSString *core_id)
{ {
bool hasDot = false; bool hasDot = false;
if (partialString.length) if ([partialString length])
for (int i = 0; i != partialString.length; i ++) for (int i = 0; i != [partialString length]; i ++)
{ {
unichar ch = [partialString characterAtIndex:i]; unichar ch = [partialString characterAtIndex:i];
if (i == 0 && (!self.minimum || self.minimum.intValue < 0) && ch == '-') if (i == 0 && (![self minimum] || [[self minimum] intValue] < 0) && ch == '-')
continue; continue;
else if (self.allowsFloats && !hasDot && ch == '.') else if ([self allowsFloats] && !hasDot && ch == '.')
hasDot = true; hasDot = true;
else if (!isdigit(ch)) else if (!isdigit(ch))
return NO; return NO;
@ -128,7 +128,7 @@ NSString *apple_get_core_display_name(NSString *core_id)
#ifdef IOS #ifdef IOS
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{ {
NSString* text = [textField.text stringByReplacingCharactersInRange:range withString:string]; NSString* text = [[textField text] stringByReplacingCharactersInRange:range withString:string];
return [self isPartialStringValid:text newEditingString:nil errorDescription:nil]; return [self isPartialStringValid:text newEditingString:nil errorDescription:nil];
} }
#endif #endif