mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 22:13:51 +00:00
ios: Clean up settings code some; move input settings into sub-pages.
This commit is contained in:
parent
0d99d9fbf8
commit
625c2c6d48
@ -26,6 +26,7 @@
|
||||
96366C7416CAF62200D64A22 /* button_getter.m in Sources */ = {isa = PBXBuildFile; fileRef = 96366C7016CAF62200D64A22 /* button_getter.m */; };
|
||||
96366C7516CAF62200D64A22 /* enumeration_list.m in Sources */ = {isa = PBXBuildFile; fileRef = 96366C7116CAF62200D64A22 /* enumeration_list.m */; };
|
||||
96366C7616CAF62200D64A22 /* settings_list.m in Sources */ = {isa = PBXBuildFile; fileRef = 96366C7316CAF62200D64A22 /* settings_list.m */; };
|
||||
963F5AB216CC14C4009BBD19 /* settings_sublist.m in Sources */ = {isa = PBXBuildFile; fileRef = 963F5AB116CC14C4009BBD19 /* settings_sublist.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 */; };
|
||||
@ -108,6 +109,7 @@
|
||||
96366C7116CAF62200D64A22 /* enumeration_list.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = enumeration_list.m; sourceTree = "<group>"; };
|
||||
96366C7216CAF62200D64A22 /* settings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = settings.h; sourceTree = "<group>"; };
|
||||
96366C7316CAF62200D64A22 /* settings_list.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = settings_list.m; sourceTree = "<group>"; };
|
||||
963F5AB116CC14C4009BBD19 /* settings_sublist.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = settings_sublist.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; };
|
||||
@ -317,6 +319,7 @@
|
||||
96366C7116CAF62200D64A22 /* enumeration_list.m */,
|
||||
96366C7216CAF62200D64A22 /* settings.h */,
|
||||
96366C7316CAF62200D64A22 /* settings_list.m */,
|
||||
963F5AB116CC14C4009BBD19 /* settings_sublist.m */,
|
||||
);
|
||||
path = settings;
|
||||
sourceTree = "<group>";
|
||||
@ -829,6 +832,7 @@
|
||||
96366C7416CAF62200D64A22 /* button_getter.m in Sources */,
|
||||
96366C7516CAF62200D64A22 /* enumeration_list.m in Sources */,
|
||||
96366C7616CAF62200D64A22 /* settings_list.m in Sources */,
|
||||
963F5AB216CC14C4009BBD19 /* settings_sublist.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -88,7 +88,7 @@ extern uint32_t ios_current_touch_count;
|
||||
|
||||
- (void)show_settings
|
||||
{
|
||||
[self.navigator pushViewController: [[settings_list alloc] init] animated:YES];
|
||||
[self.navigator pushViewController: [[SettingsList alloc] init] animated:YES];
|
||||
}
|
||||
|
||||
- (void)processTouches:(NSArray*)touches
|
||||
|
@ -57,7 +57,7 @@ static bool is_syncing = true;
|
||||
|
||||
- (void)runGame
|
||||
{
|
||||
[settings_list refresh_config_file];
|
||||
[SettingsList refreshConfigFile];
|
||||
|
||||
const char* const sd = [[RetroArch_iOS get].system_directory UTF8String];
|
||||
const char* const cf =[[RetroArch_iOS get].config_file_path UTF8String];
|
||||
|
@ -65,7 +65,7 @@ static const struct
|
||||
{ "nul", 0x00},
|
||||
};
|
||||
|
||||
static const NSString* get_key_config_name(uint32_t hid_id)
|
||||
static NSString* get_key_config_name(uint32_t hid_id)
|
||||
{
|
||||
for (int i = 0; ios_key_name_map[i].hid_id; i ++)
|
||||
{
|
||||
@ -78,15 +78,15 @@ static const NSString* get_key_config_name(uint32_t hid_id)
|
||||
return @"nul";
|
||||
}
|
||||
|
||||
@implementation button_getter
|
||||
@implementation ButtonGetter
|
||||
{
|
||||
button_getter* me;
|
||||
NSMutableDictionary* value;
|
||||
ButtonGetter* me;
|
||||
SettingData* value;
|
||||
UIAlertView* alert;
|
||||
UITableView* view;
|
||||
}
|
||||
|
||||
- (id)initWithSetting:(NSMutableDictionary*)setting fromTable:(UITableView*)table
|
||||
- (id)initWithSetting:(SettingData*)setting fromTable:(UITableView*)table
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
@ -95,7 +95,7 @@ static const NSString* get_key_config_name(uint32_t hid_id)
|
||||
me = self;
|
||||
|
||||
alert = [[UIAlertView alloc] initWithTitle:@"RetroArch"
|
||||
message:[value objectForKey:@"LABEL"]
|
||||
message:value.label
|
||||
delegate:self
|
||||
cancelButtonTitle:@"Cancel"
|
||||
otherButtonTitles:nil];
|
||||
@ -106,7 +106,7 @@ static const NSString* get_key_config_name(uint32_t hid_id)
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
|
||||
- (void)alertView:(UIAlertView*)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
me = nil;
|
||||
@ -116,7 +116,7 @@ static const NSString* get_key_config_name(uint32_t hid_id)
|
||||
{
|
||||
int keycode = [[notification.userInfo objectForKey:@"keycode"] intValue];
|
||||
|
||||
[value setObject:get_key_config_name(keycode) forKey:@"VALUE"];
|
||||
value.value = get_key_config_name(keycode);
|
||||
|
||||
[alert dismissWithClickedButtonIndex:0 animated:YES];
|
||||
[view reloadData];
|
||||
|
@ -8,30 +8,30 @@
|
||||
|
||||
#import "settings.h"
|
||||
|
||||
@implementation enumeration_list
|
||||
@implementation SettingEnumerationList
|
||||
{
|
||||
NSMutableDictionary* value;
|
||||
SettingData* value;
|
||||
UITableView* view;
|
||||
};
|
||||
|
||||
- (id)initWithSetting:(NSMutableDictionary*)setting fromTable:(UITableView*)table
|
||||
- (id)initWithSetting:(SettingData*)setting fromTable:(UITableView*)table
|
||||
{
|
||||
self = [super initWithStyle:UITableViewStyleGrouped];
|
||||
|
||||
value = setting;
|
||||
view = table;
|
||||
[self setTitle: [value objectForKey:@"LABEL"]];
|
||||
[self setTitle: value.label];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView*)tableView
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
- (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return (section == 1) ? [[value objectForKey:@"VALUES"] count] : 1;
|
||||
return (section == 1) ? [value.subValues count] : 1;
|
||||
}
|
||||
|
||||
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
@ -40,19 +40,19 @@
|
||||
cell = cell ? cell : [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"option"];
|
||||
|
||||
if (indexPath.section == 1)
|
||||
cell.textLabel.text = [[value objectForKey:@"VALUES"] objectAtIndex:indexPath.row];
|
||||
cell.textLabel.text = [value.subValues objectAtIndex:indexPath.row];
|
||||
else
|
||||
cell.textLabel.text = @"None";
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (indexPath.section == 1)
|
||||
[value setObject:[[value objectForKey:@"VALUES"] objectAtIndex:indexPath.row] forKey:@"VALUE"];
|
||||
value.value = [value.subValues objectAtIndex:indexPath.row];
|
||||
else
|
||||
[value setObject:@"" forKey:@"VALUE"];
|
||||
value.value = @"";
|
||||
|
||||
[view reloadData];
|
||||
[[RetroArch_iOS get].navigator popViewControllerAnimated:YES];
|
||||
|
@ -6,10 +6,28 @@
|
||||
// Copyright (c) 2013 RetroArch. All rights reserved.
|
||||
//
|
||||
|
||||
@interface button_getter : NSObject<UIAlertViewDelegate>
|
||||
- (id)initWithSetting:(NSMutableDictionary*)setting fromTable:(UITableView*)table;
|
||||
#include "conf/config_file.h"
|
||||
|
||||
enum SettingTypes
|
||||
{
|
||||
BooleanSetting, ButtonSetting, EnumerationSetting, FileListSetting, GroupSetting
|
||||
};
|
||||
|
||||
@interface SettingData : NSObject
|
||||
@property enum SettingTypes type;
|
||||
|
||||
@property (strong) NSString* label;
|
||||
@property (strong) NSString* name;
|
||||
@property (strong) NSString* value;
|
||||
|
||||
@property (strong) NSString* path;
|
||||
@property (strong) NSArray* subValues;
|
||||
@end
|
||||
|
||||
@interface enumeration_list : UITableViewController
|
||||
- (id)initWithSetting:(NSMutableDictionary*)setting fromTable:(UITableView*)table;
|
||||
@interface ButtonGetter : NSObject<UIAlertViewDelegate>
|
||||
- (id)initWithSetting:(SettingData*)setting fromTable:(UITableView*)table;
|
||||
@end
|
||||
|
||||
@interface SettingEnumerationList : UITableViewController
|
||||
- (id)initWithSetting:(SettingData*)setting fromTable:(UITableView*)table;
|
||||
@end
|
||||
|
@ -10,14 +10,16 @@
|
||||
#import "settings.h"
|
||||
#include "config_file.h"
|
||||
|
||||
static const char* const SETTINGID = "SETTING";
|
||||
@implementation SettingData
|
||||
@end
|
||||
|
||||
|
||||
static NSString* get_value_from_config(config_file_t* config, NSString* name, NSString* defaultValue)
|
||||
{
|
||||
NSString* value = nil;
|
||||
|
||||
char* v = 0;
|
||||
if (config_get_string(config, [name UTF8String], &v))
|
||||
if (config && config_get_string(config, [name UTF8String], &v))
|
||||
{
|
||||
value = [[NSString alloc] initWithUTF8String:v];
|
||||
free(v);
|
||||
@ -30,44 +32,47 @@ static NSString* get_value_from_config(config_file_t* config, NSString* name, NS
|
||||
return value;
|
||||
}
|
||||
|
||||
static NSMutableDictionary* boolean_setting(config_file_t* config, NSString* name, NSString* label, NSString* defaultValue)
|
||||
static SettingData* boolean_setting(config_file_t* config, NSString* name, NSString* label, NSString* defaultValue)
|
||||
{
|
||||
NSString* value = get_value_from_config(config, name, defaultValue);
|
||||
|
||||
return [[NSMutableDictionary alloc] initWithObjectsAndKeys:
|
||||
@"B", @"TYPE",
|
||||
name, @"NAME",
|
||||
label, @"LABEL",
|
||||
value, @"VALUE",
|
||||
nil];
|
||||
SettingData* result = [[SettingData alloc] init];
|
||||
result.type = BooleanSetting;
|
||||
result.label = label;
|
||||
result.name = name;
|
||||
result.value = get_value_from_config(config, name, defaultValue);
|
||||
return result;
|
||||
}
|
||||
|
||||
static NSMutableDictionary* button_setting(config_file_t* config, NSString* name, NSString* label, NSString* defaultValue)
|
||||
static SettingData* button_setting(config_file_t* config, NSString* name, NSString* label, NSString* defaultValue)
|
||||
{
|
||||
NSString* value = get_value_from_config(config, name, defaultValue);
|
||||
|
||||
return [[NSMutableDictionary alloc] initWithObjectsAndKeys:
|
||||
@"C", @"TYPE",
|
||||
name, @"NAME",
|
||||
label, @"LABEL",
|
||||
value, @"VALUE",
|
||||
nil];
|
||||
SettingData* result = [[SettingData alloc] init];
|
||||
result.type = ButtonSetting;
|
||||
result.label = label;
|
||||
result.name = name;
|
||||
result.value = get_value_from_config(config, name, defaultValue);
|
||||
return result;
|
||||
}
|
||||
|
||||
static NSMutableDictionary* enumeration_setting(config_file_t* config, NSString* name, NSString* label, NSString* defaultValue, NSArray* values)
|
||||
static SettingData* group_setting(NSString* label, NSArray* settings)
|
||||
{
|
||||
NSString* value = get_value_from_config(config, name, defaultValue);
|
||||
|
||||
return [[NSMutableDictionary alloc] initWithObjectsAndKeys:
|
||||
@"E", @"TYPE",
|
||||
name, @"NAME",
|
||||
label, @"LABEL",
|
||||
value, @"VALUE",
|
||||
values, @"VALUES",
|
||||
nil];
|
||||
SettingData* result = [[SettingData alloc] init];
|
||||
result.type = GroupSetting;
|
||||
result.label = label;
|
||||
result.subValues = settings;
|
||||
return result;
|
||||
}
|
||||
|
||||
static NSMutableDictionary* subpath_setting(config_file_t* config, NSString* name, NSString* label, NSString* defaultValue, NSString* path, NSString* extension)
|
||||
static SettingData* enumeration_setting(config_file_t* config, NSString* name, NSString* label, NSString* defaultValue, NSArray* values)
|
||||
{
|
||||
SettingData* result = [[SettingData alloc] init];
|
||||
result.type = EnumerationSetting;
|
||||
result.label = label;
|
||||
result.name = name;
|
||||
result.value = get_value_from_config(config, name, defaultValue);
|
||||
result.subValues = values;
|
||||
return result;
|
||||
}
|
||||
|
||||
static SettingData* subpath_setting(config_file_t* config, NSString* name, NSString* label, NSString* defaultValue, NSString* path, NSString* extension)
|
||||
{
|
||||
NSString* value = get_value_from_config(config, name, defaultValue);
|
||||
value = [value stringByReplacingOccurrencesOfString:path withString:@""];
|
||||
@ -75,34 +80,25 @@ static NSMutableDictionary* subpath_setting(config_file_t* config, NSString* nam
|
||||
NSArray* values = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath: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];
|
||||
SettingData* result = [[SettingData alloc] init];
|
||||
result.type = FileListSetting;
|
||||
result.label = label;
|
||||
result.name = name;
|
||||
result.value = value;
|
||||
result.subValues = values;
|
||||
result.path = path;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@implementation settings_list
|
||||
{
|
||||
NSArray* settings;
|
||||
config_file_t* config;
|
||||
};
|
||||
|
||||
@implementation SettingsList
|
||||
- (id)init
|
||||
{
|
||||
self = [super initWithStyle:UITableViewStyleGrouped];
|
||||
|
||||
config = config_file_new([[RetroArch_iOS get].config_file_path UTF8String]);
|
||||
if (!config) config = config_file_new(0);
|
||||
config_file_t* config = config_file_new([[RetroArch_iOS get].config_file_path UTF8String]);
|
||||
|
||||
NSString* overlay_path = [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/overlays/"];
|
||||
NSString* shader_path = [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/shaders/"];
|
||||
|
||||
settings = [NSArray arrayWithObjects:
|
||||
NSArray* settings = [NSArray arrayWithObjects:
|
||||
[NSArray arrayWithObjects:@"Video",
|
||||
boolean_setting(config, @"video_smooth", @"Smooth Video", @"true"),
|
||||
boolean_setting(config, @"video_crop_overscan", @"Crop Overscan", @"false"),
|
||||
@ -117,45 +113,46 @@ static NSMutableDictionary* subpath_setting(config_file_t* config, NSString* nam
|
||||
|
||||
[NSArray arrayWithObjects:@"Input",
|
||||
subpath_setting(config, @"input_overlay", @"Input Overlay", @"", overlay_path, @"cfg"),
|
||||
group_setting(@"Player 1 Keys", [NSArray arrayWithObjects:
|
||||
[NSArray arrayWithObjects:@"Player 1",
|
||||
button_setting(config, @"input_player1_up", @"Up", @"up"),
|
||||
button_setting(config, @"input_player1_down", @"Down", @"down"),
|
||||
button_setting(config, @"input_player1_left", @"Left", @"left"),
|
||||
button_setting(config, @"input_player1_right", @"Right", @"right"),
|
||||
|
||||
button_setting(config, @"input_player1_start", @"Start", @"enter"),
|
||||
button_setting(config, @"input_player1_select", @"Select", @"rshift"),
|
||||
|
||||
button_setting(config, @"input_player1_b", @"B", @"z"),
|
||||
button_setting(config, @"input_player1_a", @"A", @"x"),
|
||||
button_setting(config, @"input_player1_x", @"X", @"s"),
|
||||
button_setting(config, @"input_player1_y", @"Y", @"a"),
|
||||
|
||||
button_setting(config, @"input_player1_l", @"L", @"q"),
|
||||
button_setting(config, @"input_player1_r", @"R", @"w"),
|
||||
button_setting(config, @"input_player1_l2", @"L2", @""),
|
||||
button_setting(config, @"input_player1_r2", @"R2", @""),
|
||||
button_setting(config, @"input_player1_l3", @"L3", @""),
|
||||
button_setting(config, @"input_player1_r3", @"R3", @""),
|
||||
nil],
|
||||
nil]),
|
||||
group_setting(@"System Keys", [NSArray arrayWithObjects:
|
||||
[NSArray arrayWithObjects:@"System Keys",
|
||||
button_setting(config, @"input_save_state", @"Save State", @"f2"),
|
||||
button_setting(config, @"input_load_state", @"Load State", @"f4"),
|
||||
button_setting(config, @"input_state_slot_increase", @"Next State Slot", @"f7"),
|
||||
button_setting(config, @"input_state_slot_decrease", @"Previous State Slot", @"f6"),
|
||||
button_setting(config, @"input_toggle_fast_forward", @"Toggle Fast Forward", @"space"),
|
||||
button_setting(config, @"input_hold_fast_forward", @"Hold Fast Forward", @"l"),
|
||||
button_setting(config, @"input_rewind", @"Rewind", @"r"),
|
||||
button_setting(config, @"input_slowmotion", @"Slow Motion", @"e"),
|
||||
button_setting(config, @"input_reset", @"Reset", @"h"),
|
||||
button_setting(config, @"input_exit_emulator", @"Close Game", @"escape"),
|
||||
nil],
|
||||
nil]),
|
||||
nil],
|
||||
|
||||
[NSArray arrayWithObjects:@"Player 1",
|
||||
button_setting(config, @"input_player1_up", @"Up", @"up"),
|
||||
button_setting(config, @"input_player1_down", @"Down", @"down"),
|
||||
button_setting(config, @"input_player1_left", @"Left", @"left"),
|
||||
button_setting(config, @"input_player1_right", @"Right", @"right"),
|
||||
|
||||
button_setting(config, @"input_player1_start", @"Start", @"enter"),
|
||||
button_setting(config, @"input_player1_select", @"Select", @"rshift"),
|
||||
|
||||
button_setting(config, @"input_player1_b", @"B", @"z"),
|
||||
button_setting(config, @"input_player1_a", @"A", @"x"),
|
||||
button_setting(config, @"input_player1_x", @"X", @"s"),
|
||||
button_setting(config, @"input_player1_y", @"Y", @"a"),
|
||||
|
||||
button_setting(config, @"input_player1_l", @"L", @"q"),
|
||||
button_setting(config, @"input_player1_r", @"R", @"w"),
|
||||
button_setting(config, @"input_player1_l2", @"L2", @""),
|
||||
button_setting(config, @"input_player1_r2", @"R2", @""),
|
||||
button_setting(config, @"input_player1_l3", @"L3", @""),
|
||||
button_setting(config, @"input_player1_r3", @"R3", @""),
|
||||
nil],
|
||||
|
||||
[NSArray arrayWithObjects:@"System Keys",
|
||||
button_setting(config, @"input_save_state", @"Save State", @"f2"),
|
||||
button_setting(config, @"input_load_state", @"Load State", @"f4"),
|
||||
button_setting(config, @"input_state_slot_increase", @"Next State Slot", @"f7"),
|
||||
button_setting(config, @"input_state_slot_decrease", @"Previous State Slot", @"f6"),
|
||||
button_setting(config, @"input_toggle_fast_forward", @"Toggle Fast Forward", @"space"),
|
||||
button_setting(config, @"input_hold_fast_forward", @"Hold Fast Forward", @"l"),
|
||||
button_setting(config, @"input_rewind", @"Rewind", @"r"),
|
||||
button_setting(config, @"input_slowmotion", @"Slow Motion", @"e"),
|
||||
button_setting(config, @"input_pause_toogle", @"Pause", @"p"),
|
||||
button_setting(config, @"input_frame_advance", @"Advance Frame", @"k"),
|
||||
button_setting(config, @"input_reset", @"Reset", @"h"),
|
||||
button_setting(config, @"input_exit_emulator", @"Close Game", @"escape"),
|
||||
nil],
|
||||
|
||||
|
||||
[NSArray arrayWithObjects:@"Save States",
|
||||
boolean_setting(config, @"rewind_enable", @"Enable Rewinding", @"false"),
|
||||
boolean_setting(config, @"block_sram_overwrite", @"Disable SRAM on Load", @"false"),
|
||||
@ -164,125 +161,35 @@ static NSMutableDictionary* subpath_setting(config_file_t* config, NSString* nam
|
||||
nil],
|
||||
nil
|
||||
];
|
||||
|
||||
[self setTitle:@"RetroArch Settings"];
|
||||
|
||||
if (config)
|
||||
config_file_free(config);
|
||||
|
||||
self = [super initWithSettings:settings title:@"RetroArch Settings"];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[self write_to_file];
|
||||
[self writeToDisk];
|
||||
}
|
||||
|
||||
+ (void)refresh_config_file
|
||||
+ (void)refreshConfigFile
|
||||
{
|
||||
[[[settings_list alloc] init] write_to_file];
|
||||
[[[SettingsList alloc] init] writeToDisk];
|
||||
}
|
||||
|
||||
- (void)write_to_file
|
||||
- (void)writeToDisk
|
||||
{
|
||||
config_file_t* config = config_file_new([[RetroArch_iOS get].config_file_path UTF8String]);
|
||||
config = config ? config : config_file_new(0);
|
||||
|
||||
config_set_string(config, "system_directory", [[RetroArch_iOS get].system_directory UTF8String]);
|
||||
|
||||
for (int i = 0; i != [settings count]; i ++)
|
||||
{
|
||||
NSArray* group = [settings objectAtIndex:i];
|
||||
|
||||
for (int j = 1; j < [group count]; j ++)
|
||||
{
|
||||
NSMutableDictionary* setting = [group objectAtIndex:j];
|
||||
|
||||
NSString* name = [setting objectForKey:@"NAME"];
|
||||
NSString* value = [setting objectForKey:@"VALUE"];
|
||||
|
||||
if ([[setting objectForKey:@"TYPE"] isEqualToString:@"F"] && [value length] > 0)
|
||||
value = [[setting objectForKey:@"PATH"] stringByAppendingPathComponent:value];
|
||||
|
||||
config_set_string(config, [name UTF8String], [value UTF8String]);
|
||||
}
|
||||
}
|
||||
[self writeSettings:nil toConfig:config];
|
||||
|
||||
config_file_write(config, [[RetroArch_iOS get].config_file_path UTF8String]);
|
||||
}
|
||||
|
||||
- (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];
|
||||
}
|
||||
else if([type isEqualToString:@"C"])
|
||||
{
|
||||
(void)[[button_getter alloc] initWithSetting:setting fromTable:(UITableView*)self.view];
|
||||
}
|
||||
}
|
||||
|
||||
- (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];
|
||||
}
|
||||
|
||||
- (void)handle_boolean_switch:(UISwitch*)swt
|
||||
{
|
||||
NSDictionary* setting = objc_getAssociatedObject(swt, SETTINGID);
|
||||
[setting setValue: (swt.on ? @"true" : @"false") forKey:@"VALUE"];
|
||||
}
|
||||
|
||||
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
NSMutableDictionary* setting = [[settings objectAtIndex:indexPath.section] objectAtIndex:indexPath.row + 1];
|
||||
UITableViewCell* cell = nil;
|
||||
|
||||
NSString* type = [setting valueForKey:@"TYPE"];
|
||||
|
||||
if ([type isEqualToString:@"B"])
|
||||
{
|
||||
cell = [self.tableView dequeueReusableCellWithIdentifier:@"boolean"];
|
||||
|
||||
if (cell == nil)
|
||||
{
|
||||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"boolean"];
|
||||
|
||||
UISwitch* accessory = [[UISwitch alloc] init];
|
||||
[accessory addTarget:self action:@selector(handle_boolean_switch:) forControlEvents:UIControlEventValueChanged];
|
||||
|
||||
cell.accessoryView = accessory;
|
||||
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
|
||||
}
|
||||
|
||||
UISwitch* swt = (UISwitch*)cell.accessoryView;
|
||||
swt.on = [[setting valueForKey:@"VALUE"] isEqualToString:@"true"];
|
||||
|
||||
objc_setAssociatedObject(swt, SETTINGID, setting, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
else if ([type isEqualToString:@"E"] || [type isEqualToString:@"F"] || [type isEqualToString:@"C"])
|
||||
{
|
||||
cell = [self.tableView dequeueReusableCellWithIdentifier:@"enumeration"];
|
||||
|
||||
if (cell == nil)
|
||||
{
|
||||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"enumeration"];
|
||||
}
|
||||
}
|
||||
|
||||
cell.textLabel.text = [setting valueForKey:@"LABEL"];
|
||||
cell.detailTextLabel.text = [setting valueForKey:@"VALUE"];
|
||||
|
||||
return cell;
|
||||
config_file_free(config);
|
||||
}
|
||||
|
||||
@end
|
||||
|
173
ios/RetroArch/settings/settings_sublist.m
Normal file
173
ios/RetroArch/settings/settings_sublist.m
Normal file
@ -0,0 +1,173 @@
|
||||
//
|
||||
// settings_list.m
|
||||
// RetroArch
|
||||
//
|
||||
// Created by Jason Fetters on 2/8/13.
|
||||
// Copyright (c) 2013 RetroArch. All rights reserved.
|
||||
//
|
||||
|
||||
#import <objc/runtime.h>
|
||||
#import "settings.h"
|
||||
|
||||
static const char* const SETTINGID = "SETTING";
|
||||
|
||||
@implementation SettingsSubList
|
||||
{
|
||||
NSArray* settings;
|
||||
};
|
||||
|
||||
- (id)initWithSettings:(NSArray*)values title:(NSString*)title
|
||||
{
|
||||
self = [super initWithStyle:UITableViewStyleGrouped];
|
||||
settings = values;
|
||||
|
||||
[self setTitle:title];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)writeSettings:(NSArray*)settingList toConfig:(config_file_t *)config
|
||||
{
|
||||
NSArray* list = settingList ? settingList : settings;
|
||||
|
||||
for (int i = 0; i != [list count]; i ++)
|
||||
{
|
||||
NSArray* group = [list objectAtIndex:i];
|
||||
|
||||
for (int j = 1; j < [group count]; j ++)
|
||||
{
|
||||
SettingData* setting = [group objectAtIndex:j];
|
||||
|
||||
switch (setting.type)
|
||||
{
|
||||
case GroupSetting:
|
||||
[self writeSettings:setting.subValues toConfig:config];
|
||||
break;
|
||||
|
||||
case FileListSetting:
|
||||
if ([setting.value length] > 0)
|
||||
config_set_string(config, [setting.name UTF8String], [[setting.path stringByAppendingPathComponent:setting.value] UTF8String]);
|
||||
else
|
||||
config_set_string(config, [setting.name UTF8String], "");
|
||||
break;
|
||||
|
||||
default:
|
||||
config_set_string(config, [setting.name UTF8String], [setting.value UTF8String]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
SettingData* setting = [[settings objectAtIndex:indexPath.section] objectAtIndex:indexPath.row + 1];
|
||||
|
||||
switch (setting.type)
|
||||
{
|
||||
case EnumerationSetting:
|
||||
case FileListSetting:
|
||||
[[RetroArch_iOS get].navigator
|
||||
pushViewController:[[SettingEnumerationList alloc] initWithSetting:setting fromTable:(UITableView*)self.view]
|
||||
animated:YES];
|
||||
break;
|
||||
|
||||
case ButtonSetting:
|
||||
(void)[[ButtonGetter alloc] initWithSetting:setting fromTable:(UITableView*)self.view];
|
||||
break;
|
||||
|
||||
case GroupSetting:
|
||||
[[RetroArch_iOS get].navigator
|
||||
pushViewController:[[SettingsSubList alloc] initWithSettings:setting.subValues title:setting.label]
|
||||
animated:YES];
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)handle_boolean_switch:(UISwitch*)swt
|
||||
{
|
||||
SettingData* setting = objc_getAssociatedObject(swt, SETTINGID);
|
||||
setting.value = (swt.on ? @"true" : @"false");
|
||||
}
|
||||
|
||||
- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
SettingData* setting = [[settings objectAtIndex:indexPath.section] objectAtIndex:indexPath.row + 1];
|
||||
|
||||
UITableViewCell* cell = nil;
|
||||
|
||||
switch (setting.type)
|
||||
{
|
||||
case BooleanSetting:
|
||||
{
|
||||
cell = [self.tableView dequeueReusableCellWithIdentifier:@"boolean"];
|
||||
|
||||
if (cell == nil)
|
||||
{
|
||||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"boolean"];
|
||||
|
||||
UISwitch* accessory = [[UISwitch alloc] init];
|
||||
[accessory addTarget:self action:@selector(handle_boolean_switch:) forControlEvents:UIControlEventValueChanged];
|
||||
cell.accessoryView = accessory;
|
||||
|
||||
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
|
||||
}
|
||||
|
||||
UISwitch* swt = (UISwitch*)cell.accessoryView;
|
||||
swt.on = [setting.value isEqualToString:@"true"];
|
||||
objc_setAssociatedObject(swt, SETTINGID, setting, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
break;
|
||||
|
||||
case EnumerationSetting:
|
||||
case FileListSetting:
|
||||
case ButtonSetting:
|
||||
{
|
||||
cell = [self.tableView dequeueReusableCellWithIdentifier:@"enumeration"];
|
||||
|
||||
if (cell == nil)
|
||||
{
|
||||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"enumeration"];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GroupSetting:
|
||||
{
|
||||
cell = [self.tableView dequeueReusableCellWithIdentifier:@"group"];
|
||||
|
||||
if (cell == nil)
|
||||
{
|
||||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"group"];
|
||||
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
cell.textLabel.text = setting.label;
|
||||
cell.detailTextLabel.text = setting.value;
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
// UITableView item counts
|
||||
- (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];
|
||||
}
|
||||
|
||||
|
||||
@end
|
@ -1,6 +1,8 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <GLKit/GLKit.h>
|
||||
|
||||
#include "conf/config_file.h"
|
||||
|
||||
@interface game_view : UIViewController
|
||||
- (id)initWithGame:(NSString*)path;
|
||||
@end
|
||||
@ -13,6 +15,12 @@
|
||||
- (id)initWithPath:(NSString*)path;
|
||||
@end
|
||||
|
||||
@interface settings_list : UITableViewController
|
||||
+ (void)refresh_config_file;
|
||||
@end
|
||||
|
||||
@interface SettingsSubList : UITableViewController
|
||||
- (id)initWithSettings:(NSArray*)values title:(NSString*)title;
|
||||
- (void)writeSettings:(NSArray*)settingList toConfig:(config_file_t*)config;
|
||||
@end
|
||||
|
||||
@interface SettingsList : SettingsSubList
|
||||
+ (void)refreshConfigFile;
|
||||
@end
|
||||
|
Loading…
x
Reference in New Issue
Block a user