mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-28 07:58:08 +01:00
pass tile value into drawCell(). Java code doesn't use it yet, but I
want to play with drawing cells tray-tile-style when they're big enough.
This commit is contained in:
parent
ae2e27e651
commit
52d02f04dd
7 changed files with 33 additions and 22 deletions
|
@ -232,11 +232,12 @@ and_draw_boardBegin( DrawCtx* dctx, const XP_Rect* rect,
|
|||
|
||||
static XP_Bool
|
||||
and_draw_drawCell( DrawCtx* dctx, const XP_Rect* rect, const XP_UCHAR* text,
|
||||
const XP_Bitmaps* bitmaps, Tile tile, XP_S16 owner,
|
||||
XWBonusType bonus, HintAtts hintAtts, CellFlags flags )
|
||||
const XP_Bitmaps* bitmaps, Tile tile, XP_U16 value,
|
||||
XP_S16 owner, XWBonusType bonus, HintAtts hintAtts,
|
||||
CellFlags flags )
|
||||
{
|
||||
DRAW_CBK_HEADER("drawCell",
|
||||
"(Landroid/graphics/Rect;Ljava/lang/String;IIIII)Z" );
|
||||
"(Landroid/graphics/Rect;Ljava/lang/String;IIIIII)Z" );
|
||||
jobject jrect = makeJRect( draw, JCACHE_RECT0, rect );
|
||||
jstring jtext = NULL;
|
||||
if ( !!text ) {
|
||||
|
@ -247,7 +248,7 @@ and_draw_drawCell( DrawCtx* dctx, const XP_Rect* rect, const XP_UCHAR* text,
|
|||
}
|
||||
|
||||
jboolean result = (*env)->CallBooleanMethod( env, draw->jdraw, mid,
|
||||
jrect, jtext, tile,
|
||||
jrect, jtext, tile, value,
|
||||
owner, bonus, hintAtts,
|
||||
flags );
|
||||
if ( !!jtext ) {
|
||||
|
|
|
@ -529,8 +529,9 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean drawCell( final Rect rect, String text, int tile, int owner,
|
||||
int bonus, int hintAtts, final int flags )
|
||||
public boolean drawCell( final Rect rect, String text, int tile, int value,
|
||||
int owner, int bonus, int hintAtts,
|
||||
final int flags )
|
||||
{
|
||||
boolean canDraw = figureFontDims();
|
||||
if ( canDraw ) {
|
||||
|
@ -819,7 +820,8 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
|
||||
if ( val >= 0 ) {
|
||||
if ( null == m_valRect ) {
|
||||
m_valRect = new Rect( 0, 0, rect.width() / 4, rect.height() / 4 );
|
||||
m_valRect = new Rect( 0, 0, rect.width() / 4,
|
||||
rect.height() / 4 );
|
||||
m_valRect.inset( 2, 2 );
|
||||
}
|
||||
m_valRect.offsetTo( rect.right - (rect.width() / 4),
|
||||
|
|
|
@ -51,7 +51,7 @@ public interface DrawCtx {
|
|||
void drawTimer( Rect rect, int player, int secondsLeft );
|
||||
boolean boardBegin( Rect rect, int cellWidth, int cellHeight );
|
||||
|
||||
boolean drawCell( Rect rect, String text, int tile,
|
||||
boolean drawCell( Rect rect, String text, int tile, int value,
|
||||
int owner, int bonus, int hintAtts, int flags );
|
||||
void drawBoardArrow ( Rect rect, int bonus, boolean vert, int hintAtts,
|
||||
int flags );
|
||||
|
|
|
@ -397,6 +397,7 @@ drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks )
|
|||
HintAtts hintAtts;
|
||||
CellFlags flags = CELL_NONE;
|
||||
XP_Bool isOrigin;
|
||||
XP_U16 value = 0;
|
||||
|
||||
isEmpty = !model_getTile( model, modelCol, modelRow, showPending,
|
||||
selPlayer, &tile, &isBlank,
|
||||
|
@ -416,6 +417,9 @@ drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks )
|
|||
} else if ( isBlank && skipBlanks ) {
|
||||
break;
|
||||
} else {
|
||||
Tile valTile = isBlank? dict_getBlankTile( dict ) : tile;
|
||||
value = dict_getTileValue( dict, valTile );
|
||||
|
||||
if ( board->showColors ) {
|
||||
owner = (XP_S16)model_getCellOwner( model, modelCol,
|
||||
modelRow );
|
||||
|
@ -424,9 +428,7 @@ drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks )
|
|||
invert = showPending? pending : recent;
|
||||
|
||||
if ( board->showCellValues ) {
|
||||
Tile valTile = isBlank? dict_getBlankTile( dict ) : tile;
|
||||
XP_U16 val = dict_getTileValue( dict, valTile );
|
||||
XP_SNPRINTF( ch, VSIZE(ch), "%d", val );
|
||||
XP_SNPRINTF( ch, VSIZE(ch), "%d", value );
|
||||
textP = ch;
|
||||
} else {
|
||||
if ( dict_faceIsBitmap( dict, tile ) ) {
|
||||
|
@ -458,7 +460,8 @@ drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks )
|
|||
#endif
|
||||
|
||||
success = draw_drawCell( board->draw, &cellRect, textP, bptr,
|
||||
tile, owner, bonus, hintAtts, flags );
|
||||
tile, value, owner, bonus, hintAtts,
|
||||
flags );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@ typedef struct DrawCtxVTable {
|
|||
null */
|
||||
const XP_UCHAR* text,
|
||||
const XP_Bitmaps* bitmaps,
|
||||
Tile tile,
|
||||
Tile tile, XP_U16 value,
|
||||
XP_S16 owner, /* -1 means don't use */
|
||||
XWBonusType bonus, HintAtts hintAtts,
|
||||
CellFlags flags );
|
||||
|
@ -229,6 +229,8 @@ struct DrawCtx {
|
|||
linked##_draw_##name(dc,(p1),(p2),(p3),(p4),(p5),(p6))
|
||||
# define CALL_DRAW_NAME8(name,dc,p1,p2,p3,p4,p5,p6,p7,p8) \
|
||||
linked##_draw_##name(dc,(p1),(p2),(p3),(p4),(p5),(p6),(p7),(p8))
|
||||
# define CALL_DRAW_NAME9(name,dc,p1,p2,p3,p4,p5,p6,p7,p8,p9) \
|
||||
linked##_draw_##name(dc,(p1),(p2),(p3),(p4),(p5),(p6),(p7),(p8),(p9))
|
||||
# define CALL_DRAW_NAME10(name,dc,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) \
|
||||
linked##_draw_##name(dc,(p1),(p2),(p3),(p4),(p5),(p6),(p7),\
|
||||
(p8),(p9),(p10))
|
||||
|
@ -246,8 +248,11 @@ struct DrawCtx {
|
|||
# define CALL_DRAW_NAME6(name,dc,p1,p2,p3,p4,p5,p6) \
|
||||
((dc)->vtable->m_draw_##name)(dc,(p1),(p2),(p3),(p4),(p5),(p6))
|
||||
# define CALL_DRAW_NAME8(name,dc,p1,p2,p3,p4,p5,p6,p7,p8) \
|
||||
((dc)->vtable->m_draw_##name)(dc,(p1),(p2),(p3),(p4),(p5),(p6),(p7),\
|
||||
(p8))
|
||||
((dc)->vtable->m_draw_##name)(dc,(p1),(p2),(p3),(p4),(p5),(p6),(p7), \
|
||||
(p8))
|
||||
# define CALL_DRAW_NAME9(name,dc,p1,p2,p3,p4,p5,p6,p7,p8,p9) \
|
||||
((dc)->vtable->m_draw_##name)(dc,(p1),(p2),(p3),(p4),(p5),(p6),(p7), \
|
||||
(p8),(p9))
|
||||
# define CALL_DRAW_NAME10(name,dc,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) \
|
||||
((dc)->vtable->m_draw_##name)(dc,(p1),(p2),(p3),(p4),(p5),(p6),(p7),\
|
||||
(p8),(p9),(p10))
|
||||
|
@ -277,8 +282,8 @@ struct DrawCtx {
|
|||
CALL_DRAW_NAME4(score_pendingScore,(dc), (r), (s), (p), (f))
|
||||
#define draw_drawTimer( dc, r, plyr, sec ) \
|
||||
CALL_DRAW_NAME3(drawTimer,(dc),(r),(plyr),(sec))
|
||||
#define draw_drawCell( dc, rect, txt, bmap, t, o, bon, hi, f ) \
|
||||
CALL_DRAW_NAME8(drawCell,(dc),(rect),(txt),(bmap),(t),(o),(bon),(hi),\
|
||||
#define draw_drawCell( dc, rect, txt, bmap, t, v,o, bon, hi, f ) \
|
||||
CALL_DRAW_NAME9(drawCell,(dc),(rect),(txt),(bmap),(t),(v),(o),(bon),(hi), \
|
||||
(f))
|
||||
#define draw_invertCell( dc, rect ) CALL_DRAW_NAME1(invertCell,(dc),(rect))
|
||||
#define draw_drawTile( dc, rect, text, bmp, val, hil ) \
|
||||
|
|
|
@ -298,9 +298,9 @@ static XP_Bool
|
|||
curses_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect,
|
||||
const XP_UCHAR* letter,
|
||||
const XP_Bitmaps* XP_UNUSED(bitmaps),
|
||||
Tile XP_UNUSED(tile), XP_S16 XP_UNUSED(owner),
|
||||
XWBonusType bonus, HintAtts XP_UNUSED(hintAtts),
|
||||
CellFlags flags )
|
||||
Tile XP_UNUSED(tile), XP_U16 XP_UNUSED(value),
|
||||
XP_S16 XP_UNUSED(owner), XWBonusType bonus,
|
||||
HintAtts XP_UNUSED(hintAtts), CellFlags flags )
|
||||
{
|
||||
CursesDrawCtx* dctx = (CursesDrawCtx*)p_dctx;
|
||||
XP_Bool highlight = (flags & (CELL_HIGHLIGHT|CELL_ISCURSOR)) != 0;
|
||||
|
|
|
@ -506,8 +506,8 @@ drawCrosshairs( GtkDrawCtx* dctx, const XP_Rect* rect, CellFlags flags )
|
|||
static XP_Bool
|
||||
gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter,
|
||||
const XP_Bitmaps* bitmaps, Tile XP_UNUSED(tile),
|
||||
XP_S16 owner, XWBonusType bonus, HintAtts hintAtts,
|
||||
CellFlags flags )
|
||||
XP_U16 XP_UNUSED(value), XP_S16 owner, XWBonusType bonus,
|
||||
HintAtts hintAtts, CellFlags flags )
|
||||
{
|
||||
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
|
||||
XP_Rect rectInset = *rect;
|
||||
|
|
Loading…
Add table
Reference in a new issue