mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-09-02 15:32:49 +02:00
Add an option to view the Library in Files
This commit is contained in:
@@ -16,6 +16,12 @@
|
||||
{
|
||||
self = [super initWithStyle:UITableViewStyleGrouped];
|
||||
self.navigationItem.rightBarButtonItem = self.editButtonItem;
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(deselectRow)
|
||||
name:UIApplicationDidBecomeActiveNotification
|
||||
object:nil];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -26,7 +32,7 @@
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
if (section == 1) return 1;
|
||||
if (section == 1) return 2;
|
||||
return [GBROMManager sharedManager].allROMs.count;
|
||||
}
|
||||
|
||||
@@ -34,7 +40,10 @@
|
||||
{
|
||||
if (indexPath.section == 1) {
|
||||
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
|
||||
cell.textLabel.text = @"Import ROM files";
|
||||
switch (indexPath.item) {
|
||||
case 0: cell.textLabel.text = @"Import ROM files"; break;
|
||||
case 1: cell.textLabel.text = @"Show Library in Files"; break;
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
|
||||
@@ -83,6 +92,8 @@
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (indexPath.section == 1) {
|
||||
switch (indexPath.item) {
|
||||
case 0: {
|
||||
UIViewController *parent = self.presentingViewController;
|
||||
NSString *gbUTI = (__bridge_transfer NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)@"gb", NULL);
|
||||
NSString *gbcUTI = (__bridge_transfer NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)@"gbc", NULL);
|
||||
@@ -127,6 +138,14 @@
|
||||
}];
|
||||
return;
|
||||
}
|
||||
case 1: {
|
||||
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"shareddocuments://%@", NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true).firstObject]]
|
||||
options:nil
|
||||
completionHandler:nil];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
[GBROMManager sharedManager].currentROM = [GBROMManager sharedManager].allROMs[[indexPath indexAtPosition:1]];
|
||||
[self.presentingViewController dismissViewControllerAnimated:true completion:^{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBROMChanged" object:nil];
|
||||
@@ -297,4 +316,11 @@ contextMenuConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)deselectRow
|
||||
{
|
||||
if (self.tableView.indexPathForSelectedRow) {
|
||||
[self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:true];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
Reference in New Issue
Block a user