mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-05 20:45:49 +01:00
allow long-tap lookup of pending words too
When a word's been formed as part of the current turn, but not yet committed, allow long-tap to trigger an offer to look it up online same as for already-committed words. Allows checking the legality of potential plays AND figuring WTF the hint feature just suggested.
This commit is contained in:
parent
48880281dc
commit
fec0124f8c
5 changed files with 44 additions and 32 deletions
|
@ -1315,35 +1315,38 @@ timerFiredForPen( BoardCtxt* board )
|
|||
#ifdef XWFEATURE_RAISETILE
|
||||
draw = dragDropSetAdd( board );
|
||||
#endif
|
||||
} else {
|
||||
XP_Bool listWords = XP_FALSE;
|
||||
#ifdef XWFEATURE_BOARDWORDS
|
||||
XP_U16 modelCol, modelRow;
|
||||
flipIf( board, col, row, &modelCol, &modelRow );
|
||||
listWords = model_getTile( board->model, modelCol, modelRow,
|
||||
XP_TRUE, board->selPlayer, NULL,
|
||||
NULL, NULL, NULL );
|
||||
if ( listWords ) {
|
||||
XWStreamCtxt* stream =
|
||||
mem_stream_make_raw( MPPARM(board->mpool)
|
||||
dutil_getVTManager(board->dutil) );
|
||||
model_listWordsThrough( board->model, modelCol, modelRow,
|
||||
stream );
|
||||
util_cellSquareHeld( board->util, stream );
|
||||
stream_destroy( stream );
|
||||
}
|
||||
}
|
||||
|
||||
/* We calculate words even for a pending tile set, meaning
|
||||
dragDrop might be happening too. */
|
||||
XP_Bool listWords = XP_FALSE;
|
||||
#ifdef XWFEATURE_BOARDWORDS /* here it is */
|
||||
XP_U16 modelCol, modelRow;
|
||||
flipIf( board, col, row, &modelCol, &modelRow );
|
||||
listWords = model_getTile( board->model, modelCol, modelRow,
|
||||
XP_TRUE, board->selPlayer, NULL,
|
||||
NULL, NULL, NULL );
|
||||
if ( listWords ) {
|
||||
XP_LOGF( "%s(): listWords came back true", __func__ );
|
||||
XWStreamCtxt* stream =
|
||||
mem_stream_make_raw( MPPARM(board->mpool)
|
||||
dutil_getVTManager(board->dutil) );
|
||||
model_listWordsThrough( board->model, modelCol, modelRow,
|
||||
board->selPlayer, stream );
|
||||
util_cellSquareHeld( board->util, stream );
|
||||
stream_destroy( stream );
|
||||
}
|
||||
#endif
|
||||
if ( !listWords ) {
|
||||
XWBonusType bonus;
|
||||
bonus = model_getSquareBonus( board->model, col, row );
|
||||
if ( bonus != BONUS_NONE ) {
|
||||
if ( !listWords ) {
|
||||
XWBonusType bonus;
|
||||
bonus = model_getSquareBonus( board->model, col, row );
|
||||
if ( bonus != BONUS_NONE ) {
|
||||
#ifdef XWFEATURE_MINIWIN
|
||||
text = draw_getMiniWText( board->draw,
|
||||
(XWMiniTextType)bonus );
|
||||
text = draw_getMiniWText( board->draw,
|
||||
(XWMiniTextType)bonus );
|
||||
#else
|
||||
util_bonusSquareHeld( board->util, bonus );
|
||||
util_bonusSquareHeld( board->util, bonus );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
board->penTimerFired = XP_TRUE;
|
||||
|
|
|
@ -1708,13 +1708,13 @@ commitTurn( ModelCtxt* model, XP_S16 turn, const TrayTileSet* newTiles,
|
|||
PlayerCtxt* player = &model->players[turn];
|
||||
|
||||
if ( useStack ) {
|
||||
MoveInfo moveInfo = {0};
|
||||
XP_Bool isHorizontal;
|
||||
#ifdef DEBUG
|
||||
XP_Bool inLine =
|
||||
#endif
|
||||
tilesInLine( model, turn, &isHorizontal );
|
||||
XP_ASSERT( inLine );
|
||||
MoveInfo moveInfo = {0};
|
||||
normalizeMoves( model, turn, isHorizontal, &moveInfo );
|
||||
|
||||
stack_addMove( model->vol.stack, turn, &moveInfo, newTiles );
|
||||
|
@ -2396,11 +2396,20 @@ listWordsThrough( const XP_UCHAR* word, XP_Bool XP_UNUSED(isLegal),
|
|||
* How? Undo backwards until we find the move that placed that tile.*/
|
||||
void
|
||||
model_listWordsThrough( ModelCtxt* model, XP_U16 col, XP_U16 row,
|
||||
XWStreamCtxt* stream )
|
||||
XP_S16 turn, XWStreamCtxt* stream )
|
||||
{
|
||||
ModelCtxt* tmpModel = makeTmpModel( model, NULL, NULL, NULL, NULL );
|
||||
copyStack( model, tmpModel->vol.stack, model->vol.stack );
|
||||
|
||||
XP_Bool isHorizontal;
|
||||
if ( tilesInLine( model, turn, &isHorizontal ) ) {
|
||||
MoveInfo moveInfo = {0};
|
||||
normalizeMoves( model, turn, isHorizontal, &moveInfo );
|
||||
model_makeTurnFromMoveInfo( tmpModel, turn, &moveInfo );
|
||||
TrayTileSet newTiles = {0};
|
||||
commitTurn( tmpModel, turn, &newTiles, NULL, NULL, XP_TRUE );
|
||||
}
|
||||
|
||||
XP_ASSERT( !!stream );
|
||||
StackCtxt* stack = tmpModel->vol.stack;
|
||||
XP_U16 nEntriesBefore = stack_getNEntries( stack );
|
||||
|
|
|
@ -282,7 +282,7 @@ XP_Bool model_getPlayersLastScore( ModelCtxt* model, XP_S16 player,
|
|||
LastMoveInfo* info );
|
||||
#ifdef XWFEATURE_BOARDWORDS
|
||||
void model_listWordsThrough( ModelCtxt* model, XP_U16 col, XP_U16 row,
|
||||
XWStreamCtxt* stream );
|
||||
XP_S16 turn, XWStreamCtxt* stream );
|
||||
#endif
|
||||
|
||||
/* Have there been too many passes (so game should end)? */
|
||||
|
|
|
@ -90,7 +90,7 @@ struct ModelCtxt {
|
|||
|
||||
void invalidateScore( ModelCtxt* model, XP_S16 player );
|
||||
XP_Bool tilesInLine( ModelCtxt* model, XP_S16 turn, XP_Bool* isHorizontal );
|
||||
void normalizeMoves( ModelCtxt* model, XP_S16 turn,
|
||||
void normalizeMoves( const ModelCtxt* model, XP_S16 turn,
|
||||
XP_Bool isHorizontal, MoveInfo* moveInfo );
|
||||
void adjustScoreForUndone( ModelCtxt* model, MoveInfo* mi, XP_U16 turn );
|
||||
#ifdef CPLUS
|
||||
|
|
|
@ -277,15 +277,15 @@ tilesInLine( ModelCtxt* model, XP_S16 turn, XP_Bool* isHorizontal )
|
|||
} /* tilesInLine */
|
||||
|
||||
void
|
||||
normalizeMoves( ModelCtxt* model, XP_S16 turn, XP_Bool isHorizontal,
|
||||
normalizeMoves( const ModelCtxt* model, XP_S16 turn, XP_Bool isHorizontal,
|
||||
MoveInfo* moveInfo )
|
||||
{
|
||||
XP_S16 lowCol, ii, jj, thisCol; /* unsigned is a problem on palm */
|
||||
PlayerCtxt* player = &model->players[turn];
|
||||
const PlayerCtxt* player = &model->players[turn];
|
||||
XP_U16 nTiles = player->nPending;
|
||||
XP_S16 lastTaken;
|
||||
short lowIndex = 0;
|
||||
PendingTile* pt;
|
||||
const PendingTile* pt;
|
||||
|
||||
moveInfo->isHorizontal = isHorizontal;
|
||||
moveInfo->nTiles = (XP_U8)nTiles;
|
||||
|
|
Loading…
Add table
Reference in a new issue