(iOS) menu.m - use g_defaults.history

This commit is contained in:
Twinaphex 2014-10-17 05:12:57 +02:00
parent 8860784068
commit c82145ff48
2 changed files with 19 additions and 20 deletions

View File

@ -118,8 +118,7 @@
/* launching a file from the content history. */ /* launching a file from the content history. */
/*************************************************/ /*************************************************/
@interface RAHistoryMenu : RAMenuBase @interface RAHistoryMenu : RAMenuBase
@property (nonatomic) content_playlist_t* history; - (id)init;
- (id)initWithHistoryPath:(const char*)historyPath;
@end @end
/*********************************************/ /*********************************************/

View File

@ -653,9 +653,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
- (void)loadHistory - (void)loadHistory
{ {
char history_path[PATH_MAX]; [self.navigationController pushViewController:[[RAHistoryMenu alloc] init] animated:YES];
fill_pathname_join(history_path, g_defaults.system_dir, "retroarch-content-history.txt", sizeof(history_path));
[self.navigationController pushViewController:[[RAHistoryMenu alloc] initWithHistoryPath:history_path] animated:YES];
} }
@end @end
@ -669,18 +667,17 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
- (void)dealloc - (void)dealloc
{ {
if (self.history)
content_playlist_free(self.history);
} }
- (id)initWithHistoryPath:(const char*)historyPath - (id)init
{ {
if ((self = [super initWithStyle:UITableViewStylePlain])) if ((self = [super initWithStyle:UITableViewStylePlain]))
{ {
self.history = content_playlist_init(historyPath, 100); if (g_defaults.history)
{
[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)]; }
} }
return self; return self;
@ -688,25 +685,27 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
- (void)clearHistory - (void)clearHistory
{ {
if (self.history) if (g_defaults.history)
content_playlist_clear(self.history); content_playlist_clear(g_defaults.history);
[self reloadData]; [self reloadData];
} }
- (void)willReloadData - (void)willReloadData
{ {
size_t i; size_t i;
RAHistoryMenu* __weak weakSelf = self;
NSMutableArray *section = [NSMutableArray arrayWithObject:BOXSTRING("")]; NSMutableArray *section = [NSMutableArray arrayWithObject:BOXSTRING("")];
for (i = 0; self.history && i < content_playlist_size(self.history); i ++) if (!g_defaults.history)
return;
for (i = 0; i < content_playlist_size(g_defaults.history); i ++)
{ {
RAMenuItemBasic *item; RAMenuItemBasic *item;
const char *path = NULL; const char *path = NULL;
const char *core_path = NULL; const char *core_path = NULL;
const char *core_name = NULL; const char *core_name = NULL;
content_playlist_get_index(weakSelf.history, i, &path, &core_path, &core_name); content_playlist_get_index(g_defaults.history, i, &path, &core_path, &core_name);
item = [ item = [
RAMenuItemBasic itemWithDescription:BOXSTRING(path_basename(path ? path : "")) RAMenuItemBasic itemWithDescription:BOXSTRING(path_basename(path ? path : ""))
@ -716,7 +715,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
const char *core_path = NULL; const char *core_path = NULL;
const char *core_name = NULL; const char *core_name = NULL;
content_playlist_get_index(weakSelf.history, i, &path, &core_path, &core_name); content_playlist_get_index(g_defaults.history, i, &path, &core_path, &core_name);
if (!path || !core_path) if (!path || !core_path)
return; return;
@ -732,7 +731,8 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
const char *core_path = NULL; const char *core_path = NULL;
const char *core_name = NULL; const char *core_name = NULL;
content_playlist_get_index(weakSelf.history, i, &path, &core_path, &core_name); if (g_defaults.history)
content_playlist_get_index(g_defaults.history, i, &path, &core_path, &core_name);
if (core_name) if (core_name)
return BOXSTRING(core_name); return BOXSTRING(core_name);