From caebf04d588b07dd8691c65a9b5cc145829e69b9 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Sun, 17 Apr 2016 10:05:39 +0200 Subject: [PATCH] Use missing SVG from parent if -pid name starts with sub_ If the current piece-image directory's name starts with "sub_", any pieces not found in it will be searched in the parent directory. This allows variants that need just a few pieces of a theme changed to get their own sub_xxx sub-directory within the directory with SVG images, containing the deviating SVGs. This will work recursively. --- draw.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/draw.c b/draw.c index 4ad6887..82072bf 100644 --- a/draw.c +++ b/draw.c @@ -351,6 +351,15 @@ LoadSVG (char *dir, int color, int piece, int retry) if(!svg && *dir) { svg = rsvg_handle_new_from_file(buf, &svgerror); + if(!svg) { // failed! If -pid name starts with "sub_" we try to load the piece from the parent directory + char *p = buf, *q; + safeStrCpy(buf, dir, MSG_SIZ); + while((q = strchr(p, '/'))) p = q + 1; + if(!strncmp(p, "sub_", 4)) { + if(p == buf) safeStrCpy(buf, ".", MSG_SIZ); else p[-1] = NULLCHAR; // strip last directory off path + return LoadSVG(buf, color, piece, retry); + } + } if(!svg && *appData.inscriptions) { // if there is no piece-specific SVG, but we make inscriptions, try general background snprintf(buf, MSG_SIZ, "%s/%sTile.svg", dir, color ? "Black" : "White"); svg = rsvg_handle_new_from_file(buf, &svgerror); -- 1.7.0.4