mirror of
https://github.com/libretro/RetroArch.git
synced 2024-12-03 13:51:02 +00:00
Add optional playlist sublabels (associated core + play time, where available)
This commit is contained in:
parent
44431ad227
commit
0b04312412
@ -1961,6 +1961,8 @@ bool command_event(enum event_command cmd, void *data)
|
||||
|
||||
content_get_status(&contentless, &is_inited);
|
||||
|
||||
if (!contentless)
|
||||
rarch_ctl(RARCH_CTL_CONTENT_RUNTIME_LOG_DEINIT, NULL);
|
||||
command_event(CMD_EVENT_AUTOSAVE_STATE, NULL);
|
||||
command_event(CMD_EVENT_DISABLE_OVERRIDES, NULL);
|
||||
command_event(CMD_EVENT_RESTORE_DEFAULT_SHADER_PRESET, NULL);
|
||||
|
@ -714,6 +714,8 @@ static const bool playlist_use_old_format = false;
|
||||
* (RGUI only) */
|
||||
static const bool playlist_show_core_name = true;
|
||||
|
||||
static const bool playlist_show_sublabels = false;
|
||||
|
||||
/* Show Menu start-up screen on boot. */
|
||||
static const bool default_menu_show_start_screen = true;
|
||||
|
||||
|
@ -1575,6 +1575,7 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings,
|
||||
|
||||
SETTING_BOOL("playlist_use_old_format", &settings->bools.playlist_use_old_format, true, playlist_use_old_format, false);
|
||||
SETTING_BOOL("content_runtime_log", &settings->bools.content_runtime_log, true, content_runtime_log, false);
|
||||
SETTING_BOOL("playlist_show_sublabels", &settings->bools.playlist_show_sublabels, true, playlist_show_sublabels, false);
|
||||
|
||||
SETTING_BOOL("playlist_sort_alphabetical", &settings->bools.playlist_sort_alphabetical, true, playlist_sort_alphabetical, false);
|
||||
|
||||
|
@ -311,6 +311,7 @@ typedef struct settings
|
||||
|
||||
bool playlist_show_core_name;
|
||||
bool playlist_sort_alphabetical;
|
||||
bool playlist_show_sublabels;
|
||||
} bools;
|
||||
|
||||
struct
|
||||
|
@ -1789,3 +1789,5 @@ MSG_HASH(MENU_ENUM_LABEL_PLAYLIST_SHOW_CORE_NAME,
|
||||
"playlist_show_core_name")
|
||||
MSG_HASH(MENU_ENUM_LABEL_PLAYLIST_SORT_ALPHABETICAL,
|
||||
"playlist_sort_alphabetical")
|
||||
MSG_HASH(MENU_ENUM_LABEL_PLAYLIST_SHOW_SUBLABELS,
|
||||
"playlist_show_sublabels")
|
||||
|
@ -8298,3 +8298,19 @@ MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_CONTENT_RUNTIME_LOG,
|
||||
"Keeps track of how long your content has been running over time."
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SHOW_SUBLABELS,
|
||||
"Show playlist sublabels"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_PLAYLIST_SHOW_SUBLABELS,
|
||||
"Shows additional information for each playlist entry, such as current core association and play time (if available). Has a variable performance impact."
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_CORE,
|
||||
"Core:"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_RUNTIME,
|
||||
"Play Time:"
|
||||
)
|
||||
|
@ -47,6 +47,8 @@
|
||||
#include "../input/input_driver.h"
|
||||
#include "../tasks/tasks_internal.h"
|
||||
|
||||
#include "../../defaults.h"
|
||||
|
||||
#define default_sublabel_macro(func_name, lbl) \
|
||||
static int (func_name)(file_list_t *list, unsigned type, unsigned i, const char *label, const char *path, char *s, size_t len) \
|
||||
{ \
|
||||
@ -509,6 +511,7 @@ default_sublabel_macro(action_bind_sublabel_switch_gpu_profile, MENU
|
||||
default_sublabel_macro(action_bind_sublabel_switch_backlight_control, MENU_ENUM_SUBLABEL_SWITCH_BACKLIGHT_CONTROL)
|
||||
#endif
|
||||
|
||||
default_sublabel_macro(action_bind_sublabel_playlist_show_sublabels, MENU_ENUM_SUBLABEL_PLAYLIST_SHOW_SUBLABELS)
|
||||
default_sublabel_macro(action_bind_sublabel_menu_rgui_border_filler_enable, MENU_ENUM_SUBLABEL_MENU_RGUI_BORDER_FILLER_ENABLE)
|
||||
default_sublabel_macro(action_bind_sublabel_menu_rgui_border_filler_thickness_enable, MENU_ENUM_SUBLABEL_MENU_RGUI_BORDER_FILLER_THICKNESS_ENABLE)
|
||||
default_sublabel_macro(action_bind_sublabel_menu_rgui_background_filler_thickness_enable, MENU_ENUM_SUBLABEL_MENU_RGUI_BACKGROUND_FILLER_THICKNESS_ENABLE)
|
||||
@ -809,6 +812,104 @@ static int action_bind_sublabel_netplay_room(
|
||||
}
|
||||
#endif
|
||||
|
||||
static int action_bind_sublabel_playlist_entry(
|
||||
file_list_t *list,
|
||||
unsigned type, unsigned i,
|
||||
const char *label, const char *path,
|
||||
char *s, size_t len)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
playlist_t *playlist = NULL;
|
||||
const char *playlist_path = NULL;
|
||||
const char *core_path = NULL;
|
||||
const char *core_name = NULL;
|
||||
|
||||
if (!settings->bools.playlist_show_sublabels)
|
||||
return 0;
|
||||
|
||||
/* Get current playlist */
|
||||
playlist = playlist_get_cached();
|
||||
if (!playlist)
|
||||
return 0;
|
||||
if (i >= playlist_get_size(playlist))
|
||||
return 0;
|
||||
|
||||
/* Read playlist entry */
|
||||
playlist_get_index(playlist, i, &playlist_path, NULL, &core_path, &core_name, NULL, NULL);
|
||||
|
||||
/* Only add sublabel if a core is currently assigned */
|
||||
if (string_is_empty(core_name) || string_is_equal(core_name, file_path_str(FILE_PATH_DETECT)))
|
||||
return 0;
|
||||
|
||||
/* Add core name */
|
||||
snprintf(s, len, "%s %s",
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_CORE),
|
||||
core_name);
|
||||
|
||||
/* Get runtime *if* 'content_runtime_log' is enabled
|
||||
* NB: Runtime is currently stored in an independent
|
||||
* 'content_runtime.lpl' file, similar to the content
|
||||
* history. It therefore only really makes sense to
|
||||
* check runtime when viewing the content history
|
||||
* playlist. If runtime were added to all playlists
|
||||
* (would be nice), we could do this trivially for all
|
||||
* content. */
|
||||
if (!settings->bools.content_runtime_log)
|
||||
return 0;
|
||||
|
||||
if (!string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_LOAD_CONTENT_HISTORY))
|
||||
&& !string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_HISTORY_TAB)))
|
||||
return 0;
|
||||
|
||||
/* Check that 'content_runtime.lpl' exists, and playlist has
|
||||
* non-null path/core_path values... */
|
||||
if (g_defaults.content_runtime && !string_is_empty(playlist_path) && !string_is_empty(core_path))
|
||||
{
|
||||
unsigned runtime_hours;
|
||||
unsigned runtime_minutes;
|
||||
unsigned runtime_seconds;
|
||||
unsigned j;
|
||||
|
||||
/* This is lame, but unless runtime is added to all playlists
|
||||
* we can't really do it any other way...
|
||||
* Search 'content_runtime.lpl' until we find the current
|
||||
* content+core combo. */
|
||||
for (j = 0; j < playlist_get_size(g_defaults.content_runtime); j++)
|
||||
{
|
||||
const char *runtime_path = NULL;
|
||||
const char *runtime_core_path = NULL;
|
||||
|
||||
playlist_get_runtime_index(g_defaults.content_runtime, j, &runtime_path, &runtime_core_path,
|
||||
&runtime_hours, &runtime_minutes, &runtime_seconds);
|
||||
|
||||
if (string_is_equal(playlist_path, runtime_path) && string_is_equal(core_path, runtime_core_path))
|
||||
{
|
||||
int n = 0;
|
||||
char tmp[64];
|
||||
tmp[0] = '\0';
|
||||
|
||||
n = snprintf(tmp, sizeof(tmp), "\n%s %02u:%02u:%02u",
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_RUNTIME),
|
||||
runtime_hours, runtime_minutes, runtime_seconds);
|
||||
|
||||
/* Stupid nonsense... GCC will generate warnings if we
|
||||
* don't do something here... */
|
||||
if ((n < 0) || (n >= 64))
|
||||
{
|
||||
n = 0;
|
||||
}
|
||||
|
||||
if (!string_is_empty(tmp))
|
||||
strlcat(s, tmp, len);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int action_bind_sublabel_generic(
|
||||
file_list_t *list,
|
||||
unsigned type, unsigned i,
|
||||
@ -2236,6 +2337,12 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
|
||||
case MENU_ENUM_LABEL_DISCORD_ALLOW:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_discord_allow);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_PLAYLIST_ENTRY:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_playlist_entry);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_PLAYLIST_SHOW_SUBLABELS:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_playlist_show_sublabels);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_MENU_RGUI_BORDER_FILLER_ENABLE:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_rgui_border_filler_enable);
|
||||
break;
|
||||
|
@ -5309,6 +5309,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist
|
||||
ret = menu_displaylist_parse_settings_enum(menu, info,
|
||||
MENU_ENUM_LABEL_PLAYLIST_USE_OLD_FORMAT,
|
||||
PARSE_ONLY_BOOL, false);
|
||||
ret = menu_displaylist_parse_settings_enum(menu, info,
|
||||
MENU_ENUM_LABEL_PLAYLIST_SHOW_SUBLABELS,
|
||||
PARSE_ONLY_BOOL, false);
|
||||
if (string_is_equal(settings->arrays.menu_driver, "rgui"))
|
||||
{
|
||||
ret = menu_displaylist_parse_settings_enum(menu, info,
|
||||
|
@ -9836,6 +9836,22 @@ static bool setting_append_list(
|
||||
SD_FLAG_NONE
|
||||
);
|
||||
|
||||
CONFIG_BOOL(
|
||||
list, list_info,
|
||||
&settings->bools.playlist_show_sublabels,
|
||||
MENU_ENUM_LABEL_PLAYLIST_SHOW_SUBLABELS,
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SHOW_SUBLABELS,
|
||||
playlist_show_sublabels,
|
||||
MENU_ENUM_LABEL_VALUE_OFF,
|
||||
MENU_ENUM_LABEL_VALUE_ON,
|
||||
&group_info,
|
||||
&subgroup_info,
|
||||
parent_group,
|
||||
general_write_handler,
|
||||
general_read_handler,
|
||||
SD_FLAG_NONE
|
||||
);
|
||||
|
||||
if (string_is_equal(settings->arrays.menu_driver, "rgui"))
|
||||
{
|
||||
CONFIG_BOOL(
|
||||
|
@ -2275,6 +2275,10 @@ enum msg_hash_enums
|
||||
|
||||
MENU_LABEL(PLAYLIST_SHOW_CORE_NAME),
|
||||
MENU_LABEL(PLAYLIST_SORT_ALPHABETICAL),
|
||||
MENU_LABEL(PLAYLIST_SHOW_SUBLABELS),
|
||||
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_CORE,
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_RUNTIME,
|
||||
|
||||
MSG_LAST
|
||||
};
|
||||
|
@ -1862,9 +1862,9 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
|
||||
const char *path = path_get(RARCH_PATH_CONTENT);
|
||||
const char *core_path = path_get(RARCH_PATH_CORE);
|
||||
|
||||
if (!string_is_empty(path) && !string_is_empty(core_path))
|
||||
if (!string_is_empty(path) && !string_is_empty(core_path) && !string_is_equal(core_path, "builtin"))
|
||||
{
|
||||
playlist_push_runtime(g_defaults.content_runtime, path_get(RARCH_PATH_CONTENT), path_get(RARCH_PATH_CORE), 0, 0, 0);
|
||||
playlist_push_runtime(g_defaults.content_runtime, path, core_path, 0, 0, 0);
|
||||
|
||||
/* if entry already existed, the runtime won't be updated, so manually update it again */
|
||||
if (playlist_get_size(g_defaults.content_runtime) > 0)
|
||||
@ -1893,7 +1893,7 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
|
||||
|
||||
runtime_hours += hours;
|
||||
|
||||
playlist_update_runtime(g_defaults.content_runtime, 0, path_get(RARCH_PATH_CONTENT), path_get(RARCH_PATH_CORE), runtime_hours, runtime_minutes, runtime_seconds);
|
||||
playlist_update_runtime(g_defaults.content_runtime, 0, path, core_path, runtime_hours, runtime_minutes, runtime_seconds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user