(Menu) Refator common code into calls to menu_action_setting_apply

This commit is contained in:
twinaphex 2014-09-15 00:34:00 +02:00
parent 1682d83831
commit 696b1cdef8
3 changed files with 24 additions and 76 deletions

View File

@ -235,17 +235,7 @@ static int menu_common_setting_set_current_path_selection(
break;
}
if (setting->change_handler)
setting->change_handler(setting);
if (setting->flags & SD_FLAG_EXIT
&& setting->cmd_trigger.triggered)
{
setting->cmd_trigger.triggered = false;
return -1;
}
return 0;
return menu_action_setting_apply(setting);
}
static int menu_common_setting_set_current_string_path(
@ -253,17 +243,7 @@ static int menu_common_setting_set_current_string_path(
{
fill_pathname_join(setting->value.string, dir, path, setting->size);
if (setting->change_handler)
setting->change_handler(setting);
if (setting->flags & SD_FLAG_EXIT
&& setting->cmd_trigger.triggered)
{
setting->cmd_trigger.triggered = false;
return -1;
}
return 0;
return menu_action_setting_apply(setting);
}
int menu_common_set_current_string_based_on_label(
@ -286,17 +266,7 @@ int menu_common_setting_set_current_string(
{
strlcpy(setting->value.string, str, setting->size);
if (setting->change_handler)
setting->change_handler(setting);
if (setting->flags & SD_FLAG_EXIT
&& setting->cmd_trigger.triggered)
{
setting->cmd_trigger.triggered = false;
return -1;
}
return 0;
return menu_action_setting_apply(setting);
}
static int handle_setting(rarch_setting_t *setting,
@ -317,16 +287,7 @@ static int handle_setting(rarch_setting_t *setting,
if (action == MENU_ACTION_START)
{
*setting->value.string = '\0';
if (setting->change_handler)
setting->change_handler(setting);
if (setting->flags & SD_FLAG_EXIT
&& setting->cmd_trigger.triggered)
{
setting->cmd_trigger.triggered = false;
return -1;
}
return menu_action_setting_apply(setting);
}
return 0;
}

View File

@ -18,6 +18,21 @@
#include "menu_input_line_cb.h"
#include "menu_action.h"
int menu_action_setting_apply(rarch_setting_t *setting)
{
if (setting->change_handler)
setting->change_handler(setting);
if (setting->flags & SD_FLAG_EXIT
&& setting->cmd_trigger.triggered)
{
setting->cmd_trigger.triggered = false;
return -1;
}
return 0;
}
int menu_action_setting_boolean(
rarch_setting_t *setting, unsigned action)
{
@ -61,17 +76,7 @@ int menu_action_setting_boolean(
}
}
if (setting->change_handler)
setting->change_handler(setting);
if (setting->flags & SD_FLAG_EXIT
&& setting->cmd_trigger.triggered)
{
setting->cmd_trigger.triggered = false;
return -1;
}
return 0;
return menu_action_setting_apply(setting);
}
int menu_action_setting_unsigned_integer(
@ -124,17 +129,7 @@ int menu_action_setting_unsigned_integer(
}
}
if (setting->change_handler)
setting->change_handler(setting);
if (setting->flags & SD_FLAG_EXIT
&& setting->cmd_trigger.triggered)
{
setting->cmd_trigger.triggered = false;
return -1;
}
return 0;
return menu_action_setting_apply(setting);
}
int menu_action_setting_fraction(
@ -221,17 +216,7 @@ int menu_action_setting_fraction(
}
}
if (setting->change_handler)
setting->change_handler(setting);
if (setting->flags & SD_FLAG_EXIT
&& setting->cmd_trigger.triggered)
{
setting->cmd_trigger.triggered = false;
return -1;
}
return 0;
return menu_action_setting_apply(setting);
}
void menu_action_setting_driver(

View File

@ -19,6 +19,8 @@
#include "../../settings_data.h"
int menu_action_setting_apply(rarch_setting_t *setting);
int menu_action_setting_boolean(
rarch_setting_t *setting, unsigned action);