diff --git a/common/boarddrw.c b/common/boarddrw.c index 32da4583a..e0e7de4fa 100644 --- a/common/boarddrw.c +++ b/common/boarddrw.c @@ -346,7 +346,7 @@ drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks ) XP_UCHAR ch[4] = {'\0'}; XP_S16 owner = -1; XP_Bool invert = XP_FALSE; - XP_Bitmap bitmap = NULL; + XP_Bitmaps bitmaps; XP_UCHAR* textP = NULL; HintAtts hintAtts; CellFlags flags = CELL_NONE; @@ -385,8 +385,7 @@ drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks ) textP = ch; } else { if ( dict_faceIsBitmap( dict, tile ) ) { - bitmap = dict_getFaceBitmap( dict, tile, XP_FALSE ); - XP_ASSERT( !!bitmap ); + dict_getFaceBitmaps( dict, tile, &bitmaps ); } (void)dict_tilesToString( dict, &tile, 1, ch, sizeof(ch) ); textP = ch; @@ -410,7 +409,8 @@ drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks ) } #endif - success = draw_drawCell( board->draw, &cellRect, textP, bitmap, + success = draw_drawCell( board->draw, &cellRect, textP, + bitmaps.nBitmaps > 0? &bitmaps : NULL, tile, owner, bonus, hintAtts, flags ); break; } @@ -473,7 +473,7 @@ drawDragTileIf( BoardCtxt* board ) XP_Bool isBlank; XP_UCHAR buf[4]; XP_UCHAR* face; - XP_Bitmap bitmap = NULL; + XP_Bitmaps bitmaps; XP_S16 value; CellFlags flags; @@ -481,7 +481,7 @@ drawDragTileIf( BoardCtxt* board ) dragDropTileInfo( board, &tile, &isBlank ); - face = getTileDrawInfo( board, tile, isBlank, &bitmap, + face = getTileDrawInfo( board, tile, isBlank, &bitmaps, &value, buf, sizeof(buf) ); flags = CELL_DRAGCUR; @@ -491,8 +491,9 @@ drawDragTileIf( BoardCtxt* board ) if ( board->hideValsInTray && !board->showCellValues ) { flags |= CELL_VALHIDDEN; } - draw_drawTileMidDrag( board->draw, &rect, face, bitmap, value, - board->selPlayer, flags ); + draw_drawTileMidDrag( board->draw, &rect, face, + bitmaps.nBitmaps > 0 ? &bitmaps : NULL, + value, board->selPlayer, flags ); } } } /* drawDragTileIf */ diff --git a/common/boardp.h b/common/boardp.h index 228b3264b..b0071d98b 100644 --- a/common/boardp.h +++ b/common/boardp.h @@ -270,7 +270,7 @@ void moveTileInTray( BoardCtxt* board, XP_U16 moveTo, XP_U16 moveFrom ); XP_Bool handleTrayDuringTrade( BoardCtxt* board, XP_S16 index ); XP_UCHAR* getTileDrawInfo( const BoardCtxt* board, Tile tile, XP_Bool isBlank, - XP_Bitmap* bitmap, XP_S16* value, + XP_Bitmaps* bitmaps, XP_S16* value, XP_UCHAR* buf, XP_U16 len ); XP_Bool dividerMoved( BoardCtxt* board, XP_U8 newLoc ); diff --git a/common/dictnry.c b/common/dictnry.c index f2f76d72e..f91180349 100644 --- a/common/dictnry.c +++ b/common/dictnry.c @@ -368,11 +368,11 @@ XP_Bool dict_faceIsBitmap( const DictionaryCtxt* dict, Tile tile ) { XP_UCHAR face = dict_getTileChar( dict, tile ); - return /* face != 0 && */IS_SPECIAL(face); + return IS_SPECIAL(face); } /* dict_faceIsBitmap */ -XP_Bitmap -dict_getFaceBitmap( const DictionaryCtxt* dict, Tile tile, XP_Bool isLarge ) +void +dict_getFaceBitmaps( const DictionaryCtxt* dict, Tile tile, XP_Bitmaps* bmps ) { SpecialBitmaps* bitmaps; XP_UCHAR face = dict_getTileChar( dict, tile ); @@ -381,7 +381,9 @@ dict_getFaceBitmap( const DictionaryCtxt* dict, Tile tile, XP_Bool isLarge ) XP_ASSERT( !!dict->bitmaps ); bitmaps = &dict->bitmaps[(XP_U16)face]; - return isLarge? bitmaps->largeBM:bitmaps->smallBM; + bmps->nBitmaps = 2; + bmps->bmps[0] = bitmaps->smallBM; + bmps->bmps[1] = bitmaps->largeBM; } /* dict_getFaceBitmap */ #ifdef TALL_FONTS diff --git a/common/dictnry.h b/common/dictnry.h index 660c91688..69cffc420 100644 --- a/common/dictnry.h +++ b/common/dictnry.h @@ -56,6 +56,10 @@ typedef struct SpecialBitmaps { XP_Bitmap smallBM; } SpecialBitmaps; +typedef struct _XP_Bitmaps { + XP_U16 nBitmaps; + XP_Bitmap bmps[2]; /* 2 is private, may change */ +} XP_Bitmaps; struct DictionaryCtxt { void (*destructor)( DictionaryCtxt* dict ); @@ -139,8 +143,8 @@ const XP_UCHAR* dict_getName( const DictionaryCtxt* ctxt ); Tile dict_tileForString( const DictionaryCtxt* dict, const XP_UCHAR* key ); XP_Bool dict_faceIsBitmap( const DictionaryCtxt* dict, Tile tile ); -XP_Bitmap dict_getFaceBitmap( const DictionaryCtxt* dict, Tile tile, - XP_Bool isLarge ); +void dict_getFaceBitmaps( const DictionaryCtxt* dict, Tile tile, + XP_Bitmaps* bmps ); #ifdef TALL_FONTS XP_LangCode dict_getLangCode( const DictionaryCtxt* dict ); diff --git a/common/draw.h b/common/draw.h index 85b6f30cd..6fe64668b 100644 --- a/common/draw.h +++ b/common/draw.h @@ -159,7 +159,7 @@ typedef struct DrawCtxVTable { /* at least one of these two will be null */ const XP_UCHAR* text, - const XP_Bitmap bitmap, + const XP_Bitmaps* bitmaps, Tile tile, XP_S16 owner, /* -1 means don't use */ XWBonusType bonus, HintAtts hintAtts, @@ -170,13 +170,13 @@ typedef struct DrawCtxVTable { void DRAW_VTABLE_NAME(drawTile) ( DrawCtx* dctx, const XP_Rect* rect, /* at least 1 of these two will be null*/ const XP_UCHAR* text, - const XP_Bitmap bitmap, + const XP_Bitmaps* bitmaps, XP_U16 val, CellFlags flags ); #ifdef POINTER_SUPPORT void DRAW_VTABLE_NAME(drawTileMidDrag) ( DrawCtx* dctx, const XP_Rect* rect, /* at least 1 of these two will be null*/ const XP_UCHAR* text, - const XP_Bitmap bitmap, + const XP_Bitmaps* bitmaps, XP_U16 val, XP_U16 owner, CellFlags flags ); #endif diff --git a/common/tray.c b/common/tray.c index ff7711770..cb3f79057 100644 --- a/common/tray.c +++ b/common/tray.c @@ -1,6 +1,7 @@ -/* -*-mode: C; fill-column: 78; compile-command: "cd ../linux && make MEMDEBUG=TRUE"; -*- */ +/* -*- compile-command: "cd ../linux && make MEMDEBUG=TRUE"; -*- */ /* - * Copyright 1997 - 2008 by Eric House (xwords@eehouse.org). All rights reserved. + * Copyright 1997 - 2009 by Eric House (xwords@eehouse.org). All rights + * reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -186,7 +187,7 @@ drawTray( BoardCtxt* board ) NULL, -1, flags | CELL_ISEMPTY ); } else if ( showFaces ) { XP_UCHAR buf[4]; - XP_Bitmap bitmap = NULL; + XP_Bitmaps bitmaps; XP_UCHAR* textP = (XP_UCHAR*)NULL; XP_U8 traySelBits = pti->traySelBits; XP_S16 value; @@ -210,7 +211,7 @@ drawTray( BoardCtxt* board ) } textP = getTileDrawInfo( board, tile, isBlank, - &bitmap, &value, + &bitmaps, &value, buf, sizeof(buf) ); if ( isADrag ) { if ( ddAddedIndx == ii ) { @@ -224,7 +225,8 @@ drawTray( BoardCtxt* board ) } draw_drawTile( board->draw, &tileRect, textP, - bitmap, value, flags ); + bitmaps.nBitmaps > 0? &bitmaps:NULL, + value, flags ); } else { draw_drawTileBack( board->draw, &tileRect, flags ); } @@ -232,7 +234,7 @@ drawTray( BoardCtxt* board ) } if ( (board->dividerWidth > 0) && board->dividerInvalid ) { - CellFlags flags = cursorOnDivider? CELL_ISCURSOR : CELL_NONE; + CellFlags flags = cursorOnDivider? CELL_ISCURSOR:CELL_NONE; XP_Rect divider; figureDividerRect( board, ÷r ); if ( pti->dividerSelected @@ -258,7 +260,7 @@ drawTray( BoardCtxt* board ) XP_UCHAR* getTileDrawInfo( const BoardCtxt* board, Tile tile, XP_Bool isBlank, - XP_Bitmap* bitmap, XP_S16* value, XP_UCHAR* buf, XP_U16 len ) + XP_Bitmaps* bitmaps, XP_S16* value, XP_UCHAR* buf, XP_U16 len ) { XP_UCHAR* face = NULL; DictionaryCtxt* dict = model_getDictionary( board->model ); @@ -271,8 +273,10 @@ getTileDrawInfo( const BoardCtxt* board, Tile tile, XP_Bool isBlank, *value = dict_getTileValue( dict, tile ); if ( dict_faceIsBitmap( dict, tile ) ) { - *bitmap = dict_getFaceBitmap( dict, tile, XP_TRUE ); - } + dict_getFaceBitmaps( dict, tile, bitmaps ); + } else { + bitmaps->nBitmaps = 0; + } return face; }