diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 3e91536411..8ecbf7b7f9 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -1546,48 +1546,48 @@ static int touchregion_setup_setting(struct skin_element *element, int param_no, #ifndef __PCTOOL__ int p = param_no; char *name = get_param_text(element, p++); - int j; - - region->setting_data.setting = find_setting_by_cfgname(name, &j); - if (region->setting_data.setting == NULL) + const struct settings_list *setting = find_setting_by_cfgname(name, NULL); + if (!setting) return WPS_ERROR_INVALID_PARAM; + region->setting_data.setting = setting; + if (region->action == ACTION_SETTINGS_SET) { char* text; int temp; - struct touchsetting *setting = + struct touchsetting *touchsetting = ®ion->setting_data; if (element->params_count < p+1) return -1; text = get_param_text(element, p++); - switch (settings[j].flags&F_T_MASK) + switch (setting->flags & F_T_MASK) { case F_T_CUSTOM: - setting->value.text = PTRTOSKINOFFSET(skin_buffer, text); + touchsetting->value.text = PTRTOSKINOFFSET(skin_buffer, text); break; case F_T_INT: 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) - setting->value.number = - settings[j].table_setting->values[temp]; + if (setting->flags & F_TABLE_SETTING) + touchsetting->value.number = + setting->table_setting->values[temp]; else - setting->value.number = temp; + touchsetting->value.number = temp; } else return -1; break; 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 return -1; diff --git a/apps/settings.c b/apps/settings.c index f166abd06f..d8e4af1460 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -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 temp[MAX_PATH]; int count = 0; @@ -353,7 +353,7 @@ bool settings_load_config(const char* file, bool apply) else { 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 (setting->flags & F_TABLE_SETTING) @@ -370,7 +370,7 @@ bool settings_load_config(const char* file, bool apply) case F_T_BOOL: { int temp; - if (cfg_string_to_int(index, &temp, value)) + if (cfg_string_to_int(setting, &temp, value)) *(bool*)setting->setting = !!temp; if (setting->bool_setting->option_callback) setting->bool_setting->option_callback(!!temp); diff --git a/apps/settings.h b/apps/settings.h index df82ae3687..5d1237b1a5 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -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_by_cfgname(const char* name, int *id); 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 copy_filename_setting(char *buf, size_t buflen, const char *input, const struct filename_setting *fs);