(menu_displaylist) menu_displaylist_parse_core_info - cut down on more

code duplication
This commit is contained in:
twinaphex 2019-04-22 20:22:24 +02:00
parent 799872e59d
commit d08f9cb212
1 changed files with 41 additions and 57 deletions

View File

@ -202,50 +202,34 @@ static int menu_displaylist_parse_core_info(menu_displaylist_info_t *info)
return 0; return 0;
} }
if (core_info->core_name)
{ {
fill_pathname_join_concat_noext(tmp, unsigned i;
msg_hash_to_str( typedef struct menu_features_info
MENU_ENUM_LABEL_VALUE_CORE_INFO_CORE_NAME), {
": ", const char *name;
core_info->core_name, enum msg_hash_enums msg;
sizeof(tmp)); } menu_features_info_t;
menu_entries_append_enum(info->list, tmp, "",
MENU_ENUM_LABEL_CORE_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0);
}
if (core_info->display_name) menu_features_info_t info_list[] = {
{ {core_info->core_name, MENU_ENUM_LABEL_VALUE_CORE_INFO_CORE_NAME},
fill_pathname_join_concat_noext(tmp, {core_info->display_name, MENU_ENUM_LABEL_VALUE_CORE_INFO_CORE_LABEL},
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_CORE_LABEL), {core_info->systemname, MENU_ENUM_LABEL_VALUE_CORE_INFO_SYSTEM_NAME},
": ", {core_info->system_manufacturer, MENU_ENUM_LABEL_VALUE_CORE_INFO_SYSTEM_MANUFACTURER},
core_info->display_name, };
sizeof(tmp));
menu_entries_append_enum(info->list, tmp, "",
MENU_ENUM_LABEL_CORE_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0);
}
if (core_info->systemname) for (i = 0; i < ARRAY_SIZE(info_list); i++)
{ {
fill_pathname_join_concat_noext(tmp, if (!info_list[i].name)
msg_hash_to_str( continue;
MENU_ENUM_LABEL_VALUE_CORE_INFO_SYSTEM_NAME),
": ",
core_info->systemname,
sizeof(tmp));
menu_entries_append_enum(info->list, tmp, "",
MENU_ENUM_LABEL_CORE_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0);
}
if (core_info->system_manufacturer) fill_pathname_join_concat_noext(tmp,
{ msg_hash_to_str(info_list[i].msg),
fill_pathname_join_concat_noext(tmp, ": ",
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_SYSTEM_MANUFACTURER), info_list[i].name,
": ", sizeof(tmp));
core_info->system_manufacturer, menu_entries_append_enum(info->list, tmp, "",
sizeof(tmp)); MENU_ENUM_LABEL_CORE_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0);
menu_entries_append_enum(info->list, tmp, "", }
MENU_ENUM_LABEL_CORE_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0);
} }
if (core_info->categories_list) if (core_info->categories_list)
@ -338,24 +322,24 @@ static int menu_displaylist_parse_core_info(menu_displaylist_info_t *info)
for (i = 0; i < core_info->firmware_count; i++) for (i = 0; i < core_info->firmware_count; i++)
{ {
if (core_info->firmware[i].desc) if (!core_info->firmware[i].desc)
{ continue;
snprintf(tmp, sizeof(tmp), "(!) %s, %s: %s",
core_info->firmware[i].missing ?
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_MISSING) :
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PRESENT),
core_info->firmware[i].optional ?
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OPTIONAL) :
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_REQUIRED),
core_info->firmware[i].desc ?
core_info->firmware[i].desc :
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_NAME)
);
menu_entries_append_enum(info->list, tmp, "", snprintf(tmp, sizeof(tmp), "(!) %s, %s: %s",
MENU_ENUM_LABEL_CORE_INFO_ENTRY, core_info->firmware[i].missing ?
MENU_SETTINGS_CORE_INFO_NONE, 0, 0); msg_hash_to_str(MENU_ENUM_LABEL_VALUE_MISSING) :
} msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PRESENT),
core_info->firmware[i].optional ?
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OPTIONAL) :
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_REQUIRED),
core_info->firmware[i].desc ?
core_info->firmware[i].desc :
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_NAME)
);
menu_entries_append_enum(info->list, tmp, "",
MENU_ENUM_LABEL_CORE_INFO_ENTRY,
MENU_SETTINGS_CORE_INFO_NONE, 0, 0);
} }
} }
} }