Add To Playlist from quickmenu can't rely on the current playlist (#17556)
Some checks are pending
CI 3DS / build (push) Waiting to run
CI Android / build (push) Waiting to run
CI DOS/DJGPP / build (push) Waiting to run
CI Emscripten / build (push) Waiting to run
CI GameCube / build (push) Waiting to run
CI Linux (i686) / build (push) Waiting to run
CI Windows (MSVC) / msvc (Debug, x64, 2019) (push) Waiting to run
CI Windows (MSVC) / msvc (Debug, x64, 2022) (push) Waiting to run
CI Windows (MSVC) / msvc (Release, x64, 2019) (push) Waiting to run
CI Windows (MSVC) / msvc (Release, x64, 2022) (push) Waiting to run
CI Windows (MSVC) / msvc (Release, x64, UWP) (push) Waiting to run
CI Windows (MSVC) / msvc (ReleaseAngle, x64, UWP) (push) Waiting to run
CI Windows (MSYS2) / msys2-build-test (CLANG64) (push) Waiting to run
CI Windows (MSYS2) / msys2-build-test (MINGW64) (push) Waiting to run
CI Windows (MSYS2) / msys2-build-test (UCRT64) (push) Waiting to run
CI macOS / build (push) Waiting to run
CI Miyoo ARM32 / build (push) Waiting to run
CI PS2 / build (push) Waiting to run
CI PS4/ORBIS / build (push) Waiting to run
CI PSP / build (push) Waiting to run
CI PSVita / build (push) Waiting to run
CI RS90 Odbeta MIPS32 / build (push) Waiting to run
CI RetroFW MIPS32 / build (push) Waiting to run
CI Switch/libnx / build (push) Waiting to run
CI Wii / build (push) Waiting to run
CI WiiU / build (push) Waiting to run
CI Windows i686 (MXE) / build (push) Waiting to run
CI Windows x64 (MXE) / build (push) Waiting to run
RetroArch CI / linux-c89 (push) Waiting to run
CI webOS / build (push) Waiting to run

This commit is contained in:
Eric Warmenhoven 2025-02-11 15:01:42 -05:00 committed by GitHub
parent 5372f3fe84
commit 422a4310f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 211 additions and 24 deletions

View File

@ -3506,6 +3506,22 @@ MSG_HASH(
MENU_ENUM_LABEL_CREATE_NEW_PLAYLIST,
"playlist_create"
)
MSG_HASH(
MENU_ENUM_LABEL_ADD_TO_PLAYLIST_QUICKMENU,
"playlist_add_quickmenu"
)
MSG_HASH(
MENU_ENUM_LABEL_DEFERRED_ADD_TO_PLAYLIST_QUICKMENU,
"deferred_add_to_playlist_quickmenu"
)
MSG_HASH(
MENU_ENUM_LABEL_ADD_ENTRY_TO_PLAYLIST_QUICKMENU,
"add_entry_to_playlist_quickmenu"
)
MSG_HASH(
MENU_ENUM_LABEL_CREATE_NEW_PLAYLIST_QUICKMENU,
"playlist_create_quickmenu"
)
MSG_HASH(
MENU_ENUM_LABEL_SET_CORE_ASSOCIATION,
"set_core_association"

View File

@ -692,6 +692,7 @@ GENERIC_DEFERRED_PUSH_GENERAL(deferred_push_dropdown_box_list_input_select_physi
GENERIC_DEFERRED_PUSH_GENERAL(deferred_push_dropdown_box_list_netplay_mitm_server, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_NETPLAY_MITM_SERVER)
#endif
GENERIC_DEFERRED_PUSH(deferred_push_add_to_playlist_list, DISPLAYLIST_ADD_TO_PLAYLIST_LIST)
GENERIC_DEFERRED_PUSH(deferred_push_add_to_playlist_quickmenu, DISPLAYLIST_ADD_TO_PLAYLIST_QUICKMENU)
static int menu_cbs_init_bind_deferred_push_compare_label(
menu_file_list_cbs_t *cbs,
@ -955,6 +956,7 @@ static int menu_cbs_init_bind_deferred_push_compare_label(
{MENU_ENUM_LABEL_DEFERRED_LAKKA_LIST, deferred_push_lakka_list},
#endif
{MENU_ENUM_LABEL_DEFERRED_ADD_TO_PLAYLIST_LIST, deferred_push_add_to_playlist_list},
{MENU_ENUM_LABEL_DEFERRED_ADD_TO_PLAYLIST_QUICKMENU, deferred_push_add_to_playlist_quickmenu},
#ifdef HAVE_GAME_AI
{MENU_ENUM_LABEL_CORE_GAME_AI_OPTIONS, deferred_push_core_game_ai_options},
@ -1423,6 +1425,9 @@ static int menu_cbs_init_bind_deferred_push_compare_label(
case MENU_ENUM_LABEL_DEFERRED_ADD_TO_PLAYLIST_LIST:
BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_add_to_playlist_list);
break;
case MENU_ENUM_LABEL_DEFERRED_ADD_TO_PLAYLIST_QUICKMENU:
BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_add_to_playlist_quickmenu);
break;
#ifdef HAVE_GAME_AI
case MENU_ENUM_LABEL_CORE_GAME_AI_OPTIONS:
BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_core_game_ai_options);

View File

@ -527,6 +527,8 @@ static enum msg_hash_enums action_ok_dl_to_enum(unsigned lbl)
return MENU_ENUM_LABEL_DEFERRED_REMAP_FILE_MANAGER_LIST;
case ACTION_OK_DL_ADD_TO_PLAYLIST:
return MENU_ENUM_LABEL_DEFERRED_ADD_TO_PLAYLIST_LIST;
case ACTION_OK_DL_ADD_TO_PLAYLIST_QUICKMENU:
return MENU_ENUM_LABEL_DEFERRED_ADD_TO_PLAYLIST_QUICKMENU;
default:
break;
}
@ -1850,6 +1852,7 @@ int generic_action_ok_displaylist_push(
case ACTION_OK_DL_CORE_OPTION_OVERRIDE_LIST:
case ACTION_OK_DL_REMAP_FILE_MANAGER_LIST:
case ACTION_OK_DL_ADD_TO_PLAYLIST:
case ACTION_OK_DL_ADD_TO_PLAYLIST_QUICKMENU:
ACTION_OK_DL_LBL(action_ok_dl_to_enum(action_type), DISPLAYLIST_GENERIC);
break;
case ACTION_OK_DL_CDROM_INFO_DETAIL_LIST:
@ -5869,6 +5872,132 @@ static int action_ok_add_to_favorites(const char *path,
return ret;
}
/* This function is called when selecting 'add to playlist'
* while viewing the quick menu (i.e. content is running) */
static int action_ok_add_entry_to_playlist_quickmenu(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
const char *content_path = path_get(RARCH_PATH_CONTENT);
int ret = 0;
/* Error checking
* > If content path is empty, cannot do anything... */
if (!string_is_empty(content_path))
{
union string_list_elem_attr attr;
char core_name[NAME_MAX_LENGTH];
char content_label[NAME_MAX_LENGTH];
char core_path[PATH_MAX_LENGTH];
runloop_state_t *runloop_st = runloop_state_get_ptr();
struct retro_system_info *sysinfo = &runloop_st->system.info;
struct string_list *str_list = NULL;
const char *crc32 = NULL;
const char *db_name = NULL;
core_path[0] = '\0';
core_name[0] = '\0';
/* Create string list container for playlist parameters */
attr.i = 0;
if (!(str_list = string_list_new()))
return 0;
/* Determine playlist parameters */
/* > content_label */
if (!string_is_empty(runloop_st->name.label))
strlcpy(content_label, runloop_st->name.label,
sizeof(content_label));
else
content_label[0] = '\0';
/* Label is empty - use file name instead */
if (string_is_empty(content_label))
fill_pathname(content_label,
path_basename(content_path), "",
sizeof(content_label));
/* > core_path + core_name */
if (sysinfo)
{
if (!string_is_empty(path_get(RARCH_PATH_CORE)))
{
core_info_t *core_info = NULL;
/* >> core_path */
strlcpy(core_path, path_get(RARCH_PATH_CORE),
sizeof(core_path));
/* >> core_name
* (always use display name, if available) */
if (core_info_find(core_path, &core_info))
if (!string_is_empty(core_info->display_name))
strlcpy(core_name, core_info->display_name,
sizeof(core_name));
}
/* >> core_name (continued) */
if ( string_is_empty(core_name)
&& !string_is_empty(sysinfo->library_name))
strlcpy(core_name, sysinfo->library_name, sizeof(core_name));
}
if (string_is_empty(core_path) || string_is_empty(core_name))
{
strlcpy(core_path, FILE_PATH_DETECT, sizeof(core_path));
strlcpy(core_name, FILE_PATH_DETECT, sizeof(core_name));
}
/* > crc32 + db_name */
{
menu_handle_t *menu = menu_state_get_ptr()->driver_data;
if (menu)
{
playlist_t *playlist_curr = playlist_get_cached();
if (playlist_index_is_valid(playlist_curr,
menu->rpl_entry_selection_ptr,
content_path, core_path))
{
playlist_get_crc32(playlist_curr,
menu->rpl_entry_selection_ptr, &crc32);
playlist_get_db_name(playlist_curr,
menu->rpl_entry_selection_ptr, &db_name);
}
}
}
/* Copy playlist parameters into string list
* [0]: content_path
* [1]: content_label
* [2]: core_path
* [3]: core_name
* [4]: crc32
* [5]: db_name
* [6]: playlist*/
string_list_append(str_list, content_path, attr);
string_list_append(str_list, content_label, attr);
string_list_append(str_list, core_path, attr);
string_list_append(str_list, core_name, attr);
string_list_append(str_list, !string_is_empty(crc32)
? crc32 : "", attr);
string_list_append(str_list, !string_is_empty(db_name)
? db_name : "", attr);
string_list_append(str_list, label, attr);
/* Trigger 'ADD_TO_PLAYLIST' event */
if (!command_event(CMD_EVENT_ADD_TO_PLAYLIST, (void*)str_list))
ret = -1;
/* Clean up */
string_list_free(str_list);
str_list = NULL;
}
return ret;
}
/* This function is called when selecting 'add to playlist'
* while viewing a playlist entry */
static int action_ok_add_entry_to_playlist(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
@ -6028,6 +6157,23 @@ static void action_input_add_entry_to_new_playlist(void *userdata, const char *l
action_ok_add_entry_to_playlist(NULL, path, 0, 0, 0);
}
static void action_input_add_entry_to_new_playlist_quickmenu(void *userdata, const char *line)
{
char path[PATH_MAX_LENGTH];
settings_t *settings = config_get_ptr();
size_t _len = 0;
menu_input_dialog_end();
if(!line)
return;
/* Create path for new file */
_len = fill_pathname_join_special(path, settings->paths.directory_playlist, line, sizeof(path));
strlcpy(path + _len, ".lpl", sizeof(path) - _len);
action_ok_add_entry_to_playlist_quickmenu(NULL, path, 0, 0, 0);
}
static int action_ok_add_entry_to_new_playlist(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
@ -6036,7 +6182,9 @@ static int action_ok_add_entry_to_new_playlist(const char *path,
line.label_setting = NULL;
line.type = 0;
line.idx = 0;
line.cb = action_input_add_entry_to_new_playlist;
line.cb = (string_is_equal(label, (char*)msg_hash_to_str(MENU_ENUM_LABEL_CREATE_NEW_PLAYLIST)) ?
action_input_add_entry_to_new_playlist :
action_input_add_entry_to_new_playlist_quickmenu);
menu_input_dialog_start(&line);
return 0;
@ -6446,6 +6594,7 @@ STATIC_DEFAULT_ACTION_OK_FUNC(action_ok_push_remap_file_manager_list, ACTION_OK_
STATIC_DEFAULT_ACTION_OK_FUNC(action_ok_push_savestate_list, ACTION_OK_DL_SAVESTATE_LIST)
STATIC_DEFAULT_ACTION_OK_FUNC(action_ok_push_core_options_list, ACTION_OK_DL_CORE_OPTIONS_LIST)
STATIC_DEFAULT_ACTION_OK_FUNC(action_ok_push_add_to_playlist_list, ACTION_OK_DL_ADD_TO_PLAYLIST)
STATIC_DEFAULT_ACTION_OK_FUNC(action_ok_push_add_to_playlist_quickmenu, ACTION_OK_DL_ADD_TO_PLAYLIST_QUICKMENU)
DEFAULT_ACTION_OK_FUNC(action_ok_push_playlist_manager_settings, ACTION_OK_DL_PLAYLIST_MANAGER_SETTINGS)
#ifdef HAVE_CHEEVOS
DEFAULT_ACTION_OK_FUNC(action_ok_push_achievements_hardcore_pause_list, ACTION_OK_DL_ACHIEVEMENTS_HARDCORE_PAUSE_LIST)
@ -8862,11 +9011,14 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs,
{MENU_ENUM_LABEL_RESUME_CONTENT, action_ok_resume_content},
{MENU_ENUM_LABEL_ADD_TO_FAVORITES_PLAYLIST, action_ok_add_to_favorites_playlist},
{MENU_ENUM_LABEL_ADD_ENTRY_TO_PLAYLIST, action_ok_add_entry_to_playlist},
{MENU_ENUM_LABEL_ADD_ENTRY_TO_PLAYLIST_QUICKMENU, action_ok_add_entry_to_playlist_quickmenu},
{MENU_ENUM_LABEL_CREATE_NEW_PLAYLIST, action_ok_add_entry_to_new_playlist},
{MENU_ENUM_LABEL_CREATE_NEW_PLAYLIST_QUICKMENU, action_ok_add_entry_to_new_playlist},
{MENU_ENUM_LABEL_SET_CORE_ASSOCIATION, action_ok_set_core_association},
{MENU_ENUM_LABEL_RESET_CORE_ASSOCIATION, action_ok_reset_core_association},
{MENU_ENUM_LABEL_ADD_TO_FAVORITES, action_ok_add_to_favorites},
{MENU_ENUM_LABEL_ADD_TO_PLAYLIST, action_ok_push_add_to_playlist_list},
{MENU_ENUM_LABEL_ADD_TO_PLAYLIST_QUICKMENU, action_ok_push_add_to_playlist_quickmenu},
{MENU_ENUM_LABEL_RESTART_CONTENT, action_ok_restart_content},
{MENU_ENUM_LABEL_TAKE_SCREENSHOT, action_ok_screenshot},
{MENU_ENUM_LABEL_RENAME_ENTRY, action_ok_rename_entry},

View File

@ -248,7 +248,8 @@ enum
ACTION_OK_DL_CORE_OPTION_OVERRIDE_LIST,
ACTION_OK_DL_CORE_OPTIONS_LIST,
ACTION_OK_DL_REMAP_FILE_MANAGER_LIST,
ACTION_OK_DL_ADD_TO_PLAYLIST
ACTION_OK_DL_ADD_TO_PLAYLIST,
ACTION_OK_DL_ADD_TO_PLAYLIST_QUICKMENU
};
/* Function callbacks */

View File

@ -3891,8 +3891,8 @@ static int menu_displaylist_parse_load_content_settings(
{
if (menu_entries_append(list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ADD_TO_PLAYLIST),
msg_hash_to_str(MENU_ENUM_LABEL_ADD_TO_PLAYLIST),
MENU_ENUM_LABEL_ADD_TO_PLAYLIST,
msg_hash_to_str(MENU_ENUM_LABEL_ADD_TO_PLAYLIST_QUICKMENU),
MENU_ENUM_LABEL_ADD_TO_PLAYLIST_QUICKMENU,
MENU_SETTING_ACTION, 0, 0, NULL))
count++;
}
@ -4714,7 +4714,7 @@ static unsigned menu_displaylist_parse_cores(menu_handle_t *menu,
}
static unsigned menu_displaylist_parse_add_to_playlist_list(file_list_t *list,
const char *dir_playlist, bool show_hidden_files)
enum menu_displaylist_ctl_state type, const char *dir_playlist, bool show_hidden_files)
{
char playlist_display_name[NAME_MAX_LENGTH];
unsigned count = 0;
@ -4759,7 +4759,9 @@ static unsigned menu_displaylist_parse_add_to_playlist_list(file_list_t *list,
sizeof(playlist_display_name));
menu_entries_append(list, playlist_display_name, path,
MENU_ENUM_LABEL_ADD_ENTRY_TO_PLAYLIST,
(type == DISPLAYLIST_ADD_TO_PLAYLIST_LIST ?
MENU_ENUM_LABEL_ADD_ENTRY_TO_PLAYLIST :
MENU_ENUM_LABEL_ADD_ENTRY_TO_PLAYLIST_QUICKMENU),
MENU_SETTING_ACTION, 0, 0, NULL);
count++;
}
@ -14252,27 +14254,33 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
info->flags |= MD_FLAG_NEED_PUSH;
break;
case DISPLAYLIST_ADD_TO_PLAYLIST_LIST:
menu_entries_clear(info->list);
case DISPLAYLIST_ADD_TO_PLAYLIST_QUICKMENU:
{
enum msg_hash_enums lbl = (type == DISPLAYLIST_ADD_TO_PLAYLIST_LIST ?
MENU_ENUM_LABEL_CREATE_NEW_PLAYLIST : MENU_ENUM_LABEL_CREATE_NEW_PLAYLIST_QUICKMENU);
menu_entries_clear(info->list);
/* add new list button here */
menu_entries_append(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CREATE_NEW_PLAYLIST),
msg_hash_to_str(MENU_ENUM_LABEL_CREATE_NEW_PLAYLIST),
MENU_ENUM_LABEL_CREATE_NEW_PLAYLIST,
MENU_SETTING_ACTION, 0, 0, NULL);
count = menu_displaylist_parse_add_to_playlist_list(info->list,
settings->paths.directory_playlist,
settings->bools.show_hidden_files);
if (count == 0)
/* add new list button here */
menu_entries_append(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_ENTRIES_TO_DISPLAY),
msg_hash_to_str(MENU_ENUM_LABEL_NO_ENTRIES_TO_DISPLAY),
MENU_ENUM_LABEL_NO_ENTRIES_TO_DISPLAY,
FILE_TYPE_NONE, 0, 0, NULL);
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CREATE_NEW_PLAYLIST),
msg_hash_to_str(lbl),
lbl,
MENU_SETTING_ACTION, 0, 0, NULL);
info->flags |= MD_FLAG_NEED_PUSH;
count = menu_displaylist_parse_add_to_playlist_list(info->list,
type,
settings->paths.directory_playlist,
settings->bools.show_hidden_files);
if (count == 0)
menu_entries_append(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_ENTRIES_TO_DISPLAY),
msg_hash_to_str(MENU_ENUM_LABEL_NO_ENTRIES_TO_DISPLAY),
MENU_ENUM_LABEL_NO_ENTRIES_TO_DISPLAY,
FILE_TYPE_NONE, 0, 0, NULL);
info->flags |= MD_FLAG_NEED_PUSH;
}
break;
case DISPLAYLIST_PLAYLIST_MANAGER_SETTINGS:
menu_entries_clear(info->list);

View File

@ -253,6 +253,7 @@ enum menu_displaylist_ctl_state
DISPLAYLIST_PLAYLIST_SETTINGS_LIST,
DISPLAYLIST_PLAYLIST_MANAGER_LIST,
DISPLAYLIST_ADD_TO_PLAYLIST_LIST,
DISPLAYLIST_ADD_TO_PLAYLIST_QUICKMENU,
DISPLAYLIST_PLAYLIST_MANAGER_SETTINGS,
DISPLAYLIST_ACCOUNTS_CHEEVOS_LIST,
DISPLAYLIST_ACCOUNTS_YOUTUBE_LIST,

View File

@ -584,9 +584,13 @@ enum msg_hash_enums
MSG_ADDED_TO_PLAYLIST,
MSG_ADD_TO_PLAYLIST_FAILED,
MENU_ENUM_LABEL_ADD_ENTRY_TO_PLAYLIST,
MENU_ENUM_LABEL_ADD_ENTRY_TO_PLAYLIST_QUICKMENU,
MENU_ENUM_LABEL_DEFERRED_ADD_TO_PLAYLIST_LIST,
MENU_ENUM_LABEL_DEFERRED_ADD_TO_PLAYLIST_QUICKMENU,
MENU_LABEL(ADD_TO_PLAYLIST),
MENU_LABEL(CREATE_NEW_PLAYLIST),
MENU_LABEL(ADD_TO_PLAYLIST_QUICKMENU),
MENU_LABEL(CREATE_NEW_PLAYLIST_QUICKMENU),
MENU_LABEL(MENU_XMB_ANIMATION_HORIZONTAL_HIGHLIGHT),
MENU_LABEL(MENU_XMB_ANIMATION_MOVE_UP_DOWN),