From c5e79d2e39fbafdeb7fac07906891d33b7a5363a Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Wed, 23 Oct 2013 16:31:01 +0200 Subject: [PATCH] Supply oriental theme settings Install creates a new directory .../themes/conf, in which a number of settings files are places for defining oriental themes. These redefine the user settings file for each of them to ~/.xboard-xxx-rc, so the settings cannot leak into the default user settings file, but are nevertheless persistent on revisiting the theme. XBoard now looks in this directory for settingsfiles it could otherwise not find, so they can be invoked with @shogi, @xq, @chu on the XBoard command line. Filenames starting with ~~ will now be expanded to the directory where the XBoard data files are installed, so the installed settings files can easily refer to installed other files (e.g. piece SVGs and textures). The themes files will also redefine the default engine when they belong to variants that Fairy-Max does not play. Some minor settings files for implementing variants that are not standard (such as mini- and Sho Shogi) are also added in the conf directory. --- Makefile.am | 7 ++++++- args.h | 14 ++++++++++++++ conf/chu | 42 ++++++++++++++++++++++++++++++++++++++++++ conf/ics | 10 ++++++++++ conf/judkins | 19 +++++++++++++++++++ conf/judkins.fen | 2 ++ conf/mini | 24 ++++++++++++++++++++++++ conf/mini.fen | 2 ++ conf/sho | 24 ++++++++++++++++++++++++ conf/sho.fen | 2 ++ conf/shogi | 41 +++++++++++++++++++++++++++++++++++++++++ conf/xiangqi | 30 ++++++++++++++++++++++++++++++ conf/xq | 36 ++++++++++++++++++++++++++++++++++++ usystem.c | 3 +++ 14 files changed, 255 insertions(+), 1 deletions(-) create mode 100644 conf/chu create mode 100644 conf/ics create mode 100644 conf/judkins create mode 100644 conf/judkins.fen create mode 100644 conf/mini create mode 100644 conf/mini.fen create mode 100644 conf/sho create mode 100644 conf/sho.fen create mode 100644 conf/shogi create mode 100644 conf/xiangqi create mode 100644 conf/xq diff --git a/Makefile.am b/Makefile.am index e9d8ca8..8ad5afc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -70,7 +70,7 @@ DISTCLEANFILES = stamp-h GITVERSION=$(shell sh -c 'git describe --dirty --always 2>/dev/null') AM_CPPFLAGS=-DINFODIR='"$(infodir)"' @X_CFLAGS@ @CAIRO_CFLAGS@ @FRONTEND_CFLAGS@ -DSYSCONFDIR='"$(sysconfdir)"' \ -DLOCALEDIR='"$(localedir)"' -DSVGDIR='"$(svgdir)"' -D__GIT_VERSION='"$(GITVERSION)"' \ - -DCONFIGURE_OPTIONS='"@CONFIGURE_OPTIONS@"' $(headers) + -DCONFIGURE_OPTIONS='"@CONFIGURE_OPTIONS@"' -DDATADIR='"$(datadir)/games/xboard"' $(headers) ACLOCAL_AMFLAGS = -I m4 @@ -176,6 +176,11 @@ dist_xiangqi_DATA = themes/xiangqi/BlackAdvisor.svg themes/xiangqi/WhiteAdvisor themes/xiangqi/BlackPawn.svg themes/xiangqi/WhitePawn.svg \ themes/xiangqi/BlackRook.svg themes/xiangqi/WhiteRook.svg +### directory and files for themes (and other) configuration files + +themesdir = $(datadir)/games/xboard/themes/conf +dist_themes_DATA = conf/shogi conf/xq conf/chu conf/ics conf/mini conf/mini.fen conf/sho conf/sho.fen + ### directory and files for pixmaps pixmapsdir = $(gamedatadir)/pixmaps/textures diff --git a/args.h b/args.h index 03a7f43..827952e 100644 --- a/args.h +++ b/args.h @@ -875,6 +875,12 @@ ParseSettingsFile(char *name, char **addr) } if (ok) { f = fopen(fullname, "r"); +#ifdef DATADIR + if(f == NULL && *fullname != '/') { // when a relative name did not work + MySearchPath(DATADIR "/themes/conf", name, fullname); // also look in standard place + f = fopen(fullname, "r"); + } +#endif if (f != NULL) { if (addr != NULL) { ASSIGN(*addr, fullname); @@ -1107,6 +1113,14 @@ ParseArgs(GetFunc get, void *cl) case ArgString: case ArgFilename: +#ifdef DATADIR + if(argValue[0] == '~' && argValue[1] == '~') { + char buf[4*MSG_SIZ]; // expand ~~ + snprintf(buf, 4*MSG_SIZ, DATADIR "%s", argValue+2); + ASSIGN(*(char **) ad->argLoc, buf); + break; + } +#endif ASSIGN(*(char **) ad->argLoc, argValue); break; diff --git a/conf/chu b/conf/chu new file mode 100644 index 0000000..45195ef --- /dev/null +++ b/conf/chu @@ -0,0 +1,42 @@ +; +; settings for oriental Chu-Shogi theme +; +-variant chu +; +; pieces: supplied chu-shogi svg's, and flip them in flipView +; +-pid ~~/themes/chu +-flipBlack true +-trueColors true +; +; board: no checkering (both w. and w.o. texture) +; +-liteBackTextureFile "~~/themes/textures/wood_l.png" +-darkBackTextureFile "~~/themes/textures/wood_l.png" +-lightSquareColor #FF8040 +-darkSquareColor #FF8040 +; +; detour under-promotion is less convenient when non-pawns promote +; +-sweepPromotions false +; +; legality testing must be on for double-moves to work, no adjudication +; +-testLegality true +-trivialDraws false +-materialDraws false +; +; make the Lion roar on double captures +; +-roarSound roar.wav +; +; redefine default engine +; +-fcp hachu +-scp hachu +; +; set up own persistence file, used for this theme only +; +-settingsFile ~/.xboard-chu-rc +-saveSettingsFile ~/.xboard-chu-rc + diff --git a/conf/ics b/conf/ics new file mode 100644 index 0000000..9823c73 --- /dev/null +++ b/conf/ics @@ -0,0 +1,10 @@ +; +; settings for Internet Chess Server client +; +-ics +; +; set up own persistence file, used for ICS play +; +-settingsFile ~/.xboard-ics-rc +-saveSettingsFile ~/.xboard-ics-rc + diff --git a/conf/judkins b/conf/judkins new file mode 100644 index 0000000..250369d --- /dev/null +++ b/conf/judkins @@ -0,0 +1,19 @@ +; +; additional settings for Judkins Shogi +; +-variant shogi +; +; size overrides +; +-boardWidth 6 +-boardHeight 6 +-holdingsSize 6 +; +; remove L from piece set +; +-pieceToCharTable "PNBR.S...G.++++.+Kpnbr.s...g.++++.+k" +; +; provide initial position +; +-loadPositionFile "~~/themes/conf/judkins.fen" + diff --git a/conf/judkins.fen b/conf/judkins.fen new file mode 100644 index 0000000..d805858 --- /dev/null +++ b/conf/judkins.fen @@ -0,0 +1,2 @@ +rbnsgk/6p/6/6/P5/KGSNBR w 0 1 + diff --git a/conf/mini b/conf/mini new file mode 100644 index 0000000..ee6fce6 --- /dev/null +++ b/conf/mini @@ -0,0 +1,24 @@ +; +; additional settings for mini-Shogi +; +-variant shogi +; +; size overrides +; +-boardWidth 5 +-boardHeight 5 +-holdingsSize 5 +; +; remove L and N from piece set +; +-pieceToCharTable "P.BR.S...G.+.++.+Kp.br.s...g.+.++.+k" +; +; redefine default engine +; +-fcp gnuminishogi +-scp gnuminishogi +; +; provide initial position +; +-loadPositionFile "~~/themes/conf/mini.fen" + diff --git a/conf/mini.fen b/conf/mini.fen new file mode 100644 index 0000000..7ddea3a --- /dev/null +++ b/conf/mini.fen @@ -0,0 +1,2 @@ +rbsgk/4p/5/P4/KGSBR w 0 1 + diff --git a/conf/sho b/conf/sho new file mode 100644 index 0000000..f77620f --- /dev/null +++ b/conf/sho @@ -0,0 +1,24 @@ +; +; additional settings for Sho Shogi +; +-variant shogi +; +; size overrides +; +-boardWidth 9 +-boardHeight 9 +-holdingsSize 0 +; +; add Elephant to piece set +; +-pieceToCharTable "PNBRLSE..G.++++++Kpnbrlse..g.++++++k" +; +; provide initial position +; +-loadPositionFile "~~/themes/conf/sho.fen" +; +; redefine default engine +; +-fcp hachu +-scp hachu + diff --git a/conf/sho.fen b/conf/sho.fen new file mode 100644 index 0000000..689e5a6 --- /dev/null +++ b/conf/sho.fen @@ -0,0 +1,2 @@ +lnsgkgsnl/1r2e2b1/ppppppppp/9/9/9/PPPPPPPPP/1B2E2R1/LNSGKGSNL w 0 1 + diff --git a/conf/shogi b/conf/shogi new file mode 100644 index 0000000..90cde91 --- /dev/null +++ b/conf/shogi @@ -0,0 +1,41 @@ +; +; settings for oriental Shogi theme +; +-variant shogi +; +; pieces: supplied shogi svg's, and flip them in flipView +; +-pid ~~/themes/shogi +-flipBlack true +-trueColors true +; +; board: no checkering (both w. and w.o. texture) +; +-liteBackTextureFile "~~/themes/textures/wood_l.png" +-darkBackTextureFile "~~/themes/textures/wood_l.png" +-lightSquareColor #FF8040 +-darkSquareColor #FF8040 +; +; detour under-promotion is less convenient when non-pawns promote +; +-sweepPromotions false +; +; no adjudication +; +-trivialDraws false +-materialDraws false +; +; common non-compliant notations +; +-colorNickNames "sg" +; +; redefine default engine +; +-fcp gnushogi +-scp gnushogi +; +; set up own persistence file, used for this theme only +; +-settingsFile ~/.xboard-shogi-rc +-saveSettingsFile ~/.xboard-shogi-rc + diff --git a/conf/xiangqi b/conf/xiangqi new file mode 100644 index 0000000..23aeb36 --- /dev/null +++ b/conf/xiangqi @@ -0,0 +1,30 @@ +; +; settings for oriental Xiangqi theme +; +-variant xiangqi +; +; pieces: supplied xiangqi svg's +; +-pid ~~/themes/xiangqi +-trueColors true +; +; board: supplied board bitmap +; +-liteBackTextureFile "~~/themes/textures/xqboard.png" +-darkBackTextureFile "~~/themes/textures/xqboard.png" +; +; suppress square boundaries and highlight with arrow instead +; +-overrideLineGap 0 +-highlightMovesWithArrow true +; +; define common non-compliant notations +; +-pieceNickNames ".N...MB..G..n...mb..g." +-colorNickNames "r." +; +; set up own persistence file, used for this theme only +; +-settingsFile ~/.xboard-xiangqi-rc +-saveSettingsFile ~/.xboard-xiangqi-rc + diff --git a/conf/xq b/conf/xq new file mode 100644 index 0000000..fe659ba --- /dev/null +++ b/conf/xq @@ -0,0 +1,36 @@ +; +; settings for oriental Xiangqi theme +; +-variant xiangqi +; +; pieces: supplied xiangqi svg's +; +-pid ~~/themes/xiangqi +-trueColors true +; +; board: supplied board bitmap +; +-useBoardTexture true +-liteBackTextureFile "~~/themes/textures/xqboard.png" +-darkBackTextureFile "~~/themes/textures/xqboard.png" +; +; suppress square boundaries and highlight with arrow instead +; +-overrideLineGap 0 +-highlightMoveWithArrow true +; +; define common non-compliant notations +; +-pieceNickNames ".N...MB..G..n...mb..g." +-colorNickNames "r." +; +; set default engines +; +-fcp maxqi +-scp maxqi +; +; set up own persistence file, used for this theme only +; +-settingsFile ~/.xboard-xiangqi-rc +-saveSettingsFile ~/.xboard-xiangqi-rc + diff --git a/usystem.c b/usystem.c index 275d739..a051523 100644 --- a/usystem.c +++ b/usystem.c @@ -358,6 +358,9 @@ ExpandPathName (char *path) } if (*s == '~') { + if(s[1] == '~') { // use ~~ for XBoard's private data directory + snprintf(d, 4*MSG_SIZ, DATADIR "%s", s+2); + } else if (*(s+1) == '/') { safeStrCpy(d, getpwuid(getuid())->pw_dir, 4*MSG_SIZ ); strcat(d, s+1); -- 1.7.0.4