From 7112c9346e502b141b5a5d5c677856559ed347b2 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Fri, 15 Apr 2011 19:18:46 +0200 Subject: [PATCH] Fix switching between pixmap and bitmap pieces There were still several flags that had to be reset when redoing the graphics initialization. The Debian patch to use a default bitmap directory when none is given but monoMode is selected or forced, is moved to a more sensible place, so that it does not disturb matters when compiled without LIBXPM (when we do have built-in bitmaps). --- xboard.c | 45 ++++++++++++++++++++++++++------------------- xoptions.c | 10 ++++------ 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/xboard.c b/xboard.c index 2178163..449f5b3 100644 --- a/xboard.c +++ b/xboard.c @@ -243,6 +243,7 @@ RETSIGTYPE CmailSigHandler P((int sig)); RETSIGTYPE IntSigHandler P((int sig)); RETSIGTYPE TermSizeSigHandler P((int sig)); void CreateGCs P((int redo)); +void CreateAnyPieces P((void)); void CreateXIMPieces P((void)); void CreateXPMPieces P((void)); void CreateXPMBoard P((char *s, int n)); @@ -1898,6 +1899,28 @@ int MakeColors() return forceMono; } +void +CreateAnyPieces() +{ // [HGM] taken out of main +#if HAVE_LIBXPM + if (appData.monoMode && // [HGM] no sense to go on to certain doom + (appData.bitmapDirectory == NULL || appData.bitmapDirectory[0] == NULLCHAR)) + appData.bitmapDirectory = DEF_BITMAP_DIR; + + if (appData.bitmapDirectory[0] != NULLCHAR) { + CreatePieces(); + } else { + CreateXPMPieces(); + CreateXPMBoard(appData.liteBackTextureFile, 1); + CreateXPMBoard(appData.darkBackTextureFile, 0); + } +#else + CreateXIMPieces(); + /* Create regular pieces */ + if (!useImages) CreatePieces(); +#endif +} + int main(argc, argv) int argc; @@ -2138,10 +2161,7 @@ XBoard square size (hint): %d\n\ if (forceMono) { fprintf(stderr, _("%s: too few colors available; trying monochrome mode\n"), programName); - - if (appData.bitmapDirectory == NULL || - appData.bitmapDirectory[0] == NULLCHAR) - appData.bitmapDirectory = DEF_BITMAP_DIR; + appData.monoMode = True; } if (appData.lowTimeWarning && !appData.monoMode) { @@ -2551,19 +2571,7 @@ XBoard square size (hint): %d\n\ CreateGCs(False); CreateGrid(); -#if HAVE_LIBXPM - if (appData.bitmapDirectory[0] != NULLCHAR) { - CreatePieces(); - } else { - CreateXPMPieces(); - CreateXPMBoard(appData.liteBackTextureFile, 1); - CreateXPMBoard(appData.darkBackTextureFile, 0); - } -#else - CreateXIMPieces(); - /* Create regular pieces */ - if (!useImages) CreatePieces(); -#endif + CreateAnyPieces(); CreatePieceMenus(); @@ -8010,8 +8018,7 @@ CreateAnimVars () /* For XPM pieces, we need bitmaps to use as masks. */ if (useImages) - CreateAnimMasks(info.depth); - xpmDone = 1; + CreateAnimMasks(info.depth), xpmDone = 1; } #ifndef HAVE_USLEEP diff --git a/xoptions.c b/xoptions.c index ec9a81b..ab6efac 100644 --- a/xoptions.c +++ b/xoptions.c @@ -735,8 +735,7 @@ char *trialSound; static int oldCores, oldPonder; int MakeColors P((void)); void CreateGCs P((int redo)); -void CreateXPMBoard P((char *s, int kind)); -void CreateXPMPieces P((void)); +void CreateAnyPieces P((void)); void GenericReadout(); Widget shells[10]; Widget marked[10]; @@ -1149,12 +1148,11 @@ void AdjustColor(int i) void BoardOptionsOK(int n) { - extern int defaultLineGap; + extern int defaultLineGap, useImages, useImageSqs; if(appData.overrideLineGap >= 0) lineGap = appData.overrideLineGap; else lineGap = defaultLineGap; + useImages = useImageSqs = 0; MakeColors(); CreateGCs(True); - CreateXPMPieces(); - CreateXPMBoard(appData.liteBackTextureFile, 1); - CreateXPMBoard(appData.darkBackTextureFile, 0); + CreateAnyPieces(); InitDrawingSizes(-1, 0); DrawPosition(True, NULL); } -- 1.7.0.4