* Simplify menu_entries_get_title

* Add TODO/FIXME - localize strings to hardcoded strings
* Some more simplifications in for loops
This commit is contained in:
LibretroAdmin 2022-09-01 15:42:25 +02:00
parent 003cea5d42
commit 6f84af2efa
6 changed files with 35 additions and 41 deletions

View File

@ -882,6 +882,7 @@ static void menu_action_setting_disp_set_label_input_desc_kbd(
if (key_descriptors[key_id].key != RETROK_FIRST)
{
/* TODO/FIXME - Localize */
strlcpy(s, "Keyboard ", len);
strlcat(s, key_descriptors[key_id].desc, len);
}

View File

@ -8027,11 +8027,10 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs,
STRLEN_CONST("input_binds_list")))
{
unsigned i;
unsigned first_char = atoi(&str[0]);
for (i = 0; i < MAX_USERS; i++)
{
unsigned first_char = atoi(&str[0]);
if (first_char != ((i+1)))
continue;

View File

@ -43,11 +43,9 @@ static int action_select_default(
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
if (selection_buf)
cbs = (menu_file_list_cbs_t*)
file_list_get_actiondata_at_offset(selection_buf, idx);
if (!cbs)
return -1;
if (!(cbs = (menu_file_list_cbs_t*)
file_list_get_actiondata_at_offset(selection_buf, idx)))
return -1;
if (cbs->setting)
{
@ -62,7 +60,7 @@ static int action_select_default(
if (cbs->action_ok)
action = MENU_ACTION_OK;
else
action = MENU_ACTION_RIGHT;
action = MENU_ACTION_RIGHT;
break;
case ST_PATH:
case ST_DIR:
@ -70,7 +68,7 @@ static int action_select_default(
case ST_STRING:
case ST_HEX:
case ST_BIND:
action = MENU_ACTION_OK;
action = MENU_ACTION_OK;
break;
default:
break;
@ -138,12 +136,6 @@ static int menu_cbs_init_bind_select_compare_type(
return 0;
}
static int menu_cbs_init_bind_select_compare_label(menu_file_list_cbs_t *cbs,
const char *label)
{
return -1;
}
int menu_cbs_init_bind_select(menu_file_list_cbs_t *cbs,
const char *path, const char *label, unsigned type, size_t idx)
{
@ -159,9 +151,6 @@ int menu_cbs_init_bind_select(menu_file_list_cbs_t *cbs,
return 0;
}
if (menu_cbs_init_bind_select_compare_label(cbs, label) == 0)
return 0;
if (menu_cbs_init_bind_select_compare_type(cbs, type) == 0)
return 0;

View File

@ -1200,13 +1200,15 @@ static int action_bind_sublabel_systeminfo_controller_entry(
{
char tmp[4096];
unsigned controller;
const char *val_port_dev_name =
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PORT_DEVICE_NAME);
for (controller = 0; controller < MAX_USERS; controller++)
{
if (input_config_get_device_autoconfigured(controller))
{
snprintf(tmp, sizeof(tmp),
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PORT_DEVICE_NAME),
val_port_dev_name,
controller,
input_config_get_device_name(controller),
input_config_get_device_name_index(controller));
@ -1215,6 +1217,8 @@ static int action_bind_sublabel_systeminfo_controller_entry(
break;
}
}
/* TODO/FIXME - Localize */
snprintf(tmp, sizeof(tmp), "Device display name: %s\nDevice config name: %s\nDevice identifiers: %d/%d",
input_config_get_device_display_name(controller) ? input_config_get_device_display_name(controller) : msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE),
input_config_get_device_display_name(controller) ? input_config_get_device_config_name(controller) : msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE),
@ -1302,6 +1306,7 @@ static int action_bind_sublabel_subsystem_add(
if (subsystem && runloop_st->subsystem_current_count > 0)
{
/* TODO/FIXME - Localize */
if (content_get_subsystem_rom_id() < subsystem->num_roms)
snprintf(s, len, " Current Content: %s",
content_get_subsystem() == type - MENU_SETTINGS_SUBSYSTEM_ADD
@ -1361,9 +1366,9 @@ static int action_bind_sublabel_remap_kbd_sublabel(
char *s, size_t len)
{
unsigned user_idx = (type - MENU_SETTINGS_INPUT_DESC_KBD_BEGIN) / RARCH_ANALOG_BIND_LIST_END;
snprintf(s, len, "%s %u: %s",
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PORT),
size_t _len = strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PORT),
len);
snprintf(s + _len, len - _len, " %u: %s",
user_idx + 1,
input_config_get_device_display_name(user_idx) ?
input_config_get_device_display_name(user_idx) :
@ -1395,19 +1400,24 @@ static int action_bind_sublabel_audio_mixer_stream(
sizeof(msg));
break;
case AUDIO_STREAM_STATE_STOPPED:
/* TODO/FIXME - Localize */
strlcpy(msg, "Stopped", sizeof(msg));
break;
case AUDIO_STREAM_STATE_PLAYING:
/* TODO/FIXME - Localize */
strlcpy(msg, "Playing", sizeof(msg));
break;
case AUDIO_STREAM_STATE_PLAYING_LOOPED:
/* TODO/FIXME - Localize */
strlcpy(msg, "Playing (Looped)", sizeof(msg));
break;
case AUDIO_STREAM_STATE_PLAYING_SEQUENTIAL:
/* TODO/FIXME - Localize */
strlcpy(msg, "Playing (Sequential)", sizeof(msg));
break;
}
/* TODO/FIXME - Localize */
snprintf(s, len, "State : %s | %s: %.2f dB", msg,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_MIXER_ACTION_VOLUME),
stream->volume);
@ -1421,6 +1431,7 @@ static int action_bind_sublabel_remap_sublabel(
const char *label, const char *path,
char *s, size_t len)
{
size_t _len;
settings_t *settings = config_get_ptr();
unsigned port = (type - MENU_SETTINGS_INPUT_DESC_BEGIN)
/ (RARCH_FIRST_CUSTOM_BIND + 8);
@ -1435,8 +1446,9 @@ static int action_bind_sublabel_remap_sublabel(
* controller is connected... */
port = settings->uints.input_joypad_index[port];
snprintf(s, len, "%s %u: %s",
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PORT),
_len = strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PORT), len);
snprintf(s + _len, len - _len, " %u: %s",
port + 1,
input_config_get_device_display_name(port) ?
input_config_get_device_display_name(port) :

View File

@ -366,9 +366,10 @@ static int action_get_title_dropdown_item(
#ifdef HAVE_AUDIOMIXER
static int action_get_title_mixer_stream_actions(const char *path, const char *label, unsigned menu_type, char *s, size_t len)
{
unsigned offset = (menu_type - MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_BEGIN);
snprintf(s, len, "Mixer Stream #%d: %s", offset + 1, audio_driver_mixer_get_stream_name(offset));
unsigned offset = (menu_type - MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_BEGIN);
/* TODO/FIXME - Localize */
size_t _len = strlcpy(s, "Mixer Stream", len);
snprintf(s + _len, len - _len, " #%d: %s", offset + 1, audio_driver_mixer_get_stream_name(offset));
return 0;
}
#endif

View File

@ -5058,23 +5058,15 @@ int menu_entries_get_core_title(char *s, size_t len)
(system && system->library_version)
? system->library_version
: "";
size_t _len = strlcpy(s, PACKAGE_VERSION, len);
#if defined(_MSC_VER)
_len = strlcat(s, msvc_vercode_to_str(_MSC_VER), len);
#endif
if (!string_is_empty(core_version))
{
#if defined(_MSC_VER)
snprintf(s, len, PACKAGE_VERSION "%s" " - %s (%s)", msvc_vercode_to_str(_MSC_VER), core_name, core_version);
#else
snprintf(s, len, PACKAGE_VERSION " - %s (%s)", core_name, core_version);
#endif
}
snprintf(s + _len, len - _len, " - %s (%s)", core_name, core_version);
else
{
#if defined(_MSC_VER)
snprintf(s, len, PACKAGE_VERSION "%s" " - %s", msvc_vercode_to_str(_MSC_VER), core_name);
#else
snprintf(s, len, PACKAGE_VERSION " - %s", core_name);
#endif
}
snprintf(s + _len, len - _len, " - %s", core_name);
return 0;
}