mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
add canUndo to GameStateInfo and use to hide the undo menu
This commit is contained in:
parent
fdc807ceb8
commit
b5d6c513a6
8 changed files with 21 additions and 3 deletions
|
@ -1409,6 +1409,7 @@ static const SetInfo gsi_ints[] = {
|
||||||
};
|
};
|
||||||
static const SetInfo gsi_bools[] = {
|
static const SetInfo gsi_bools[] = {
|
||||||
ARR_MEMBER( GameStateInfo,canHint ),
|
ARR_MEMBER( GameStateInfo,canHint ),
|
||||||
|
ARR_MEMBER( GameStateInfo, canUndo ),
|
||||||
ARR_MEMBER( GameStateInfo, canRedo ),
|
ARR_MEMBER( GameStateInfo, canRedo ),
|
||||||
ARR_MEMBER( GameStateInfo, inTrade ),
|
ARR_MEMBER( GameStateInfo, inTrade ),
|
||||||
ARR_MEMBER( GameStateInfo, tradeTilesSelected ),
|
ARR_MEMBER( GameStateInfo, tradeTilesSelected ),
|
||||||
|
|
|
@ -764,10 +764,11 @@ public class BoardActivity extends XWActivity
|
||||||
!inTrade && m_gsi.canHideRack );
|
!inTrade && m_gsi.canHideRack );
|
||||||
Utils.setItemVisible( menu, R.id.board_menu_trade,
|
Utils.setItemVisible( menu, R.id.board_menu_trade,
|
||||||
m_gsi.canTrade );
|
m_gsi.canTrade );
|
||||||
|
Utils.setItemVisible( menu, R.id.board_menu_undo_last,
|
||||||
|
m_gsi.canUndo );
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils.setItemVisible( menu, R.id.board_menu_invite, 0 < m_missing );
|
Utils.setItemVisible( menu, R.id.board_menu_invite, 0 < m_missing );
|
||||||
Utils.setItemVisible( menu, R.id.board_menu_undo_last, !inTrade );
|
|
||||||
|
|
||||||
Utils.setItemVisible( menu, R.id.board_menu_trade_cancel, inTrade );
|
Utils.setItemVisible( menu, R.id.board_menu_trade_cancel, inTrade );
|
||||||
Utils.setItemVisible( menu, R.id.board_menu_trade_commit,
|
Utils.setItemVisible( menu, R.id.board_menu_trade_commit,
|
||||||
|
|
|
@ -105,6 +105,7 @@ public class JNIThread extends Thread {
|
||||||
public int visTileCount;
|
public int visTileCount;
|
||||||
public int trayVisState;
|
public int trayVisState;
|
||||||
public boolean canHint;
|
public boolean canHint;
|
||||||
|
public boolean canUndo;
|
||||||
public boolean canRedo;
|
public boolean canRedo;
|
||||||
public boolean inTrade;
|
public boolean inTrade;
|
||||||
public boolean tradeTilesSelected;
|
public boolean tradeTilesSelected;
|
||||||
|
|
|
@ -704,7 +704,8 @@ board_canShuffle( const BoardCtxt* board )
|
||||||
XP_Bool
|
XP_Bool
|
||||||
board_canHideRack( const BoardCtxt* board )
|
board_canHideRack( const BoardCtxt* board )
|
||||||
{
|
{
|
||||||
XP_Bool result = board->boardObscuresTray || !board->gameOver;
|
XP_Bool result = 0 <= server_getCurrentTurn( board->server )
|
||||||
|
&& (board->boardObscuresTray || !board->gameOver);
|
||||||
LOG_RETURNF( "%d", result );
|
LOG_RETURNF( "%d", result );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -321,6 +321,7 @@ game_getState( const XWGame* game, GameStateInfo* gsi )
|
||||||
gsi->trayVisState = board_getTrayVisState( board );
|
gsi->trayVisState = board_getTrayVisState( board );
|
||||||
gsi->visTileCount = board_visTileCount( board );
|
gsi->visTileCount = board_visTileCount( board );
|
||||||
gsi->canHint = !gameOver && board_canHint( board );
|
gsi->canHint = !gameOver && board_canHint( board );
|
||||||
|
gsi->canUndo = model_canUndo( game->model );
|
||||||
gsi->canRedo = board_canTogglePending( board );
|
gsi->canRedo = board_canTogglePending( board );
|
||||||
gsi->inTrade = board_inTrade( board, &gsi->tradeTilesSelected );
|
gsi->inTrade = board_inTrade( board, &gsi->tradeTilesSelected );
|
||||||
gsi->canChat = !!game->comms && comms_canChat( game->comms );
|
gsi->canChat = !!game->comms && comms_canChat( game->comms );
|
||||||
|
|
|
@ -36,6 +36,7 @@ typedef struct _GameStateInfo {
|
||||||
XP_U16 visTileCount;
|
XP_U16 visTileCount;
|
||||||
XW_TrayVisState trayVisState;
|
XW_TrayVisState trayVisState;
|
||||||
XP_Bool canHint;
|
XP_Bool canHint;
|
||||||
|
XP_Bool canUndo;
|
||||||
XP_Bool canRedo;
|
XP_Bool canRedo;
|
||||||
XP_Bool inTrade;
|
XP_Bool inTrade;
|
||||||
XP_Bool tradeTilesSelected;
|
XP_Bool tradeTilesSelected;
|
||||||
|
|
|
@ -822,6 +822,18 @@ model_rejectPreviousMove( ModelCtxt* model, PoolContext* pool, XP_U16* turn )
|
||||||
*turn = entry.playerNum;
|
*turn = entry.playerNum;
|
||||||
} /* model_rejectPreviousMove */
|
} /* model_rejectPreviousMove */
|
||||||
|
|
||||||
|
XP_Bool
|
||||||
|
model_canUndo( const ModelCtxt* model )
|
||||||
|
{
|
||||||
|
const StackCtxt* stack = model->vol.stack;
|
||||||
|
XP_U16 nStackEntries = stack_getNEntries( stack );
|
||||||
|
|
||||||
|
/* More than just tile assignment? */
|
||||||
|
XP_Bool result = nStackEntries > model->nPlayers;
|
||||||
|
LOG_RETURNF( "%d", result );
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/* Undo a move, but only if it's the move we're expecting to undo (as
|
/* Undo a move, but only if it's the move we're expecting to undo (as
|
||||||
* indicated by *moveNumP, if >= 0).
|
* indicated by *moveNumP, if >= 0).
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -192,7 +192,7 @@ void model_commitRejectedPhony( ModelCtxt* model, XP_S16 player );
|
||||||
void model_makeTileTrade( ModelCtxt* model, XP_S16 player,
|
void model_makeTileTrade( ModelCtxt* model, XP_S16 player,
|
||||||
const TrayTileSet* oldTiles,
|
const TrayTileSet* oldTiles,
|
||||||
const TrayTileSet* newTiles );
|
const TrayTileSet* newTiles );
|
||||||
|
XP_Bool model_canUndo( const ModelCtxt* model );
|
||||||
XP_Bool model_undoLatestMoves( ModelCtxt* model, PoolContext* pool,
|
XP_Bool model_undoLatestMoves( ModelCtxt* model, PoolContext* pool,
|
||||||
XP_U16 nMovesSought, XP_U16* turn,
|
XP_U16 nMovesSought, XP_U16* turn,
|
||||||
XP_S16* moveNum );
|
XP_S16* moveNum );
|
||||||
|
|
Loading…
Reference in a new issue