diff --git a/intl/msg_hash_us.c b/intl/msg_hash_us.c index bcc110c24d..3247431b50 100644 --- a/intl/msg_hash_us.c +++ b/intl/msg_hash_us.c @@ -2796,6 +2796,8 @@ static const char *menu_hash_to_str_us_label_enum(enum msg_hash_enums msg) return "restart_content"; case MENU_ENUM_LABEL_TAKE_SCREENSHOT: return "take_screenshot"; + case MENU_ENUM_LABEL_DELETE_ENTRY: + return "delete_entry"; case MENU_ENUM_LABEL_CORE_UPDATER_LIST: return "core_updater_list"; case MENU_ENUM_LABEL_START_VIDEO_PROCESSOR: @@ -4023,6 +4025,8 @@ const char *msg_hash_to_str_us(enum msg_hash_enums msg) return "Core Counters"; case MENU_ENUM_LABEL_VALUE_TAKE_SCREENSHOT: return "Take Screenshot"; + case MENU_ENUM_LABEL_VALUE_DELETE_ENTRY: + return "Remove from Playlist"; case MENU_ENUM_LABEL_VALUE_RESUME: return "Resume"; case MENU_ENUM_LABEL_VALUE_DISK_INDEX: diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 33c49a5676..199c3b8f89 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -2537,6 +2537,18 @@ static int action_ok_screenshot(const char *path, return generic_action_ok_command(CMD_EVENT_TAKE_SCREENSHOT); } +static int action_ok_delete_entry(const char *path, + const char *label, unsigned type, size_t idx, size_t entry_idx) +{ + playlist_t *playlist = NULL; + + menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &playlist); + + playlist_delete_index(playlist, rpl_entry_selection_ptr); + + return 0; +} + static int action_ok_shader_apply_changes(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { @@ -3312,6 +3324,9 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_TAKE_SCREENSHOT: BIND_ACTION_OK(cbs, action_ok_screenshot); break; + case MENU_ENUM_LABEL_DELETE_ENTRY: + BIND_ACTION_OK(cbs, action_ok_delete_entry); + break; case MENU_ENUM_LABEL_QUIT_RETROARCH: BIND_ACTION_OK(cbs, action_ok_quit); break; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index da2216e33d..f789b989f1 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1621,6 +1621,8 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb, return xmb->textures.list[XMB_TEXTURE_LOADSTATE]; case MENU_ENUM_LABEL_TAKE_SCREENSHOT: return xmb->textures.list[XMB_TEXTURE_SCREENSHOT]; + case MENU_ENUM_LABEL_DELETE_ENTRY: + return xmb->textures.list[XMB_TEXTURE_CLOSE]; case MENU_ENUM_LABEL_RESTART_CONTENT: return xmb->textures.list[XMB_TEXTURE_RELOAD]; case MENU_ENUM_LABEL_RESUME_CONTENT: @@ -1695,6 +1697,8 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb, return xmb->textures.list[XMB_TEXTURE_SHADER_OPTIONS]; case MENU_SETTING_ACTION_SCREENSHOT: return xmb->textures.list[XMB_TEXTURE_SCREENSHOT]; + case MENU_SETTING_ACTION_DELETE_ENTRY: + return xmb->textures.list[XMB_TEXTURE_CLOSE]; case MENU_SETTING_ACTION_RESET: return xmb->textures.list[XMB_TEXTURE_RELOAD]; case MENU_SETTING_ACTION: diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 72861a64ba..45859d26d5 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2772,10 +2772,17 @@ static int menu_displaylist_parse_horizontal_content_actions( && string_is_equal(menu->deferred_path, fullpath)) menu_displaylist_parse_load_content_settings(info); else + { menu_entries_append_enum(info->list, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RUN), msg_hash_to_str(MENU_ENUM_LABEL_RUN), MENU_ENUM_LABEL_RUN, FILE_TYPE_PLAYLIST_ENTRY, 0, idx); + menu_entries_append_enum(info->list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DELETE_ENTRY), + msg_hash_to_str(MENU_ENUM_LABEL_DELETE_ENTRY), + MENU_ENUM_LABEL_DELETE_ENTRY, + MENU_SETTING_ACTION_DELETE_ENTRY, 0, 0); + } menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &playlist); diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 65fec26934..c28e227ceb 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -190,6 +190,7 @@ enum menu_settings_type MENU_SETTING_ACTION_SAVESTATE, MENU_SETTING_ACTION_LOADSTATE, MENU_SETTING_ACTION_SCREENSHOT, + MENU_SETTING_ACTION_DELETE_ENTRY, MENU_SETTING_ACTION_RESET, MENU_SETTING_STRING_OPTIONS, MENU_SETTING_GROUP, diff --git a/msg_hash.h b/msg_hash.h index ddce2844f0..bb74cb42ae 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1578,6 +1578,8 @@ enum msg_hash_enums MENU_ENUM_LABEL_VALUE_RESTART_CONTENT, MENU_ENUM_LABEL_TAKE_SCREENSHOT, MENU_ENUM_LABEL_VALUE_TAKE_SCREENSHOT, + MENU_ENUM_LABEL_DELETE_ENTRY, + MENU_ENUM_LABEL_VALUE_DELETE_ENTRY, MENU_ENUM_LABEL_CONFIGURATIONS, MENU_ENUM_LABEL_VALUE_CONFIGURATIONS, MENU_ENUM_LABEL_VALUE_CHEAT_FILE_SAVE_AS, diff --git a/playlist.c b/playlist.c index 15d9f5a8a6..5ad11904a4 100644 --- a/playlist.c +++ b/playlist.c @@ -90,6 +90,27 @@ void playlist_get_index(playlist_t *playlist, *crc32 = playlist->entries[idx].crc32; } +/** + * playlist_delete_index: + * @playlist : Playlist handle. + * @idx : Index of playlist entry. + * + * Delete the entry at the index: + **/ +void playlist_delete_index(playlist_t *playlist, + size_t idx) +{ + if (!playlist) + return; + + memmove(playlist->entries + idx, playlist->entries + idx + 1, + (playlist->size - idx) * sizeof(struct playlist_entry)); + + playlist->size = playlist->size - 1; + + playlist_write_file(playlist); +} + void playlist_get_index_by_path(playlist_t *playlist, const char *search_path, char **path, char **label, diff --git a/playlist.h b/playlist.h index 2cdc970f33..eee10c7ba2 100644 --- a/playlist.h +++ b/playlist.h @@ -65,7 +65,7 @@ size_t playlist_size(playlist_t *playlist); /** * playlist_get_index: - * @playlist : Playlist handle. + * @playlist : Playlist handle. * @idx : Index of playlist entry. * @path : Path of playlist entry. * @core_path : Core path of playlist entry. @@ -80,6 +80,16 @@ void playlist_get_index(playlist_t *playlist, const char **db_name, const char **crc32); +/** + * playlist_delete_index: + * @playlist : Playlist handle. + * @idx : Index of playlist entry. + * + * Deletes the entry at index: + **/ +void playlist_delete_index(playlist_t *playlist, + size_t idx); + /** * playlist_push: * @playlist : Playlist handle.