ios: Add support for enumeration and file based settings.
This commit is contained in:
parent
582ba2ccd5
commit
72543d1310
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
@property (strong, nonatomic) UIWindow *window;
|
@property (strong, nonatomic) UIWindow *window;
|
||||||
@property (strong, nonatomic) NSString *module_path;
|
@property (strong, nonatomic) NSString *module_path;
|
||||||
|
@property (strong, nonatomic) NSString *overlay_path;
|
||||||
@property (strong, nonatomic) UINavigationController *navigator;
|
@property (strong, nonatomic) UINavigationController *navigator;
|
||||||
@property (strong, nonatomic) UIImage* file_icon;
|
@property (strong, nonatomic) UIImage* file_icon;
|
||||||
@property (strong, nonatomic) UIImage* folder_icon;
|
@property (strong, nonatomic) UIImage* folder_icon;
|
||||||
|
|
|
@ -31,6 +31,8 @@ extern uint32_t ios_current_touch_count ;
|
||||||
self.system_directory = "/var/mobile/Library/RetroArch/";
|
self.system_directory = "/var/mobile/Library/RetroArch/";
|
||||||
mkdir(self.system_directory, 0755);
|
mkdir(self.system_directory, 0755);
|
||||||
|
|
||||||
|
self.overlay_path = [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/overlays"];
|
||||||
|
|
||||||
// Load icons
|
// Load icons
|
||||||
self.file_icon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ic_file" ofType:@"png"]];
|
self.file_icon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ic_file" ofType:@"png"]];
|
||||||
self.folder_icon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ic_dir" ofType:@"png"]];
|
self.folder_icon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ic_dir" ofType:@"png"]];
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
// Copyright (c) 2013 RetroArch. All rights reserved.
|
// Copyright (c) 2013 RetroArch. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
static NSDictionary* boolean_setting(NSString* name, NSString* label, NSString* value)
|
static NSMutableDictionary* boolean_setting(NSString* name, NSString* label, NSString* value)
|
||||||
{
|
{
|
||||||
return [[NSDictionary alloc] initWithObjectsAndKeys:
|
return [[NSMutableDictionary alloc] initWithObjectsAndKeys:
|
||||||
@"B", @"TYPE",
|
@"B", @"TYPE",
|
||||||
name, @"NAME",
|
name, @"NAME",
|
||||||
label, @"LABEL",
|
label, @"LABEL",
|
||||||
|
@ -16,6 +16,81 @@ static NSDictionary* boolean_setting(NSString* name, NSString* label, NSString*
|
||||||
nil];
|
nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static NSMutableDictionary* enumeration_setting(NSString* name, NSString* label, NSString* value, NSArray* values)
|
||||||
|
{
|
||||||
|
return [[NSMutableDictionary alloc] initWithObjectsAndKeys:
|
||||||
|
@"E", @"TYPE",
|
||||||
|
name, @"NAME",
|
||||||
|
label, @"LABEL",
|
||||||
|
value, @"VALUE",
|
||||||
|
values, @"VALUES",
|
||||||
|
nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
static NSMutableDictionary* subpath_setting(NSString* name, NSString* label, NSString* value, NSString* path, NSString* extension)
|
||||||
|
{
|
||||||
|
NSArray* values = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath:[RetroArch_iOS get].overlay_path error:nil];
|
||||||
|
values = [values pathsMatchingExtensions:[NSArray arrayWithObject:extension]];
|
||||||
|
|
||||||
|
return [[NSMutableDictionary alloc] initWithObjectsAndKeys:
|
||||||
|
@"F", @"TYPE",
|
||||||
|
name, @"NAME",
|
||||||
|
label, @"LABEL",
|
||||||
|
value, @"VALUE",
|
||||||
|
values, @"VALUES",
|
||||||
|
path, @"PATH",
|
||||||
|
nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
@interface enumeration_list : UITableViewController
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation enumeration_list
|
||||||
|
{
|
||||||
|
NSMutableDictionary* value;
|
||||||
|
UITableView* view;
|
||||||
|
};
|
||||||
|
|
||||||
|
- (id)initWithSetting:(NSMutableDictionary*)setting fromTable:(UITableView*)table
|
||||||
|
{
|
||||||
|
self = [super initWithStyle:UITableViewStyleGrouped];
|
||||||
|
|
||||||
|
value = setting;
|
||||||
|
view = table;
|
||||||
|
[self setTitle: [value objectForKey:@"LABEL"]];
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||||
|
{
|
||||||
|
return [[value objectForKey:@"VALUES"] count];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||||
|
{
|
||||||
|
UITableViewCell* cell = [self.tableView dequeueReusableCellWithIdentifier:@"option"];
|
||||||
|
cell = cell ? cell : [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"option"];
|
||||||
|
|
||||||
|
cell.textLabel.text = [[value objectForKey:@"VALUES"] objectAtIndex:indexPath.row];
|
||||||
|
|
||||||
|
return cell;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||||
|
{
|
||||||
|
[value setObject:[[value objectForKey:@"VALUES"] objectAtIndex:indexPath.row] forKey:@"VALUE"];
|
||||||
|
|
||||||
|
[view reloadData];
|
||||||
|
[[RetroArch_iOS get].navigator popViewControllerAnimated:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation settings_list
|
@implementation settings_list
|
||||||
{
|
{
|
||||||
NSArray* settings;
|
NSArray* settings;
|
||||||
|
@ -25,6 +100,7 @@ static NSDictionary* boolean_setting(NSString* name, NSString* label, NSString*
|
||||||
{
|
{
|
||||||
self = [super initWithStyle:UITableViewStyleGrouped];
|
self = [super initWithStyle:UITableViewStyleGrouped];
|
||||||
|
|
||||||
|
|
||||||
settings = [NSArray arrayWithObjects:
|
settings = [NSArray arrayWithObjects:
|
||||||
[NSArray arrayWithObjects:@"Video",
|
[NSArray arrayWithObjects:@"Video",
|
||||||
boolean_setting(@"video_smooth", @"Smooth Video", @"true"),
|
boolean_setting(@"video_smooth", @"Smooth Video", @"true"),
|
||||||
|
@ -36,6 +112,10 @@ static NSDictionary* boolean_setting(NSString* name, NSString* label, NSString*
|
||||||
boolean_setting(@"audio_sync", @"Sync on Audio Stream", @"true"),
|
boolean_setting(@"audio_sync", @"Sync on Audio Stream", @"true"),
|
||||||
boolean_setting(@"audio_rate_control", @"Adjust for Better Sync", @"true"),
|
boolean_setting(@"audio_rate_control", @"Adjust for Better Sync", @"true"),
|
||||||
nil],
|
nil],
|
||||||
|
|
||||||
|
[NSArray arrayWithObjects:@"Input",
|
||||||
|
subpath_setting(@"input_overlay", @"Input Overlay", @"", [RetroArch_iOS get].overlay_path, @"cfg"),
|
||||||
|
nil],
|
||||||
|
|
||||||
[NSArray arrayWithObjects:@"Save States",
|
[NSArray arrayWithObjects:@"Save States",
|
||||||
boolean_setting(@"rewind_enable", @"Enable Rewinding", @"false"),
|
boolean_setting(@"rewind_enable", @"Enable Rewinding", @"false"),
|
||||||
|
@ -65,9 +145,12 @@ static NSDictionary* boolean_setting(NSString* name, NSString* label, NSString*
|
||||||
|
|
||||||
for (int j = 1; j < [group count]; j ++)
|
for (int j = 1; j < [group count]; j ++)
|
||||||
{
|
{
|
||||||
NSDictionary* setting = [group objectAtIndex:j];
|
NSMutableDictionary* setting = [group objectAtIndex:j];
|
||||||
|
|
||||||
fprintf(output, "%s = %s\n", [[setting objectForKey:@"NAME"] UTF8String], [[setting objectForKey:@"VALUE"] UTF8String]);
|
if ([[setting objectForKey:@"TYPE"] isEqualToString:@"F"])
|
||||||
|
fprintf(output, "%s = \"%s/%s\"\n", [[setting objectForKey:@"NAME"] UTF8String], [[setting objectForKey:@"PATH"] UTF8String], [[setting objectForKey:@"VALUE"] UTF8String]);
|
||||||
|
else
|
||||||
|
fprintf(output, "%s = %s\n", [[setting objectForKey:@"NAME"] UTF8String], [[setting objectForKey:@"VALUE"] UTF8String]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,10 +159,20 @@ static NSDictionary* boolean_setting(NSString* name, NSString* label, NSString*
|
||||||
|
|
||||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
|
NSMutableDictionary* setting = [[settings objectAtIndex:indexPath.section] objectAtIndex:indexPath.row + 1];
|
||||||
|
NSString* type = [setting valueForKey:@"TYPE"];
|
||||||
|
|
||||||
|
if ([type isEqualToString:@"E"] || [type isEqualToString:@"F"])
|
||||||
|
{
|
||||||
|
[[RetroArch_iOS get].navigator
|
||||||
|
pushViewController:[[enumeration_list alloc] initWithSetting:setting fromTable:(UITableView*)self.view]
|
||||||
|
animated:YES];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||||
{
|
{
|
||||||
|
[self write_to_file];
|
||||||
return [settings count];
|
return [settings count];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,10 +188,12 @@ static NSDictionary* boolean_setting(NSString* name, NSString* label, NSString*
|
||||||
|
|
||||||
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
NSDictionary* setting = [[settings objectAtIndex:indexPath.section] objectAtIndex:indexPath.row + 1];
|
NSMutableDictionary* setting = [[settings objectAtIndex:indexPath.section] objectAtIndex:indexPath.row + 1];
|
||||||
UITableViewCell* cell = nil;
|
UITableViewCell* cell = nil;
|
||||||
|
|
||||||
if ([[setting valueForKey:@"TYPE"] isEqualToString:@"B"])
|
NSString* type = [setting valueForKey:@"TYPE"];
|
||||||
|
|
||||||
|
if ([type isEqualToString:@"B"])
|
||||||
{
|
{
|
||||||
cell = [self.tableView dequeueReusableCellWithIdentifier:@"boolean"];
|
cell = [self.tableView dequeueReusableCellWithIdentifier:@"boolean"];
|
||||||
|
|
||||||
|
@ -112,8 +207,18 @@ static NSDictionary* boolean_setting(NSString* name, NSString* label, NSString*
|
||||||
UISwitch* swt = (UISwitch*)cell.accessoryView;
|
UISwitch* swt = (UISwitch*)cell.accessoryView;
|
||||||
swt.on = [[setting valueForKey:@"VALUE"] isEqualToString:@"true"];
|
swt.on = [[setting valueForKey:@"VALUE"] isEqualToString:@"true"];
|
||||||
}
|
}
|
||||||
|
else if ([type isEqualToString:@"E"] || [type isEqualToString:@"F"])
|
||||||
|
{
|
||||||
|
cell = [self.tableView dequeueReusableCellWithIdentifier:@"enumeration"];
|
||||||
|
|
||||||
|
if (cell == nil)
|
||||||
|
{
|
||||||
|
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"enumeration"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cell.textLabel.text = [setting valueForKey:@"LABEL"];
|
cell.textLabel.text = [setting valueForKey:@"LABEL"];
|
||||||
|
cell.detailTextLabel.text = [setting valueForKey:@"VALUE"];
|
||||||
|
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue