Create new playlist format

This commit is contained in:
twinaphex 2015-05-26 00:12:49 +02:00
parent e05c0ab4f4
commit 8fb8887c34
13 changed files with 88 additions and 43 deletions

View File

@ -78,7 +78,7 @@ public final class HistorySelection extends DialogFragment
adapter = new IconAdapter<HistoryWrapper>(ctx, R.layout.line_list_item); adapter = new IconAdapter<HistoryWrapper>(ctx, R.layout.line_list_item);
// Populate the adapter // Populate the adapter
File history = new File(ctx.getApplicationInfo().dataDir, "retroarch-content-history.txt"); File history = new File(ctx.getApplicationInfo().dataDir, "content_history.rpl");
try try
{ {
BufferedReader br = new BufferedReader(new InputStreamReader( BufferedReader br = new BufferedReader(new InputStreamReader(

View File

@ -253,7 +253,7 @@ public final class UserPreferences
} }
config.setBoolean("video_font_enable", prefs.getBoolean("video_font_enable", true)); config.setBoolean("video_font_enable", prefs.getBoolean("video_font_enable", true));
config.setString("game_history_path", dataDir + "/retroarch-content-history.txt"); config.setString("content_history_path", dataDir + "/content_history.rpl");
// FIXME: This is incomplete. Need analog axes as well. // FIXME: This is incomplete. Need analog axes as well.
for (int i = 1; i <= 4; i++) for (int i = 1; i <= 4; i++)

View File

@ -1529,8 +1529,8 @@ static bool config_load_file(const char *path, bool set_defaults)
CONFIG_GET_BOOL_BASE(conf, settings, history_list_enable, "history_list_enable"); CONFIG_GET_BOOL_BASE(conf, settings, history_list_enable, "history_list_enable");
CONFIG_GET_PATH_BASE(conf, settings, content_history_path, "game_history_path"); CONFIG_GET_PATH_BASE(conf, settings, content_history_path, "content_history_path");
CONFIG_GET_INT_BASE(conf, settings, content_history_size, "game_history_size"); CONFIG_GET_INT_BASE(conf, settings, content_history_size, "content_history_size");
CONFIG_GET_INT_BASE(conf, settings, input.turbo_period, "input_turbo_period"); CONFIG_GET_INT_BASE(conf, settings, input.turbo_period, "input_turbo_period");
CONFIG_GET_INT_BASE(conf, settings, input.turbo_duty_cycle, "input_duty_cycle"); CONFIG_GET_INT_BASE(conf, settings, input.turbo_duty_cycle, "input_duty_cycle");
@ -1601,13 +1601,13 @@ static bool config_load_file(const char *path, bool set_defaults)
{ {
fill_pathname_join(settings->content_history_path, fill_pathname_join(settings->content_history_path,
settings->content_history_directory, settings->content_history_directory,
"retroarch-content-history.txt", "content_history.rpl",
sizeof(settings->content_history_path)); sizeof(settings->content_history_path));
} }
else else
{ {
fill_pathname_resolve_relative(settings->content_history_path, fill_pathname_resolve_relative(settings->content_history_path,
global->config_path, "retroarch-content-history.txt", global->config_path, "content_history.rpl",
sizeof(settings->content_history_path)); sizeof(settings->content_history_path));
} }
} }
@ -2438,8 +2438,8 @@ bool config_save_file(const char *path)
settings->menu.title_color); settings->menu.title_color);
#endif #endif
config_set_path(conf, "game_history_path", settings->content_history_path); config_set_path(conf, "content_history_path", settings->content_history_path);
config_set_int(conf, "game_history_size", settings->content_history_size); config_set_int(conf, "content_history_size", settings->content_history_size);
config_set_path(conf, "joypad_autoconfig_dir", config_set_path(conf, "joypad_autoconfig_dir",
settings->input.autoconfig_dir); settings->input.autoconfig_dir);
config_set_bool(conf, "input_autodetect_enable", config_set_bool(conf, "input_autodetect_enable",

View File

@ -180,8 +180,10 @@ static void history_playlist_push(content_playlist_t *playlist,
if (global->system.no_content || *tmp) if (global->system.no_content || *tmp)
content_playlist_push(playlist, content_playlist_push(playlist,
*tmp ? tmp : NULL, *tmp ? tmp : NULL,
NULL,
core_path, core_path,
info->library_name); info->library_name,
NULL);
} }
/** /**

View File

@ -69,8 +69,10 @@ static void push_to_history_playlist(void)
content_playlist_push(g_defaults.history, content_playlist_push(g_defaults.history,
global->fullpath, global->fullpath,
NULL,
settings->libretro, settings->libretro,
global->menu.info.library_name); global->menu.info.library_name,
NULL);
} }
/** /**

View File

@ -725,13 +725,15 @@ static int menu_displaylist_parse_playlist(menu_displaylist_info_t *info,
char path_copy[PATH_MAX_LENGTH]; char path_copy[PATH_MAX_LENGTH];
const char *core_name = NULL; const char *core_name = NULL;
const char *path = NULL; const char *path = NULL;
const char *label = NULL;
const char *crc32 = NULL;
strlcpy(path_copy, info->path, sizeof(path_copy)); strlcpy(path_copy, info->path, sizeof(path_copy));
path = path_copy; path = path_copy;
content_playlist_get_index(playlist, i, content_playlist_get_index(playlist, i,
&path, NULL, &core_name); &path, &label, NULL, &core_name, &crc32);
strlcpy(fill_buf, core_name, sizeof(fill_buf)); strlcpy(fill_buf, core_name, sizeof(fill_buf));
if (path) if (path)
@ -741,7 +743,8 @@ static int menu_displaylist_parse_playlist(menu_displaylist_info_t *info,
fill_short_pathname_representation(path_short, path, fill_short_pathname_representation(path_short, path,
sizeof(path_short)); sizeof(path_short));
snprintf(fill_buf,sizeof(fill_buf),"%s (%s)", snprintf(fill_buf,sizeof(fill_buf),"%s (%s)",
path_short, core_name); (label && label[0] != '\0') ? label : path_short,
core_name);
} }
if (!strcmp(path_playlist, "collection")) if (!strcmp(path_playlist, "collection"))

View File

@ -301,7 +301,7 @@ static int deferred_push_cursor_manager_list(menu_displaylist_info_t *info)
static int deferred_push_content_collection_list(menu_displaylist_info_t *info) static int deferred_push_content_collection_list(menu_displaylist_info_t *info)
{ {
info->type_default = MENU_FILE_PLAIN; info->type_default = MENU_FILE_PLAIN;
strlcpy(info->exts, "cfg", sizeof(info->exts)); strlcpy(info->exts, "rpl", sizeof(info->exts));
return menu_displaylist_push_list(info, DISPLAYLIST_DATABASE_PLAYLISTS); return menu_displaylist_push_list(info, DISPLAYLIST_DATABASE_PLAYLISTS);
} }
@ -413,7 +413,7 @@ static int deferred_push_video_font_path(menu_displaylist_info_t *info)
static int deferred_push_content_history_path(menu_displaylist_info_t *info) static int deferred_push_content_history_path(menu_displaylist_info_t *info)
{ {
info->type_default = MENU_FILE_PLAIN; info->type_default = MENU_FILE_PLAIN;
strlcpy(info->exts, "cfg", sizeof(info->exts)); strlcpy(info->exts, "rpl", sizeof(info->exts));
return menu_displaylist_push_list(info, DISPLAYLIST_CONTENT_HISTORY); return menu_displaylist_push_list(info, DISPLAYLIST_CONTENT_HISTORY);
} }
@ -578,7 +578,7 @@ void menu_entries_cbs_init_bind_deferred_push(menu_file_list_cbs_t *cbs,
cbs->action_deferred_push = deferred_push_input_osk_overlay; cbs->action_deferred_push = deferred_push_input_osk_overlay;
else if (!strcmp(label, "video_font_path")) else if (!strcmp(label, "video_font_path"))
cbs->action_deferred_push = deferred_push_video_font_path; cbs->action_deferred_push = deferred_push_video_font_path;
else if (!strcmp(label, "game_history_path")) else if (!strcmp(label, "content_history_path"))
cbs->action_deferred_push = deferred_push_content_history_path; cbs->action_deferred_push = deferred_push_content_history_path;
else if (!strcmp(label, "detect_core_list")) else if (!strcmp(label, "detect_core_list"))
cbs->action_deferred_push = deferred_push_detect_core_list; cbs->action_deferred_push = deferred_push_detect_core_list;

View File

@ -36,24 +36,30 @@
**/ **/
void content_playlist_get_index(content_playlist_t *playlist, void content_playlist_get_index(content_playlist_t *playlist,
size_t idx, size_t idx,
const char **path, const char **core_path, const char **path, const char **label,
const char **core_name) const char **core_path, const char **core_name,
const char **crc32)
{ {
if (!playlist) if (!playlist)
return; return;
if (path) if (path)
*path = playlist->entries[idx].path; *path = playlist->entries[idx].path;
if (label)
*label = playlist->entries[idx].label;
if (core_path) if (core_path)
*core_path = playlist->entries[idx].core_path; *core_path = playlist->entries[idx].core_path;
if (core_name) if (core_name)
*core_name = playlist->entries[idx].core_name; *core_name = playlist->entries[idx].core_name;
if (crc32)
*crc32 = playlist->entries[idx].crc32;
} }
void content_playlist_get_index_by_path(content_playlist_t *playlist, void content_playlist_get_index_by_path(content_playlist_t *playlist,
const char *search_path, const char *search_path,
char **path, char **core_path, char **path, char **label,
char **core_name) char **core_path, char **core_name,
char **crc32)
{ {
size_t i; size_t i;
if (!playlist) if (!playlist)
@ -66,10 +72,14 @@ void content_playlist_get_index_by_path(content_playlist_t *playlist,
if (path) if (path)
*path = playlist->entries[i].path; *path = playlist->entries[i].path;
if (label)
*label = playlist->entries[i].label;
if (core_path) if (core_path)
*core_path = playlist->entries[i].core_path; *core_path = playlist->entries[i].core_path;
if (core_name) if (core_name)
*core_name = playlist->entries[i].core_name; *core_name = playlist->entries[i].core_name;
if (crc32)
*crc32 = playlist->entries[i].crc32;
break; break;
} }
@ -89,13 +99,23 @@ static void content_playlist_free_entry(content_playlist_entry_t *entry)
if (entry->path) if (entry->path)
free(entry->path); free(entry->path);
entry->path = NULL; entry->path = NULL;
if (entry->label)
free(entry->label);
entry->label = NULL;
if (entry->core_path) if (entry->core_path)
free(entry->core_path); free(entry->core_path);
entry->core_path = NULL; entry->core_path = NULL;
if (entry->core_name) if (entry->core_name)
free(entry->core_name); free(entry->core_name);
entry->core_name = NULL; entry->core_name = NULL;
if (entry->crc32)
free(entry->crc32);
entry->crc32 = NULL;
memset(entry, 0, sizeof(*entry)); memset(entry, 0, sizeof(*entry));
} }
@ -109,8 +129,9 @@ static void content_playlist_free_entry(content_playlist_entry_t *entry)
* Push entry to top of playlist. * Push entry to top of playlist.
**/ **/
void content_playlist_push(content_playlist_t *playlist, void content_playlist_push(content_playlist_t *playlist,
const char *path, const char *core_path, const char *path, const char *label,
const char *core_name) const char *core_path, const char *core_name,
const char *crc32)
{ {
size_t i; size_t i;
@ -119,7 +140,7 @@ void content_playlist_push(content_playlist_t *playlist,
if (!core_path || !*core_path || !core_name || !*core_name) if (!core_path || !*core_path || !core_name || !*core_name)
{ {
RARCH_ERR("cannot push NULL or empty core info into the playlist"); RARCH_ERR("cannot push NULL or empty core info into the playlist.\n");
return; return;
} }
@ -165,8 +186,10 @@ void content_playlist_push(content_playlist_t *playlist,
(playlist->cap - 1) * sizeof(content_playlist_entry_t)); (playlist->cap - 1) * sizeof(content_playlist_entry_t));
playlist->entries[0].path = path ? strdup(path) : NULL; playlist->entries[0].path = path ? strdup(path) : NULL;
playlist->entries[0].label = label ? strdup(label) : NULL;
playlist->entries[0].core_path = strdup(core_path); playlist->entries[0].core_path = strdup(core_path);
playlist->entries[0].core_name = strdup(core_name); playlist->entries[0].core_name = strdup(core_name);
playlist->entries[0].crc32 = crc32 ? strdup(crc32) : NULL;
playlist->size++; playlist->size++;
} }
@ -184,10 +207,12 @@ void content_playlist_write_file(content_playlist_t *playlist)
return; return;
for (i = 0; i < playlist->size; i++) for (i = 0; i < playlist->size; i++)
fprintf(file, "%s\n%s\n%s\n", fprintf(file, "%s\n%s\n%s\n%s\n%s\n",
playlist->entries[i].path ? playlist->entries[i].path : "", playlist->entries[i].path ? playlist->entries[i].path : "",
playlist->entries[i].label ? playlist->entries[i].label : "",
playlist->entries[i].core_path, playlist->entries[i].core_path,
playlist->entries[i].core_name); playlist->entries[i].core_name,
playlist->entries[i].crc32 ? playlist->entries[i].crc32 : "");
fclose(file); fclose(file);
} }
@ -247,10 +272,14 @@ size_t content_playlist_size(content_playlist_t *playlist)
return playlist->size; return playlist->size;
} }
#ifndef PLAYLIST_ENTRIES
#define PLAYLIST_ENTRIES 5
#endif
static bool content_playlist_read_file( static bool content_playlist_read_file(
content_playlist_t *playlist, const char *path) content_playlist_t *playlist, const char *path)
{ {
char buf[3][1024]; char buf[PLAYLIST_ENTRIES][1024];
unsigned i; unsigned i;
content_playlist_entry_t *entry = NULL; content_playlist_entry_t *entry = NULL;
char *last = NULL; char *last = NULL;
@ -264,7 +293,7 @@ static bool content_playlist_read_file(
for (playlist->size = 0; playlist->size < playlist->cap; ) for (playlist->size = 0; playlist->size < playlist->cap; )
{ {
for (i = 0; i < 3; i++) for (i = 0; i < PLAYLIST_ENTRIES; i++)
{ {
*buf[i] = '\0'; *buf[i] = '\0';
@ -278,13 +307,17 @@ static bool content_playlist_read_file(
entry = &playlist->entries[playlist->size]; entry = &playlist->entries[playlist->size];
if (!*buf[1] || !*buf[2]) if (!*buf[2] || !*buf[3])
continue; continue;
if (*buf[0]) if (*buf[0])
entry->path = strdup(buf[0]); entry->path = strdup(buf[0]);
entry->core_path = strdup(buf[1]); if (*buf[1])
entry->core_name = strdup(buf[2]); entry->label = strdup(buf[1]);
entry->core_path = strdup(buf[2]);
entry->core_name = strdup(buf[3]);
if (*buf[4])
entry->crc32 = strdup(buf[4]);
playlist->size++; playlist->size++;
} }

View File

@ -27,8 +27,10 @@ extern "C" {
typedef struct content_playlist_entry typedef struct content_playlist_entry
{ {
char *path; char *path;
char *label;
char *core_path; char *core_path;
char *core_name; char *core_name;
char *crc32;
} content_playlist_entry_t; } content_playlist_entry_t;
typedef struct content_playlist typedef struct content_playlist
@ -87,9 +89,10 @@ size_t content_playlist_size(content_playlist_t *playlist);
* Gets values of playlist index: * Gets values of playlist index:
**/ **/
void content_playlist_get_index(content_playlist_t *playlist, void content_playlist_get_index(content_playlist_t *playlist,
size_t index, size_t idx,
const char **path, const char **core_path, const char **path, const char **label,
const char **core_name); const char **core_path, const char **core_name,
const char **crc32);
/** /**
* content_playlist_push: * content_playlist_push:
@ -101,13 +104,15 @@ void content_playlist_get_index(content_playlist_t *playlist,
* Push entry to top of playlist. * Push entry to top of playlist.
**/ **/
void content_playlist_push(content_playlist_t *playlist, void content_playlist_push(content_playlist_t *playlist,
const char *path, const char *core_path, const char *path, const char *label,
const char *core_name); const char *core_path, const char *core_name,
const char *crc32);
void content_playlist_get_index_by_path(content_playlist_t *playlist, void content_playlist_get_index_by_path(content_playlist_t *playlist,
const char *search_path, const char *search_path,
char **path, char **core_path, char **path, char **label,
char **core_name); char **core_path, char **core_name,
char **crc32);
void content_playlist_write_file(content_playlist_t *playlist); void content_playlist_write_file(content_playlist_t *playlist);

View File

@ -1340,7 +1340,7 @@ void rarch_playlist_load_content(content_playlist_t *playlist,
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
content_playlist_get_index(playlist, content_playlist_get_index(playlist,
idx, &path, &core_path, NULL); idx, &path, NULL, &core_path, NULL, NULL);
strlcpy(settings->libretro, core_path, sizeof(settings->libretro)); strlcpy(settings->libretro, core_path, sizeof(settings->libretro));

View File

@ -69,10 +69,10 @@
# Path to content load history file. # Path to content load history file.
# RetroArch keeps track of all content loaded in the menu and from CLI directly for convenient quick loading. # RetroArch keeps track of all content loaded in the menu and from CLI directly for convenient quick loading.
# A default path will be assigned if not set. # A default path will be assigned if not set.
# game_history_path = # content_history_path =
# Number of entries that will be kept in content history file. # Number of entries that will be kept in content history file.
# game_history_size = 100 # content_history_size = 100
# Sets the "system" directory. # Sets the "system" directory.
# Implementations can query for this directory to load BIOSes, system-specific configs, etc. # Implementations can query for this directory to load BIOSes, system-specific configs, etc.

View File

@ -5977,7 +5977,7 @@ static bool setting_append_list_playlist_options(
CONFIG_UINT( CONFIG_UINT(
settings->content_history_size, settings->content_history_size,
"game_history_size", "content_history_size",
"History List Size", "History List Size",
default_content_history_size, default_content_history_size,
group_info.name, group_info.name,

View File

@ -168,7 +168,7 @@ static int database_info_list_iterate_found_match(
snprintf(db_crc, sizeof(db_crc), "%s|crc", db_info_entry->crc32); snprintf(db_crc, sizeof(db_crc), "%s|crc", db_info_entry->crc32);
content_playlist_push(playlist, entry_path, "Test", db_crc); content_playlist_push(playlist, entry_path, db_info_entry->name, "DETECT", "DETECT", db_crc);
content_playlist_write_file(playlist); content_playlist_write_file(playlist);
content_playlist_free(playlist); content_playlist_free(playlist);