From beeb8dbd7dd40a5ff53ff27d99eb76d694b8624d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 Feb 2015 09:16:01 +0100 Subject: [PATCH] Implement disk index as representation callback --- menu/menu_entries_cbs.c | 33 +++++++++++++++++++++++++++++++++ settings_data.c | 13 ------------- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index ece4c2bfa6..d319b19437 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -4068,6 +4068,35 @@ static void menu_action_setting_disp_set_label_menu_file_plain( strlcpy(path_buf, path, path_buf_size); } +static void menu_action_setting_disp_set_label_menu_disk_index( + file_list_t* list, + unsigned *w, unsigned type, unsigned i, + const char *label, + char *type_str, size_t type_str_size, + const char *entry_label, + const char *path, + char *path_buf, size_t path_buf_size) +{ + const struct retro_disk_control_callback *control = + (const struct retro_disk_control_callback*) + &g_extern.system.disk_control; + unsigned images = 0, current = 0; + + *w = 19; + *type_str = '\0'; + strlcpy(path_buf, path, path_buf_size); + if (!control) + return; + + images = control->get_num_images(); + current = control->get_image_index(); + + if (current >= images) + strlcpy(type_str, "No Disk", type_str_size); + else + snprintf(type_str, type_str_size, "%u", current + 1); +} + static void menu_action_setting_disp_set_label_menu_file_use_directory( file_list_t* list, unsigned *w, unsigned type, unsigned i, @@ -4879,6 +4908,10 @@ static void menu_entries_cbs_init_bind_get_string_representation(menu_file_list_ cbs->action_get_representation = menu_action_setting_disp_set_label_menu_more; break; + case MENU_SETTINGS_CORE_DISK_OPTIONS_DISK_INDEX: + cbs->action_get_representation = + menu_action_setting_disp_set_label_menu_disk_index; + break; default: cbs->action_get_representation = menu_action_setting_disp_set_label; break; diff --git a/settings_data.c b/settings_data.c index b437ef447b..1cdeb8dc92 100644 --- a/settings_data.c +++ b/settings_data.c @@ -2817,19 +2817,6 @@ static int get_fallback_label(char *type_str, } break; #endif - case MENU_SETTINGS_CORE_DISK_OPTIONS_DISK_INDEX: - { - const struct retro_disk_control_callback *control = - (const struct retro_disk_control_callback*) - &g_extern.system.disk_control; - unsigned images = control->get_num_images(); - unsigned current = control->get_image_index(); - if (current >= images) - strlcpy(type_str, "No Disk", type_str_size); - else - snprintf(type_str, type_str_size, "%u", current + 1); - } - break; default: ret = -1; break;