1
0
Fork 0
forked from len0rd/rockbox

skin engine: Settings ID to pointer conversions

Convert %St tag to operate on settings pointers instead of IDs.

Change-Id: Iabf4c280be82b495a64b560b59620fb477e0c738
This commit is contained in:
Aidan MacDonald 2022-11-30 12:27:52 +00:00
parent 4ff97ae07c
commit 1e6c8d2ea6
7 changed files with 19 additions and 18 deletions

View file

@ -578,9 +578,8 @@ bool option_screen(const struct settings_list *setting,
return false;
}
int get_setting_info_for_bar(int setting_id, int *count, int *val)
int get_setting_info_for_bar(const struct settings_list *setting, int *count, int *val)
{
const struct settings_list *setting = &settings[setting_id];
int var_type = setting->flags&F_T_MASK;
void (*function)(int) = NULL;
int oldvalue;
@ -605,9 +604,8 @@ int get_setting_info_for_bar(int setting_id, int *count, int *val)
}
#ifdef HAVE_TOUCHSCREEN
void update_setting_value_from_touch(int setting_id, int selection)
void update_setting_value_from_touch(const struct settings_list *setting, int selection)
{
const struct settings_list *setting = &settings[setting_id];
int new_val = selection_to_val(setting, selection);
int var_type = setting->flags&F_T_MASK;

View file

@ -46,9 +46,9 @@ void option_talk_value(const struct settings_list *setting, int value, bool enqu
/* only use this for int and bool settings */
int option_value_as_int(const struct settings_list *setting);
int get_setting_info_for_bar(int setting_id, int *count, int *val);
int get_setting_info_for_bar(const struct settings_list *setting, int *count, int *val);
#ifdef HAVE_TOUCHSCREEN
void update_setting_value_from_touch(int setting_id, int selection);
void update_setting_value_from_touch(const struct settings_list *setting, int selection);
#endif
#endif /* _GUI_OPTION_SELECT_H_ */

View file

@ -212,7 +212,7 @@ void draw_progressbar(struct gui_wps *gwps, struct skin_viewport* skin_viewport,
else if (pb->type == SKIN_TOKEN_SETTINGBAR)
{
int val, count;
get_setting_info_for_bar(pb->setting_id, &count, &val);
get_setting_info_for_bar(pb->setting, &count, &val);
length = count - 1;
end = val;
}

View file

@ -803,14 +803,14 @@ static int parse_setting_and_lang(struct skin_element *element,
*/
(void)wps_data;
char *temp = get_param_text(element, 0);
int i;
if (token->type == SKIN_TOKEN_TRANSLATEDSTRING)
{
#ifndef __PCTOOL__
i = lang_english_to_id(temp);
int i = lang_english_to_id(temp);
if (i < 0)
i = LANG_LAST_INDEX_IN_ARRAY;
token->value.i = i;
#endif
}
else if (element->params_count > 1)
@ -823,12 +823,13 @@ static int parse_setting_and_lang(struct skin_element *element,
else
{
#ifndef __PCTOOL__
if (find_setting_by_cfgname(temp, &i) == NULL)
const struct settings_list *setting = find_setting_by_cfgname(temp, NULL);
if (!setting)
return WPS_ERROR_INVALID_PARAM;
token->value.xdata = (void *)setting;
#endif
}
/* Store the setting number */
token->value.i = i;
return 0;
}
@ -972,7 +973,7 @@ static int parse_progressbar_tag(struct skin_element* element,
pb->image = PTRTOSKINOFFSET(skin_buffer, NULL);
pb->slider = PTRTOSKINOFFSET(skin_buffer, NULL);
pb->backdrop = PTRTOSKINOFFSET(skin_buffer, NULL);
pb->setting_id = -1;
pb->setting = NULL;
pb->invert_fill_direction = false;
pb->horizontal = true;
@ -1157,7 +1158,8 @@ static int parse_progressbar_tag(struct skin_element* element,
param++;
text = SKINOFFSETTOPTR(skin_buffer, param->data.text);
#ifndef __PCTOOL__
if (find_setting_by_cfgname(text, &pb->setting_id) == NULL)
pb->setting = find_setting_by_cfgname(text, NULL);
if (!pb->setting)
return WPS_ERROR_INVALID_PARAM;
#endif
}

View file

@ -1371,7 +1371,7 @@ const char *get_token_value(struct gui_wps *gwps,
case SKIN_TOKEN_SETTING:
{
const struct settings_list *s = settings+token->value.i;
const struct settings_list *s = token->value.xdata;
if (intval)
{
/* Handle contionals */

View file

@ -313,9 +313,9 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset)
if (bar && edge_offset)
{
int val, count;
get_setting_info_for_bar(bar->setting_id, &count, &val);
get_setting_info_for_bar(bar->setting, &count, &val);
val = *edge_offset * count / 1000;
update_setting_value_from_touch(bar->setting_id, val);
update_setting_value_from_touch(bar->setting, val);
}
}
break;

View file

@ -73,6 +73,7 @@ struct wps_token {
unsigned short i;
long l;
OFFSETTYPE(void*) data;
void *xdata;
} value;
enum skin_token_type type; /* enough to store the token type */
@ -131,7 +132,7 @@ struct progressbar {
OFFSETTYPE(struct gui_img *) slider;
bool horizontal;
OFFSETTYPE(struct gui_img *) backdrop;
int setting_id; /* for the setting bar type */
const struct settings_list *setting;
};