diff --git a/apple/iOS/menu.m b/apple/iOS/menu.m index 84998afbe2..18d697075f 100644 --- a/apple/iOS/menu.m +++ b/apple/iOS/menu.m @@ -551,10 +551,6 @@ static void RunActionSheet(const char* title, const struct string_list* items, U self.sections = [NSMutableArray array]; menu_handle_t *mh = driver.menu; - // XXX Writing these down for reference - mh->list_mainmenu; - mh->list_settings; - mh->menu_list; char title[256]; const char *dir = NULL; @@ -602,6 +598,11 @@ static void RunActionSheet(const char* title, const struct string_list* items, U driver.menu->menu_list->selection_buf->list[i].label); (void)setting; + menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*) + menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf, i); + + bool is_category = menu_common_type_is(entry_label, type) == MENU_SETTINGS; + disp_set_label (driver.menu->menu_list->selection_buf, &w, type, i, label, type_str, sizeof(type_str), @@ -614,32 +615,51 @@ static void RunActionSheet(const char* title, const struct string_list* items, U // everything is a button. [RAMenuItemBasic itemWithDescription:BOXSTRING(path_buf) - action:^{ - // XXX This is not doing what I expect. In - // particular, "Settings" doesn't open a new - // menu. (I assumed it would call some command - // that would go out, change the driver.menu - // value, then call back into here with a new - // thing. - // - // Idea 1: setting->action_ok doesn't work like that. - // - // Idea 2: I need to explicitly go back to - // gameView and let RA run. - // - // Idea 3: setting is actually totally busted - // because this is an ObjC block and I need to - // store it in a ObjC object that is controlled - // by the GC. [I don't think this is the case, - // because saving a new config works, but if it - // is, this is actually quite easy to fix.] - if ( setting != NULL ) { + action:^{ + driver.menu->selection_ptr = i; + if (cbs && cbs->action_ok) { + cbs->action_ok(path, entry_label, type, i); + } else if (is_category) { + if (cbs && cbs->action_start) { + cbs->action_start(type, entry_label, MENU_ACTION_START); + } + if (cbs && cbs->action_toggle) { + cbs->action_toggle(type, entry_label, MENU_ACTION_RIGHT); + } + menu_list_push_stack(driver.menu->menu_list, "", "info_screen", + 0, i); + } else if ( setting && setting->action_ok ) { setting->action_ok(setting, MENU_ACTION_OK); } + + [self menuRefresh]; + [self reloadData]; }]]; } [self.sections addObject:everything]; + + if (menu_list_get_stack_size(driver.menu->menu_list) > 1) { + self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:BOXSTRING("Back") style:UIBarButtonItemStyleBordered target:self action:@selector(menuBack)]; + } else { + self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:BOXSTRING("Resume") style:UIBarButtonItemStyleBordered target:[RetroArch_iOS get] action:@selector(showGameView)]; + } +} + +- (void)menuRefresh { + if (driver.menu->need_refresh) { + menu_entries_deferred_push(driver.menu->menu_list->selection_buf, + driver.menu->menu_list->menu_stack); + + driver.menu->need_refresh = false; + } +} + +- (void)menuBack { + apply_deferred_settings(); + menu_list_pop_stack(driver.menu->menu_list); + [self menuRefresh]; + [self reloadData]; } - (void)willReloadDataOLD diff --git a/apple/iOS/platform.m b/apple/iOS/platform.m index fc9c399b6e..6214715c90 100644 --- a/apple/iOS/platform.m +++ b/apple/iOS/platform.m @@ -237,7 +237,7 @@ void switch_to_ios() { if (rarch_main(0, NULL)) apple_rarch_exited(); - if ( driver.menu != NULL && driver.menu->userdata != NULL ) { + if ( driver.menu_ctx && driver.menu_ctx == &menu_ctx_ios && driver.menu && driver.menu->userdata ) { ios_handle_t *ih = (ios_handle_t*)driver.menu->userdata; ih->switch_to_ios = switch_to_ios; } diff --git a/frontend/platform/platform_apple.c b/frontend/platform/platform_apple.c index 2785593376..d986a791ab 100644 --- a/frontend/platform/platform_apple.c +++ b/frontend/platform/platform_apple.c @@ -137,7 +137,7 @@ static void frontend_apple_get_environment_settings(int *argc, char *argv[], fill_pathname_join(g_defaults.system_dir, home_dir_buf, ".RetroArch", sizeof(g_defaults.system_dir)); fill_pathname_join(g_defaults.core_dir, bundle_path_buf, "modules", sizeof(g_defaults.core_dir)); - strlcpy(g_defaults.menu_config_dir, g_defaults.system_dir, sizeof(g_defaults.menu_config_dir)); + strlcpy(g_defaults.menu_config_dir, "/tmp" /*g_defaults.system_dir*/, sizeof(g_defaults.menu_config_dir)); fill_pathname_join(g_defaults.config_path, g_defaults.menu_config_dir, "retroarch.cfg", sizeof(g_defaults.config_path)); strlcpy(g_defaults.sram_dir, g_defaults.system_dir, sizeof(g_defaults.sram_dir)); diff --git a/menu/disp/ios.c b/menu/disp/ios.c index 73f10c6c21..97a03c2b74 100644 --- a/menu/disp/ios.c +++ b/menu/disp/ios.c @@ -48,10 +48,10 @@ static void ios_free ( void* data ) { return; } -static void ios_render() { +static int menu_ios_iterate(unsigned action) { ios_handle_t *ih = NULL; if (driver.menu == NULL) { - return; + return 0; } ih = (ios_handle_t*)driver.menu->userdata; @@ -59,13 +59,19 @@ static void ios_render() { ih->switch_to_ios(); } - return; + return 0; } +menu_ctx_driver_backend_t menu_ctx_backend_ios = { + menu_ios_iterate, + + "menu_ios", +}; + menu_ctx_driver_t menu_ctx_ios = { NULL, // set_texture NULL, // render_messagebox - ios_render, // render + NULL, // render NULL, // frame ios_init, // init NULL, // init_lists @@ -87,6 +93,6 @@ menu_ctx_driver_t menu_ctx_ios = { NULL, // list_clear NULL, // list_set_selection NULL, // init_core_info - &menu_ctx_backend_common, // backend + &menu_ctx_backend_ios, // backend "ios", };