skin_engine: make skin file type available to parser

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]>
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit 50b13493d2f83b8644414cefb315658ac653f201
Author: Christian Soffke <[email protected]>
Date:   Sun Aug 16 15:36:44 2026 +0200

    skin_engine: make skin file type available to parser
    
    Keep track of the type of skin file being parsed,
    in case a tag needs this info.
    
    E.g. %Lt should be ignored in any skin other than
    SBS files.
    
    Change-Id: Ib7e52c3e6810196cb566adb65619a1b847cf20ef

diff --git a/apps/gui/skin_engine/skin_engine.c b/apps/gui/skin_engine/skin_engine.c
index b7aaf65a6b..e382fb65c0 100644
--- a/apps/gui/skin_engine/skin_engine.c
+++ b/apps/gui/skin_engine/skin_engine.c
@@ -211,12 +211,12 @@ static void skin_load(enum skinnable_screens skin, enum screen_type screen,
     skin_helpers[skin]->process(screen, &skins[skin][screen].data, true);
 
     if (filename && *filename)
-        loaded = skin_data_load(screen, &skins[skin][screen].data,
+        loaded = skin_data_load(skin, screen, &skins[skin][screen].data,
                                 filename, true, &skins[skin][screen].stats);
 
     if (!loaded && skin_helpers[skin]->default_skin)
     {
-        loaded = skin_data_load(screen, &skins[skin][screen].data,
+        loaded = skin_data_load(skin, screen, &skins[skin][screen].data,
                                 skin_helpers[skin]->default_skin(screen),
                                 false, &skins[skin][screen].stats);
         skins[skin][screen].failsafe_loaded = loaded;
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index 0bbabb9f3f..14ec327a67 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -115,8 +115,9 @@ get_param(struct skin_element *element, int param_number)
     return &params[param_number];
 }
 
-/* which screen are we parsing for? */
+/* which screen and skin are we parsing for? */
 static enum screen_type curr_screen;
+static enum skinnable_screens curr_skin;
 
 /* the current viewport */
 static struct skin_element *curr_viewport_element;
@@ -2593,8 +2594,9 @@ static int skin_element_callback(struct skin_element* element, void* data)
 
 /* Set up skin data from a format buffer (isfile = false)
                        or from skin file (isfile = true) */
-bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
-                    const char *buf, bool isfile, struct skin_stats *stats)
+bool skin_data_load(enum skinnable_screens skin, enum screen_type screen,
+                    struct wps_data *wps_data, const char *buf, bool isfile,
+                    struct skin_stats *stats)
 {
     char *wps_buffer = NULL;
     if (!wps_data || !buf)
@@ -2624,6 +2626,7 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
     skin_data_reset(wps_data);
     wps_data->wps_loaded = false;
     curr_screen = screen;
+    curr_skin = skin;
     curr_line = NULL;
     curr_vp = NULL;
     curr_viewport_element = NULL;
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h
index 092f0991b0..74c51e9994 100644
--- a/apps/gui/skin_engine/wps_internals.h
+++ b/apps/gui/skin_engine/wps_internals.h
@@ -25,6 +25,7 @@
 #define _WPS_ENGINE_INTERNALS_
 
 #include "tag_table.h"
+#include "skin_engine.h"
 #include "skin_parser.h"
 #include "gesture.h"
 #ifndef __PCTOOL__
@@ -46,8 +47,9 @@ bool skin_backdrop_get_debug(int index, char **path, int *ref_count, size_t *siz
 
 /* Set up skin data from a format buffer (isfile = false)
                        or from skin file (isfile = true) */
-bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
-                    const char *buf, bool isfile, struct skin_stats *stats);
+bool skin_data_load(enum skinnable_screens skin, enum screen_type screen,
+                    struct wps_data *wps_data, const char *buf, bool isfile,
+                    struct skin_stats *stats);
 
 /* Timeout unit expressed in HZ. In WPS, all timeouts are given in seconds
    (possibly with a decimal fraction) but stored as integer values.
diff --git a/tools/checkwps/checkwps.c b/tools/checkwps/checkwps.c
index f46e57173d..6534fa9eac 100644
--- a/tools/checkwps/checkwps.c
+++ b/tools/checkwps/checkwps.c
@@ -278,6 +278,61 @@ struct font* font_get(int font)
 /* This is no longer defined in ROCKBOX builds so just use a huge value */
 #define SKIN_BUFFER_SIZE (200*1024)
 
+int check_filetype(const char *ext, enum skinnable_screens *skin,
+                    enum screen_type *screen)
+{
+    if (!strcmp(ext, "sbs"))
+    {
+        *skin = CUSTOM_STATUSBAR;
+        *screen = SCREEN_MAIN;
+    }
+    else if (!strcmp(ext, "wps"))
+    {
+        *skin = WPS;
+        *screen = SCREEN_MAIN;
+    }
+    else if (!strcmp(ext, "fms"))
+    {
+#if CONFIG_TUNER
+        *skin = FM_SCREEN;
+        *screen = SCREEN_MAIN;
+#else
+        return 1;
+#endif
+    }
+    else if (!strcmp(ext, "rsbs"))
+    {
+#ifdef HAVE_REMOTE_LCD
+        *skin = CUSTOM_STATUSBAR;
+        *screen = SCREEN_REMOTE;
+#else
+        return 1;  /* unsupported, but not an error */
+#endif
+    }
+    else if (!strcmp(ext, "rwps"))
+    {
+#ifdef HAVE_REMOTE_LCD
+        *skin = WPS;
+        *screen = SCREEN_REMOTE;
+#else
+        return 1;
+#endif
+    }
+    else if (!strcmp(ext, "rfms"))
+    {
+#if defined(HAVE_REMOTE_LCD) && CONFIG_TUNER
+        *skin = FM_SCREEN;
+        *screen = SCREEN_REMOTE;
+#else
+        return 1;
+#endif
+    }
+    else
+        return -1;
+
+    return 0;
+}
+
 int main(int argc, char **argv)
 {
     int ret = 0;
@@ -286,6 +341,7 @@ int main(int argc, char **argv)
 
     struct wps_data wps={0};
     enum screen_type screen = SCREEN_MAIN;
+    enum skinnable_screens skin;
     struct screen* wps_screen;
 
     /* No arguments -> print the help text
@@ -335,28 +391,20 @@ int main(int argc, char **argv)
             goto done;
         }
         ext++;
-        if (!strcmp(ext, "rwps") || !strcmp(ext, "rsbs") || !strcmp(ext, "rfms"))
-        {
-#ifdef HAVE_REMOTE_LCD
-            screen = SCREEN_REMOTE;
-#else
-            /* skip rwps etc. if not supported on this target (not an error) */
-            continue;
-#endif
-        }
-        else if (!strcmp(ext, "wps")  || !strcmp(ext, "sbs")  || !strcmp(ext, "fms"))
-        {
-            screen = SCREEN_MAIN;
-        }
-        else
+
+        int valid = check_filetype(ext, &skin, &screen);
+        if (valid < 0)
         {
             printf("Invalid extension\n");
             ret = 2;
             goto done;
         }
+        else if (valid > 0)
+            continue; /* skip (unsupported by this target but not an error) */
+
         wps_screen = &screens[screen];
 
-        res = skin_data_load(screen, &wps, name, true, &stats);
+        res = skin_data_load(skin, screen, &wps, name, true, &stats);
 
         if (!res) {
             printf("WPS parsing failure\n");
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.