(iOS) Cleanups in menu.m

This commit is contained in:
Twinaphex 2015-02-13 20:23:23 +01:00
parent 31b272f25a
commit f3a579260b

View File

@ -610,8 +610,12 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
const char *dir = NULL; const char *dir = NULL;
const char *label = NULL; const char *label = NULL;
unsigned menu_type = 0; unsigned menu_type = 0;
menu_handle_t *menu = menu_driver_resolve();
menu_list_get_last_stack(driver.menu->menu_list, if (!menu)
return;
menu_list_get_last_stack(menu->menu_list,
&dir, &label, &menu_type); &dir, &label, &menu_type);
get_title(label, dir, menu_type, title, sizeof(title)); get_title(label, dir, menu_type, title, sizeof(title));
@ -636,9 +640,9 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
everything = [NSMutableArray array]; everything = [NSMutableArray array];
[everything addObject:BOXSTRING(title)]; [everything addObject:BOXSTRING(title)];
end = menu_list_get_size(driver.menu->menu_list); end = menu_list_get_size(menu->menu_list);
for (i = driver.menu->begin; i < end; i++) for (i = menu->begin; i < end; i++)
{ {
rarch_setting_t *setting; rarch_setting_t *setting;
char type_str[PATH_MAX_LENGTH], path_buf[PATH_MAX_LENGTH]; char type_str[PATH_MAX_LENGTH], path_buf[PATH_MAX_LENGTH];
@ -646,19 +650,19 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
const char *path = NULL, *entry_label = NULL; const char *path = NULL, *entry_label = NULL;
unsigned type = 0, w = 0; unsigned type = 0, w = 0;
menu_list_get_at_offset(driver.menu->menu_list->selection_buf, i, &path, menu_list_get_at_offset(menu->menu_list->selection_buf, i, &path,
&entry_label, &type); &entry_label, &type);
setting = setting =
(rarch_setting_t*)setting_data_find_setting (rarch_setting_t*)setting_data_find_setting
(driver.menu->list_settings, (menu->list_settings,
driver.menu->menu_list->selection_buf->list[i].label); menu->menu_list->selection_buf->list[i].label);
cbs = (menu_file_list_cbs_t*)menu_list_get_actiondata_at_offset( cbs = (menu_file_list_cbs_t*)menu_list_get_actiondata_at_offset(
driver.menu->menu_list->selection_buf, i); menu->menu_list->selection_buf, i);
if (cbs && cbs->action_get_representation) { if (cbs && cbs->action_get_representation) {
cbs->action_get_representation cbs->action_get_representation
(driver.menu->menu_list->selection_buf, (menu->menu_list->selection_buf,
&w, type, i, label, &w, type, i, label,
type_str, sizeof(type_str), type_str, sizeof(type_str),
entry_label, path, entry_label, path,
@ -683,7 +687,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
[RAMenuItemGeneralSetting [RAMenuItemGeneralSetting
itemForSetting:setting itemForSetting:setting
action:^{ action:^{
driver.menu->selection_ptr = i; 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);
}]]; }]];
@ -695,7 +699,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
[RAMenuItemBasic [RAMenuItemBasic
itemWithDescription:BOXSTRING(path_buf) itemWithDescription:BOXSTRING(path_buf)
action:^{ action:^{
driver.menu->selection_ptr = i; 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
@ -704,7 +708,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
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(menu->menu_list, "",
"info_screen", 0, i); "info_screen", 0, i);
} }
@ -716,29 +720,36 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
[self.sections addObject:everything]; [self.sections addObject:everything];
if (menu_list_get_stack_size(driver.menu->menu_list) > 1) if (menu_list_get_stack_size(menu->menu_list) > 1)
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:BOXSTRING("Back") style:UIBarButtonItemStyleBordered target:weakSelf action:@selector(menuBack)]; self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:BOXSTRING("Back") style:UIBarButtonItemStyleBordered target:weakSelf action:@selector(menuBack)];
else else
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:BOXSTRING("Resume") style:UIBarButtonItemStyleBordered target:[RetroArch_iOS get] action:@selector(showGameView)]; self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:BOXSTRING("Resume") style:UIBarButtonItemStyleBordered target:[RetroArch_iOS get] action:@selector(showGameView)];
if ( driver.menu->message_contents[0] != '\0' ) if ( menu->message_contents[0] != '\0' )
apple_display_alert(driver.menu->message_contents, NULL); apple_display_alert(menu->message_contents, NULL);
} }
- (void)menuRefresh - (void)menuRefresh
{ {
if (!driver.menu->need_refresh) menu_handle_t *menu = menu_driver_resolve();
if (!menu)
return;
if (!menu->need_refresh)
return; return;
menu_entries_deferred_push(driver.menu->menu_list->selection_buf, menu_entries_deferred_push(menu->menu_list->selection_buf,
driver.menu->menu_list->menu_stack); menu->menu_list->menu_stack);
driver.menu->need_refresh = false; menu->need_refresh = false;
} }
- (void)menuBack - (void)menuBack
{ {
menu_handle_t *menu = menu_driver_resolve();
if (!menu)
return;
menu_apply_deferred_settings(); menu_apply_deferred_settings();
menu_list_pop_stack(driver.menu->menu_list); menu_list_pop_stack(menu->menu_list);
[self menuRefresh]; [self menuRefresh];
[self reloadData]; [self reloadData];
} }