ios: First draft of settings menu.
This commit is contained in:
parent
73fc504546
commit
582ba2ccd5
|
@ -15,6 +15,7 @@
|
|||
96297A0F16C5AEA100E6DCE0 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 96297A0E16C5AEA100E6DCE0 /* main.m */; };
|
||||
96297A1116C5AEDE00E6DCE0 /* game_view.m in Sources */ = {isa = PBXBuildFile; fileRef = 96297A1016C5AEDE00E6DCE0 /* game_view.m */; };
|
||||
96297A1316C5AEFD00E6DCE0 /* directory_list.m in Sources */ = {isa = PBXBuildFile; fileRef = 96297A1216C5AEFD00E6DCE0 /* directory_list.m */; };
|
||||
96297A1D16C6D20900E6DCE0 /* settings_list.m in Sources */ = {isa = PBXBuildFile; fileRef = 96297A1C16C6D20900E6DCE0 /* settings_list.m */; };
|
||||
96AFAE2A16C1D4EA009DE44C /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96AFAE2916C1D4EA009DE44C /* UIKit.framework */; };
|
||||
96AFAE2C16C1D4EA009DE44C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96AFAE2B16C1D4EA009DE44C /* Foundation.framework */; };
|
||||
96AFAE2E16C1D4EA009DE44C /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96AFAE2D16C1D4EA009DE44C /* CoreGraphics.framework */; };
|
||||
|
@ -89,6 +90,7 @@
|
|||
96297A0E16C5AEA100E6DCE0 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
96297A1016C5AEDE00E6DCE0 /* game_view.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = game_view.m; sourceTree = "<group>"; };
|
||||
96297A1216C5AEFD00E6DCE0 /* directory_list.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = directory_list.m; sourceTree = "<group>"; };
|
||||
96297A1C16C6D20900E6DCE0 /* settings_list.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = settings_list.m; sourceTree = "<group>"; };
|
||||
96AFAE2516C1D4EA009DE44C /* RetroArch.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RetroArch.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
96AFAE2916C1D4EA009DE44C /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
|
||||
96AFAE2B16C1D4EA009DE44C /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
|
@ -338,6 +340,7 @@
|
|||
96AFAE3416C1D4EA009DE44C /* Supporting Files */,
|
||||
96CF015B16C2F72900ABF9C9 /* ios_input.c */,
|
||||
96297A0816C59EC000E6DCE0 /* module_list.m */,
|
||||
96297A1C16C6D20900E6DCE0 /* settings_list.m */,
|
||||
);
|
||||
path = RetroArch;
|
||||
sourceTree = "<group>";
|
||||
|
@ -785,6 +788,7 @@
|
|||
96297A0F16C5AEA100E6DCE0 /* main.m in Sources */,
|
||||
96297A1116C5AEDE00E6DCE0 /* game_view.m in Sources */,
|
||||
96297A1316C5AEFD00E6DCE0 /* directory_list.m in Sources */,
|
||||
96297A1D16C6D20900E6DCE0 /* settings_list.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -40,6 +40,8 @@ extern uint32_t ios_current_touch_count ;
|
|||
initWithTitle:@"Settings"
|
||||
style:UIBarButtonItemStyleBordered
|
||||
target:nil action:nil];
|
||||
self.settings_button.target = self;
|
||||
self.settings_button.action = @selector(show_settings);
|
||||
|
||||
// Setup window
|
||||
self.navigator = [[UINavigationController alloc] init];
|
||||
|
@ -50,6 +52,11 @@ extern uint32_t ios_current_touch_count ;
|
|||
[self.window makeKeyAndVisible];
|
||||
}
|
||||
|
||||
- (void)show_settings
|
||||
{
|
||||
[self.navigator pushViewController: [[settings_list alloc] init] animated:YES];
|
||||
}
|
||||
|
||||
- (void)processTouches:(NSArray*)touches
|
||||
{
|
||||
ios_current_touch_count = [touches count];
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
//
|
||||
// settings_list.m
|
||||
// RetroArch
|
||||
//
|
||||
// Created by Jason Fetters on 2/8/13.
|
||||
// Copyright (c) 2013 RetroArch. All rights reserved.
|
||||
//
|
||||
|
||||
static NSDictionary* boolean_setting(NSString* name, NSString* label, NSString* value)
|
||||
{
|
||||
return [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||
@"B", @"TYPE",
|
||||
name, @"NAME",
|
||||
label, @"LABEL",
|
||||
value, @"VALUE",
|
||||
nil];
|
||||
}
|
||||
|
||||
@implementation settings_list
|
||||
{
|
||||
NSArray* settings;
|
||||
};
|
||||
|
||||
- (id)init
|
||||
{
|
||||
self = [super initWithStyle:UITableViewStyleGrouped];
|
||||
|
||||
settings = [NSArray arrayWithObjects:
|
||||
[NSArray arrayWithObjects:@"Video",
|
||||
boolean_setting(@"video_smooth", @"Smooth Video", @"true"),
|
||||
boolean_setting(@"video_crop_overscan", @"Crop Overscan", @"false"),
|
||||
nil],
|
||||
|
||||
[NSArray arrayWithObjects:@"Audio",
|
||||
boolean_setting(@"audio_enable", @"Enable Output", @"true"),
|
||||
boolean_setting(@"audio_sync", @"Sync on Audio Stream", @"true"),
|
||||
boolean_setting(@"audio_rate_control", @"Adjust for Better Sync", @"true"),
|
||||
nil],
|
||||
|
||||
[NSArray arrayWithObjects:@"Save States",
|
||||
boolean_setting(@"rewind_enable", @"Enable Rewinding", @"false"),
|
||||
boolean_setting(@"block_sram_overwrite", @"Disable SRAM on Load", @"false"),
|
||||
boolean_setting(@"savestate_auto_save", @"Auto Save on Exit", @"false"),
|
||||
boolean_setting(@"savestate_auto_load", @"Auto Load on Startup", @"true"),
|
||||
nil],
|
||||
nil
|
||||
];
|
||||
|
||||
[self setTitle:@"RetroArch Settings"];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)write_to_file
|
||||
{
|
||||
const char* const sd = [RetroArch_iOS get].system_directory;
|
||||
char config_path[PATH_MAX];
|
||||
snprintf(config_path, PATH_MAX, "%s/retroarch.cfg", sd);
|
||||
config_path[PATH_MAX - 1] = 0;
|
||||
|
||||
FILE* output = fopen(config_path, "w");
|
||||
|
||||
for (int i = 0; i != [settings count]; i ++)
|
||||
{
|
||||
NSArray* group = [settings objectAtIndex:i];
|
||||
|
||||
for (int j = 1; j < [group count]; j ++)
|
||||
{
|
||||
NSDictionary* setting = [group objectAtIndex:j];
|
||||
|
||||
fprintf(output, "%s = %s\n", [[setting objectForKey:@"NAME"] UTF8String], [[setting objectForKey:@"VALUE"] UTF8String]);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(output);
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||
{
|
||||
return [settings count];
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return [[settings objectAtIndex:section] count] -1;
|
||||
}
|
||||
|
||||
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
return [[settings objectAtIndex:section] objectAtIndex:0];
|
||||
}
|
||||
|
||||
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
NSDictionary* setting = [[settings objectAtIndex:indexPath.section] objectAtIndex:indexPath.row + 1];
|
||||
UITableViewCell* cell = nil;
|
||||
|
||||
if ([[setting valueForKey:@"TYPE"] isEqualToString:@"B"])
|
||||
{
|
||||
cell = [self.tableView dequeueReusableCellWithIdentifier:@"boolean"];
|
||||
|
||||
if (cell == nil)
|
||||
{
|
||||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"boolean"];
|
||||
cell.accessoryView = [[UISwitch alloc] init];
|
||||
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
|
||||
}
|
||||
|
||||
UISwitch* swt = (UISwitch*)cell.accessoryView;
|
||||
swt.on = [[setting valueForKey:@"VALUE"] isEqualToString:@"true"];
|
||||
}
|
||||
|
||||
cell.textLabel.text = [setting valueForKey:@"LABEL"];
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
@end
|
|
@ -12,3 +12,6 @@
|
|||
@interface directory_list : UITableViewController
|
||||
- (id)initWithPath:(NSString*)path;
|
||||
@end
|
||||
|
||||
@interface settings_list : UITableViewController
|
||||
@end
|
Loading…
Reference in New Issue