tap on pending blank tile brings up picker

It's been annoying to have to move a placed blank to change its
value. No more.
This commit is contained in:
Eric House 2017-04-08 13:44:59 -07:00
parent 832b3adfd2
commit 9e66d294a2
3 changed files with 22 additions and 5 deletions

View file

@ -2861,6 +2861,21 @@ tryMoveArrow( BoardCtxt* board, XP_U16 col, XP_U16 row )
return result; return result;
} /* tryMoveArrow */ } /* tryMoveArrow */
static XP_Bool
tryChangeBlank( const BoardCtxt* board, XP_U16 col, XP_U16 row )
{
XP_Bool handled = XP_FALSE;
XP_Bool isBlank, isPending;
model_getTile( board->model, col, row, XP_TRUE, board->selPlayer, NULL,
&isBlank, &isPending, NULL );
handled = isBlank && isPending;
if ( handled ) {
(void)model_askBlankTile( board->model, board->selPlayer, col, row );
}
return handled;
}
XP_Bool XP_Bool
holdsPendingTile( BoardCtxt* board, XP_U16 pencol, XP_U16 penrow ) holdsPendingTile( BoardCtxt* board, XP_U16 pencol, XP_U16 penrow )
{ {
@ -2905,6 +2920,7 @@ handleActionInCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool isPen )
|| moveSelTileToBoardXY( board, col, row ) || moveSelTileToBoardXY( board, col, row )
#endif #endif
|| tryMoveArrow( board, col, row ) || tryMoveArrow( board, col, row )
|| tryChangeBlank( board, col, row )
|| (!isPen && tryReplaceTile( board, col, row )) || (!isPen && tryReplaceTile( board, col, row ))
; ;
} /* handleActionInCell */ } /* handleActionInCell */

View file

@ -1332,8 +1332,8 @@ model_packTilesUtil( ModelCtxt* model, PoolContext* pool,
/* setup async query for blank value, but while at it return a reasonable /* setup async query for blank value, but while at it return a reasonable
default. */ default. */
static Tile Tile
askBlankTile( ModelCtxt* model, XP_U16 turn, XP_U16 col, XP_U16 row) model_askBlankTile( ModelCtxt* model, XP_U16 turn, XP_U16 col, XP_U16 row)
{ {
XP_U16 nUsed = MAX_UNIQUE_TILES; XP_U16 nUsed = MAX_UNIQUE_TILES;
const XP_UCHAR* tfaces[MAX_UNIQUE_TILES]; const XP_UCHAR* tfaces[MAX_UNIQUE_TILES];
@ -1345,7 +1345,7 @@ askBlankTile( ModelCtxt* model, XP_U16 turn, XP_U16 col, XP_U16 row)
util_notifyPickTileBlank( model->vol.util, turn, col, row, util_notifyPickTileBlank( model->vol.util, turn, col, row,
tfaces, nUsed ); tfaces, nUsed );
return tiles[0]; return tiles[0];
} /* askBlankTile */ } /* model_askBlankTile */
void void
model_moveTrayToBoard( ModelCtxt* model, XP_S16 turn, XP_U16 col, XP_U16 row, model_moveTrayToBoard( ModelCtxt* model, XP_S16 turn, XP_U16 col, XP_U16 row,
@ -1361,7 +1361,7 @@ model_moveTrayToBoard( ModelCtxt* model, XP_S16 turn, XP_U16 col, XP_U16 row,
tile = blankFace; tile = blankFace;
} else { } else {
XP_ASSERT( turn >= 0 ); XP_ASSERT( turn >= 0 );
tile = TILE_BLANK_BIT | askBlankTile( model, (XP_U16)turn, col, row ); tile = TILE_BLANK_BIT | model_askBlankTile( model, (XP_U16)turn, col, row );
} }
tile |= TILE_BLANK_BIT; tile |= TILE_BLANK_BIT;
} }
@ -1530,7 +1530,7 @@ model_moveTileOnBoard( ModelCtxt* model, XP_S16 turn, XP_U16 colCur,
pt->col = colNew; pt->col = colNew;
pt->row = rowNew; pt->row = rowNew;
if ( isBlank ) { if ( isBlank ) {
(void)askBlankTile( model, turn, colNew, rowNew ); (void)model_askBlankTile( model, turn, colNew, rowNew );
} }
decrPendingTileCountAt( model, colCur, rowCur ); decrPendingTileCountAt( model, colCur, rowCur );

View file

@ -323,6 +323,7 @@ void model_packTilesUtil( ModelCtxt* model, PoolContext* pool,
XP_U16* nUsed, const XP_UCHAR** texts, XP_U16* nUsed, const XP_UCHAR** texts,
Tile* tiles ); Tile* tiles );
Tile model_askBlankTile( ModelCtxt* model, XP_U16 turn, XP_U16 col, XP_U16 row);
#ifdef CPLUS #ifdef CPLUS
} }