From: H.G.Muller Date: Sun, 17 Apr 2016 08:05:39 +0000 (+0200) Subject: Use missing SVG from parent if -pid name starts with sub_ X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=caebf04d588b07dd8691c65a9b5cc145829e69b9 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. --- 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);