From 00d05083b79425df65a461924f112a950f727601 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Fri, 13 Mar 2015 21:42:53 +0100 Subject: [PATCH] Also allow Princess SVG piece to be diversify The image for the Grasshopper has a copy in the Chu-promoted series. The unpromoted image (not needed in Chu) is now preferentially taken from a Crown image rather than Princess, allowing distinction between the promoted and unpromoted piece in kanji themes for Wa Shogi. Any piece between Grasshopper and chu-promoted Marhall can now in principle use a backup. --- draw.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) diff --git a/draw.c b/draw.c index d0b3eda..848fa61 100644 --- a/draw.c +++ b/draw.c @@ -284,11 +284,12 @@ char *pngPieceNames[] = // must be in same order as internal piece encoding { "Pawn", "Knight", "Bishop", "Rook", "Queen", "Advisor", "Elephant", "Archbishop", "Marshall", "Gold", "Commoner", "Canon", "Nightrider", "CrownedBishop", "CrownedRook", "Princess", "Chancellor", "Hawk", "Lance", "Cobra", "Unicorn", "Lion", "GoldPawn", "HSword", "PromoHorse", "PromoDragon", "Leopard", "PromoSword", "Prince", "Phoenix", "Kylin", "PromoRook", "PromoHSword", - "Dolphin", "Chancellor", "Unicorn", "Hawk", "Sword", "Princess", "HCrown", "Knight", "Elephant", "PromoBishop", "King", + "Dolphin", "Chancellor", "Unicorn", "Hawk", "Sword", "Crown", "HCrown", "Knight", "Elephant", "PromoBishop", "King", "Claw", "GoldKnight", "GoldLance", "GoldSilver", NULL }; -char *backupPiece[] = { "King", "Queen", "Lion" }; // pieces that map on other when not kanji +char *backupPiece[] = { "Princess", NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, "King", "Queen", "Lion" }; // pieces that map on other when not kanji RsvgHandle * LoadSVG (char *dir, int color, int piece, int retry) @@ -299,9 +300,11 @@ LoadSVG (char *dir, int color, int piece, int retry) GError *svgerror=NULL; cairo_surface_t *img; cairo_t *cr; + char *name = (retry ? backupPiece[piece - WhiteGrasshopper] : pngPieceNames[piece]); - snprintf(buf, MSG_SIZ, "%s/%s%s.svg", dir, color ? "Black" : "White", - retry ? backupPiece[piece - WhiteMonarch] : pngPieceNames[piece]); + if(!name) return NULL; + + snprintf(buf, MSG_SIZ, "%s/%s%s.svg", dir, color ? "Black" : "White", name); if(svg || *dir && (svg = rsvg_handle_new_from_file(buf, &svgerror))) { @@ -319,7 +322,7 @@ LoadSVG (char *dir, int color, int piece, int retry) return svg; } - if(!retry && piece >= WhiteMonarch && piece <= WhiteNothing) // pieces that are only different in kanji sets + if(!retry && piece >= WhiteGrasshopper && piece <= WhiteNothing) // pieces that are only different in kanji sets return LoadSVG(dir, color, piece, 1); if(svgerror) g_error_free(svgerror); -- 1.7.0.4