diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardCanvas.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardCanvas.java index 0c520d074..9763a8564 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardCanvas.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardCanvas.java @@ -372,7 +372,7 @@ public class BoardCanvas extends Canvas implements DrawCtx { } @Override - public boolean drawCell( Rect rect, String text, int tile, int value, + public boolean drawCell( Rect rect, String text, int tile, String value, int owner, int bonus, int hintAtts, int flags ) { boolean canDraw = figureFontDims(); @@ -432,15 +432,19 @@ public class BoardCanvas extends Canvas implements DrawCtx { } } else { m_fillPaint.setColor( adjustColor(foreColor) ); - Rect smaller = new Rect(rect); - smaller.bottom -= smaller.height() / 4; - smaller.right -= smaller.width() / 4; - drawCentered( text, smaller, m_fontDims ); + if ( null == value ) { + drawCentered( text, rect, m_fontDims ); + } else { + Rect smaller = new Rect(rect); + smaller.bottom -= smaller.height() / 4; + smaller.right -= smaller.width() / 4; + drawCentered( text, smaller, m_fontDims ); - smaller = new Rect(rect); - smaller.left += (3 * smaller.width()) / 4; - smaller.top += (3 * smaller.height()) / 4; - drawCentered( String.format("%d", value), smaller, m_fontDims ); + smaller = new Rect(rect); + smaller.left += (3 * smaller.width()) / 4; + smaller.top += (3 * smaller.height()) / 4; + drawCentered( value, smaller, m_fontDims ); + } } if ( (CELL_ISBLANK & flags) != 0 ) { @@ -667,7 +671,6 @@ public class BoardCanvas extends Canvas implements DrawCtx { { boolean canDraw = figureFontDims(); if ( canDraw ) { - // boolean valHidden = (flags & CELL_VALHIDDEN) != 0; boolean notEmpty = (flags & CELL_ISEMPTY) == 0; boolean isCursor = (flags & CELL_ISCURSOR) != 0; diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/DrawCtx.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/DrawCtx.java index 9eb93ffed..3e5a82948 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/DrawCtx.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/DrawCtx.java @@ -30,7 +30,7 @@ public interface DrawCtx { static final int CELL_ISSTAR = 0x04; static final int CELL_ISCURSOR = 0x08; static final int CELL_ISEMPTY = 0x10; /* of a tray tile slot */ - static final int CELL_VALHIDDEN = 0x20; /* show letter only, not value */ + // static final int CELL_VALHIDDEN = 0x20; /* show letter only, not value */ static final int CELL_DRAGSRC = 0x40; /* where drag originated */ static final int CELL_DRAGCUR = 0x80; /* where drag is now */ static final int CELL_CROSSVERT = 0x100; @@ -59,7 +59,7 @@ public interface DrawCtx { void drawTimer( Rect rect, int player, int secondsLeft, boolean inDuplicateMode ); - boolean drawCell( Rect rect, String text, int tile, int value, + boolean drawCell( Rect rect, String text, int tile, String value, int owner, int bonus, int hintAtts, int flags ); void drawBoardArrow ( Rect rect, int bonus, boolean vert, int hintAtts, int flags ); diff --git a/xwords4/android/app/src/main/res/values/strings.xml b/xwords4/android/app/src/main/res/values/strings.xml index f497d070d..4e884b7b5 100644 --- a/xwords4/android/app/src/main/res/values/strings.xml +++ b/xwords4/android/app/src/main/res/values/strings.xml @@ -1394,8 +1394,8 @@ remind themselves how much played tiles are worth while planning a move. --> This button changes whether the - board shows letters on placed tiles or their point values. - Use it to remind yourself what a tile is worth. + board shows values (in addition to letters) on tiles on the + board. diff --git a/xwords4/android/jni/drawwrapper.c b/xwords4/android/jni/drawwrapper.c index 1f7bbe962..a4a8009bc 100644 --- a/xwords4/android/jni/drawwrapper.c +++ b/xwords4/android/jni/drawwrapper.c @@ -1,6 +1,6 @@ -/* -*-mode: C; compile-command: "find-and-gradle.sh insXwdDeb"; -*- */ +/* -*- compile-command: "find-and-gradle.sh inXw4dDeb"; -*- */ /* - * Copyright 2001-2010 by Eric House (xwords@eehouse.org). All rights + * Copyright 2001-2021 by Eric House (xwords@eehouse.org). All rights * reserved. * * This program is free software; you can redistribute it and/or @@ -409,14 +409,14 @@ and_draw_boardBegin( DrawCtx* XP_UNUSED(dctx), XWEnv XP_UNUSED(xwe), static XP_Bool and_draw_drawCell( DrawCtx* dctx, XWEnv xwe, const XP_Rect* rect, - const XP_UCHAR* text, - const XP_Bitmaps* bitmaps, Tile tile, XP_U16 value, + const XP_UCHAR* text, const XP_Bitmaps* bitmaps, + Tile tile, const XP_UCHAR* value, XP_S16 owner, XWBonusType bonus, HintAtts hintAtts, CellFlags flags ) { jboolean result; DRAW_CBK_HEADER("drawCell", - "(Landroid/graphics/Rect;Ljava/lang/String;IIIIII)Z" ); + "(Landroid/graphics/Rect;Ljava/lang/String;ILjava/lang/String;IIII)Z" ); jobject jrect = makeJRect( draw, xwe, JCACHE_RECT0, rect ); jstring jtext = NULL; if ( !!text ) { @@ -425,13 +425,14 @@ and_draw_drawCell( DrawCtx* dctx, XWEnv xwe, const XP_Rect* rect, } jtext = (*env)->NewStringUTF( env, text ); } + jstring jval = !!value ? (*env)->NewStringUTF( env, value ) : NULL; result = (*env)->CallBooleanMethod( env, draw->jdraw, mid, - jrect, jtext, tile, value, + jrect, jtext, tile, jval, owner, bonus, hintAtts, flags ); returnJRect( draw, JCACHE_RECT0, jrect ); - deleteLocalRef( env, jtext ); + deleteLocalRefs( env, jtext, jval, DELETE_NO_REF ); DRAW_CBK_HEADER_END(); return result; diff --git a/xwords4/common/boarddrw.c b/xwords4/common/boarddrw.c index 12026178c..5c25c3bce 100644 --- a/xwords4/common/boarddrw.c +++ b/xwords4/common/boarddrw.c @@ -397,7 +397,6 @@ drawCell( BoardCtxt* board, XWEnv xwe, const XP_U16 col, while ( board->trayVisState == TRAY_HIDDEN || !rectContainsRect( &board->trayBounds, &cellRect ) ) { XP_Bool recent = XP_FALSE; - XP_UCHAR ch[4] = {'\0'}; XP_S16 owner = -1; XP_Bitmaps bitmaps; XP_Bitmaps* bptr = NULL; @@ -405,7 +404,8 @@ drawCell( BoardCtxt* board, XWEnv xwe, const XP_U16 col, HintAtts hintAtts; CellFlags flags = CELL_NONE; XP_Bool isOrigin; - XP_U16 value = 0; + XP_UCHAR valBuf[4]; + XP_UCHAR* value = NULL; isEmpty = !model_getTile( model, modelCol, modelRow, showPending, selPlayer, &tile, &isBlank, @@ -426,7 +426,7 @@ drawCell( BoardCtxt* board, XWEnv xwe, const XP_U16 col, break; } else { Tile valTile = isBlank? dict_getBlankTile( dict ) : tile; - value = dict_getTileValue( dict, valTile ); + XP_U16 val = dict_getTileValue( dict, valTile ); if ( board->showColors ) { owner = (XP_S16)model_getCellOwner( model, modelCol, @@ -434,15 +434,14 @@ drawCell( BoardCtxt* board, XWEnv xwe, const XP_U16 col, } if ( board->showCellValues ) { - XP_SNPRINTF( ch, VSIZE(ch), "%d", value ); - textP = ch; - } else { - if ( dict_faceIsBitmap( dict, tile ) ) { - dict_getFaceBitmaps( dict, tile, &bitmaps ); - bptr = &bitmaps; - } - textP = dict_getTileString( dict, tile ); + XP_SNPRINTF( valBuf, VSIZE(valBuf), "%d", val ); + value = valBuf; } + if ( dict_faceIsBitmap( dict, tile ) ) { + dict_getFaceBitmaps( dict, tile, &bitmaps ); + bptr = &bitmaps; + } + textP = dict_getTileString( dict, tile ); } bonus = model_getSquareBonus( model, xwe, col, row ); hintAtts = figureHintAtts( board, col, row ); diff --git a/xwords4/common/draw.h b/xwords4/common/draw.h index 758dcfdce..5e5eb52fc 100644 --- a/xwords4/common/draw.h +++ b/xwords4/common/draw.h @@ -177,11 +177,9 @@ typedef struct DrawCtxVTable { XP_Bool turnDone ); XP_Bool DRAW_VTABLE_NAME(drawCell) ( DrawCtx* dctx, XWEnv xwe, const XP_Rect* rect, - /* at least one of these two will be - null */ - const XP_UCHAR* text, - const XP_Bitmaps* bitmaps, - Tile tile, XP_U16 value, + /* at least one of these two will be null */ + const XP_UCHAR* text, const XP_Bitmaps* bitmaps, + Tile tile, const XP_UCHAR* value, /* null if hidden */ XP_S16 owner, /* -1 means don't use */ XWBonusType bonus, HintAtts hintAtts, CellFlags flags ); diff --git a/xwords4/linux/cursesdraw.c b/xwords4/linux/cursesdraw.c index 0ead5cf7e..0a28cb905 100644 --- a/xwords4/linux/cursesdraw.c +++ b/xwords4/linux/cursesdraw.c @@ -392,7 +392,7 @@ static XP_Bool curses_draw_drawCell( DrawCtx* p_dctx, XWEnv XP_UNUSED(xwe), const XP_Rect* rect, const XP_UCHAR* letter, const XP_Bitmaps* XP_UNUSED(bitmaps), - Tile XP_UNUSED(tile), XP_U16 XP_UNUSED(value), + Tile XP_UNUSED(tile), const XP_UCHAR* XP_UNUSED(value), XP_S16 XP_UNUSED(owner), XWBonusType bonus, HintAtts XP_UNUSED(hintAtts), CellFlags flags ) { diff --git a/xwords4/linux/gtkdraw.c b/xwords4/linux/gtkdraw.c index 6e953fd4c..c8a497e06 100644 --- a/xwords4/linux/gtkdraw.c +++ b/xwords4/linux/gtkdraw.c @@ -607,9 +607,10 @@ drawCrosshairs( GtkDrawCtx* dctx, const XP_Rect* rect, CellFlags flags ) #endif static XP_Bool -gtk_draw_drawCell( DrawCtx* p_dctx, XWEnv XP_UNUSED(xwe), const XP_Rect* rect, const XP_UCHAR* letter, +gtk_draw_drawCell( DrawCtx* p_dctx, XWEnv XP_UNUSED(xwe), const XP_Rect* rect, + const XP_UCHAR* letter, const XP_Bitmaps* bitmaps, Tile XP_UNUSED(tile), - XP_U16 XP_UNUSED(value), XP_S16 owner, XWBonusType bonus, + const XP_UCHAR* value, XP_S16 owner, XWBonusType bonus, HintAtts hintAtts, CellFlags flags ) { GtkDrawCtx* dctx = (GtkDrawCtx*)(void*)p_dctx; @@ -620,6 +621,7 @@ gtk_draw_drawCell( DrawCtx* p_dctx, XWEnv XP_UNUSED(xwe), const XP_Rect* rect, c XP_Bool pending = (flags & CELL_PENDING) != 0; GdkRGBA* cursor = ((flags & CELL_ISCURSOR) != 0) ? &dctx->cursor : NULL; + GdkRGBA* foreground = &dctx->white; gtkEraseRect( dctx, rect ); @@ -643,13 +645,12 @@ gtk_draw_drawCell( DrawCtx* p_dctx, XWEnv XP_UNUSED(xwe), const XP_Rect* rect, c in the cell or if CELL_DRAGSRC is set */ if ( (flags & (CELL_DRAGSRC|CELL_ISEMPTY)) != 0 ) { if ( !!cursor || bonus != BONUS_NONE ) { - GdkRGBA* foreground; if ( !!cursor ) { foreground = cursor; } else if ( bonus != BONUS_NONE ) { foreground = &dctx->bonusColors[bonus-1]; - } else { - foreground = &dctx->white; + /* } else { */ + /* foreground = &dctx->white; */ } if ( !!foreground ) { #ifdef USE_CAIRO @@ -668,10 +669,14 @@ gtk_draw_drawCell( DrawCtx* p_dctx, XWEnv XP_UNUSED(xwe), const XP_Rect* rect, c XP_GTK_JUST_CENTER, &dctx->black, NULL ); } } else if ( !!bitmaps && !!bitmaps->bmps[0] ) { - drawBitmapFromLBS( dctx, bitmaps->bmps[0], rect ); + XP_Rect tmpRect = *rect; + if ( !!value ) { + tmpRect.width = tmpRect.width * 3 / 4; + tmpRect.height = tmpRect.height * 3 / 4; + } + drawBitmapFromLBS( dctx, bitmaps->bmps[0], &tmpRect ); } else if ( !!letter ) { XP_Bool isBlank = (flags & CELL_ISBLANK) != 0; - GdkRGBA* foreground; if ( cursor ) { gtkSetForeground( dctx, cursor ); } else if ( !recent && !pending ) { @@ -692,7 +697,14 @@ gtk_draw_drawCell( DrawCtx* p_dctx, XWEnv XP_UNUSED(xwe), const XP_Rect* rect, c } else { foreground = &dctx->playerColors[owner]; } - draw_string_at( dctx, NULL, letter, dctx->cellHeight, &rectInset, + XP_Rect tmpRect = rectInset; + XP_U16 fontHt = dctx->cellHeight; + if ( !!value ) { + tmpRect.width = tmpRect.width * 3 / 4; + tmpRect.height = tmpRect.height * 3 / 4; + fontHt = fontHt * 3 / 4; + } + draw_string_at( dctx, NULL, letter, fontHt, &tmpRect, XP_GTK_JUST_CENTER, foreground, cursor ); if ( isBlank ) { @@ -709,6 +721,16 @@ gtk_draw_drawCell( DrawCtx* p_dctx, XWEnv XP_UNUSED(xwe), const XP_Rect* rect, c } } + if ( !!value ) { + XP_Rect tmpRect = *rect; + tmpRect.left += tmpRect.width * 3 / 4; + tmpRect.width /= 4; + tmpRect.top += tmpRect.height * 3 / 4; + tmpRect.height /= 4; + draw_string_at( dctx, NULL, value, dctx->cellHeight/4, &tmpRect, + XP_GTK_JUST_CENTER, foreground, cursor ); + } + drawHintBorders( dctx, rect, hintAtts ); drawCrosshairs( dctx, rect, flags );