mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
add to game state whether any tiles selected. Use that to disable
'commit exchange' button when there's nothing to commit, and get rid of error message used when committing nothing since it's now impossible (on Android).
This commit is contained in:
parent
66fb5f87fb
commit
c9c498786e
8 changed files with 18 additions and 9 deletions
|
@ -1182,6 +1182,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1getState
|
|||
setBool( env, jgsi, "canHint", info.canHint );
|
||||
setBool( env, jgsi, "canRedo", info.canRedo);
|
||||
setBool( env, jgsi, "inTrade", info.inTrade );
|
||||
setBool( env, jgsi, "tradeTilesSelected", info.tradeTilesSelected );
|
||||
setBool( env, jgsi, "gameIsConnected", info.gameIsConnected );
|
||||
setBool( env, jgsi, "canShuffle", info.canShuffle );
|
||||
|
||||
|
|
|
@ -135,8 +135,6 @@
|
|||
<string name="str_tiles_must_contact">New pieces must contact others already in place (or the middle square on the first move)</string>
|
||||
<string name="str_not_your_turn">You can\'t do that; it\'s not your turn!</string>
|
||||
<string name="str_no_peek_robot_tiles">No peeking at the robot\'s tiles!</string>
|
||||
<string name="str_no_empty_trade">Please tap to select tiles to be
|
||||
exchanged.</string>
|
||||
<string name="str_too_few_tiles_left_to_trade">Too few tiles left to exchange.</string>
|
||||
<string name="str_cant_undo_tileassign">Tile assignment can\'t be undone.</string>
|
||||
<string name="str_cant_hint_while_disabled">The hint feature is disabled for this game. Enable it for a new game using the Settings dialog.</string>
|
||||
|
@ -546,7 +544,7 @@
|
|||
exchanged. Use the buttons to commit your turn or exit exchange
|
||||
mode.</string>
|
||||
|
||||
<string name="entering_trade">Entering exchange mode</string>
|
||||
<string name="entering_trade">Tap to select tiles...</string>
|
||||
|
||||
<string name="relay_game_explainf">To start a basic networked two-player
|
||||
game in %s:</string>
|
||||
|
|
|
@ -1078,7 +1078,9 @@ public class BoardActivity extends XWActivity
|
|||
resid = R.string.str_no_peek_robot_tiles;
|
||||
break;
|
||||
case UtilCtxt.ERR_NO_EMPTY_TRADE:
|
||||
resid = R.string.str_no_empty_trade;
|
||||
// This should not be possible as the button's
|
||||
// disabled when no tiles selected.
|
||||
Assert.fail();
|
||||
break;
|
||||
case UtilCtxt.ERR_TOO_FEW_TILES_LEFT_TO_TRADE:
|
||||
resid = R.string.str_too_few_tiles_left_to_trade;
|
||||
|
@ -1223,9 +1225,9 @@ public class BoardActivity extends XWActivity
|
|||
updateToolbar();
|
||||
if ( m_inTrade != m_gsi.inTrade ) {
|
||||
m_inTrade = m_gsi.inTrade;
|
||||
adjustTradeVisibility();
|
||||
m_view.setInTrade( m_inTrade );
|
||||
}
|
||||
adjustTradeVisibility();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1437,6 +1439,9 @@ public class BoardActivity extends XWActivity
|
|||
{
|
||||
m_toolbar.setVisibility( m_inTrade? View.GONE : View.VISIBLE );
|
||||
m_tradeButtons.setVisibility( m_inTrade? View.VISIBLE : View.GONE );
|
||||
if ( m_inTrade ) {
|
||||
m_exchCommmitButton.setEnabled( m_gsi.tradeTilesSelected );
|
||||
}
|
||||
}
|
||||
|
||||
private void setBackgroundColor()
|
||||
|
|
|
@ -94,6 +94,7 @@ public class JNIThread extends Thread {
|
|||
public boolean canHint;
|
||||
public boolean canRedo;
|
||||
public boolean inTrade;
|
||||
public boolean tradeTilesSelected;
|
||||
public boolean gameIsConnected;
|
||||
public boolean canShuffle;
|
||||
public GameStateInfo clone() {
|
||||
|
|
|
@ -1596,9 +1596,12 @@ board_flip( BoardCtxt* board )
|
|||
} /* board_flip */
|
||||
|
||||
XP_Bool
|
||||
board_inTrade( const BoardCtxt* board )
|
||||
board_inTrade( const BoardCtxt* board, XP_Bool* anySelected )
|
||||
{
|
||||
const PerTurnInfo* pti = &board->pti[board->selPlayer];
|
||||
if ( !!anySelected ) {
|
||||
*anySelected = 0 != pti->traySelBits;
|
||||
}
|
||||
return pti->tradeInProgress;
|
||||
}
|
||||
|
||||
|
@ -2101,7 +2104,7 @@ board_beginTrade( BoardCtxt* board )
|
|||
XP_Bool
|
||||
board_endTrade( BoardCtxt* board )
|
||||
{
|
||||
XP_Bool result = board_inTrade( board );
|
||||
XP_Bool result = board_inTrade( board, NULL );
|
||||
if ( result ) {
|
||||
PerTurnInfo* pti = board->selInfo;
|
||||
invalSelTradeWindow( board );
|
||||
|
|
|
@ -100,7 +100,7 @@ XP_Bool board_draw( BoardCtxt* board );
|
|||
|
||||
XP_Bool board_get_flipped( const BoardCtxt* board );
|
||||
XP_Bool board_flip( BoardCtxt* board );
|
||||
XP_Bool board_inTrade( const BoardCtxt* board );
|
||||
XP_Bool board_inTrade( const BoardCtxt* board, XP_Bool* anySelected );
|
||||
XP_Bool board_get_showValues( const BoardCtxt* board );
|
||||
XP_Bool board_toggle_showValues( BoardCtxt* board );
|
||||
XP_Bool board_replaceTiles( BoardCtxt* board );
|
||||
|
|
|
@ -283,7 +283,7 @@ game_getState( const XWGame* game, GameStateInfo* gsi )
|
|||
gsi->visTileCount = board_visTileCount( game->board );
|
||||
gsi->canHint = board_canHint( game->board );
|
||||
gsi->canRedo = board_canTogglePending( game->board );
|
||||
gsi->inTrade = board_inTrade( game->board );
|
||||
gsi->inTrade = board_inTrade( game->board, &gsi->tradeTilesSelected );
|
||||
gsi->gameIsConnected = !!game->comms && comms_canChat( game->comms );
|
||||
gsi->canShuffle = board_canShuffle( game->board );
|
||||
}
|
||||
|
|
|
@ -93,6 +93,7 @@ typedef struct _GameStateInfo {
|
|||
XP_Bool canHint;
|
||||
XP_Bool canRedo;
|
||||
XP_Bool inTrade;
|
||||
XP_Bool tradeTilesSelected;
|
||||
XP_Bool gameIsConnected;
|
||||
XP_Bool canShuffle;
|
||||
} GameStateInfo;
|
||||
|
|
Loading…
Add table
Reference in a new issue