mirror of
https://github.com/libretro/RetroArch
synced 2025-04-02 07:20:34 +00:00
Using iOS browser for Cores and Content
This commit is contained in:
parent
681f332183
commit
7bb75162f7
@ -418,6 +418,13 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
|
|||||||
NSString *path;
|
NSString *path;
|
||||||
RADirectoryList* list;
|
RADirectoryList* list;
|
||||||
RAMenuItemPathSetting __weak* weakSelf = self;
|
RAMenuItemPathSetting __weak* weakSelf = self;
|
||||||
|
|
||||||
|
if (self.setting && self.setting->type == ST_ACTION &&
|
||||||
|
self.setting->flags & SD_FLAG_BROWSER_ACTION &&
|
||||||
|
self.setting->action_toggle &&
|
||||||
|
self.setting->change_handler ) {
|
||||||
|
self.setting->action_toggle( self.setting, MENU_ACTION_RIGHT );
|
||||||
|
}
|
||||||
|
|
||||||
path = [BOXSTRING(self.setting->value.string) stringByDeletingLastPathComponent];
|
path = [BOXSTRING(self.setting->value.string) stringByDeletingLastPathComponent];
|
||||||
list = [[RADirectoryList alloc] initWithPath:path extensions:self.setting->values action:
|
list = [[RADirectoryList alloc] initWithPath:path extensions:self.setting->values action:
|
||||||
@ -438,7 +445,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
|
|||||||
|
|
||||||
newval = "";
|
newval = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
setting_data_set_with_string_representation(weakSelf.setting, newval);
|
setting_data_set_with_string_representation(weakSelf.setting, newval);
|
||||||
[[list navigationController] popViewControllerAnimated:YES];
|
[[list navigationController] popViewControllerAnimated:YES];
|
||||||
|
|
||||||
@ -638,37 +645,47 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
|
|||||||
entry_label, path,
|
entry_label, path,
|
||||||
path_buf, sizeof(path_buf));
|
path_buf, sizeof(path_buf));
|
||||||
|
|
||||||
if (setting && ST_ACTION < setting->type && setting->type < ST_GROUP)
|
if (setting && setting->type == ST_ACTION &&
|
||||||
[everything addObject:
|
setting->flags & SD_FLAG_BROWSER_ACTION &&
|
||||||
[RAMenuItemGeneralSetting
|
setting->action_toggle &&
|
||||||
|
setting->change_handler ) {
|
||||||
|
[everything
|
||||||
|
addObject:
|
||||||
|
[[RAMenuItemPathSetting alloc]
|
||||||
|
initWithSetting:setting
|
||||||
|
action:^{}]];
|
||||||
|
} else if (setting && ST_ACTION < setting->type && setting->type < ST_GROUP) {
|
||||||
|
[everything
|
||||||
|
addObject:
|
||||||
|
[RAMenuItemGeneralSetting
|
||||||
itemForSetting:setting
|
itemForSetting:setting
|
||||||
action:^{
|
action:^{
|
||||||
driver.menu->selection_ptr = i;
|
driver.menu->selection_ptr = i;
|
||||||
if (cbs && cbs->action_ok)
|
if (cbs && cbs->action_ok)
|
||||||
cbs->action_ok(path, entry_label, type, i);
|
cbs->action_ok(path, entry_label, type, i);
|
||||||
}]];
|
}]];
|
||||||
else
|
} else {
|
||||||
{
|
[everything
|
||||||
[everything addObject:
|
addObject:
|
||||||
[RAMenuItemBasic
|
[RAMenuItemBasic
|
||||||
itemWithDescription:BOXSTRING(path_buf)
|
itemWithDescription:BOXSTRING(path_buf)
|
||||||
action:^{
|
action:^{
|
||||||
driver.menu->selection_ptr = i;
|
driver.menu->selection_ptr = i;
|
||||||
if (cbs && cbs->action_ok)
|
if (cbs && cbs->action_ok)
|
||||||
cbs->action_ok(path, entry_label, type, i);
|
cbs->action_ok(path, entry_label, type, i);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (cbs && cbs->action_start)
|
if (cbs && cbs->action_start)
|
||||||
cbs->action_start(type, entry_label, MENU_ACTION_START);
|
cbs->action_start(type, entry_label, MENU_ACTION_START);
|
||||||
if (cbs && cbs->action_toggle)
|
if (cbs && cbs->action_toggle)
|
||||||
cbs->action_toggle(type, entry_label, MENU_ACTION_RIGHT);
|
cbs->action_toggle(type, entry_label, MENU_ACTION_RIGHT);
|
||||||
menu_list_push_stack(driver.menu->menu_list, "",
|
menu_list_push_stack(driver.menu->menu_list, "",
|
||||||
"info_screen", 0, i);
|
"info_screen", 0, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
[weakSelf menuRefresh];
|
[weakSelf menuRefresh];
|
||||||
[weakSelf reloadData];
|
[weakSelf reloadData];
|
||||||
}]];
|
}]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,12 +171,11 @@ void setting_data_set_with_string_representation(rarch_setting_t* setting,
|
|||||||
case ST_PATH:
|
case ST_PATH:
|
||||||
case ST_DIR:
|
case ST_DIR:
|
||||||
case ST_STRING:
|
case ST_STRING:
|
||||||
|
case ST_ACTION:
|
||||||
strlcpy(setting->value.string, value, setting->size);
|
strlcpy(setting->value.string, value, setting->size);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* TODO */
|
/* TODO */
|
||||||
case ST_ACTION:
|
|
||||||
break;
|
|
||||||
case ST_HEX:
|
case ST_HEX:
|
||||||
break;
|
break;
|
||||||
case ST_GROUP:
|
case ST_GROUP:
|
||||||
@ -2835,6 +2834,41 @@ static void settings_data_list_current_add_flags(
|
|||||||
setting_data_add_special_callbacks(list, list_info, values);
|
setting_data_add_special_callbacks(list, list_info, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int core_list_action_toggle(void *data, unsigned action) {
|
||||||
|
rarch_setting_t *setting = (rarch_setting_t *)data;
|
||||||
|
// If the user CANCELs the browse, then g_settings.libretro is now
|
||||||
|
// set to a directory, which is very bad and will cause a crash
|
||||||
|
// later on. I need to be able to add something to call when a
|
||||||
|
// cancel happens.
|
||||||
|
strlcpy(setting->value.string, g_settings.libretro_directory, setting->size);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
void core_list_change_handler(void *data) {
|
||||||
|
rarch_setting_t *setting = (rarch_setting_t *)data;
|
||||||
|
rarch_main_command(RARCH_CMD_LOAD_CORE);
|
||||||
|
}
|
||||||
|
|
||||||
|
int load_content_action_toggle(void *data, unsigned action) {
|
||||||
|
rarch_setting_t *setting = (rarch_setting_t *)data;
|
||||||
|
|
||||||
|
strlcpy(setting->value.string, g_settings.menu_content_directory, setting->size);
|
||||||
|
|
||||||
|
if (g_extern.menu.info.valid_extensions) {
|
||||||
|
setting->values = g_extern.menu.info.valid_extensions;
|
||||||
|
} else {
|
||||||
|
setting->values = g_extern.system.valid_extensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
void load_content_change_handler(void *data) {
|
||||||
|
rarch_setting_t *setting = (rarch_setting_t *)data;
|
||||||
|
// This does not appear to be robust enough because sometimes I get
|
||||||
|
// crashes. I think it is because LOAD_CORE has not yet run. I'm not
|
||||||
|
// sure the best way to test for that.
|
||||||
|
rarch_main_command(RARCH_CMD_LOAD_CONTENT);
|
||||||
|
}
|
||||||
|
|
||||||
static bool setting_data_append_list_main_menu_options(
|
static bool setting_data_append_list_main_menu_options(
|
||||||
rarch_setting_t **list,
|
rarch_setting_t **list,
|
||||||
rarch_setting_info_t *list_info)
|
rarch_setting_info_t *list_info)
|
||||||
@ -2850,6 +2884,16 @@ static bool setting_data_append_list_main_menu_options(
|
|||||||
"Core",
|
"Core",
|
||||||
group_info.name,
|
group_info.name,
|
||||||
subgroup_info.name);
|
subgroup_info.name);
|
||||||
|
(*list)[list_info->index - 1].size = sizeof(g_settings.libretro);
|
||||||
|
(*list)[list_info->index - 1].value.string = g_settings.libretro;
|
||||||
|
(*list)[list_info->index - 1].values = EXT_EXECUTABLES;
|
||||||
|
// It is not a good idea to have chosen action_toggle as the place
|
||||||
|
// to put this callback. It should be called whenever the browser
|
||||||
|
// needs to get the directory to browse into. It's not quite like
|
||||||
|
// get_string_representation, but it is close.
|
||||||
|
(*list)[list_info->index - 1].action_toggle = core_list_action_toggle;
|
||||||
|
(*list)[list_info->index - 1].change_handler = core_list_change_handler;
|
||||||
|
settings_data_list_current_add_flags(list, list_info, SD_FLAG_BROWSER_ACTION);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CONFIG_ACTION(
|
CONFIG_ACTION(
|
||||||
@ -2883,6 +2927,10 @@ static bool setting_data_append_list_main_menu_options(
|
|||||||
"Load Content",
|
"Load Content",
|
||||||
group_info.name,
|
group_info.name,
|
||||||
subgroup_info.name);
|
subgroup_info.name);
|
||||||
|
(*list)[list_info->index - 1].size = sizeof(g_extern.fullpath);
|
||||||
|
(*list)[list_info->index - 1].value.string = g_extern.fullpath;
|
||||||
|
(*list)[list_info->index - 1].action_toggle = load_content_action_toggle;
|
||||||
|
(*list)[list_info->index - 1].change_handler = load_content_change_handler;
|
||||||
settings_data_list_current_add_flags(list, list_info, SD_FLAG_BROWSER_ACTION);
|
settings_data_list_current_add_flags(list, list_info, SD_FLAG_BROWSER_ACTION);
|
||||||
|
|
||||||
CONFIG_ACTION(
|
CONFIG_ACTION(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user