From 7f8cb059e272b27320dda0302bfb61c2e3f415c3 Mon Sep 17 00:00:00 2001 From: meancoot Date: Sun, 7 Jul 2013 17:50:17 -0400 Subject: [PATCH] (iOS) Temporarily remove custom config support --- apple/RetroArch/RAModuleInfo.h | 7 ---- apple/RetroArch/RAModuleInfo.m | 43 +---------------------- apple/RetroArch/RetroArch_Apple.h | 5 +++ apple/RetroArch/main.m | 37 +++++++++++++------- apple/iOS/settings.m | 58 +++---------------------------- 5 files changed, 35 insertions(+), 115 deletions(-) diff --git a/apple/RetroArch/RAModuleInfo.h b/apple/RetroArch/RAModuleInfo.h index 6cd8d6c312..739099d78a 100644 --- a/apple/RetroArch/RAModuleInfo.h +++ b/apple/RetroArch/RAModuleInfo.h @@ -31,13 +31,6 @@ + (NSArray*)getModules; - (bool)supportsFileAtPath:(NSString*)path; -- (void)createCustomConfig; -- (void)deleteCustomConfig; -- (bool)hasCustomConfig; - -+ (NSString*)globalConfigPath; -@property (strong) NSString* customConfigPath; -- (NSString*)configPath; @end #endif diff --git a/apple/RetroArch/RAModuleInfo.m b/apple/RetroArch/RAModuleInfo.m index 25f561e47c..43889a4ed6 100644 --- a/apple/RetroArch/RAModuleInfo.m +++ b/apple/RetroArch/RAModuleInfo.m @@ -25,13 +25,9 @@ static core_info_list_t* coreList; @implementation RAModuleInfo + (NSArray*)getModules { -#ifdef IOS if (!moduleList) { - char pattern[PATH_MAX]; - snprintf(pattern, PATH_MAX, "%s/modules", [[NSBundle mainBundle].bundlePath UTF8String]); - - coreList = get_core_info_list(pattern); + coreList = get_core_info_list(apple_platform.corePath.UTF8String); moduleList = [NSMutableArray arrayWithCapacity:coreList->count]; for (int i = 0; coreList && i < coreList->count; i ++) @@ -44,9 +40,6 @@ static core_info_list_t* coreList; newInfo.data = core->data; newInfo.displayName = [NSString stringWithUTF8String:core->display_name]; - NSString* baseName = newInfo.path.lastPathComponent.stringByDeletingPathExtension; - newInfo.customConfigPath = [NSString stringWithFormat:@"%@/%@.cfg", RetroArch_iOS.get.systemDirectory, baseName]; - [moduleList addObject:newInfo]; } @@ -55,7 +48,6 @@ static core_info_list_t* coreList; return [left.displayName caseInsensitiveCompare:right.displayName]; }]; } -#endif return moduleList; } @@ -69,39 +61,6 @@ static core_info_list_t* coreList; return does_core_support_file(self.info, path.UTF8String); } -#ifdef IOS -- (void)createCustomConfig -{ - if (!self.hasCustomConfig) - [NSFileManager.defaultManager copyItemAtPath:RAModuleInfo.globalConfigPath toPath:self.customConfigPath error:nil]; -} - -- (void)deleteCustomConfig -{ - if (self.hasCustomConfig) - [NSFileManager.defaultManager removeItemAtPath:self.customConfigPath error:nil]; -} - -+ (NSString*)globalConfigPath -{ - static NSString* path; - if (!path) - path = [NSString stringWithFormat:@"%@/retroarch.cfg", RetroArch_iOS.get.systemDirectory]; - - return path; -} - -- (bool)hasCustomConfig -{ - return path_file_exists(self.customConfigPath.UTF8String); -} - -- (NSString*)configPath -{ - return self.hasCustomConfig ? self.customConfigPath : RAModuleInfo.globalConfigPath; -} -#endif - @end #ifdef IOS diff --git a/apple/RetroArch/RetroArch_Apple.h b/apple/RetroArch/RetroArch_Apple.h index a40344509f..27c9d27f0c 100644 --- a/apple/RetroArch/RetroArch_Apple.h +++ b/apple/RetroArch/RetroArch_Apple.h @@ -25,8 +25,12 @@ void apple_run_core(RAModuleInfo* core, const char* file); @protocol RetroArch_Platform - (void)loadingCore:(RAModuleInfo*)core withFile:(const char*)file; - (void)unloadingCore:(RAModuleInfo*)core; +- (NSString*)retroarchConfigPath; +- (NSString*)corePath; @end +extern id apple_platform; + #ifdef IOS // RAGameView.m @@ -45,6 +49,7 @@ void apple_run_core(RAModuleInfo* core, const char* file); - (void)loadingCore:(RAModuleInfo*)core withFile:(const char*)file; - (void)unloadingCore:(RAModuleInfo*)core; +- (NSString*)retroarchConfigPath; - (void)refreshConfig; - (void)refreshSystemConfig; diff --git a/apple/RetroArch/main.m b/apple/RetroArch/main.m index 47fcb180c9..04be8b1260 100644 --- a/apple/RetroArch/main.m +++ b/apple/RetroArch/main.m @@ -36,12 +36,7 @@ //#define HAVE_DEBUG_FILELOG static bool use_tv_mode; -#ifdef IOS -static RetroArch_iOS* apple_platform; -#else -static RetroArch_OSX* apple_platform; -#endif - +id apple_platform; // From frontend/frontend_ios.c extern void* rarch_main_apple(void* args); @@ -101,6 +96,8 @@ void apple_run_core(RAModuleInfo* core, const char* file) struct rarch_main_wrap* load_data = malloc(sizeof(struct rarch_main_wrap)); memset(load_data, 0, sizeof(struct rarch_main_wrap)); + load_data->config_path = strdup(apple_platform.retroarchConfigPath.UTF8String); + #ifdef IOS load_data->sram_path = strdup(RetroArch_iOS.get.systemDirectory.UTF8String); load_data->state_path = strdup(RetroArch_iOS.get.systemDirectory.UTF8String); @@ -115,14 +112,7 @@ void apple_run_core(RAModuleInfo* core, const char* file) load_data->libretro_path = strdup("/Users/jason/Desktop/libretro.dylib"); #endif load_data->rom_path = strdup(file); -#ifdef IOS - load_data->config_path = strdup(apple_core.configPath.UTF8String); -#endif } -#ifdef IOS - else - load_data->config_path = strdup(RAModuleInfo.globalConfigPath.UTF8String); -#endif if (pthread_create(&apple_retro_thread, 0, rarch_main_apple, load_data)) { @@ -352,6 +342,16 @@ int main(int argc, char *argv[]) btpad_set_inquiry_state(true); } +- (NSString*)retroarchConfigPath +{ + return [NSString stringWithFormat:@"%@/retroarch.cfg", self.systemDirectory]; +} + +- (NSString*)corePath +{ + return [NSBundle.mainBundle.bundlePath stringByAppendingPathComponent:@"modules"]; +} + - (void)refreshConfig { if (apple_is_running) @@ -553,6 +553,17 @@ int main(int argc, char *argv[]) { } +- (NSString*)retroarchConfigPath +{ + NSArray* paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); + return [paths[0] stringByAppendingPathComponent:@"RetroArch/retroarch.cfg"]; +} + +- (NSString*)corePath +{ + return [NSBundle.mainBundle.bundlePath stringByAppendingPathComponent:@"modules"]; +} + #pragma mark Menus - (IBAction)basicEvent:(id)sender { diff --git a/apple/iOS/settings.m b/apple/iOS/settings.m index aac804486f..d42132b75a 100644 --- a/apple/iOS/settings.m +++ b/apple/iOS/settings.m @@ -219,7 +219,7 @@ static NSArray* build_input_port_group(config_file_t* config, uint32_t player) - (id)initWithModule:(RAModuleInfo*)module { _module = module; - _configPath = _module ? _module.configPath : RAModuleInfo.globalConfigPath; + _configPath = RetroArch_iOS.get.retroarchConfigPath; config_file_t* config = config_file_new([_configPath UTF8String]); @@ -229,7 +229,6 @@ static NSArray* build_input_port_group(config_file_t* config, uint32_t player) NSArray* settings = [NSArray arrayWithObjects: [NSArray arrayWithObjects:@"Core", custom_action(@"Core Info", nil, nil), - _module.hasCustomConfig ? custom_action(@"Delete Custom Config", nil, nil) : nil, nil], [NSArray arrayWithObjects:@"Video", @@ -319,12 +318,6 @@ static NSArray* build_input_port_group(config_file_t* config, uint32_t player) { if ([@"Core Info" isEqualToString:setting.label]) [[RetroArch_iOS get] pushViewController:[[RAModuleInfoList alloc] initWithModuleInfo:_module] animated:YES]; - else if([@"Delete Custom Config" isEqualToString:setting.label]) - { - [_module deleteCustomConfig]; - _cancelSave = true; - [self.navigationController popViewControllerAnimated:YES]; - } } @end @@ -334,16 +327,6 @@ static NSArray* build_input_port_group(config_file_t* config, uint32_t player) { config_file_t* config = config_file_new([[RetroArch_iOS get].systemConfigPath UTF8String]); - NSMutableArray* modules = [NSMutableArray array]; - [modules addObject:@"Cores"]; - [modules addObject:custom_action(@"Global Core Config", nil, nil)]; - - NSArray* moduleList = [RAModuleInfo getModules]; - for (RAModuleInfo* i in moduleList) - { - [modules addObject:custom_action(i.displayName, i.hasCustomConfig ? @"[Custom]" : @"[Global]", i)]; - } - NSArray* settings = [NSArray arrayWithObjects: [NSArray arrayWithObjects:@"Frontend", custom_action(@"Diagnostic Log", nil, nil), @@ -360,7 +343,9 @@ static NSArray* build_input_port_group(config_file_t* config, uint32_t player) boolean_setting(config, @"ios_allow_landscape_left", @"Landscape Left", @"true"), boolean_setting(config, @"ios_allow_landscape_right", @"Landscape Right", @"true"), nil], - modules, + [NSArray arrayWithObjects:@"Cores", + custom_action(@"Core Configuration", nil, nil), + nil], nil ]; @@ -394,41 +379,8 @@ static NSArray* build_input_port_group(config_file_t* config, uint32_t player) [[RetroArch_iOS get] pushViewController:[RALogView new] animated:YES]; else if ([@"Enable BTstack" isEqualToString:setting.label]) btstack_set_poweron([setting.value isEqualToString:@"true"]); - else if([@"Global Core Config" isEqualToString:setting.label]) + else if([@"Core Configuration" isEqualToString:setting.label]) [RetroArch_iOS.get pushViewController:[[RASettingsList alloc] initWithModule:nil] animated:YES]; - else - { - RAModuleInfo* data = (RAModuleInfo*)objc_getAssociatedObject(setting, "USERDATA"); - if (data) - { - if (!data.hasCustomConfig) - { - UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"RetroArch" - message:@"No custom configuration for this core exists, " - "would you like to create one?" - delegate:self - cancelButtonTitle:@"No" - otherButtonTitles:@"Yes", nil]; - objc_setAssociatedObject(alert, "MODULE", data, OBJC_ASSOCIATION_RETAIN_NONATOMIC); - [alert show]; - } - else - [RetroArch_iOS.get pushViewController:[[RASettingsList alloc] initWithModule:data] animated:YES]; - } - } -} - -- (void)alertView:(UIAlertView*)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex -{ - RAModuleInfo* data = (RAModuleInfo*)objc_getAssociatedObject(alertView, "MODULE"); - - if (data) - { - if (buttonIndex == alertView.firstOtherButtonIndex) - [data createCustomConfig]; - - [RetroArch_iOS.get pushViewController:[[RASettingsList alloc] initWithModule:data] animated:YES]; - } } @end