mirror of
https://github.com/libretro/RetroArch
synced 2025-02-25 12:41:18 +00:00
(iOS) Long pressing on a setting menu item will give the option to reset it to default. (Except booleans)
This commit is contained in:
parent
bfc4bba70f
commit
dab783a7fd
@ -84,37 +84,40 @@ static const char* get_axis_name(const rarch_setting_t* setting)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
void setting_data_reset_setting(const rarch_setting_t* setting)
|
||||||
|
{
|
||||||
|
switch (setting->type)
|
||||||
|
{
|
||||||
|
case ST_BOOL: *setting->value.boolean = setting->default_value.boolean; break;
|
||||||
|
case ST_INT: *setting->value.integer = setting->default_value.integer; break;
|
||||||
|
case ST_UINT: *setting->value.unsigned_integer = setting->default_value.unsigned_integer; break;
|
||||||
|
case ST_FLOAT: *setting->value.fraction = setting->default_value.fraction; break;
|
||||||
|
case ST_BIND: *setting->value.keybind = *setting->default_value.keybind; break;
|
||||||
|
|
||||||
|
case ST_STRING:
|
||||||
|
case ST_PATH:
|
||||||
|
{
|
||||||
|
if (setting->default_value.string)
|
||||||
|
{
|
||||||
|
if (setting->type == ST_STRING)
|
||||||
|
strlcpy(setting->value.string, setting->default_value.string, setting->size);
|
||||||
|
else
|
||||||
|
fill_pathname_expand_special(setting->value.string, setting->default_value.string, setting->size);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void setting_data_reset(const rarch_setting_t* settings)
|
void setting_data_reset(const rarch_setting_t* settings)
|
||||||
{
|
{
|
||||||
memset(&fake_settings, 0, sizeof(fake_settings));
|
memset(&fake_settings, 0, sizeof(fake_settings));
|
||||||
memset(&fake_extern, 0, sizeof(fake_extern));
|
memset(&fake_extern, 0, sizeof(fake_extern));
|
||||||
|
|
||||||
for (const rarch_setting_t* i = settings; i->type != ST_NONE; i ++)
|
for (const rarch_setting_t* i = settings; i->type != ST_NONE; i ++)
|
||||||
{
|
setting_data_reset_setting(i);
|
||||||
switch (i->type)
|
|
||||||
{
|
|
||||||
case ST_BOOL: *i->value.boolean = i->default_value.boolean; break;
|
|
||||||
case ST_INT: *i->value.integer = i->default_value.integer; break;
|
|
||||||
case ST_UINT: *i->value.unsigned_integer = i->default_value.unsigned_integer; break;
|
|
||||||
case ST_FLOAT: *i->value.fraction = i->default_value.fraction; break;
|
|
||||||
case ST_BIND: *i->value.keybind = *i->default_value.keybind; break;
|
|
||||||
|
|
||||||
case ST_STRING:
|
|
||||||
case ST_PATH:
|
|
||||||
{
|
|
||||||
if (i->default_value.string)
|
|
||||||
{
|
|
||||||
if (i->type == ST_STRING)
|
|
||||||
strlcpy(i->value.string, i->default_value.string, i->size);
|
|
||||||
else
|
|
||||||
fill_pathname_expand_special(i->value.string, i->default_value.string, i->size);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool setting_data_load_config_path(const rarch_setting_t* settings, const char* path)
|
bool setting_data_load_config_path(const rarch_setting_t* settings, const char* path)
|
||||||
|
@ -81,6 +81,7 @@ typedef struct
|
|||||||
#define BINDFOR(s) (*(&s)->value.keybind)
|
#define BINDFOR(s) (*(&s)->value.keybind)
|
||||||
|
|
||||||
|
|
||||||
|
void setting_data_reset_setting(const rarch_setting_t* setting);
|
||||||
void setting_data_reset(const rarch_setting_t* settings);
|
void setting_data_reset(const rarch_setting_t* settings);
|
||||||
|
|
||||||
bool setting_data_load_config_path(const rarch_setting_t* settings, const char* path);
|
bool setting_data_load_config_path(const rarch_setting_t* settings, const char* path);
|
||||||
|
@ -230,6 +230,8 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
|
|||||||
result = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cell_id];
|
result = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cell_id];
|
||||||
result.selectionStyle = UITableViewCellSelectionStyleNone;
|
result.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[self attachDefaultingGestureTo:result];
|
||||||
|
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
result.textLabel.text = BOXSTRING(self.setting->short_description);
|
result.textLabel.text = BOXSTRING(self.setting->short_description);
|
||||||
@ -270,6 +272,32 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)attachDefaultingGestureTo:(UIView*)view
|
||||||
|
{
|
||||||
|
for (UIGestureRecognizer* i in view.gestureRecognizers)
|
||||||
|
[view removeGestureRecognizer:i];
|
||||||
|
[view addGestureRecognizer:[[UILongPressGestureRecognizer alloc] initWithTarget:self
|
||||||
|
action:@selector(resetValue:)]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)resetValue:(UIGestureRecognizer*)gesture
|
||||||
|
{
|
||||||
|
if (gesture.state == UIGestureRecognizerStateBegan)
|
||||||
|
{
|
||||||
|
RAMenuItemGeneralSetting __weak* weakSelf = self;
|
||||||
|
|
||||||
|
struct string_list* items = string_split("OK", "|");
|
||||||
|
RunActionSheet("Really Reset Value?", items, self.parentTable,
|
||||||
|
^(UIActionSheet* actionSheet, NSInteger buttonIndex)
|
||||||
|
{
|
||||||
|
if (buttonIndex != actionSheet.cancelButtonIndex)
|
||||||
|
setting_data_reset_setting(self.setting);
|
||||||
|
[weakSelf.parentTable reloadData];
|
||||||
|
});
|
||||||
|
string_list_free(items);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/*********************************************/
|
/*********************************************/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user