diff --git a/apple/common/setting_data.c b/apple/common/setting_data.c index 204d67c518..f9e97ef4b9 100644 --- a/apple/common/setting_data.c +++ b/apple/common/setting_data.c @@ -16,6 +16,16 @@ #include "setting_data.h" #include "config.def.h" +// HACK +struct settings fake_settings; +struct global fake_extern; + +void setting_data_load_current() +{ + memcpy(&fake_settings, &g_settings, sizeof(struct settings)); + memcpy(&fake_extern, &g_extern, sizeof(struct global)); +} + // Input static const char* get_input_config_prefix(const rarch_setting_t* setting) { @@ -76,6 +86,9 @@ static const char* get_axis_name(const rarch_setting_t* setting) // void setting_data_reset(const rarch_setting_t* settings) { + memset(&fake_settings, 0, sizeof(fake_settings)); + memset(&fake_extern, 0, sizeof(fake_extern)); + for (const rarch_setting_t* i = settings; i->type != ST_NONE; i ++) { switch (i->type) @@ -85,6 +98,20 @@ void setting_data_reset(const rarch_setting_t* settings) case ST_UINT: *i->value.unsigned_integer = i->default_value.unsigned_integer; break; case ST_FLOAT: *i->value.fraction = i->default_value.fraction; break; case ST_BIND: *i->value.keybind = *i->default_value.keybind; break; + + case ST_STRING: + case ST_PATH: + { + if (i->default_value.string) + // if (i->type == ST_STRING) + strlcpy(i->value.string, i->default_value.string, i->size); + // else + // fill_pathname_expand_special(i->value.string, i->default_value.string, i->size); + else + *i->value.string = 0; + break; + } + default: break; } } @@ -116,7 +143,7 @@ bool setting_data_load_config(const rarch_setting_t* settings, config_file_t* co case ST_INT: config_get_int (config, i->name, i->value.integer); break; case ST_UINT: config_get_uint (config, i->name, i->value.unsigned_integer); break; case ST_FLOAT: config_get_float (config, i->name, i->value.fraction); break; - case ST_PATH: config_get_array (config, i->name, i->value.string, i->size); break; + case ST_PATH: config_get_path (config, i->name, i->value.string, i->size); break; case ST_STRING: config_get_array (config, i->name, i->value.string, i->size); break; case ST_BIND: @@ -164,6 +191,7 @@ bool setting_data_save_config(const rarch_setting_t* settings, config_file_t* co case ST_UINT: config_set_uint64(config, i->name, *i->value.unsigned_integer); break; case ST_FLOAT: config_set_float (config, i->name, *i->value.fraction); break; case ST_PATH: config_set_string(config, i->name, i->value.string); break; + // case ST_PATH: config_set_path(config, i->name, i->value.string); break; case ST_STRING: config_set_string(config, i->name, i->value.string); break; case ST_BIND: @@ -278,16 +306,6 @@ rarch_setting_t setting_data_bind_setting(const char* name, const char* descript } -// HACK -struct settings fake_settings; -struct global fake_extern; - -void setting_data_load_current() -{ - memcpy(&fake_settings, &g_settings, sizeof(struct settings)); - memcpy(&fake_extern, &g_extern, sizeof(struct global)); -} - #ifdef IOS static const uint32_t features = SD_FEATURE_SHADERS; #elif defined(OSX) @@ -349,20 +367,20 @@ const rarch_setting_t* setting_data_get_list() /*********/ START_GROUP("Paths") START_SUB_GROUP("Paths") - CONFIG_PATH(g_settings.libretro, "libretro_path", "libretro Path", "") - CONFIG_PATH(g_settings.core_options_path, "core_options_path", "Core Options Path", DEFAULT_ME_YO) - CONFIG_PATH(g_settings.screenshot_directory, "screenshot_directory", "Screenshot Directory", DEFAULT_ME_YO) - CONFIG_PATH(g_settings.cheat_database, "cheat_database_path", "Cheat Database", DEFAULT_ME_YO) - CONFIG_PATH(g_settings.cheat_settings_path, "cheat_settings_path", "Cheat Settings", DEFAULT_ME_YO) - CONFIG_PATH(g_settings.game_history_path, "game_history_path", "Content History Path", DEFAULT_ME_YO) + CONFIG_PATH(g_settings.libretro, "libretro_path", "libretro Path", "") WITH_FLAGS(SD_FLAG_ALLOW_EMPTY) + CONFIG_PATH(g_settings.core_options_path, "core_options_path", "Core Options Path", DEFAULT_ME_YO) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY) + CONFIG_PATH(g_settings.screenshot_directory, "screenshot_directory", "Screenshot Directory", DEFAULT_ME_YO) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR) + CONFIG_PATH(g_settings.cheat_database, "cheat_database_path", "Cheat Database", DEFAULT_ME_YO) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY) + CONFIG_PATH(g_settings.cheat_settings_path, "cheat_settings_path", "Cheat Settings", DEFAULT_ME_YO) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY) + CONFIG_PATH(g_settings.game_history_path, "game_history_path", "Content History Path", DEFAULT_ME_YO) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY) CONFIG_UINT(g_settings.game_history_size, "game_history_size", "Content History Size", game_history_size) #ifdef HAVE_RGUI - CONFIG_PATH(g_settings.rgui_browser_directory, "rgui_browser_directory", "Browser Directory", DEFAULT_ME_YO) + CONFIG_PATH(g_settings.rgui_browser_directory, "rgui_browser_directory", "Browser Directory", DEFAULT_ME_YO) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR) #endif #ifdef HAVE_OVERLAY - CONFIG_PATH(g_extern.overlay_dir, "overlay_directory", "Overlay Directory", DEFAULT_ME_YO) + CONFIG_PATH(g_extern.overlay_dir, "overlay_directory", "Overlay Directory", DEFAULT_ME_YO) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR) #endif END_SUB_GROUP() END_GROUP() @@ -428,8 +446,8 @@ const rarch_setting_t* setting_data_get_list() WITH_FEATURE(SD_FEATURE_SHADERS) START_SUB_GROUP("Shader") CONFIG_BOOL(g_settings.video.shader_enable, "video_shader_enable", "Enable Shaders", shader_enable) - CONFIG_PATH(g_settings.video.shader_dir, "video_shader_dir", "Shader Directory", DEFAULT_ME_YO) - CONFIG_PATH(g_settings.video.shader_path, "video_shader", "Shader", DEFAULT_ME_YO) + CONFIG_PATH(g_settings.video.shader_dir, "video_shader_dir", "Shader Directory", DEFAULT_ME_YO) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR) + CONFIG_PATH(g_settings.video.shader_path, "video_shader", "Shader", DEFAULT_ME_YO) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY) END_SUB_GROUP() WITH_FEATURE(SD_FEATURE_VSYNC) START_SUB_GROUP("Sync") @@ -447,12 +465,12 @@ const rarch_setting_t* setting_data_get_list() CONFIG_BOOL(g_settings.video.crop_overscan, "video_crop_overscan", "Crop Overscan", crop_overscan) #ifdef HAVE_DYLIB - CONFIG_PATH(g_settings.video.filter_path, "video_filter", "Software filter"), + CONFIG_PATH(g_settings.video.filter_path, "video_filter", "Software filter") WITH_FLAGS(SD_FLAG_ALLOW_EMPTY) #endif END_SUB_GROUP() START_SUB_GROUP("Messages") - CONFIG_PATH(g_settings.video.font_path, "video_font_path", "Font Path", DEFAULT_ME_YO) + CONFIG_PATH(g_settings.video.font_path, "video_font_path", "Font Path", DEFAULT_ME_YO) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY) CONFIG_FLOAT(g_settings.video.font_size, "video_font_size", "Font Size", font_size) CONFIG_BOOL(g_settings.video.font_enable, "video_font_enable", "Font Enable", font_enable) CONFIG_BOOL(g_settings.video.font_scale, "video_font_scale", "Font Scale", font_scale) @@ -481,7 +499,7 @@ const rarch_setting_t* setting_data_get_list() WITH_FEATURE(SD_FEATURE_AUDIO_DEVICE) START_SUB_GROUP("Misc") CONFIG_STRING(g_settings.audio.device, "audio_device", "Device", DEFAULT_ME_YO) CONFIG_UINT(g_settings.audio.out_rate, "audio_out_rate", "Ouput Rate", out_rate) - CONFIG_PATH(g_settings.audio.dsp_plugin, "audio_dsp_plugin", "DSP Plugin", DEFAULT_ME_YO) + CONFIG_PATH(g_settings.audio.dsp_plugin, "audio_dsp_plugin", "DSP Plugin", DEFAULT_ME_YO) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY) END_SUB_GROUP() END_GROUP() @@ -492,7 +510,7 @@ const rarch_setting_t* setting_data_get_list() START_SUB_GROUP("Input") /* Input: Autoconfig */ CONFIG_BOOL(g_settings.input.autodetect_enable, "input_autodetect_enable", "Use joypad autodetection", input_autodetect_enable) - CONFIG_PATH(g_settings.input.autoconfig_dir, "joypad_autoconfig_dir", "Joypad Autoconfig Directory", DEFAULT_ME_YO) + CONFIG_PATH(g_settings.input.autoconfig_dir, "joypad_autoconfig_dir", "Joypad Autoconfig Directory", DEFAULT_ME_YO) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR) END_SUB_GROUP() START_SUB_GROUP("Joypad Mapping") @@ -516,7 +534,7 @@ const rarch_setting_t* setting_data_get_list() #ifdef HAVE_OVERLAY START_SUB_GROUP("Overlay") - CONFIG_PATH(g_settings.input.overlay, "input_overlay", "Input Overlay", DEFAULT_ME_YO) WITH_FLAGS(SD_FLAG_PATH_FILE) WITH_VALUES("cfg") + CONFIG_PATH(g_settings.input.overlay, "input_overlay", "Input Overlay", DEFAULT_ME_YO) WITH_FLAGS(SD_FLAG_ALLOW_EMPTY) WITH_VALUES("cfg") CONFIG_FLOAT(g_settings.input.overlay_opacity, "input_overlay_opacity", "Overlay Opacity", 1.0f) WITH_RANGE(0, 1) CONFIG_FLOAT(g_settings.input.overlay_scale, "input_overlay_scale", "Overlay Scale", 1.0f) END_SUB_GROUP() diff --git a/apple/iOS/browser.m b/apple/iOS/browser.m index 90df6a295e..2341bed703 100644 --- a/apple/iOS/browser.m +++ b/apple/iOS/browser.m @@ -100,7 +100,7 @@ static void file_action(enum file_action action, NSString* source, NSString* tar { RADirectoryItem* item = [RADirectoryItem new]; item.path = path; - item.isDirectory = path_is_absolute(path.UTF8String); + item.isDirectory = path_is_directory(path.UTF8String); return item; } @@ -145,7 +145,7 @@ static void file_action(enum file_action action, NSString* source, NSString* tar NSString* _extensions; } -- (id)initWithPath:(NSString*)path extensions:(const char*)extensions forDirectory:(bool)forDirectory delegate:(id)delegate +- (id)initWithPath:(NSString*)path extensions:(const char*)extensions delegate:(id)delegate { if ((self = [super initWithStyle:UITableViewStylePlain])) { @@ -155,10 +155,17 @@ static void file_action(enum file_action action, NSString* source, NSString* tar self = [super initWithStyle:UITableViewStylePlain]; self.hidesHeaders = YES; + + self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Up" style:UIBarButtonItemStyleBordered target:self + action:@selector(gotoParent)]; + + self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self + action:@selector(cancelBrowser)]; + + // NOTE: The "App" and "Root" buttons aren't really needed for non-jailbreak devices. - self.toolbarItems = - @[ + NSMutableArray* toolbarButtons = [NSMutableArray arrayWithObjects: [[UIBarButtonItem alloc] initWithTitle:@"Home" style:UIBarButtonItemStyleBordered target:self action:@selector(gotoHomeDir)], [[UIBarButtonItem alloc] initWithTitle:@"App" style:UIBarButtonItemStyleBordered target:self @@ -170,19 +177,30 @@ static void file_action(enum file_action action, NSString* source, NSString* tar [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refresh)], [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self - action:@selector(createNewFolder)] + action:@selector(createNewFolder)], + nil ]; + self.toolbarItems = toolbarButtons; + [self.tableView addGestureRecognizer:[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(fileAction:)]]; - self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Up" - style:UIBarButtonItemStyleBordered target:self action:@selector(gotoParent)]; } return self; } +- (void)cancelBrowser +{ + [self.navigationController popViewControllerAnimated:YES]; +} + +- (void)gotoParent +{ + [self browseTo:[_path stringByDeletingLastPathComponent]]; +} + - (void)gotoHomeDir { [self browseTo:NSHomeDirectory()]; @@ -219,6 +237,15 @@ static void file_action(enum file_action action, NSString* source, NSString* tar if (contents) { + RADirectoryList __weak* weakSelf = self; + + if (self.allowBlank) + [self.sections[0] addObject:[RAMenuItemBasic itemWithDescription:@"[ Use Empty Path ]" + action:^{ [weakSelf.directoryDelegate directoryList:weakSelf itemWasSelected:nil]; }]]; + if (self.forDirectory) + [self.sections[0] addObject:[RAMenuItemBasic itemWithDescription:@"[ Use This Folder ]" + action:^{ [weakSelf.directoryDelegate directoryList:weakSelf itemWasSelected:[RADirectoryItem directoryItemFromPath:path]]; }]]; + dir_list_sort(contents, true); for (int i = 0; i < contents->size; i ++) @@ -234,7 +261,10 @@ static void file_action(enum file_action action, NSString* source, NSString* tar dir_list_free(contents); } else - apple_display_alert([NSString stringWithFormat:@"Browsed path is not a directory: %@", _path], 0); + { + [self gotoHomeDir]; + return; + } [self.tableView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:NO]; [UIView transitionWithView:self.tableView duration:.25f options:UIViewAnimationOptionTransitionCrossDissolve @@ -244,11 +274,6 @@ static void file_action(enum file_action action, NSString* source, NSString* tar } completion:nil]; } -- (void)gotoParent -{ - [self browseTo:[_path stringByDeletingLastPathComponent]]; -} - - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; diff --git a/apple/iOS/menu.h b/apple/iOS/menu.h index b57d6152a4..9a17c6543c 100644 --- a/apple/iOS/menu.h +++ b/apple/iOS/menu.h @@ -36,6 +36,7 @@ - (id)initWithStyle:(UITableViewStyle)style; - (id)itemForIndexPath:(NSIndexPath*)indexPath; + @end /*********************************************/ @@ -50,7 +51,10 @@ @property (copy) void (^action)(id userdata); @property (copy) NSString* (^detail)(id userdata); ++ (RAMenuItemBasic*)itemWithDescription:(NSString*)description action:(void (^)())action; ++ (RAMenuItemBasic*)itemWithDescription:(NSString*)description action:(void (^)())action detail:(NSString* (^)())detail; + (RAMenuItemBasic*)itemWithDescription:(NSString*)description association:(id)userdata action:(void (^)())action detail:(NSString* (^)())detail; + @end /*********************************************/ diff --git a/apple/iOS/menu.m b/apple/iOS/menu.m index 5300740460..9490ad52cd 100644 --- a/apple/iOS/menu.m +++ b/apple/iOS/menu.m @@ -306,13 +306,23 @@ static void RunActionSheet(const char* title, const struct string_list* items, U - (void)wasSelectedOnTableView:(UITableView*)tableView ofController:(UIViewController*)controller { NSString* path = [BOXSTRING(self.setting->value.string) stringByDeletingLastPathComponent]; - RADirectoryList* list = [[RADirectoryList alloc] initWithPath:path extensions:self.setting->values forDirectory:false delegate:self]; + RADirectoryList* list = [[RADirectoryList alloc] initWithPath:path extensions:self.setting->values delegate:self]; + + list.allowBlank = (self.setting->flags & SD_FLAG_ALLOW_EMPTY); + list.forDirectory = (self.setting->flags & SD_FLAG_PATH_DIR); + [controller.navigationController pushViewController:list animated:YES]; } -- (bool)directoryList:(id)list itemWasSelected:(RADirectoryItem *)path +- (bool)directoryList:(RADirectoryList*)list itemWasSelected:(RADirectoryItem *)path { - setting_data_set_with_string_representation(self.setting, path.path.UTF8String); + if (!list.allowBlank && !path) + return false; + + if (list.forDirectory && !path.isDirectory) + return false; + + setting_data_set_with_string_representation(self.setting, path ? path.path.UTF8String : ""); [[list navigationController] popViewControllerAnimated:YES]; [self.parentTable reloadData]; @@ -528,7 +538,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U NSString* ragPath = [rootPath stringByAppendingPathComponent:@"RetroArchGames"]; NSString* target = path_is_directory(ragPath.UTF8String) ? ragPath : rootPath; - [self.navigationController pushViewController:[[RADirectoryList alloc] initWithPath:target extensions:NULL forDirectory:false delegate:self] animated:YES]; + [self.navigationController pushViewController:[[RADirectoryList alloc] initWithPath:target extensions:NULL delegate:self] animated:YES]; } - (void)loadHistory @@ -539,7 +549,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U - (bool)directoryList:(id)list itemWasSelected:(RADirectoryItem*)path { - if (!path.isDirectory) + if (path && !path.isDirectory) { if (self.core) apple_run_core(self.core, path.path.UTF8String); diff --git a/apple/iOS/views.h b/apple/iOS/views.h index 2582ebc400..bbfbdfa65d 100644 --- a/apple/iOS/views.h +++ b/apple/iOS/views.h @@ -37,7 +37,9 @@ @interface RADirectoryList : RAMenuBase @property (nonatomic, weak) id directoryDelegate; @property (nonatomic, weak) RADirectoryItem* selectedItem; -- (id)initWithPath:(NSString*)path extensions:(const char*)extensions forDirectory:(bool)forDirectory delegate:(id)delegate; +@property (nonatomic) bool allowBlank; +@property (nonatomic) bool forDirectory; +- (id)initWithPath:(NSString*)path extensions:(const char*)extensions delegate:(id)delegate; - (void)browseTo:(NSString*)path; @end