mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 03:39:59 +00:00
(iOS) Add option to clear Load History menu, useful when you need to invalidate history after the GUID of the install directory gets changed.
This commit is contained in:
parent
12c1725ea6
commit
b35153855c
@ -84,6 +84,17 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
|
|||||||
[[self itemForIndexPath:indexPath] wasSelectedOnTableView:tableView ofController:self];
|
[[self itemForIndexPath:indexPath] wasSelectedOnTableView:tableView ofController:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)willReloadData
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)reloadData
|
||||||
|
{
|
||||||
|
[self willReloadData];
|
||||||
|
[[self tableView] reloadData];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/*********************************************/
|
/*********************************************/
|
||||||
@ -505,33 +516,49 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
|
|||||||
/*********************************************/
|
/*********************************************/
|
||||||
@implementation RAHistoryMenu
|
@implementation RAHistoryMenu
|
||||||
|
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
if (_history)
|
||||||
|
rom_history_free(_history);
|
||||||
|
}
|
||||||
|
|
||||||
- (id)initWithHistoryPath:(NSString *)historyPath
|
- (id)initWithHistoryPath:(NSString *)historyPath
|
||||||
{
|
{
|
||||||
if ((self = [super initWithStyle:UITableViewStylePlain]))
|
if ((self = [super initWithStyle:UITableViewStylePlain]))
|
||||||
{
|
{
|
||||||
RAHistoryMenu* __weak weakSelf = self;
|
|
||||||
|
|
||||||
_history = rom_history_init(historyPath.UTF8String, 100);
|
_history = rom_history_init(historyPath.UTF8String, 100);
|
||||||
|
[self reloadData];
|
||||||
NSMutableArray* section = [NSMutableArray arrayWithObject:@""];
|
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Clear History"
|
||||||
[self.sections addObject:section];
|
style:UIBarButtonItemStyleBordered target:self action:@selector(clearHistory)];
|
||||||
|
|
||||||
for (int i = 0; _history && i != rom_history_size(_history); i ++)
|
|
||||||
{
|
|
||||||
RAMenuItemBasic* item = [RAMenuItemBasic itemWithDescription:BOXSTRING(path_basename(apple_rom_history_get_path(weakSelf.history, i)))
|
|
||||||
action:^{ apple_run_core(BOXSTRING(apple_rom_history_get_core_path(weakSelf.history, i)),
|
|
||||||
apple_rom_history_get_path(weakSelf.history, i)); }
|
|
||||||
detail:^{ return BOXSTRING(apple_rom_history_get_core_name(weakSelf.history, i)); }];
|
|
||||||
[section addObject:item];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)clearHistory
|
||||||
{
|
{
|
||||||
rom_history_free(self.history);
|
if (_history)
|
||||||
|
rom_history_clear(_history);
|
||||||
|
[self reloadData];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)willReloadData
|
||||||
|
{
|
||||||
|
printf("DOING\n");
|
||||||
|
|
||||||
|
RAHistoryMenu* __weak weakSelf = self;
|
||||||
|
NSMutableArray* section = [NSMutableArray arrayWithObject:@""];
|
||||||
|
|
||||||
|
for (int i = 0; _history && i != rom_history_size(_history); i ++)
|
||||||
|
{
|
||||||
|
RAMenuItemBasic* item = [RAMenuItemBasic itemWithDescription:BOXSTRING(path_basename(apple_rom_history_get_path(weakSelf.history, i)))
|
||||||
|
action:^{ apple_run_core(BOXSTRING(apple_rom_history_get_core_path(weakSelf.history, i)),
|
||||||
|
apple_rom_history_get_path(weakSelf.history, i)); }
|
||||||
|
detail:^{ return BOXSTRING(apple_rom_history_get_core_name(weakSelf.history, i)); }];
|
||||||
|
[section addObject:item];
|
||||||
|
}
|
||||||
|
|
||||||
|
self.sections = [NSMutableArray arrayWithObject:section];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -134,6 +134,14 @@ void rom_history_free(rom_history_t *hist)
|
|||||||
free(hist);
|
free(hist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rom_history_clear(rom_history_t *hist)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
for (i = 0; i < hist->cap; i++)
|
||||||
|
rom_history_free_entry(&hist->entries[i]);
|
||||||
|
hist->size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
size_t rom_history_size(rom_history_t *hist)
|
size_t rom_history_size(rom_history_t *hist)
|
||||||
{
|
{
|
||||||
return hist->size;
|
return hist->size;
|
||||||
|
@ -27,6 +27,8 @@ typedef struct rom_history rom_history_t;
|
|||||||
rom_history_t *rom_history_init(const char *path, size_t size);
|
rom_history_t *rom_history_init(const char *path, size_t size);
|
||||||
void rom_history_free(rom_history_t *hist);
|
void rom_history_free(rom_history_t *hist);
|
||||||
|
|
||||||
|
void rom_history_clear(rom_history_t *hist);
|
||||||
|
|
||||||
size_t rom_history_size(rom_history_t *hist);
|
size_t rom_history_size(rom_history_t *hist);
|
||||||
|
|
||||||
void rom_history_get_index(rom_history_t *hist,
|
void rom_history_get_index(rom_history_t *hist,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user