Rename ROM history to Content history

This commit is contained in:
twinaphex 2014-07-22 05:01:35 +02:00
parent d9846f2a37
commit 87a21b2e13
11 changed files with 77 additions and 77 deletions

View File

@ -112,13 +112,13 @@
@property (nonatomic) NSString* core; @property (nonatomic) NSString* core;
@end @end
/*********************************************/ /*************************************************/
/* RAHistoryMenu */ /* RAHistoryMenu */
/* Menu object that displays and allows */ /* Menu object that displays and allows */
/* launching a file from the ROM history. */ /* launching a file from the content history. */
/*********************************************/ /*************************************************/
@interface RAHistoryMenu : RAMenuBase @interface RAHistoryMenu : RAMenuBase
@property (nonatomic) rom_history_t* history; @property (nonatomic) content_history_t* history;
- (id)initWithHistoryPath:(const char*)historyPath; - (id)initWithHistoryPath:(const char*)historyPath;
@end @end

View File

@ -635,24 +635,24 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
@end @end
/*********************************************/ /*************************************************/
/* RAHistoryMenu */ /* RAHistoryMenu */
/* Menu object that displays and allows */ /* Menu object that displays and allows */
/* launching a file from the ROM history. */ /* launching a file from the content history. */
/*********************************************/ /*************************************************/
@implementation RAHistoryMenu @implementation RAHistoryMenu
- (void)dealloc - (void)dealloc
{ {
if (_history) if (_history)
rom_history_free(_history); content_history_free(_history);
} }
- (id)initWithHistoryPath:(const char*)historyPath - (id)initWithHistoryPath:(const char*)historyPath
{ {
if ((self = [super initWithStyle:UITableViewStylePlain])) if ((self = [super initWithStyle:UITableViewStylePlain]))
{ {
_history = rom_history_init(historyPath, 100); _history = content_history_init(historyPath, 100);
[self reloadData]; [self reloadData];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:BOXSTRING("Clear History") self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:BOXSTRING("Clear History")
style:UIBarButtonItemStyleBordered target:self action:@selector(clearHistory)]; style:UIBarButtonItemStyleBordered target:self action:@selector(clearHistory)];
@ -664,7 +664,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
- (void)clearHistory - (void)clearHistory
{ {
if (_history) if (_history)
rom_history_clear(_history); content_history_clear(_history);
[self reloadData]; [self reloadData];
} }
@ -674,12 +674,12 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
RAHistoryMenu* __weak weakSelf = self; RAHistoryMenu* __weak weakSelf = self;
NSMutableArray *section = [NSMutableArray arrayWithObject:BOXSTRING("")]; NSMutableArray *section = [NSMutableArray arrayWithObject:BOXSTRING("")];
for (i = 0; _history && i < rom_history_size(_history); i ++) for (i = 0; _history && i < content_history_size(_history); i ++)
{ {
RAMenuItemBasic* item = [RAMenuItemBasic itemWithDescription:BOXSTRING(path_basename(rom_history_get_path(weakSelf.history, i))) RAMenuItemBasic* item = [RAMenuItemBasic itemWithDescription:BOXSTRING(path_basename(content_history_get_path(weakSelf.history, i)))
action:^{ apple_run_core(BOXSTRING(rom_history_get_core_path(weakSelf.history, i)), action:^{ apple_run_core(BOXSTRING(content_history_get_core_path(weakSelf.history, i)),
rom_history_get_path(weakSelf.history, i)); } content_history_get_path(weakSelf.history, i)); }
detail:^{ return BOXSTRING(rom_history_get_core_name(weakSelf.history, i)); }]; detail:^{ return BOXSTRING(content_history_get_core_name(weakSelf.history, i)); }];
[section addObject:item]; [section addObject:item];
} }

View File

@ -163,7 +163,7 @@ typedef struct
struct gfx_shader *parameter_shader; // Points to either shader or graphics driver current shader. struct gfx_shader *parameter_shader; // Points to either shader or graphics driver current shader.
unsigned current_pad; unsigned current_pad;
rom_history_t *history; content_history_t *history;
retro_time_t last_time; // Used to throttle menu in case VSync is broken. retro_time_t last_time; // Used to throttle menu in case VSync is broken.
struct menu_bind_state binds; struct menu_bind_state binds;

View File

@ -251,7 +251,7 @@ static void load_symbols(bool is_dummy)
else else
{ {
#ifdef HAVE_DYNAMIC #ifdef HAVE_DYNAMIC
// Need to use absolute path for this setting. It can be saved to ROM history, // Need to use absolute path for this setting. It can be saved to content history,
// and a relative path would break in that scenario. // and a relative path would break in that scenario.
path_resolve_realpath(g_settings.libretro, sizeof(g_settings.libretro)); path_resolve_realpath(g_settings.libretro, sizeof(g_settings.libretro));

View File

@ -367,10 +367,10 @@ returntype main_entry(signature())
if (!ret) if (!ret)
#endif #endif
{ {
// If we started a ROM directly from command line, // If we started content directly from command line,
// push it to ROM history. // push it to content history.
if (!g_extern.libretro_dummy) if (!g_extern.libretro_dummy)
menu_rom_history_push_current(); menu_content_history_push_current();
} }
#endif #endif

View File

@ -2138,7 +2138,7 @@ static void menu_parse_and_resolve(unsigned menu_type)
{ {
case MENU_SETTINGS_OPEN_HISTORY: case MENU_SETTINGS_OPEN_HISTORY:
/* History parse */ /* History parse */
list_size = rom_history_size(driver.menu->history); list_size = content_history_size(driver.menu->history);
for (i = 0; i < list_size; i++) for (i = 0; i < list_size; i++)
{ {
@ -2149,7 +2149,7 @@ static void menu_parse_and_resolve(unsigned menu_type)
core_path = NULL; core_path = NULL;
core_name = NULL; core_name = NULL;
rom_history_get_index(driver.menu->history, i, content_history_get_index(driver.menu->history, i,
&path, &core_path, &core_name); &path, &core_path, &core_name);
if (path) if (path)

View File

@ -26,23 +26,23 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
struct rom_history_entry struct content_history_entry
{ {
char *path; char *path;
char *core_path; char *core_path;
char *core_name; char *core_name;
}; };
struct rom_history struct content_history
{ {
struct rom_history_entry *entries; struct content_history_entry *entries;
size_t size; size_t size;
size_t cap; size_t cap;
char *conf_path; char *conf_path;
}; };
void rom_history_get_index(rom_history_t *hist, void content_history_get_index(content_history_t *hist,
size_t index, size_t index,
const char **path, const char **core_path, const char **path, const char **core_path,
const char **core_name) const char **core_name)
@ -55,7 +55,7 @@ void rom_history_get_index(rom_history_t *hist,
*core_name = hist->entries[index].core_name; *core_name = hist->entries[index].core_name;
} }
static void rom_history_free_entry(struct rom_history_entry *entry) static void content_history_free_entry(struct content_history_entry *entry)
{ {
free(entry->path); free(entry->path);
free(entry->core_path); free(entry->core_path);
@ -63,7 +63,7 @@ static void rom_history_free_entry(struct rom_history_entry *entry)
memset(entry, 0, sizeof(*entry)); memset(entry, 0, sizeof(*entry));
} }
void rom_history_push(rom_history_t *hist, void content_history_push(content_history_t *hist,
const char *path, const char *core_path, const char *path, const char *core_path,
const char *core_name) const char *core_name)
{ {
@ -85,9 +85,9 @@ void rom_history_push(rom_history_t *hist,
return; return;
// Seen it before, bump to top. // Seen it before, bump to top.
struct rom_history_entry tmp = hist->entries[i]; struct content_history_entry tmp = hist->entries[i];
memmove(hist->entries + 1, hist->entries, memmove(hist->entries + 1, hist->entries,
i * sizeof(struct rom_history_entry)); i * sizeof(struct content_history_entry));
hist->entries[0] = tmp; hist->entries[0] = tmp;
return; return;
} }
@ -95,12 +95,12 @@ void rom_history_push(rom_history_t *hist,
if (hist->size == hist->cap) if (hist->size == hist->cap)
{ {
rom_history_free_entry(&hist->entries[hist->cap - 1]); content_history_free_entry(&hist->entries[hist->cap - 1]);
hist->size--; hist->size--;
} }
memmove(hist->entries + 1, hist->entries, memmove(hist->entries + 1, hist->entries,
(hist->cap - 1) * sizeof(struct rom_history_entry)); (hist->cap - 1) * sizeof(struct content_history_entry));
hist->entries[0].path = path ? strdup(path) : NULL; hist->entries[0].path = path ? strdup(path) : NULL;
hist->entries[0].core_path = strdup(core_path); hist->entries[0].core_path = strdup(core_path);
@ -108,7 +108,7 @@ void rom_history_push(rom_history_t *hist,
hist->size++; hist->size++;
} }
static void rom_history_write_file(rom_history_t *hist) static void content_history_write_file(content_history_t *hist)
{ {
size_t i; size_t i;
FILE *file = NULL; FILE *file = NULL;
@ -135,42 +135,42 @@ static void rom_history_write_file(rom_history_t *hist)
fclose(file); fclose(file);
} }
void rom_history_free(rom_history_t *hist) void content_history_free(content_history_t *hist)
{ {
size_t i; size_t i;
if (!hist) if (!hist)
return; return;
if (hist->conf_path) if (hist->conf_path)
rom_history_write_file(hist); content_history_write_file(hist);
free(hist->conf_path); free(hist->conf_path);
for (i = 0; i < hist->cap; i++) for (i = 0; i < hist->cap; i++)
rom_history_free_entry(&hist->entries[i]); content_history_free_entry(&hist->entries[i]);
free(hist->entries); free(hist->entries);
free(hist); free(hist);
} }
void rom_history_clear(rom_history_t *hist) void content_history_clear(content_history_t *hist)
{ {
size_t i; size_t i;
if (!hist) if (!hist)
return; return;
for (i = 0; i < hist->cap; i++) for (i = 0; i < hist->cap; i++)
rom_history_free_entry(&hist->entries[i]); content_history_free_entry(&hist->entries[i]);
hist->size = 0; hist->size = 0;
} }
size_t rom_history_size(rom_history_t *hist) size_t content_history_size(content_history_t *hist)
{ {
if (hist) if (hist)
return hist->size; return hist->size;
return 0; return 0;
} }
static bool rom_history_read_file(rom_history_t *hist, const char *path) static bool content_history_read_file(content_history_t *hist, const char *path)
{ {
FILE *file = fopen(path, "r"); FILE *file = fopen(path, "r");
if (!file || !hist) if (!file || !hist)
@ -180,7 +180,7 @@ static bool rom_history_read_file(rom_history_t *hist, const char *path)
} }
char buf[3][PATH_MAX]; char buf[3][PATH_MAX];
struct rom_history_entry *entry = NULL; struct content_history_entry *entry = NULL;
char *last = NULL; char *last = NULL;
unsigned i; unsigned i;
@ -214,33 +214,33 @@ end:
return true; return true;
} }
rom_history_t *rom_history_init(const char *path, size_t size) content_history_t *content_history_init(const char *path, size_t size)
{ {
rom_history_t *hist = (rom_history_t*)calloc(1, sizeof(*hist)); content_history_t *hist = (content_history_t*)calloc(1, sizeof(*hist));
if (!hist) if (!hist)
{ {
RARCH_ERR("Cannot initialize content history.\n"); RARCH_ERR("Cannot initialize content history.\n");
return NULL; return NULL;
} }
hist->entries = (struct rom_history_entry*)calloc(size, sizeof(*hist->entries)); hist->entries = (struct content_history_entry*)calloc(size, sizeof(*hist->entries));
if (!hist->entries) if (!hist->entries)
goto error; goto error;
hist->cap = size; hist->cap = size;
if (!rom_history_read_file(hist, path)) if (!content_history_read_file(hist, path))
goto error; goto error;
hist->conf_path = strdup(path); hist->conf_path = strdup(path);
return hist; return hist;
error: error:
rom_history_free(hist); content_history_free(hist);
return NULL; return NULL;
} }
const char* rom_history_get_path(rom_history_t *hist, unsigned index) const char* content_history_get_path(content_history_t *hist, unsigned index)
{ {
const char *path, *core_path, *core_name; const char *path, *core_path, *core_name;
if (!hist) if (!hist)
@ -250,14 +250,14 @@ const char* rom_history_get_path(rom_history_t *hist, unsigned index)
core_path = NULL; core_path = NULL;
core_name = NULL; core_name = NULL;
rom_history_get_index(hist, index, &path, &core_path, &core_name); content_history_get_index(hist, index, &path, &core_path, &core_name);
if (path) if (path)
return path; return path;
return ""; return "";
} }
const char *rom_history_get_core_path(rom_history_t *hist, unsigned index) const char *content_history_get_core_path(content_history_t *hist, unsigned index)
{ {
const char *path, *core_path, *core_name; const char *path, *core_path, *core_name;
if (!hist) if (!hist)
@ -267,14 +267,14 @@ const char *rom_history_get_core_path(rom_history_t *hist, unsigned index)
core_path = NULL; core_path = NULL;
core_name = NULL; core_name = NULL;
rom_history_get_index(hist, index, &path, &core_path, &core_name); content_history_get_index(hist, index, &path, &core_path, &core_name);
if (core_path) if (core_path)
return core_path; return core_path;
return ""; return "";
} }
const char *rom_history_get_core_name(rom_history_t *hist, unsigned index) const char *content_history_get_core_name(content_history_t *hist, unsigned index)
{ {
const char *path, *core_path, *core_name; const char *path, *core_path, *core_name;
@ -285,7 +285,7 @@ const char *rom_history_get_core_name(rom_history_t *hist, unsigned index)
core_path = NULL; core_path = NULL;
core_name = NULL; core_name = NULL;
rom_history_get_index(hist, index, &path, &core_path, &core_name); content_history_get_index(hist, index, &path, &core_path, &core_name);
if (core_name) if (core_name)
return core_name; return core_name;

View File

@ -22,29 +22,29 @@
extern "C" { extern "C" {
#endif #endif
typedef struct rom_history rom_history_t; typedef struct content_history content_history_t;
rom_history_t *rom_history_init(const char *path, size_t size); content_history_t *content_history_init(const char *path, size_t size);
void rom_history_free(rom_history_t *hist); void content_history_free(content_history_t *hist);
void rom_history_clear(rom_history_t *hist); void content_history_clear(content_history_t *hist);
size_t rom_history_size(rom_history_t *hist); size_t content_history_size(content_history_t *hist);
void rom_history_get_index(rom_history_t *hist, void content_history_get_index(content_history_t *hist,
size_t index, size_t index,
const char **path, const char **core_path, const char **path, const char **core_path,
const char **core_name); const char **core_name);
void rom_history_push(rom_history_t *hist, void content_history_push(content_history_t *hist,
const char *path, const char *core_path, const char *path, const char *core_path,
const char *core_name); const char *core_name);
const char* rom_history_get_path(rom_history_t *hist, const char* content_history_get_path(content_history_t *hist,
unsigned index); unsigned index);
const char* rom_history_get_core_path(rom_history_t *hist, const char* content_history_get_core_path(content_history_t *hist,
unsigned index); unsigned index);
const char* rom_history_get_core_name(rom_history_t *hist, const char* content_history_get_core_name(content_history_t *hist,
unsigned index); unsigned index);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -80,7 +80,7 @@ int menu_defer_core(void *info_, const char *dir, const char *path, char *deferr
return 0; return 0;
} }
void menu_rom_history_push_current(void) void menu_content_history_push_current(void)
{ {
// g_extern.fullpath can be relative here. // g_extern.fullpath can be relative here.
// Ensure we're pushing absolute path. // Ensure we're pushing absolute path.
@ -93,7 +93,7 @@ void menu_rom_history_push_current(void)
if (g_extern.system.no_game || *tmp) if (g_extern.system.no_game || *tmp)
if (driver.menu && driver.menu->history) if (driver.menu && driver.menu->history)
rom_history_push(driver.menu->history, content_history_push(driver.menu->history,
*tmp ? tmp : NULL, *tmp ? tmp : NULL,
g_settings.libretro, g_settings.libretro,
g_extern.system.info.library_name); g_extern.system.info.library_name);
@ -120,7 +120,7 @@ void load_menu_game_prepare(void)
if (g_extern.system.no_game || *g_extern.fullpath) if (g_extern.system.no_game || *g_extern.fullpath)
#endif #endif
if (driver.menu && driver.menu->history) if (driver.menu && driver.menu->history)
rom_history_push(driver.menu->history, content_history_push(driver.menu->history,
*g_extern.fullpath ? g_extern.fullpath : NULL, *g_extern.fullpath ? g_extern.fullpath : NULL,
g_settings.libretro, g_settings.libretro,
driver.menu->info.library_name ? driver.menu->info.library_name : ""); driver.menu->info.library_name ? driver.menu->info.library_name : "");
@ -155,7 +155,7 @@ void load_menu_game_history(unsigned game_index)
if (!driver.menu) if (!driver.menu)
return; return;
rom_history_get_index(driver.menu->history, content_history_get_index(driver.menu->history,
game_index, &path, &core_path, &core_name); game_index, &path, &core_path, &core_name);
strlcpy(g_settings.libretro, core_path, sizeof(g_settings.libretro)); strlcpy(g_settings.libretro, core_path, sizeof(g_settings.libretro));
@ -173,7 +173,7 @@ static void menu_init_history(menu_handle_t *menu)
{ {
if (menu->history) if (menu->history)
{ {
rom_history_free(menu->history); content_history_free(menu->history);
menu->history = NULL; menu->history = NULL;
} }
@ -189,7 +189,7 @@ static void menu_init_history(menu_handle_t *menu)
} }
RARCH_LOG("[Menu]: Opening history: %s.\n", history_path); RARCH_LOG("[Menu]: Opening history: %s.\n", history_path);
menu->history = rom_history_init(history_path, g_settings.game_history_size); menu->history = content_history_init(history_path, g_settings.game_history_size);
} }
} }
@ -349,7 +349,7 @@ void menu_free(void *data)
file_list_free(menu->menu_stack); file_list_free(menu->menu_stack);
file_list_free(menu->selection_buf); file_list_free(menu->selection_buf);
rom_history_free(menu->history); content_history_free(menu->history);
core_info_list_free(menu->core_info); core_info_list_free(menu->core_info);
if (menu->core_info_current) if (menu->core_info_current)

View File

@ -107,7 +107,7 @@ void load_menu_game_prepare(void);
void load_menu_game_prepare_dummy(void); void load_menu_game_prepare_dummy(void);
bool load_menu_game(void); bool load_menu_game(void);
void load_menu_game_history(unsigned game_index); void load_menu_game_history(unsigned game_index);
void menu_rom_history_push_current(void); void menu_content_history_push_current(void);
bool menu_replace_config(const char *path); bool menu_replace_config(const char *path);

View File

@ -47,10 +47,10 @@ int main(int argc, char *argv[])
#ifdef HAVE_MENU #ifdef HAVE_MENU
g_extern.lifecycle_state |= 1ULL << MODE_GAME; g_extern.lifecycle_state |= 1ULL << MODE_GAME;
// If we started a ROM directly from command line, // If we started content directly from command line,
// push it to ROM history. // push it to content history.
if (!g_extern.libretro_dummy) if (!g_extern.libretro_dummy)
menu_rom_history_push_current(); menu_content_history_push_current();
#endif #endif
emscripten_set_main_loop(emscripten_mainloop, g_settings.video.vsync ? 0 : INT_MAX, 1); emscripten_set_main_loop(emscripten_mainloop, g_settings.video.vsync ? 0 : INT_MAX, 1);