Refactor get_label code

This commit is contained in:
twinaphex 2015-02-01 09:58:23 +01:00
parent e0a7c38fdb
commit 3eb2699751
2 changed files with 119 additions and 97 deletions

View File

@ -4040,6 +4040,29 @@ static void menu_action_setting_disp_set_label_menu_file_core(
strlcpy(path_buf, alt, path_buf_size);
}
static void menu_action_setting_disp_set_label_input_desc(
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)
{
unsigned inp_desc_index_offset = type - MENU_SETTINGS_INPUT_DESC_BEGIN;
unsigned inp_desc_user = inp_desc_index_offset /
RARCH_FIRST_CUSTOM_BIND;
unsigned inp_desc_button_index_offset = inp_desc_index_offset -
(inp_desc_user * RARCH_FIRST_CUSTOM_BIND);
unsigned remap_id = g_settings.input.remap_ids
[inp_desc_user][inp_desc_button_index_offset];
snprintf(type_str, type_str_size, "%s",
g_settings.input.binds[inp_desc_user][remap_id].desc);
*w = 19;
strlcpy(path_buf, path, path_buf_size);
}
static void menu_action_setting_disp_set_label_menu_more(
file_list_t* list,
unsigned *w, unsigned type, unsigned i,
@ -4863,6 +4886,14 @@ static void menu_entries_cbs_init_bind_get_string_representation(menu_file_list_
if (!cbs || !driver.menu)
return;
if (type >= MENU_SETTINGS_INPUT_DESC_BEGIN
&& type <= MENU_SETTINGS_INPUT_DESC_END)
{
cbs->action_get_representation =
menu_action_setting_disp_set_label_input_desc;
}
else
{
switch (type)
{
case MENU_FILE_CORE:
@ -4953,6 +4984,7 @@ static void menu_entries_cbs_init_bind_get_string_representation(menu_file_list_
break;
}
}
}
static void menu_entries_cbs_init_bind_deferred_push(menu_file_list_cbs_t *cbs,
const char *path, const char *label, unsigned type, size_t idx)

View File

@ -2938,16 +2938,6 @@ void setting_data_get_label(void *data, char *type_str,
g_extern.cheat->cheats[cheat_index].state ? "ON" : "OFF"
);
}
else if (type >= MENU_SETTINGS_INPUT_DESC_BEGIN
&& type <= MENU_SETTINGS_INPUT_DESC_END)
{
unsigned inp_desc_index_offset = type - MENU_SETTINGS_INPUT_DESC_BEGIN;
unsigned inp_desc_user = inp_desc_index_offset / RARCH_FIRST_CUSTOM_BIND;
unsigned inp_desc_button_index_offset = inp_desc_index_offset - (inp_desc_user * RARCH_FIRST_CUSTOM_BIND);
unsigned remap_id = g_settings.input.remap_ids[inp_desc_user][inp_desc_button_index_offset];
snprintf(type_str, type_str_size, "%s", g_settings.input.binds[inp_desc_user][remap_id].desc);
}
else if (type >= MENU_SETTINGS_PERF_COUNTERS_BEGIN
&& type <= MENU_SETTINGS_PERF_COUNTERS_END)
menu_common_setting_set_label_perf(type_str, type_str_size, w, type,