diff --git a/apple/OSX/settings.m b/apple/OSX/settings.m index fb8bb1394f..5fe2d7992d 100644 --- a/apple/OSX/settings.m +++ b/apple/OSX/settings.m @@ -128,7 +128,7 @@ NSWindowDelegate> NSMutableArray* thisGroup = nil; NSMutableArray* thisSubGroup = nil; self.settings = [NSMutableArray array]; - setting_data = (const rarch_setting_t *)setting_data_get_list(); + setting_data = (const rarch_setting_t *)setting_data_get_list(true); for (i = 0; setting_data[i].type; i ++) { @@ -246,7 +246,7 @@ NSWindowDelegate> { char buffer[PATH_MAX]; rarch_setting_t* setting_data, *setting = NULL; - setting_data = (rarch_setting_t*)setting_data_get_list(); + setting_data = (rarch_setting_t*)setting_data_get_list(false); setting = (rarch_setting_t*)&setting_data[[item intValue]]; if ([[tableColumn identifier] isEqualToString:BOXSTRING("left")]) @@ -282,7 +282,7 @@ NSWindowDelegate> if ([[tableColumn identifier] isEqualToString:BOXSTRING("left")]) return [tableColumn dataCell]; - setting_data = (const rarch_setting_t *)setting_data_get_list(); + setting_data = (const rarch_setting_t *)setting_data_get_list(false); setting = (const rarch_setting_t *)&setting_data[[item intValue]]; switch (setting->type) @@ -304,7 +304,7 @@ NSWindowDelegate> if ([item isKindOfClass:[NSNumber class]]) { - rarch_setting_t *setting_data = (rarch_setting_t*)setting_data_get_list(); + rarch_setting_t *setting_data = (rarch_setting_t*)setting_data_get_list(false); rarch_setting_t *setting = (rarch_setting_t*)&setting_data[[item intValue]]; switch (setting->type) @@ -334,7 +334,7 @@ NSWindowDelegate> if ([item isKindOfClass:[NSNumber class]]) { - rarch_setting_t *setting_data = (rarch_setting_t *)setting_data_get_list(); + rarch_setting_t *setting_data = (rarch_setting_t *)setting_data_get_list(false); rarch_setting_t *setting = (rarch_setting_t*)&setting_data[[item intValue]]; NSString *editor_string = (NSString*)editor.string; diff --git a/apple/iOS/menu.m b/apple/iOS/menu.m index 7bc68dfed0..3942ac2f1b 100644 --- a/apple/iOS/menu.m +++ b/apple/iOS/menu.m @@ -808,7 +808,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U _pathToSave = BOXSTRING(g_defaults.config_path); } - setting_data = (rarch_setting_t*)setting_data_get_list(); + setting_data = (rarch_setting_t*)setting_data_get_list(true); setting_data_load_config_path(setting_data, _pathToSave.UTF8String); // HACK: Load the key mapping table @@ -858,7 +858,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U if (config) { - setting_data_save_config(setting_data_get_list(), config); + setting_data_save_config(setting_data_get_list(false), config); config_file_write(config, self.pathToSave.UTF8String); config_file_free(config); } diff --git a/frontend/menu/backend/menu_common_backend.c b/frontend/menu/backend/menu_common_backend.c index 2d031a47e1..44595bc983 100644 --- a/frontend/menu/backend/menu_common_backend.c +++ b/frontend/menu/backend/menu_common_backend.c @@ -68,7 +68,7 @@ static int menu_info_screen_iterate(unsigned action) char needle[PATH_MAX]; unsigned info_type = 0; rarch_setting_t *current_setting = NULL; - rarch_setting_t *setting_data = (rarch_setting_t *)setting_data_get_list(); + rarch_setting_t *setting_data = (rarch_setting_t *)setting_data_get_list(false); file_list_t *list = (file_list_t*)driver.menu->selection_buf; if (!driver.menu || !setting_data) @@ -80,7 +80,7 @@ static int menu_info_screen_iterate(unsigned action) current_setting = (rarch_setting_t*)menu_entries_get_last_setting( list->list[driver.menu->selection_ptr].label, driver.menu->selection_ptr, - setting_data_get_list()); + setting_data_get_list(false)); if (current_setting) strlcpy(needle, current_setting->name, sizeof(needle)); @@ -768,7 +768,7 @@ static int menu_action_ok(const char *menu_path, const char *path = NULL; unsigned type = 0; rarch_setting_t *setting_data = (rarch_setting_t *) - setting_data_get_list(); + setting_data_get_list(false); rarch_setting_t *setting = (rarch_setting_t*) setting_data_find_setting(setting_data, menu_label); diff --git a/frontend/menu/disp/glui.c b/frontend/menu/disp/glui.c index d53041bdea..70e31a5537 100644 --- a/frontend/menu/disp/glui.c +++ b/frontend/menu/disp/glui.c @@ -246,7 +246,7 @@ static void glui_frame(void) file_list_get_at_offset(driver.menu->selection_buf, i, &path, &entry_label, &type); rarch_setting_t *setting = (rarch_setting_t*)setting_data_find_setting( - setting_data_get_list(), + setting_data_get_list(false), driver.menu->selection_buf->list[i].label); (void)setting; diff --git a/frontend/menu/disp/lakka.c b/frontend/menu/disp/lakka.c index 5dd8b6fa23..c4eb8a8118 100644 --- a/frontend/menu/disp/lakka.c +++ b/frontend/menu/disp/lakka.c @@ -801,7 +801,7 @@ static void lakka_context_destroy(void *data) void lakka_init_settings(void) { - rarch_setting_t *setting_data = (rarch_setting_t*)setting_data_get_list(); + rarch_setting_t *setting_data = (rarch_setting_t*)setting_data_get_list(false); menu_category_t *category = (menu_category_t*)&categories[0]; diff --git a/frontend/menu/disp/rgui.c b/frontend/menu/disp/rgui.c index 23600aee8e..a0014adcdb 100644 --- a/frontend/menu/disp/rgui.c +++ b/frontend/menu/disp/rgui.c @@ -356,7 +356,7 @@ static void rgui_render(void) file_list_get_at_offset(driver.menu->selection_buf, i, &path, &entry_label, &type); rarch_setting_t *setting = (rarch_setting_t*)setting_data_find_setting( - setting_data_get_list(), + setting_data_get_list(false), driver.menu->selection_buf->list[i].label); (void)setting; diff --git a/frontend/menu/menu_action.c b/frontend/menu/menu_action.c index b530ebe981..93485bf54e 100644 --- a/frontend/menu/menu_action.c +++ b/frontend/menu/menu_action.c @@ -393,7 +393,7 @@ int menu_action_setting_set(unsigned id, const char *label, rarch_setting_t *setting = (rarch_setting_t*)menu_entries_get_last_setting( list->list[driver.menu->selection_ptr].label, driver.menu->selection_ptr, - setting_data_get_list() + setting_data_get_list(false) ); if (setting) diff --git a/frontend/menu/menu_entries.c b/frontend/menu/menu_entries.c index ae84e28c2c..1f2c68c36e 100644 --- a/frontend/menu/menu_entries.c +++ b/frontend/menu/menu_entries.c @@ -167,7 +167,7 @@ int menu_entries_push_list(menu_handle_t *menu, char tmp[256]; size_t list_size = 0; rarch_setting_t *setting_data = (rarch_setting_t *) - setting_data_get_list(); + setting_data_get_list(true); bool do_action = false; #if 0 @@ -211,7 +211,6 @@ int menu_entries_push_list(menu_handle_t *menu, !strcmp(label, "Netplay Options") ) { - rarch_setting_t *setting_data = (rarch_setting_t*)setting_data_get_list(); rarch_setting_t *setting = (rarch_setting_t*)setting_data_find_setting(setting_data, label); @@ -242,7 +241,6 @@ int menu_entries_push_list(menu_handle_t *menu, } else if (!strcmp(label, "settings")) { - rarch_setting_t *setting_data = (rarch_setting_t*)setting_data_get_list(); rarch_setting_t *setting = (rarch_setting_t*)setting_data_find_setting(setting_data, "Driver Options"); diff --git a/frontend/menu/menu_input_line_cb.c b/frontend/menu/menu_input_line_cb.c index 85e0ac4a23..747d1fd120 100644 --- a/frontend/menu/menu_input_line_cb.c +++ b/frontend/menu/menu_input_line_cb.c @@ -72,7 +72,7 @@ void st_uint_callback(void *userdata, const char *str) { menu_handle_t *menu = (menu_handle_t*)userdata; rarch_setting_t *current_setting = NULL; - rarch_setting_t *setting_data = (rarch_setting_t *)setting_data_get_list(); + rarch_setting_t *setting_data = (rarch_setting_t *)setting_data_get_list(false); if (str && *str && setting_data) { @@ -88,7 +88,7 @@ void st_string_callback(void *userdata, const char *str) { menu_handle_t *menu = (menu_handle_t*)userdata; rarch_setting_t *current_setting = NULL; - rarch_setting_t *setting_data = (rarch_setting_t *)setting_data_get_list(); + rarch_setting_t *setting_data = (rarch_setting_t *)setting_data_get_list(false); if (str && *str && setting_data) { diff --git a/frontend/menu/menu_shader.c b/frontend/menu/menu_shader.c index 00616fafe2..c3158614de 100644 --- a/frontend/menu/menu_shader.c +++ b/frontend/menu/menu_shader.c @@ -361,7 +361,7 @@ int menu_shader_manager_setting_toggle( #endif rarch_setting_t *current_setting = NULL; - rarch_setting_t *setting_data = (rarch_setting_t *)setting_data_get_list(); + rarch_setting_t *setting_data = (rarch_setting_t *)setting_data_get_list(false); if (!strcmp(label, "video_shader_default_filter")) diff --git a/settings_data.c b/settings_data.c index 6251d22205..02ae90f0e0 100644 --- a/settings_data.c +++ b/settings_data.c @@ -1791,7 +1791,7 @@ void setting_data_get_label(char *type_str, size_t type_str_size, unsigned *w, unsigned type, const char *menu_label, const char *label, unsigned index) { - rarch_setting_t *setting_data = (rarch_setting_t*)setting_data_get_list(); + rarch_setting_t *setting_data = (rarch_setting_t*)setting_data_get_list(false); rarch_setting_t *setting = (rarch_setting_t*)setting_data_find_setting(setting_data, driver.menu->selection_buf->list[index].label); @@ -2331,58 +2331,6 @@ void *rarch_setting_list_new(unsigned size) return list; } -#ifdef HAVE_MENU -rarch_setting_t *setting_data_get_mainmenu(bool regenerate) -{ - rarch_setting_info_t *list_info = NULL; - rarch_setting_group_info_t group_info; - rarch_setting_group_info_t subgroup_info; - static rarch_setting_t* list = NULL; - - (void)group_info; - (void)subgroup_info; - - if (list) - { - if (!regenerate) - return list; - - rarch_setting_list_free(list); - } - - list_info = (rarch_setting_info_t*)rarch_setting_info_list_new(); - if (!list_info) - return NULL; - - list = (rarch_setting_t*)rarch_setting_list_new(list_info->size); - if (!list) - goto error; - - if (!setting_data_get_list_main_menu_options(&list, list_info)) - goto error; - - rarch_setting_t terminator = { ST_NONE }; - if (!(data_list_append(&list, list_info, terminator))) - goto error; - - /* flatten this array to save ourselves some kilobytes */ - if (!(list = (rarch_setting_t*)realloc(list, list_info->index * sizeof(rarch_setting_t)))) - goto error; - - rarch_setting_info_list_free(list_info); - - /* do not optimize into return realloc(), - * list is static and must be written. */ - return (rarch_setting_t*)list; - -error: - RARCH_ERR("Allocation failed.\n"); - rarch_setting_info_list_free(list_info); - rarch_setting_list_free(list); - - return NULL; -} -#endif bool setting_data_get_list_driver_options( rarch_setting_t **list, @@ -2951,14 +2899,68 @@ bool setting_data_get_list_privacy_options( return true; } +#ifdef HAVE_MENU +/* TODO - combine this with setting_data_get_list. */ -rarch_setting_t *setting_data_get_list(void) +rarch_setting_t *setting_data_get_mainmenu(bool need_refresh) { rarch_setting_info_t *list_info = NULL; static rarch_setting_t* list = NULL; if (list) - return list; + { + if (!need_refresh) + return list; + + rarch_setting_list_free(list); + } + + list_info = (rarch_setting_info_t*)rarch_setting_info_list_new(); + if (!list_info) + return NULL; + + list = (rarch_setting_t*)rarch_setting_list_new(list_info->size); + if (!list) + goto error; + + if (!setting_data_get_list_main_menu_options(&list, list_info)) + goto error; + + rarch_setting_t terminator = { ST_NONE }; + if (!(data_list_append(&list, list_info, terminator))) + goto error; + + /* flatten this array to save ourselves some kilobytes */ + if (!(list = (rarch_setting_t*)realloc(list, list_info->index * sizeof(rarch_setting_t)))) + goto error; + + rarch_setting_info_list_free(list_info); + + /* do not optimize into return realloc(), + * list is static and must be written. */ + return (rarch_setting_t*)list; + +error: + RARCH_ERR("Allocation failed.\n"); + rarch_setting_info_list_free(list_info); + rarch_setting_list_free(list); + + return NULL; +} +#endif + +rarch_setting_t *setting_data_get_list(bool need_refresh) +{ + rarch_setting_info_t *list_info = NULL; + static rarch_setting_t* list = NULL; + + if (list) + { + if (!need_refresh) + return list; + + rarch_setting_list_free(list); + } list_info = (rarch_setting_info_t*)rarch_setting_info_list_new(); if (!list_info) diff --git a/settings_data.h b/settings_data.h index 9c6ead1262..3cf70fbc77 100644 --- a/settings_data.h +++ b/settings_data.h @@ -202,7 +202,7 @@ void setting_data_get_label(char *type_str, size_t type_str_size, unsigned *w, unsigned type, const char *menu_label, const char *label, unsigned index); #endif -rarch_setting_t* setting_data_get_list(void); +rarch_setting_t* setting_data_get_list(bool need_refresh); #ifdef __cplusplus }