From 90f11abc370f6401929bfa4e61a76a7ff8671cea Mon Sep 17 00:00:00 2001 From: Andy2 Date: Wed, 5 Oct 2011 06:36:01 -0700 Subject: [PATCH] add to game state passed into java world whether it's the cur selected player's turn, and use that to enable/disable Pass/Turn done button. --- xwords4/android/XWords4/jni/xwjni.c | 1 + .../XWords4/src/org/eehouse/android/xw4/BoardActivity.java | 1 + .../XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java | 1 + xwords4/common/board.c | 6 ++++++ xwords4/common/board.h | 1 + xwords4/common/game.c | 1 + xwords4/common/game.h | 1 + 7 files changed, 12 insertions(+) diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c index b22cb0b40..bc83bd101 100644 --- a/xwords4/android/XWords4/jni/xwjni.c +++ b/xwords4/android/XWords4/jni/xwjni.c @@ -1185,6 +1185,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1getState setBool( env, jgsi, "tradeTilesSelected", info.tradeTilesSelected ); setBool( env, jgsi, "gameIsConnected", info.gameIsConnected ); setBool( env, jgsi, "canShuffle", info.canShuffle ); + setBool( env, jgsi, "curTurnSelected", info.curTurnSelected ); XWJNI_END(); } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java index 9fd89c5b1..319ab60dd 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java @@ -613,6 +613,7 @@ public class BoardActivity extends XWActivity strId = R.string.board_menu_done; } item.setTitle( strId ); + item.setEnabled( null == m_gsi || m_gsi.curTurnSelected ); } return true; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java index bcbfad91b..284b1f9df 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java @@ -99,6 +99,7 @@ public class JNIThread extends Thread { public boolean tradeTilesSelected; public boolean gameIsConnected; public boolean canShuffle; + public boolean curTurnSelected; public GameStateInfo clone() { GameStateInfo obj = null; try { diff --git a/xwords4/common/board.c b/xwords4/common/board.c index abba4a7cd..476cc61f9 100644 --- a/xwords4/common/board.c +++ b/xwords4/common/board.c @@ -541,6 +541,12 @@ board_getYOffset( const BoardCtxt* board ) return vsd->offset; } /* board_getYOffset */ +XP_Bool +board_curTurnSelected( const BoardCtxt* board ) +{ + return MY_TURN( board ); +} + XP_U16 board_visTileCount( const BoardCtxt* board ) { diff --git a/xwords4/common/board.h b/xwords4/common/board.h index dc5fc0cb0..2f37e7416 100644 --- a/xwords4/common/board.h +++ b/xwords4/common/board.h @@ -78,6 +78,7 @@ void board_reset( BoardCtxt* board ); XP_Bool board_setYOffset( BoardCtxt* board, XP_U16 newOffset ); XP_U16 board_getYOffset( const BoardCtxt* board ); +XP_Bool board_curTurnSelected( const BoardCtxt* board ); XP_U16 board_visTileCount( const BoardCtxt* board ); XP_Bool board_canShuffle( const BoardCtxt* board ); XP_Bool board_canTogglePending( const BoardCtxt* board ); diff --git a/xwords4/common/game.c b/xwords4/common/game.c index 20485d761..b02d58ee0 100644 --- a/xwords4/common/game.c +++ b/xwords4/common/game.c @@ -280,6 +280,7 @@ game_saveToStream( const XWGame* game, const CurGameInfo* gi, void game_getState( const XWGame* game, GameStateInfo* gsi ) { + gsi->curTurnSelected = board_curTurnSelected( game->board ); gsi->visTileCount = board_visTileCount( game->board ); gsi->canHint = board_canHint( game->board ); gsi->canRedo = board_canTogglePending( game->board ); diff --git a/xwords4/common/game.h b/xwords4/common/game.h index 1d967ec3b..139ac8878 100644 --- a/xwords4/common/game.h +++ b/xwords4/common/game.h @@ -97,6 +97,7 @@ typedef struct _GameStateInfo { XP_Bool tradeTilesSelected; XP_Bool gameIsConnected; XP_Bool canShuffle; + XP_Bool curTurnSelected; } GameStateInfo; typedef struct XWGame {