Merge pull request #7332 from grimpunch/master

Date Time setting for AM:PM as an option
This commit is contained in:
Twinaphex 2018-10-07 02:31:21 +02:00 committed by GitHub
commit c29654b504
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 170 additions and 8 deletions

View File

@ -705,6 +705,8 @@ static const unsigned menu_thumbnails_default = 3;
static const unsigned menu_left_thumbnails_default = 0;
static const unsigned menu_timedate_style = 5;
static const bool xmb_vertical_thumbnails = false;
#ifdef IOS

View File

@ -1574,6 +1574,7 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings,
#ifdef HAVE_MENU
SETTING_UINT("dpi_override_value", &settings->uints.menu_dpi_override_value, true, menu_dpi_override_value, false);
SETTING_UINT("menu_thumbnails", &settings->uints.menu_thumbnails, true, menu_thumbnails_default, false);
SETTING_UINT("menu_timedate_style", &settings->uints.menu_timedate_style, true, menu_timedate_style, false);
#ifdef HAVE_XMB
SETTING_UINT("menu_left_thumbnails", &settings->uints.menu_left_thumbnails, true, menu_left_thumbnails_default, false);
SETTING_UINT("xmb_alpha_factor", &settings->uints.menu_xmb_alpha_factor, true, xmb_alpha_factor, false);

View File

@ -393,6 +393,7 @@ typedef struct settings
unsigned video_record_scale_factor;
unsigned video_stream_scale_factor;
unsigned menu_timedate_style;
unsigned menu_thumbnails;
unsigned menu_left_thumbnails;
unsigned menu_dpi_override_value;

View File

@ -1111,6 +1111,8 @@ MSG_HASH(MENU_ENUM_LABEL_THUMBNAILS_UPDATER_LIST,
"thumbnails_updater_list")
MSG_HASH(MENU_ENUM_LABEL_TIMEDATE_ENABLE,
"menu_timedate_enable")
MSG_HASH(MENU_ENUM_LABEL_TIMEDATE_STYLE,
"menu_timedate_style")
MSG_HASH(MENU_ENUM_LABEL_TITLE_COLOR,
"menu_title_color")
MSG_HASH(MENU_ENUM_LABEL_UI_COMPANION_ENABLE,

View File

@ -1738,6 +1738,10 @@ int menu_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len)
snprintf(s, len,
"Shows current date and/or time inside menu.");
break;
case MENU_ENUM_LABEL_TIMEDATE_STYLE:
snprintf(s, len,
"Style to show the current date and/or time in.");
break;
case MENU_ENUM_LABEL_BATTERY_LEVEL_ENABLE:
snprintf(s, len,
"Shows current battery level inside menu.");

View File

@ -2906,6 +2906,46 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_TIMEDATE_ENABLE,
"Show date / time"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE,
"Style of date / time"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_TIMEDATE_STYLE,
"Changes the style current date and/or time is shown inside the menu."
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS,
"YYYY-MM-DD HH:MM:SS"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM,
"YYYY-MM-DD HH:MM"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY,
"MM-DD-YYYY HH:MM"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS,
"HH:MM:SS"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM,
"HH:MM"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DM_HM,
"DD/MM HH:MM"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM,
"MM/DD HH:MM"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_AM_PM,
"HH:MM:SS (AM/PM)"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_TITLE_COLOR,
"Menu title color"

View File

@ -296,6 +296,7 @@ default_sublabel_macro(action_bind_sublabel_pointer_enable, MENU_
default_sublabel_macro(action_bind_sublabel_thumbnails, MENU_ENUM_SUBLABEL_THUMBNAILS)
default_sublabel_macro(action_bind_sublabel_left_thumbnails, MENU_ENUM_SUBLABEL_LEFT_THUMBNAILS)
default_sublabel_macro(action_bind_sublabel_timedate_enable, MENU_ENUM_SUBLABEL_TIMEDATE_ENABLE)
default_sublabel_macro(action_bind_sublabel_timedate_style, MENU_ENUM_SUBLABEL_TIMEDATE_STYLE)
default_sublabel_macro(action_bind_sublabel_battery_level_enable, MENU_ENUM_SUBLABEL_BATTERY_LEVEL_ENABLE)
default_sublabel_macro(action_bind_sublabel_navigation_wraparound, MENU_ENUM_SUBLABEL_NAVIGATION_WRAPAROUND)
default_sublabel_macro(action_bind_sublabel_audio_resampler_quality, MENU_ENUM_SUBLABEL_AUDIO_RESAMPLER_QUALITY)
@ -1290,6 +1291,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_TIMEDATE_ENABLE:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_timedate_enable);
break;
case MENU_ENUM_LABEL_TIMEDATE_STYLE:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_timedate_style);
break;
case MENU_ENUM_LABEL_THUMBNAILS:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_thumbnails);
break;

View File

@ -596,7 +596,7 @@ static void rgui_render(void *data, bool is_idle)
datetime.s = timedate;
datetime.len = sizeof(timedate);
datetime.time_mode = 3;
datetime.time_mode = 4;
menu_display_timedate(&datetime);

View File

@ -3636,7 +3636,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
datetime.s = timedate;
datetime.len = sizeof(timedate);
datetime.time_mode = 4;
datetime.time_mode = settings->uints.menu_timedate_style;
menu_display_timedate(&datetime);

View File

@ -5779,6 +5779,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_TIMEDATE_ENABLE,
PARSE_ONLY_BOOL, false);
menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_TIMEDATE_STYLE,
PARSE_ONLY_UINT, false);
menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_BATTERY_LEVEL_ENABLE,
PARSE_ONLY_BOOL, false);

View File

@ -17,13 +17,14 @@
#include <string.h>
#include <time.h>
#include <locale.h>
#include <compat/strl.h>
#include <retro_miscellaneous.h>
#include <formats/image.h>
#include <file/file_path.h>
#include <streams/file_stream.h>
#include <string/stdstring.h>
#include <encodings/utf.h>
#ifdef WIIU
#include <wiiu/os/energy.h>
@ -346,28 +347,58 @@ void menu_display_timedate(menu_display_ctx_datetime_t *datetime)
time(&time_);
setlocale(LC_TIME, "");
switch (datetime->time_mode)
{
case 0: /* Date and time */
strftime(datetime->s, datetime->len,
"%Y-%m-%d %H:%M:%S", localtime(&time_));
break;
case 1: /* Date */
case 1: /* YY-MM-DD HH:MM */
strftime(datetime->s, datetime->len,
"%Y-%m-%d", localtime(&time_));
"%Y-%m-%d %H:%M", localtime(&time_));
break;
case 2: /* Time */
case 2: /* MM-DD-YYYY HH:MM */
strftime(datetime->s, datetime->len,
"%m-%d-%Y %H:%M", localtime(&time_));
break;
case 3: /* Time */
strftime(datetime->s, datetime->len,
"%H:%M:%S", localtime(&time_));
break;
case 3: /* Time (hours-minutes) */
case 4: /* Time (hours-minutes) */
strftime(datetime->s, datetime->len,
"%H:%M", localtime(&time_));
break;
case 4: /* Date and time, without year and seconds */
case 5: /* Date and time, without year and seconds */
strftime(datetime->s, datetime->len,
"%d/%m %H:%M", localtime(&time_));
break;
case 6:
strftime(datetime->s, datetime->len,
"%m/%d %H:%M", localtime(&time_));
break;
case 7: /* Time (hours-minutes), in 12 hour AM-PM designation */
#if defined(__linux__) && !defined(ANDROID)
strftime(datetime->s, datetime->len,
"%r", localtime(&time_));
#else
{
char *local;
strftime(datetime->s, datetime->len,
"%I:%M:%S %p", localtime(&time_));
local = local_to_utf8_string_alloc(datetime->s);
if (local)
{
strlcpy(datetime->s, local, datetime->len);
free(local);
}
}
#endif
}
}

View File

@ -505,6 +505,56 @@ static void setting_get_string_representation_uint_menu_left_thumbnails(
}
}
static void setting_get_string_representation_uint_menu_timedate_style(
rarch_setting_t *setting,
char *s, size_t len)
{
if (!setting)
return;
switch (*setting->value.target.unsigned_integer)
{
case 0:
strlcpy(s, msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS), len);
break;
case 1:
strlcpy(s, msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM), len);
break;
case 2:
strlcpy(s,
msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY), len);
break;
case 3:
strlcpy(s,
msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS), len);
break;
case 4:
strlcpy(s,
msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM), len);
break;
case 5:
strlcpy(s,
msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DM_HM), len);
break;
case 6:
strlcpy(s,
msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM), len);
break;
case 7:
strlcpy(s,
msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_AM_PM), len);
break;
}
}
static void setting_get_string_representation_uint_xmb_icon_theme(
rarch_setting_t *setting,
char *s, size_t len)
@ -8317,6 +8367,21 @@ static bool setting_append_list(
general_read_handler,
SD_FLAG_ADVANCED);
CONFIG_UINT(list, list_info,
&settings->uints.menu_timedate_style,
MENU_ENUM_LABEL_TIMEDATE_STYLE,
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE,
menu_timedate_style,
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler);
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
(*list)[list_info->index - 1].get_string_representation =
&setting_get_string_representation_uint_menu_timedate_style;
menu_settings_list_current_add_range(list, list_info, 0, 7, 1, true, true);
CONFIG_BOOL(
list, list_info,
&settings->bools.menu_battery_level_enable,

View File

@ -833,6 +833,7 @@ enum msg_hash_enums
MENU_LABEL(LEFT_THUMBNAILS),
MENU_LABEL(XMB_VERTICAL_THUMBNAILS),
MENU_LABEL(TIMEDATE_ENABLE),
MENU_LABEL(TIMEDATE_STYLE),
MENU_LABEL(BATTERY_LEVEL_ENABLE),
MENU_LABEL(MATERIALUI_MENU_COLOR_THEME),
MENU_LABEL(QUICK_MENU_OVERRIDE_OPTIONS),
@ -2129,6 +2130,14 @@ enum msg_hash_enums
MSG_CHEAT_SEARCH_ADD_MATCH_FAIL,
MSG_CHEAT_SEARCH_DELETE_MATCH_SUCCESS,
MSG_CHEEVOS_HARDCORE_MODE_DISABLED,
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS,
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM,
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY,
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS,
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM,
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DM_HM,
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM,
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_AM_PM,
#ifdef HAVE_LAKKA_SWITCH
MENU_ENUM_LABEL_SWITCH_GPU_PROFILE,