X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwinboard.c;h=293b643e9a5b3653501b39f1870bda687555d3e1;hb=0c326a397b77561e9cd232549eb98c756f5a8baf;hp=96bebcb4ad22a6c529d0f90f650dd6b1a592c7d4;hpb=8e4a958eea326db65c7621b4c1840cdca97f6d07;p=xboard.git diff --git a/winboard/winboard.c b/winboard/winboard.c index 96bebcb..293b643 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -55,6 +55,10 @@ *------------------------------------------------------------------------ ** See the file ChangeLog for a revision history. */ +#ifndef WINVER +#define WINVER 0x0500 +#endif + #include "config.h" #include @@ -2193,7 +2197,7 @@ void CreatePiecesFromFont() HBITMAP DoLoadBitmap(HINSTANCE hinst, char *piece, int squareSize, char *suffix) { - char name[128], buf[MSG_SIZ]; + char name[128], buf[MSG_SIZ], *ids = "pnbrqfeicwmohajgdvlsukaacvdklnwpwnwlwswolfgnuzebracameltowersword", *p; snprintf(name, sizeof(name)/sizeof(name[0]), "%s%d%s", piece, squareSize, suffix); if(appData.pieceDirectory[0]) { @@ -2201,6 +2205,30 @@ DoLoadBitmap(HINSTANCE hinst, char *piece, int squareSize, char *suffix) snprintf(buf, MSG_SIZ, "%s\\%s.bmp", appData.pieceDirectory, name); res = LoadImage( 0, buf, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); if(res) return res; + p = strstr(ids, piece); + if(p) { // if we could reconstruct canonical piece number, try the pieceNNN_ format before falling back on built-ins + int n = p - ids; + switch(n) { + case 21: n = WhiteKing; break; + case 22: n = WhiteAngel; break; + case 24: n = WhiteSilver; break; + case 26: n = WhiteDragon; break; + case 28: n = WhiteLion; break; + case 30: n = WhiteTokin; break; + case 32: n = WhitePKnight; break; + case 34: n = WhitePLance; break; + case 36: n = WhitePSilver; break; + case 38: n = WhiteWolf; break; + case 42: n = WhiteGnu; break; + case 45: n = WhiteZebra; break; + case 50: n = WhiteCamel; break; + case 55: n = WhiteTower; break; + case 60: n = WhiteSword; break; + } + snprintf(buf, MSG_SIZ, "%s\\piece%d_%d%s.bmp", appData.pieceDirectory, n, squareSize, suffix); + res = LoadImage( 0, buf, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); + if(res) return res; + } } if (gameInfo.event && strcmp(gameInfo.event, "Easter Egg Hunt") == 0 && @@ -2992,7 +3020,7 @@ VOID DrawPieceOnDC(HDC hdc, ChessSquare piece, int color, int sqcolor, int x, int y, HDC tmphdc) { HBITMAP oldBitmap; - HBRUSH oldBrush; + HBRUSH oldBrush = NULL; int tmpSize; if (appData.blindfold) return; @@ -3051,6 +3079,20 @@ DrawPieceOnDC(HDC hdc, ChessSquare piece, int color, int sqcolor, int x, int y, y += squareSize - minorSize - 2; tmpSize = minorSize; } +#if WINVER >= 0x0500 + HBITMAP pbm = PieceBitmap(piece, color ? OUTLINE_PIECE : SOLID_PIECE); + BITMAP b; + GetObject(pbm, sizeof(BITMAP), &b); + if(b.bmBitsPixel == 32) { // for now this is a kludge to indicate bitmaps with alpha channel + BLENDFUNCTION bf; + bf.BlendOp = AC_SRC_OVER; + bf.BlendFlags = 0; + bf.SourceConstantAlpha = 0xFF; + bf.AlphaFormat = AC_SRC_ALPHA; + oldBitmap = SelectObject(tmphdc, pbm); + AlphaBlend(hdc, x, y, tmpSize, tmpSize, tmphdc, 0, 0, tmpSize, tmpSize, bf); + } else +#endif if (color || appData.allWhite ) { oldBitmap = SelectObject(tmphdc, PieceBitmap(piece, WHITE_PIECE)); if( color ) @@ -3087,7 +3129,7 @@ DrawPieceOnDC(HDC hdc, ChessSquare piece, int color, int sqcolor, int x, int y, else BitBlt(hdc, x, y, tmpSize, tmpSize, tmphdc, 0, 0, 0x00B8074A); } - SelectObject(hdc, oldBrush); + if(oldBrush) SelectObject(hdc, oldBrush); SelectObject(tmphdc, oldBitmap); } }