mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
If no arrow visible, use cursor loc as destination when moving tile to tray.
This commit is contained in:
parent
211271d6be
commit
80adc9fb6b
1 changed files with 44 additions and 27 deletions
|
@ -117,7 +117,8 @@ static XP_Bool board_moveArrow( BoardCtxt* board, XP_Key cursorKey );
|
||||||
|
|
||||||
static XP_Bool setArrowVisibleFor( BoardCtxt* board, XP_U16 player,
|
static XP_Bool setArrowVisibleFor( BoardCtxt* board, XP_U16 player,
|
||||||
XP_Bool visible );
|
XP_Bool visible );
|
||||||
static XP_Bool moveKeyTileToBoard( BoardCtxt* board, XP_Key cursorKey );
|
static XP_Bool moveKeyTileToBoard( BoardCtxt* board, XP_Key cursorKey,
|
||||||
|
XP_Bool* gotArrow );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef KEYBOARD_NAV
|
#ifdef KEYBOARD_NAV
|
||||||
|
@ -2702,6 +2703,7 @@ board_handleKey( BoardCtxt* board, XP_Key key )
|
||||||
{
|
{
|
||||||
XP_Bool result = XP_FALSE;
|
XP_Bool result = XP_FALSE;
|
||||||
XP_Bool trayVisible = board->trayVisState == TRAY_REVEALED;
|
XP_Bool trayVisible = board->trayVisState == TRAY_REVEALED;
|
||||||
|
XP_Bool gotArrow;
|
||||||
|
|
||||||
switch( key ) {
|
switch( key ) {
|
||||||
#ifdef KEYBOARD_NAV
|
#ifdef KEYBOARD_NAV
|
||||||
|
@ -2772,9 +2774,9 @@ board_handleKey( BoardCtxt* board, XP_Key key )
|
||||||
default:
|
default:
|
||||||
XP_ASSERT( key >= XP_KEY_LAST );
|
XP_ASSERT( key >= XP_KEY_LAST );
|
||||||
|
|
||||||
result = trayVisible && moveKeyTileToBoard( board, key );
|
result = trayVisible && moveKeyTileToBoard( board, key, &gotArrow );
|
||||||
|
|
||||||
if ( result && !advanceArrow( board ) ) {
|
if ( result && gotArrow && !advanceArrow( board ) ) {
|
||||||
setArrowVisible( board, XP_FALSE );
|
setArrowVisible( board, XP_FALSE );
|
||||||
}
|
}
|
||||||
} /* switch */
|
} /* switch */
|
||||||
|
@ -3126,45 +3128,60 @@ moveTileToBoard( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_U16 tileIndex,
|
||||||
} /* moveTileToBoard */
|
} /* moveTileToBoard */
|
||||||
|
|
||||||
static XP_Bool
|
static XP_Bool
|
||||||
moveKeyTileToBoard( BoardCtxt* board, XP_Key cursorKey )
|
moveKeyTileToBoard( BoardCtxt* board, XP_Key cursorKey, XP_Bool* gotArrow )
|
||||||
{
|
{
|
||||||
/* keep compiler happy: assign defaults */
|
/* keep compiler happy: assign defaults */
|
||||||
Tile tile, blankFace;
|
Tile tile, blankFace;
|
||||||
XP_U16 col, row;
|
XP_U16 col, row;
|
||||||
DictionaryCtxt* dict = model_getDictionary( board->model );
|
DictionaryCtxt* dict = model_getDictionary( board->model );
|
||||||
XP_S16 turn = board->selPlayer;
|
XP_S16 turn = board->selPlayer;
|
||||||
XP_S16 tileIndex;
|
XP_S16 tileIndex;
|
||||||
XP_UCHAR buf[2];
|
XP_UCHAR buf[2];
|
||||||
|
XP_Bool success;
|
||||||
|
|
||||||
/* Is there a cursor at all? */
|
/* Is there a cursor at all? */
|
||||||
if ( !getArrow( board, &col, &row ) ) {
|
*gotArrow = success = getArrow( board, &col, &row );
|
||||||
return XP_FALSE;
|
#ifdef KEYBOARD_NAV
|
||||||
|
if ( !success && (board->focussed == OBJ_BOARD) && board->focusHasDived ) {
|
||||||
|
BdCursorLoc loc = board->bdCursor[turn];
|
||||||
|
col = loc.col;
|
||||||
|
row = loc.row;
|
||||||
|
success = XP_TRUE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
XP_ASSERT( !TRADE_IN_PROGRESS(board) );
|
if ( success ) {
|
||||||
|
XP_ASSERT( !TRADE_IN_PROGRESS(board) );
|
||||||
|
|
||||||
/* Figure out if we have the tile in the tray */
|
/* Figure out if we have the tile in the tray */
|
||||||
buf[0] = cursorKey;
|
buf[0] = cursorKey;
|
||||||
buf[1] = '\0';
|
buf[1] = '\0';
|
||||||
tile = dict_tileForString( dict, buf );
|
tile = dict_tileForString( dict, buf );
|
||||||
if ( tile == EMPTY_TILE ) { /* not found in dict */
|
if ( tile == EMPTY_TILE ) { /* not found in dict */
|
||||||
return XP_FALSE;
|
success = XP_FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
tileIndex = model_trayContains( board->model, turn, tile );
|
|
||||||
if ( tileIndex >= 0 ) {
|
|
||||||
blankFace = EMPTY_TILE; /* will be ignored */
|
|
||||||
} else {
|
|
||||||
Tile blankTile = dict_getBlankTile( dict );
|
|
||||||
tileIndex = model_trayContains( board->model, turn, blankTile );
|
|
||||||
if ( tileIndex >= 0 ) { /* there's a blank for it */
|
|
||||||
blankFace = tile;
|
|
||||||
} else {
|
|
||||||
return XP_FALSE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return moveTileToBoard( board, col, row, tileIndex, blankFace );
|
if ( success ) {
|
||||||
|
tileIndex = model_trayContains( board->model, turn, tile );
|
||||||
|
if ( tileIndex >= 0 ) {
|
||||||
|
blankFace = EMPTY_TILE; /* will be ignored */
|
||||||
|
} else {
|
||||||
|
Tile blankTile = dict_getBlankTile( dict );
|
||||||
|
tileIndex = model_trayContains( board->model, turn, blankTile );
|
||||||
|
if ( tileIndex >= 0 ) { /* there's a blank for it */
|
||||||
|
blankFace = tile;
|
||||||
|
} else {
|
||||||
|
success = XP_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( success ) {
|
||||||
|
success = moveTileToBoard( board, col, row, tileIndex, blankFace );
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
} /* moveKeyTileToBoard */
|
} /* moveKeyTileToBoard */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in a new issue