Skip to content

Commit

Permalink
Create command_playlist_update_write_file and move it to command.c
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Nov 25, 2017
1 parent ca616f3 commit b604a18
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 36 deletions.
32 changes: 32 additions & 0 deletions command.c
Original file line number Diff line number Diff line change
Expand Up @@ -1702,6 +1702,38 @@ static bool command_event_resize_windowed_scale(void)
return true;
}

void command_playlist_update_write(
void *data,
size_t idx,
const char *core_display_name,
const char *label,
const char *path)
{
playlist_t *plist = (playlist_t*)data;
playlist_t *playlist = NULL;

if (plist)
playlist = plist;
#ifdef HAVE_MENU
else
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &playlist);
#endif
if (!playlist)
return;

playlist_update(
playlist,
idx,
label,
NULL,
path,
core_display_name,
NULL,
NULL);

playlist_write_file(playlist);
}

/**
* command_event:
* @cmd : Event command index.
Expand Down
7 changes: 7 additions & 0 deletions command.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,13 @@ bool command_free(command_t *handle);
**/
bool command_event(enum event_command action, void *data);

void command_playlist_update_write(
void *data,
size_t idx,
const char *core_display_name,
const char *label,
const char *path);

RETRO_END_DECLS

#endif
42 changes: 6 additions & 36 deletions menu/cbs/menu_cbs_ok.c
Original file line number Diff line number Diff line change
Expand Up @@ -1443,36 +1443,6 @@ static int action_ok_file_load(const char *path,
return 0;
}

static void generic_playlist_update_write(
playlist_t *plist,
size_t idx,
const char *core_display_name,
const char *label,
const char *path)
{
playlist_t *playlist = NULL;

if (plist)
playlist = plist;
#ifdef HAVE_MENU
else
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &playlist);
#endif

retro_assert(playlist != NULL);

playlist_update(
playlist,
idx,
label,
NULL,
path,
core_display_name,
NULL,
NULL);

playlist_write_file(playlist);
}

static int action_ok_playlist_entry_collection(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
Expand Down Expand Up @@ -1563,7 +1533,7 @@ static int action_ok_playlist_entry_collection(const char *path,

menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &tmp_playlist);

generic_playlist_update_write(tmp_playlist,
command_playlist_update_write(tmp_playlist,
selection_ptr,
core_info.inf->display_name,
NULL,
Expand Down Expand Up @@ -1650,7 +1620,7 @@ static int action_ok_playlist_entry(const char *path,
return action_ok_file_load_with_detect_core(entry_path,
label, type, selection_ptr, entry_idx);

generic_playlist_update_write(NULL,
command_playlist_update_write(NULL,
selection_ptr,
core_info.inf->display_name,
NULL,
Expand Down Expand Up @@ -1757,7 +1727,7 @@ static int action_ok_playlist_entry_start_content(const char *path,

menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &tmp_playlist);

generic_playlist_update_write(
command_playlist_update_write(
tmp_playlist,
selection_ptr,
core_info.inf->display_name,
Expand Down Expand Up @@ -1936,7 +1906,7 @@ static void menu_input_st_string_cb_rename_entry(void *userdata,
const char *label = menu_input_dialog_get_buffer();

if (!string_is_empty(label))
generic_playlist_update_write(NULL,
command_playlist_update_write(NULL,
menu_input_dialog_get_kb_idx(),
NULL,
label,
Expand Down Expand Up @@ -2314,7 +2284,7 @@ static int action_ok_core_deferred_set(const char *path,
core_display_name[0] = '\0';

core_info_get_name(path, core_display_name, sizeof(core_display_name));
generic_playlist_update_write(NULL,
command_playlist_update_write(NULL,
rdb_entry_start_game_selection_ptr,
core_display_name, NULL, path);

Expand All @@ -2333,7 +2303,7 @@ static int action_ok_core_deferred_set_current_core(const char *path,
core_display_name[0] = '\0';

core_info_get_name(path, core_display_name, sizeof(core_display_name));
generic_playlist_update_write(NULL,
command_playlist_update_write(NULL,
rdb_entry_start_game_selection_ptr,
core_display_name, NULL, path);

Expand Down

0 comments on commit b604a18

Please sign in to comment.