(iOS) Add (hacky) aspect ratio setting.
This commit is contained in:
parent
ac9b75a871
commit
e9497abc61
|
@ -20,6 +20,7 @@
|
||||||
- (bool)getBoolNamed:(NSString*)name withDefault:(bool)def;
|
- (bool)getBoolNamed:(NSString*)name withDefault:(bool)def;
|
||||||
- (int)getIntNamed:(NSString*)name withDefault:(int)def;
|
- (int)getIntNamed:(NSString*)name withDefault:(int)def;
|
||||||
- (unsigned)getUintNamed:(NSString*)name withDefault:(unsigned)def;
|
- (unsigned)getUintNamed:(NSString*)name withDefault:(unsigned)def;
|
||||||
|
- (double)getDoubleNamed:(NSString*)name withDefault:(double)def;
|
||||||
- (NSString*)getStringNamed:(NSString*)name withDefault:(NSString*)def;
|
- (NSString*)getStringNamed:(NSString*)name withDefault:(NSString*)def;
|
||||||
|
|
||||||
- (void)putIntNamed:(NSString*)name value:(int)value;
|
- (void)putIntNamed:(NSString*)name value:(int)value;
|
||||||
|
|
|
@ -30,43 +30,39 @@
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
if (_config)
|
config_file_free(_config);
|
||||||
config_file_free(_config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)writeToFile:(NSString*)path
|
- (void)writeToFile:(NSString*)path
|
||||||
{
|
{
|
||||||
if (_config)
|
config_file_write(_config, [path UTF8String]);
|
||||||
config_file_write(_config, [path UTF8String]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (bool)getBoolNamed:(NSString*)name withDefault:(bool)def
|
- (bool)getBoolNamed:(NSString*)name withDefault:(bool)def
|
||||||
{
|
{
|
||||||
bool result = def;
|
bool result = def;
|
||||||
|
config_get_bool(_config, [name UTF8String], &result);
|
||||||
if (_config)
|
|
||||||
config_get_bool(_config, [name UTF8String], &result);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (int)getIntNamed:(NSString*)name withDefault:(int)def
|
- (int)getIntNamed:(NSString*)name withDefault:(int)def
|
||||||
{
|
{
|
||||||
int result = def;
|
int result = def;
|
||||||
|
config_get_int(_config, [name UTF8String], &result);
|
||||||
if (_config)
|
|
||||||
config_get_int(_config, [name UTF8String], &result);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (unsigned)getUintNamed:(NSString*)name withDefault:(unsigned)def
|
- (unsigned)getUintNamed:(NSString*)name withDefault:(unsigned)def
|
||||||
{
|
{
|
||||||
unsigned result = def;
|
unsigned result = def;
|
||||||
|
config_get_uint(_config, [name UTF8String], &result);
|
||||||
if (_config)
|
return result;
|
||||||
config_get_uint(_config, [name UTF8String], &result);
|
}
|
||||||
|
|
||||||
|
- (double)getDoubleNamed:(NSString*)name withDefault:(double)def
|
||||||
|
{
|
||||||
|
double result = def;
|
||||||
|
config_get_double(_config, [name UTF8String], &result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,27 +70,22 @@
|
||||||
{
|
{
|
||||||
NSString* result = def;
|
NSString* result = def;
|
||||||
|
|
||||||
if (_config)
|
char* data = 0;
|
||||||
{
|
if (config_get_string(_config, [name UTF8String], &data))
|
||||||
char* data = 0;
|
result = [NSString stringWithUTF8String:data];
|
||||||
if (config_get_string(_config, [name UTF8String], &data))
|
free(data);
|
||||||
result = [NSString stringWithUTF8String:data];
|
|
||||||
free(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)putIntNamed:(NSString*)name value:(int)value
|
- (void)putIntNamed:(NSString*)name value:(int)value
|
||||||
{
|
{
|
||||||
if (_config)
|
config_set_int(_config, [name UTF8String], value);
|
||||||
config_set_int(_config, [name UTF8String], value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)putStringNamed:(NSString*)name value:(NSString*)value
|
- (void)putStringNamed:(NSString*)name value:(NSString*)value
|
||||||
{
|
{
|
||||||
if (_config)
|
config_set_string(_config, [name UTF8String], [value UTF8String]);
|
||||||
config_set_string(_config, [name UTF8String], [value UTF8String]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -78,6 +78,27 @@ static RASettingData* subpath_setting(RAConfig* config, NSString* name, NSString
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static RASettingData* aspect_setting(RAConfig* config, NSString* label)
|
||||||
|
{
|
||||||
|
// Why does this need to be so difficult?
|
||||||
|
|
||||||
|
RASettingData* result = [[RASettingData alloc] initWithType:AspectSetting label:label name:@"fram"];
|
||||||
|
result.subValues = [NSArray arrayWithObjects:@"Fill Screen", @"Game Aspect", @"Pixel Aspect", @"4:3", @"16:9", nil];
|
||||||
|
|
||||||
|
bool videoForceAspect = [config getBoolNamed:@"video_force_aspect" withDefault:true];
|
||||||
|
bool videoAspectAuto = [config getBoolNamed:@"video_aspect_ratio_auto" withDefault:false];
|
||||||
|
double videoAspect = [config getDoubleNamed:@"video_aspect_ratio" withDefault:0.0];
|
||||||
|
|
||||||
|
if (!videoForceAspect)
|
||||||
|
result.value = @"Fill Screen";
|
||||||
|
else if (videoAspect < 0.0)
|
||||||
|
result.value = videoAspectAuto ? @"Game Aspect" : @"Pixel Aspect";
|
||||||
|
else
|
||||||
|
result.value = (videoAspect < 1.5) ? @"4:3" : @"16:9";
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static RASettingData* custom_action(NSString* action)
|
static RASettingData* custom_action(NSString* action)
|
||||||
{
|
{
|
||||||
return [[RASettingData alloc] initWithType:CustomAction label:action name:nil];
|
return [[RASettingData alloc] initWithType:CustomAction label:action name:nil];
|
||||||
|
@ -103,6 +124,8 @@ static RASettingData* custom_action(NSString* action)
|
||||||
boolean_setting(config, @"video_smooth", @"Smooth Video", @"true"),
|
boolean_setting(config, @"video_smooth", @"Smooth Video", @"true"),
|
||||||
boolean_setting(config, @"video_crop_overscan", @"Crop Overscan", @"true"),
|
boolean_setting(config, @"video_crop_overscan", @"Crop Overscan", @"true"),
|
||||||
subpath_setting(config, @"video_bsnes_shader", @"Shader", @"", shader_path, @"shader"),
|
subpath_setting(config, @"video_bsnes_shader", @"Shader", @"", shader_path, @"shader"),
|
||||||
|
aspect_setting(config, @"Aspect Ratio"),
|
||||||
|
boolean_setting(config, @"video_scale_integer", @"Integer Scaling", @"false"),
|
||||||
nil],
|
nil],
|
||||||
|
|
||||||
[NSArray arrayWithObjects:@"Audio",
|
[NSArray arrayWithObjects:@"Audio",
|
||||||
|
|
|
@ -69,6 +69,16 @@ static const char* const SETTINGID = "SETTING";
|
||||||
[config putStringNamed:[setting.name stringByAppendingString:@"_btn"] value:setting.msubValues[1]];
|
[config putStringNamed:[setting.name stringByAppendingString:@"_btn"] value:setting.msubValues[1]];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case AspectSetting:
|
||||||
|
[config putStringNamed:@"video_force_aspect" value:[@"Fill Screen" isEqualToString:setting.value] ? @"false" : @"true"];
|
||||||
|
[config putStringNamed:@"video_aspect_ratio_auto" value:[@"Game Aspect" isEqualToString:setting.value] ? @"true" : @"false"];
|
||||||
|
[config putStringNamed:@"video_aspect_ratio" value:@"-1.0"];
|
||||||
|
if([@"4:3" isEqualToString:setting.value])
|
||||||
|
[config putStringNamed:@"video_aspect_ratio" value:@"1.33333333"];
|
||||||
|
else if([@"16:9" isEqualToString:setting.value])
|
||||||
|
[config putStringNamed:@"video_aspect_ratio" value:@"1.777777777"];
|
||||||
|
break;
|
||||||
|
|
||||||
case CustomAction:
|
case CustomAction:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -88,6 +98,7 @@ static const char* const SETTINGID = "SETTING";
|
||||||
{
|
{
|
||||||
case EnumerationSetting:
|
case EnumerationSetting:
|
||||||
case FileListSetting:
|
case FileListSetting:
|
||||||
|
case AspectSetting:
|
||||||
[[RetroArch_iOS get] pushViewController:[[RASettingEnumerationList alloc] initWithSetting:setting fromTable:(UITableView*)self.view] animated:YES];
|
[[RetroArch_iOS get] pushViewController:[[RASettingEnumerationList alloc] initWithSetting:setting fromTable:(UITableView*)self.view] animated:YES];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -147,6 +158,7 @@ static const char* const SETTINGID = "SETTING";
|
||||||
case FileListSetting:
|
case FileListSetting:
|
||||||
case ButtonSetting:
|
case ButtonSetting:
|
||||||
case CustomAction:
|
case CustomAction:
|
||||||
|
case AspectSetting:
|
||||||
{
|
{
|
||||||
cell = [self.tableView dequeueReusableCellWithIdentifier:@"enumeration"];
|
cell = [self.tableView dequeueReusableCellWithIdentifier:@"enumeration"];
|
||||||
cell = cell ? cell : [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"enumeration"];
|
cell = cell ? cell : [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"enumeration"];
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
|
|
||||||
enum SettingTypes
|
enum SettingTypes
|
||||||
{
|
{
|
||||||
BooleanSetting, ButtonSetting, EnumerationSetting, FileListSetting, GroupSetting, CustomAction
|
BooleanSetting, ButtonSetting, EnumerationSetting, FileListSetting,
|
||||||
|
GroupSetting, AspectSetting, CustomAction
|
||||||
};
|
};
|
||||||
|
|
||||||
@interface RASettingData : NSObject
|
@interface RASettingData : NSObject
|
||||||
|
|
Loading…
Reference in New Issue