settings: Settings ID to pointer for cfg_string_to_int()
Accept a pointer to struct settings_list instead of an index in the settings array. Refactor the skin engine's touchregion_setup_setting() to avoid the use of indices. Change-Id: I784a5e49205da6874b8b419dd5413f722ad45b67
This commit is contained in:
parent
0550c64226
commit
bbe3942039
3 changed files with 21 additions and 21 deletions
|
@ -1546,48 +1546,48 @@ static int touchregion_setup_setting(struct skin_element *element, int param_no,
|
||||||
#ifndef __PCTOOL__
|
#ifndef __PCTOOL__
|
||||||
int p = param_no;
|
int p = param_no;
|
||||||
char *name = get_param_text(element, p++);
|
char *name = get_param_text(element, p++);
|
||||||
int j;
|
const struct settings_list *setting = find_setting_by_cfgname(name, NULL);
|
||||||
|
if (!setting)
|
||||||
region->setting_data.setting = find_setting_by_cfgname(name, &j);
|
|
||||||
if (region->setting_data.setting == NULL)
|
|
||||||
return WPS_ERROR_INVALID_PARAM;
|
return WPS_ERROR_INVALID_PARAM;
|
||||||
|
|
||||||
|
region->setting_data.setting = setting;
|
||||||
|
|
||||||
if (region->action == ACTION_SETTINGS_SET)
|
if (region->action == ACTION_SETTINGS_SET)
|
||||||
{
|
{
|
||||||
char* text;
|
char* text;
|
||||||
int temp;
|
int temp;
|
||||||
struct touchsetting *setting =
|
struct touchsetting *touchsetting =
|
||||||
®ion->setting_data;
|
®ion->setting_data;
|
||||||
if (element->params_count < p+1)
|
if (element->params_count < p+1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
text = get_param_text(element, p++);
|
text = get_param_text(element, p++);
|
||||||
switch (settings[j].flags&F_T_MASK)
|
switch (setting->flags & F_T_MASK)
|
||||||
{
|
{
|
||||||
case F_T_CUSTOM:
|
case F_T_CUSTOM:
|
||||||
setting->value.text = PTRTOSKINOFFSET(skin_buffer, text);
|
touchsetting->value.text = PTRTOSKINOFFSET(skin_buffer, text);
|
||||||
break;
|
break;
|
||||||
case F_T_INT:
|
case F_T_INT:
|
||||||
case F_T_UINT:
|
case F_T_UINT:
|
||||||
if (settings[j].cfg_vals == NULL)
|
if (setting->cfg_vals == NULL)
|
||||||
{
|
{
|
||||||
setting->value.number = atoi(text);
|
touchsetting->value.number = atoi(text);
|
||||||
}
|
}
|
||||||
else if (cfg_string_to_int(j, &temp, text))
|
else if (cfg_string_to_int(setting, &temp, text))
|
||||||
{
|
{
|
||||||
if (settings[j].flags&F_TABLE_SETTING)
|
if (setting->flags & F_TABLE_SETTING)
|
||||||
setting->value.number =
|
touchsetting->value.number =
|
||||||
settings[j].table_setting->values[temp];
|
setting->table_setting->values[temp];
|
||||||
else
|
else
|
||||||
setting->value.number = temp;
|
touchsetting->value.number = temp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
break;
|
break;
|
||||||
case F_T_BOOL:
|
case F_T_BOOL:
|
||||||
if (cfg_string_to_int(j, &temp, text))
|
if (cfg_string_to_int(setting, &temp, text))
|
||||||
{
|
{
|
||||||
setting->value.number = temp;
|
touchsetting->value.number = temp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -232,9 +232,9 @@ void settings_load(int which)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cfg_string_to_int(int setting_id, int* out, const char* str)
|
bool cfg_string_to_int(const struct settings_list *setting, int* out, const char* str)
|
||||||
{
|
{
|
||||||
const char* start = settings[setting_id].cfg_vals;
|
const char* start = setting->cfg_vals;
|
||||||
char* end = NULL;
|
char* end = NULL;
|
||||||
char temp[MAX_PATH];
|
char temp[MAX_PATH];
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -353,7 +353,7 @@ bool settings_load_config(const char* file, bool apply)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int temp, *v = (int*)setting->setting;
|
int temp, *v = (int*)setting->setting;
|
||||||
bool found = cfg_string_to_int(index, &temp, value);
|
bool found = cfg_string_to_int(setting, &temp, value);
|
||||||
if (found)
|
if (found)
|
||||||
{
|
{
|
||||||
if (setting->flags & F_TABLE_SETTING)
|
if (setting->flags & F_TABLE_SETTING)
|
||||||
|
@ -370,7 +370,7 @@ bool settings_load_config(const char* file, bool apply)
|
||||||
case F_T_BOOL:
|
case F_T_BOOL:
|
||||||
{
|
{
|
||||||
int temp;
|
int temp;
|
||||||
if (cfg_string_to_int(index, &temp, value))
|
if (cfg_string_to_int(setting, &temp, value))
|
||||||
*(bool*)setting->setting = !!temp;
|
*(bool*)setting->setting = !!temp;
|
||||||
if (setting->bool_setting->option_callback)
|
if (setting->bool_setting->option_callback)
|
||||||
setting->bool_setting->option_callback(!!temp);
|
setting->bool_setting->option_callback(!!temp);
|
||||||
|
|
|
@ -266,7 +266,7 @@ enum optiontype { INT, BOOL };
|
||||||
const struct settings_list* find_setting(const void* variable, int *id);
|
const struct settings_list* find_setting(const void* variable, int *id);
|
||||||
const struct settings_list* find_setting_by_cfgname(const char* name, int *id);
|
const struct settings_list* find_setting_by_cfgname(const char* name, int *id);
|
||||||
bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len);
|
bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len);
|
||||||
bool cfg_string_to_int(int setting_id, int* out, const char* str);
|
bool cfg_string_to_int(const struct settings_list *setting, int* out, const char* str);
|
||||||
bool cfg_to_string(int setting_id, char* buf, int buf_len);
|
bool cfg_to_string(int setting_id, char* buf, int buf_len);
|
||||||
bool copy_filename_setting(char *buf, size_t buflen, const char *input,
|
bool copy_filename_setting(char *buf, size_t buflen, const char *input,
|
||||||
const struct filename_setting *fs);
|
const struct filename_setting *fs);
|
||||||
|
|
Loading…
Reference in a new issue