Skip to content

Commit

Permalink
First working implementation of playlist associations
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Oct 31, 2015
1 parent 6edc7aa commit da1931a
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 13 deletions.
6 changes: 3 additions & 3 deletions core_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ void core_info_list_get_supported_cores(core_info_list_t *core_info_list,
*num_infos = supported;
}

static core_info_t *find_core_info(core_info_list_t *list,
core_info_t *core_info_find(core_info_list_t *list,
const char *core)
{
size_t i;
Expand Down Expand Up @@ -579,7 +579,7 @@ void core_info_list_update_missing_firmware(core_info_list_t *core_info_list,
if (!core_info_list || !core)
return;

if (!(info = find_core_info(core_info_list, core)))
if (!(info = core_info_find(core_info_list, core)))
return;

for (i = 0; i < info->firmware_count; i++)
Expand Down Expand Up @@ -607,7 +607,7 @@ void core_info_list_get_missing_firmware(core_info_list_t *core_info_list,
*firmware = NULL;
*num_firmware = 0;

if (!(info = find_core_info(core_info_list, core)))
if (!(info = core_info_find(core_info_list, core)))
return;

*firmware = info->firmware;
Expand Down
3 changes: 3 additions & 0 deletions core_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ bool core_info_list_get_info(core_info_list_t *list,

const char *core_info_list_get_all_extensions(void);

core_info_t *core_info_find(core_info_list_t *list,
const char *core);

bool core_info_list_get_display_name(core_info_list_t *list,
const char *path, char *buf, size_t size);

Expand Down
27 changes: 24 additions & 3 deletions menu/cbs/menu_cbs_ok.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@ static int action_ok_playlist_entry(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
size_t selection;
char new_core_path[PATH_MAX_LENGTH];
uint32_t core_name_hash, core_path_hash;
const char *entry_path = NULL;
const char *entry_label = NULL;
Expand Down Expand Up @@ -526,11 +525,33 @@ static int action_ok_playlist_entry(const char *path,
(core_name_hash == MENU_VALUE_DETECT)
)
{
if (!menu_playlist_find_associated_core(menu->db_playlist_file, new_core_path, sizeof(new_core_path)))
char new_core_path[PATH_MAX_LENGTH];
core_info_t *core_info = NULL;
global_t *global = global_get_ptr();
const char *path_base = path_basename(menu->db_playlist_file);
bool found_associated_core = menu_playlist_find_associated_core(
path_base, new_core_path, sizeof(new_core_path));

if (!(core_info = core_info_find(global->core_info.list, new_core_path)))
found_associated_core = false;

if (found_associated_core)
{
char new_display_name[PATH_MAX_LENGTH];

strlcpy(new_display_name, core_info->display_name, sizeof(new_display_name));
content_playlist_update(menu->playlist, selection_ptr,
menu->playlist->entries[selection_ptr].path, menu->playlist->entries[selection_ptr].label,
new_core_path , new_display_name,
menu->playlist->entries[selection_ptr].crc32,
menu->playlist->entries[selection_ptr].db_name);
content_playlist_write_file(menu->playlist);
}
else
return action_ok_file_load_with_detect_core(entry_path, label, type, selection_ptr, entry_idx);
}

rarch_playlist_load_content(playlist, new_core_path, selection_ptr);
rarch_playlist_load_content(playlist, selection_ptr);

if (is_history)
{
Expand Down
7 changes: 2 additions & 5 deletions retroarch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1491,10 +1491,10 @@ void rarch_main_deinit(void)
*
* Initializes core and loads content based on playlist entry.
**/
void rarch_playlist_load_content(void *data, const char *core_path, unsigned idx)
void rarch_playlist_load_content(void *data, unsigned idx)
{
unsigned i;
char new_core_path[PATH_MAX_LENGTH];
const char *core_path = NULL;
const char *path = NULL;
char *path_check = NULL;
char *path_tolower = NULL;
Expand All @@ -1508,9 +1508,6 @@ void rarch_playlist_load_content(void *data, const char *core_path, unsigned idx
if (!playlist)
return;

if (!core_path)
core_path = new_core_path;

content_playlist_get_index(playlist,
idx, &path, NULL, &core_path, NULL, NULL, NULL);

Expand Down
3 changes: 1 addition & 2 deletions retroarch.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,11 @@ void rarch_main_deinit(void);
/**
* rarch_playlist_load_content:
* @playlist : Playlist handle.
* @path : Path to associated core (optional).
* @idx : Index in playlist.
*
* Initializes core and loads content based on playlist entry.
**/
void rarch_playlist_load_content(void *data, const char *core_path, unsigned index);
void rarch_playlist_load_content(void *data, unsigned index);

/**
* rarch_defer_core:
Expand Down

0 comments on commit da1931a

Please sign in to comment.