From 96f42a56467dd72ab42f7e01949ec3cb4b7955df Mon Sep 17 00:00:00 2001 From: Evan Kenny Date: Mon, 1 Jul 2024 15:19:17 +0100 Subject: skin engine: Add tags to display Quickscreen Items A set of new tags for themes that allow them to display a quickscreen item's name or value like what is displayed on the default quickscreen. There are 8 tags in total, 2 for each direction or "item". One type of tag displays the setting name, while the other displays the setting's value. All tags output an "ERR" string if no valid setting is found for that item. Quickscreen Item name tags: %QT, %QR, %QB and %QL. Quickscreen Item value tags: %Qt, %Qr, %Qb and %Ql. Change-Id: Ia08ba5940e38065e051a0aefa2cff142c9e58684 --- apps/gui/skin_engine/skin_tokens.c | 37 +++++++++++++++++++++++++++++++++++++ lib/skin_parser/tag_table.c | 9 +++++++++ lib/skin_parser/tag_table.h | 10 ++++++++++ manual/appendix/wps_tags.tex | 18 ++++++++++++++++++ 4 files changed, 74 insertions(+) diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c index 42c56f7203..ba9396ae74 100644 --- a/apps/gui/skin_engine/skin_tokens.c +++ b/apps/gui/skin_engine/skin_tokens.c @@ -66,6 +66,7 @@ #include "fixedpoint.h" #endif #include "list.h" +#include "option_select.h" #include "wps.h" #define NOINLINE __attribute__ ((noinline)) @@ -658,6 +659,23 @@ static const char* NOINLINE get_lif_token_value(struct gui_wps *gwps, return NULL; } +#ifdef HAVE_QUICKSCREEN +static const char* get_qs_token_value(enum quickscreen_item item, bool data_token, + char *buf, int buf_size) +{ + const struct settings_list *qs_setting = global_settings.qs_items[item]; + + if (qs_setting == NULL) + return "ERR"; + + if (data_token) + return option_get_valuestring(qs_setting, buf, buf_size, + option_value_as_int(qs_setting)); + + return P2STR(ID2P(qs_setting->lang_id)); +} +#endif + /* Return the tags value as text. buf should be used as temp storage if needed. intval is used with conditionals/enums: when this function is called, @@ -1374,6 +1392,25 @@ const char *get_token_value(struct gui_wps *gwps, return NULL; #endif +#ifdef HAVE_QUICKSCREEN + case SKIN_TOKEN_TOP_QUICKSETTING_NAME: + return get_qs_token_value(QUICKSCREEN_TOP, false, buf, buf_size); + case SKIN_TOKEN_TOP_QUICKSETTING_VALUE: + return get_qs_token_value(QUICKSCREEN_TOP, true, buf, buf_size); + case SKIN_TOKEN_RIGHT_QUICKSETTING_NAME: + return get_qs_token_value(QUICKSCREEN_RIGHT, false, buf, buf_size); + case SKIN_TOKEN_RIGHT_QUICKSETTING_VALUE: + return get_qs_token_value(QUICKSCREEN_RIGHT, true, buf, buf_size); + case SKIN_TOKEN_BOTTOM_QUICKSETTING_NAME: + return get_qs_token_value(QUICKSCREEN_BOTTOM, false, buf, buf_size); + case SKIN_TOKEN_BOTTOM_QUICKSETTING_VALUE: + return get_qs_token_value(QUICKSCREEN_BOTTOM, true, buf, buf_size); + case SKIN_TOKEN_LEFT_QUICKSETTING_NAME: + return get_qs_token_value(QUICKSCREEN_LEFT, false, buf, buf_size); + case SKIN_TOKEN_LEFT_QUICKSETTING_VALUE: + return get_qs_token_value(QUICKSCREEN_LEFT, true, buf, buf_size); +#endif + case SKIN_TOKEN_SETTING: { const struct settings_list *s = token->value.xdata; diff --git a/lib/skin_parser/tag_table.c b/lib/skin_parser/tag_table.c index d2aded1b12..d9d3cebaca 100644 --- a/lib/skin_parser/tag_table.c +++ b/lib/skin_parser/tag_table.c @@ -210,6 +210,15 @@ static const struct tag_info legal_tags[] = { SKIN_TOKEN_VIEWPORT_CONDITIONAL, "Vl" , "S[IP][IP][ip][ip]i", 0 }, { SKIN_TOKEN_UIVIEWPORT_LOAD, "Vi" , "s[IP][IP][ip][ip]i", 0 }, { SKIN_TOKEN_VIEWPORT_LOAD, "V" , "[IP][IP][ip][ip]i", 0 }, + + { SKIN_TOKEN_TOP_QUICKSETTING_NAME, "QT" , "", SKIN_REFRESH_DYNAMIC }, + { SKIN_TOKEN_TOP_QUICKSETTING_VALUE, "Qt" , "", SKIN_REFRESH_DYNAMIC }, + { SKIN_TOKEN_RIGHT_QUICKSETTING_NAME, "QR" , "", SKIN_REFRESH_DYNAMIC }, + { SKIN_TOKEN_RIGHT_QUICKSETTING_VALUE, "Qr" , "", SKIN_REFRESH_DYNAMIC }, + { SKIN_TOKEN_BOTTOM_QUICKSETTING_NAME, "QB" , "", SKIN_REFRESH_DYNAMIC }, + { SKIN_TOKEN_BOTTOM_QUICKSETTING_VALUE, "Qb" , "", SKIN_REFRESH_DYNAMIC }, + { SKIN_TOKEN_LEFT_QUICKSETTING_NAME, "QL" , "", SKIN_REFRESH_DYNAMIC }, + { SKIN_TOKEN_LEFT_QUICKSETTING_VALUE, "Ql" , "", SKIN_REFRESH_DYNAMIC }, { SKIN_TOKEN_IMAGE_BACKDROP, "X" , "f", SKIN_REFRESH_STATIC|NOBREAK }, /* This uses the bar tag params also but the first item can be a string diff --git a/lib/skin_parser/tag_table.h b/lib/skin_parser/tag_table.h index 54ba23ce6e..6807be3f0e 100644 --- a/lib/skin_parser/tag_table.h +++ b/lib/skin_parser/tag_table.h @@ -245,6 +245,16 @@ enum skin_token_type { SKIN_TOKEN_MAIN_HOLD, SKIN_TOKEN_REMOTE_HOLD, + /* Quickscreen */ + SKIN_TOKEN_TOP_QUICKSETTING_NAME, + SKIN_TOKEN_TOP_QUICKSETTING_VALUE, + SKIN_TOKEN_RIGHT_QUICKSETTING_NAME, + SKIN_TOKEN_RIGHT_QUICKSETTING_VALUE, + SKIN_TOKEN_BOTTOM_QUICKSETTING_NAME, + SKIN_TOKEN_BOTTOM_QUICKSETTING_VALUE, + SKIN_TOKEN_LEFT_QUICKSETTING_NAME, + SKIN_TOKEN_LEFT_QUICKSETTING_VALUE, + /* Setting option */ SKIN_TOKEN_SETTING, SKIN_TOKEN_SETTINGBAR, diff --git a/manual/appendix/wps_tags.tex b/manual/appendix/wps_tags.tex index ecdae6c0b9..567edd3c11 100644 --- a/manual/appendix/wps_tags.tex +++ b/manual/appendix/wps_tags.tex @@ -354,6 +354,24 @@ Examples: \item As a conditional: \config{\%?St(eq enabled)} \end{enumerate} +\opt{quickscreen}{ +\subsection{Displaying Quickscreen settings} + +If your player has a quickscreen, the preset settings can be displayed using the following. + +\begin{tagmap} + \config{\%QT} & Display the name of the top quickscreen setting.\\ + \config{\%Qt} & Display the value of the top quickscreen setting.\\ + \config{\%QR} & Display the name of the right quickscreen setting.\\ + \config{\%Qr} & Display the value of the right quickscreen setting.\\ + \config{\%QB} & Display the name of the bottom quickscreen setting.\\ + \config{\%Qb} & Display the value of the bottom quickscreen setting.\\ + \config{\%QL} & Display the name of the left quickscreen setting.\\ + \config{\%Ql} & Display the value of the left quickscreen setting.\\ + \end{tagmap} + + \note{If a preset does not match a legal setting, or has no setting applied, all tags will display "ERR".} +} \section{\label{ref:wps_images}Images} \begin{tagmap} -- cgit v1.2.3