mirror of
https://github.com/libretro/RetroArch.git
synced 2025-01-21 00:05:30 +00:00
Add 'Ago' to playlist last played styles (#14086)
This commit is contained in:
parent
28a41ad1b1
commit
860155969e
@ -5940,6 +5940,66 @@ MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED,
|
||||
"Last Played:"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_SECONDS_SINGLE,
|
||||
"second"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_SECONDS_PLURAL,
|
||||
"seconds"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_MINUTES_SINGLE,
|
||||
"minute"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_MINUTES_PLURAL,
|
||||
"minutes"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_HOURS_SINGLE,
|
||||
"hour"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_HOURS_PLURAL,
|
||||
"hours"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_DAYS_SINGLE,
|
||||
"day"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_DAYS_PLURAL,
|
||||
"days"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_WEEKS_SINGLE,
|
||||
"week"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_WEEKS_PLURAL,
|
||||
"weeks"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_MONTHS_SINGLE,
|
||||
"month"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_MONTHS_PLURAL,
|
||||
"months"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_YEARS_SINGLE,
|
||||
"year"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_YEARS_PLURAL,
|
||||
"years"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_AGO,
|
||||
"ago"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SHOW_ENTRY_IDX,
|
||||
"Show Playlist Entry Index"
|
||||
@ -9060,6 +9120,10 @@ MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_TIMEDATE_HM_AMPM,
|
||||
"HH:MM (AM/PM)"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_TIMEDATE_AGO,
|
||||
"Ago"
|
||||
)
|
||||
|
||||
/* RGUI: Settings > User Interface > Appearance */
|
||||
|
||||
|
@ -5235,6 +5235,12 @@ static void setting_get_string_representation_uint_playlist_sublabel_last_played
|
||||
MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM_AMPM),
|
||||
len);
|
||||
break;
|
||||
case PLAYLIST_LAST_PLAYED_STYLE_AGO:
|
||||
strlcpy(s,
|
||||
msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_TIMEDATE_AGO),
|
||||
len);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Change date separator, if required */
|
||||
|
17
msg_hash.h
17
msg_hash.h
@ -3350,6 +3350,7 @@ enum msg_hash_enums
|
||||
MENU_ENUM_LABEL_VALUE_TIMEDATE_DDMM_HM_AMPM,
|
||||
MENU_ENUM_LABEL_VALUE_TIMEDATE_HMS_AMPM,
|
||||
MENU_ENUM_LABEL_VALUE_TIMEDATE_HM_AMPM,
|
||||
MENU_ENUM_LABEL_VALUE_TIMEDATE_AGO,
|
||||
|
||||
MENU_LABEL(SWITCH_GPU_PROFILE),
|
||||
MENU_LABEL(SWITCH_CPU_PROFILE),
|
||||
@ -3401,6 +3402,22 @@ enum msg_hash_enums
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_RUNTIME_PER_CORE,
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_RUNTIME_AGGREGATE,
|
||||
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_SECONDS_SINGLE,
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_SECONDS_PLURAL,
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_MINUTES_SINGLE,
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_MINUTES_PLURAL,
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_HOURS_SINGLE,
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_HOURS_PLURAL,
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_DAYS_SINGLE,
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_DAYS_PLURAL,
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_WEEKS_SINGLE,
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_WEEKS_PLURAL,
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_MONTHS_SINGLE,
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_MONTHS_PLURAL,
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_YEARS_SINGLE,
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_YEARS_PLURAL,
|
||||
MENU_ENUM_LABEL_VALUE_TIME_UNIT_AGO,
|
||||
|
||||
MENU_LABEL(HELP_SEND_DEBUG_INFO),
|
||||
MENU_ENUM_LABEL_VALUE_HELP_SEND_DEBUG_INFO_DESC,
|
||||
|
||||
|
@ -625,6 +625,27 @@ void runtime_log_get_last_played_time(runtime_log_t *runtime_log,
|
||||
mktime(time_info);
|
||||
}
|
||||
|
||||
void runtime_log_get_current_time(runtime_log_t *runtime_log,
|
||||
struct tm *time_info)
|
||||
{
|
||||
time_t time_;
|
||||
struct tm tm_;
|
||||
|
||||
/* Get current time */
|
||||
time(&time_);
|
||||
rtime_localtime(&time_, &tm_);
|
||||
|
||||
if (!time_ || !time_info)
|
||||
return;
|
||||
|
||||
/* Set tm values */
|
||||
time_info = &tm_;
|
||||
|
||||
/* Perform any required range adjustment + populate
|
||||
* missing entries */
|
||||
mktime(time_info);
|
||||
}
|
||||
|
||||
static void last_played_strftime(runtime_log_t *runtime_log,
|
||||
char *str, size_t len, const char *format)
|
||||
{
|
||||
@ -658,6 +679,61 @@ static void last_played_strftime(runtime_log_t *runtime_log,
|
||||
#endif
|
||||
}
|
||||
|
||||
static void last_played_human(runtime_log_t *runtime_log,
|
||||
char *str, size_t len)
|
||||
{
|
||||
struct tm time_info;
|
||||
struct tm time_info_current;
|
||||
time_t last_played;
|
||||
time_t current;
|
||||
time_t delta;
|
||||
unsigned i;
|
||||
char tmp[32];
|
||||
|
||||
unsigned units[7][2] =
|
||||
{
|
||||
{MENU_ENUM_LABEL_VALUE_TIME_UNIT_SECONDS_SINGLE, MENU_ENUM_LABEL_VALUE_TIME_UNIT_SECONDS_PLURAL},
|
||||
{MENU_ENUM_LABEL_VALUE_TIME_UNIT_MINUTES_SINGLE, MENU_ENUM_LABEL_VALUE_TIME_UNIT_MINUTES_PLURAL},
|
||||
{MENU_ENUM_LABEL_VALUE_TIME_UNIT_HOURS_SINGLE, MENU_ENUM_LABEL_VALUE_TIME_UNIT_HOURS_PLURAL},
|
||||
{MENU_ENUM_LABEL_VALUE_TIME_UNIT_DAYS_SINGLE, MENU_ENUM_LABEL_VALUE_TIME_UNIT_DAYS_PLURAL},
|
||||
{MENU_ENUM_LABEL_VALUE_TIME_UNIT_WEEKS_SINGLE, MENU_ENUM_LABEL_VALUE_TIME_UNIT_WEEKS_PLURAL},
|
||||
{MENU_ENUM_LABEL_VALUE_TIME_UNIT_MONTHS_SINGLE, MENU_ENUM_LABEL_VALUE_TIME_UNIT_MONTHS_PLURAL},
|
||||
{MENU_ENUM_LABEL_VALUE_TIME_UNIT_YEARS_SINGLE, MENU_ENUM_LABEL_VALUE_TIME_UNIT_YEARS_PLURAL},
|
||||
};
|
||||
|
||||
float periods[6] = {60.0f, 60.0f, 24.0f, 7.0f, 4.35f, 12.0f};
|
||||
|
||||
if (!runtime_log)
|
||||
{
|
||||
strlcat(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_INLINE_CORE_DISPLAY_NEVER), len);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get times */
|
||||
runtime_log_get_last_played_time(runtime_log, &time_info);
|
||||
runtime_log_get_current_time(runtime_log, &time_info_current);
|
||||
|
||||
last_played = mktime(&time_info);
|
||||
current = mktime(&time_info_current);
|
||||
delta = current - last_played;
|
||||
|
||||
if (delta <= 0)
|
||||
{
|
||||
strlcat(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_INLINE_CORE_DISPLAY_NEVER), len);
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; delta >= periods[i] && i < sizeof(periods) - 1; i++)
|
||||
delta /= periods[i];
|
||||
|
||||
/* Generate string */
|
||||
snprintf(tmp, sizeof(tmp), "%u %s",
|
||||
(int)delta, msg_hash_to_str((delta == 1) ? units[i][0] : units[i][1]));
|
||||
strlcat(str, tmp, len);
|
||||
strlcat(str, " ", len);
|
||||
strlcat(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_TIME_UNIT_AGO), len);
|
||||
}
|
||||
|
||||
/* Gets last played entry value as a pre-formatted string */
|
||||
void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||
char *str, size_t len,
|
||||
@ -1088,6 +1164,13 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
|
||||
runtime_log->last_played.day, runtime_log->last_played.month);
|
||||
return;
|
||||
case PLAYLIST_LAST_PLAYED_STYLE_AGO:
|
||||
last_played_human(runtime_log, tmp, sizeof(tmp));
|
||||
snprintf(str, len, "%s %s",
|
||||
msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
|
||||
tmp);
|
||||
return;
|
||||
case PLAYLIST_LAST_PLAYED_STYLE_YMD_HMS:
|
||||
default:
|
||||
switch (date_separator)
|
||||
|
@ -59,6 +59,7 @@ enum playlist_sublabel_last_played_style_type
|
||||
PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HMS_AMPM,
|
||||
PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HM_AMPM,
|
||||
PLAYLIST_LAST_PLAYED_STYLE_DDMM_HM_AMPM,
|
||||
PLAYLIST_LAST_PLAYED_STYLE_AGO,
|
||||
PLAYLIST_LAST_PLAYED_STYLE_LAST
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user