mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-01 15:48:49 +00:00
(iOS) Add a range based setting for input_overlay_opacity.
This commit is contained in:
parent
e1aff3cfa6
commit
f0774266a1
@ -84,6 +84,15 @@ static RASettingData* subpath_setting(config_file_t* config, NSString* name, NSS
|
||||
return result;
|
||||
}
|
||||
|
||||
static RASettingData* range_setting(config_file_t* config, NSString* name, NSString* label, NSString* defaultValue, double minValue, double maxValue)
|
||||
{
|
||||
RASettingData* result = [[RASettingData alloc] initWithType:RangeSetting label:label name:name];
|
||||
result.value = get_value_from_config(config, name, defaultValue);
|
||||
result.rangeMin = minValue;
|
||||
result.rangeMax = maxValue;
|
||||
return result;
|
||||
}
|
||||
|
||||
static RASettingData* aspect_setting(config_file_t* config, NSString* label)
|
||||
{
|
||||
// Why does this need to be so difficult?
|
||||
@ -152,6 +161,7 @@ static RASettingData* custom_action(NSString* action)
|
||||
|
||||
[NSArray arrayWithObjects:@"Input",
|
||||
subpath_setting(config, @"input_overlay", @"Input Overlay", @"", overlay_path, @"cfg"),
|
||||
range_setting(config, @"input_overlay_opacity", @"Overlay Opacity", @"1.0", 0.0, 1.0),
|
||||
group_setting(@"Player 1 Keys", [NSArray arrayWithObjects:
|
||||
[NSArray arrayWithObjects:@"Player 1",
|
||||
button_setting(config, @"input_player1_up", @"Up", @"up"),
|
||||
|
@ -128,6 +128,12 @@ static const char* const SETTINGID = "SETTING";
|
||||
setting.value = (swt.on ? @"true" : @"false");
|
||||
}
|
||||
|
||||
- (void)handleSlider:(UISlider*)sld
|
||||
{
|
||||
RASettingData* setting = objc_getAssociatedObject(sld, SETTINGID);
|
||||
setting.value = [NSString stringWithFormat:@"%f", sld.value];
|
||||
}
|
||||
|
||||
- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
RASettingData* setting = [[settings objectAtIndex:indexPath.section] objectAtIndex:indexPath.row + 1];
|
||||
@ -156,6 +162,30 @@ static const char* const SETTINGID = "SETTING";
|
||||
objc_setAssociatedObject(swt, SETTINGID, setting, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
break;
|
||||
|
||||
case RangeSetting:
|
||||
{
|
||||
cell = [self.tableView dequeueReusableCellWithIdentifier:@"range"];
|
||||
|
||||
if (cell == nil)
|
||||
{
|
||||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"range"];
|
||||
|
||||
UISlider* accessory = [UISlider new];
|
||||
[accessory addTarget:self action:@selector(handleSlider:) forControlEvents:UIControlEventValueChanged];
|
||||
accessory.continuous = NO;
|
||||
cell.accessoryView = accessory;
|
||||
|
||||
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
|
||||
}
|
||||
|
||||
UISlider* sld = (UISlider*)cell.accessoryView;
|
||||
sld.minimumValue = setting.rangeMin;
|
||||
sld.maximumValue = setting.rangeMax;
|
||||
sld.value = [setting.value doubleValue];
|
||||
objc_setAssociatedObject(sld, SETTINGID, setting, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
break;
|
||||
|
||||
case EnumerationSetting:
|
||||
case FileListSetting:
|
||||
@ -168,7 +198,7 @@ static const char* const SETTINGID = "SETTING";
|
||||
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case GroupSetting:
|
||||
{
|
||||
cell = [self.tableView dequeueReusableCellWithIdentifier:@"group"];
|
||||
|
@ -16,7 +16,7 @@
|
||||
enum SettingTypes
|
||||
{
|
||||
BooleanSetting, ButtonSetting, EnumerationSetting, FileListSetting,
|
||||
GroupSetting, AspectSetting, CustomAction
|
||||
GroupSetting, AspectSetting, RangeSetting, CustomAction
|
||||
};
|
||||
|
||||
@interface RASettingData : NSObject
|
||||
@ -30,6 +30,9 @@ enum SettingTypes
|
||||
@property (strong) NSArray* subValues;
|
||||
@property (strong) NSMutableArray* msubValues;
|
||||
|
||||
@property double rangeMin;
|
||||
@property double rangeMax;
|
||||
|
||||
- (id)initWithType:(enum SettingTypes)aType label:(NSString*)aLabel name:(NSString*)aName;
|
||||
@end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user