mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-13 08:01:33 +01:00
Don't offer to rematch game that can't (yet) be rematched
This commit is contained in:
parent
86def1ca9a
commit
f84bb85f22
9 changed files with 21 additions and 7 deletions
|
@ -885,7 +885,7 @@ public class BoardDelegate extends DelegateBase
|
|||
}
|
||||
}
|
||||
|
||||
enable = null != m_gsi && m_gsi.canRematch;
|
||||
enable = null != m_summary && m_summary.canRematch;
|
||||
Utils.setItemVisible( menu, R.id.board_menu_rematch, enable );
|
||||
|
||||
enable = m_gameOver && !inArchiveGroup();
|
||||
|
|
|
@ -41,7 +41,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||
private static final String TAG = DBHelper.class.getSimpleName();
|
||||
|
||||
private static final String DB_NAME = BuildConfig.DB_NAME;
|
||||
private static final int DB_VERSION = 34;
|
||||
private static final int DB_VERSION = 35;
|
||||
|
||||
public static final String GAME_NAME = "GAME_NAME";
|
||||
public static final String VISID = "VISID";
|
||||
|
@ -83,6 +83,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||
public static final String NEXTNAG = "NEXTNAG";
|
||||
public static final String GROUPID = "GROUPID";
|
||||
public static final String NPACKETSPENDING = "NPACKETSPENDING";
|
||||
public static final String CAN_REMATCH = "CAN_REMATCH";
|
||||
|
||||
public static final String DICTNAME = "DICTNAME";
|
||||
public static final String MD5SUM = "MD5SUM";
|
||||
|
@ -136,6 +137,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||
{ PLAYERS, "TEXT" },
|
||||
{ GAME_OVER, "INTEGER" },
|
||||
{ QUASHED, "INTEGER" },
|
||||
{ CAN_REMATCH, "INTEGER(1) default 0" },
|
||||
{ SERVERROLE, "INTEGER" },
|
||||
{ CONTYPE, "INTEGER" },
|
||||
{ ROOMNAME, "TEXT" },
|
||||
|
@ -387,6 +389,11 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||
addColumn( db, TABLE_NAMES.SUM, QUASHED );
|
||||
}
|
||||
|
||||
case 34:
|
||||
if ( !madeSumTable ) {
|
||||
addColumn( db, TABLE_NAMES.SUM, CAN_REMATCH );
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
for ( TABLE_NAMES table : TABLE_NAMES.values() ) {
|
||||
|
|
|
@ -139,7 +139,7 @@ public class DBUtils {
|
|||
DBHelper.LASTPLAY_TIME, DBHelper.REMOTEDEVS,
|
||||
DBHelper.LASTMOVE, DBHelper.NPACKETSPENDING,
|
||||
DBHelper.EXTRAS, DBHelper.NEXTDUPTIMER,
|
||||
DBHelper.CREATE_TIME,
|
||||
DBHelper.CREATE_TIME, DBHelper.CAN_REMATCH,
|
||||
};
|
||||
String selection = String.format( ROW_ID_FMT, lock.getRowid() );
|
||||
|
||||
|
@ -197,6 +197,9 @@ public class DBUtils {
|
|||
summary.created = cursor
|
||||
.getLong(cursor.getColumnIndex(DBHelper.CREATE_TIME));
|
||||
|
||||
tmp = cursor.getInt( cursor.getColumnIndex( DBHelper.CAN_REMATCH ));
|
||||
summary.canRematch = 0 != tmp;
|
||||
|
||||
String str = cursor
|
||||
.getString(cursor.getColumnIndex(DBHelper.EXTRAS));
|
||||
summary.setExtras( str );
|
||||
|
@ -307,6 +310,7 @@ public class DBUtils {
|
|||
values.put( DBHelper.QUASHED, summary.quashed? 1 : 0 );
|
||||
values.put( DBHelper.LASTMOVE, summary.lastMoveTime );
|
||||
values.put( DBHelper.NEXTDUPTIMER, summary.dupTimerExpires );
|
||||
values.put( DBHelper.CAN_REMATCH, summary.canRematch?1:0 );
|
||||
|
||||
// Don't overwrite extras! Sometimes this method is called from
|
||||
// JNIThread which has created the summary from common code that
|
||||
|
|
|
@ -2074,6 +2074,9 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
enable = false;
|
||||
boolean isMultiGame = false;
|
||||
if ( null != summary ) {
|
||||
Utils.setItemVisible( menu, R.id.games_game_rematch,
|
||||
summary.canRematch );
|
||||
|
||||
isMultiGame = summary.isMultiGame();
|
||||
enable = isMultiGame
|
||||
&& (BuildConfig.DEBUG || XWPrefs.getDebugEnabled( m_activity ));
|
||||
|
|
|
@ -84,6 +84,7 @@ public class GameSummary implements Serializable {
|
|||
public ISOCode isoCode;
|
||||
public DeviceRole serverRole;
|
||||
public int nPacketsPending;
|
||||
public boolean canRematch;
|
||||
|
||||
private Integer m_giFlags;
|
||||
private String m_playersSummary;
|
||||
|
|
|
@ -129,7 +129,6 @@ public class JNIThread extends Thread implements AutoCloseable {
|
|||
public boolean canTrade;
|
||||
public boolean canPause;
|
||||
public boolean canUnpause;
|
||||
public boolean canRematch;
|
||||
@Override
|
||||
public GameStateInfo clone() {
|
||||
GameStateInfo obj;
|
||||
|
|
|
@ -2318,6 +2318,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1summarize
|
|||
setBool( env, jsummary, "quashed", summary.quashed );
|
||||
setInt( env, jsummary, "turn", summary.turn );
|
||||
setBool( env, jsummary, "turnIsLocal", summary.turnIsLocal );
|
||||
setBool( env, jsummary, "canRematch", summary.canRematch );
|
||||
setInt( env, jsummary, "lastMoveTime", summary.lastMoveTime );
|
||||
setInt( env, jsummary, "dupTimerExpires", summary.dupTimerExpires );
|
||||
|
||||
|
@ -2488,7 +2489,6 @@ static const SetInfo gsi_bools[] = {
|
|||
ARR_MEMBER( GameStateInfo, canTrade ),
|
||||
ARR_MEMBER( GameStateInfo, canPause ),
|
||||
ARR_MEMBER( GameStateInfo, canUnpause ),
|
||||
ARR_MEMBER( GameStateInfo, canRematch ),
|
||||
};
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
|
|
|
@ -519,7 +519,6 @@ game_getState( const XWGame* game, XWEnv xwe, GameStateInfo* gsi )
|
|||
gsi->canTrade = board_canTrade( board, xwe );
|
||||
gsi->nPendingMessages = !!game->comms ?
|
||||
comms_countPendingPackets(game->comms, NULL) : 0;
|
||||
gsi->canRematch = server_canRematch( server, NULL );
|
||||
gsi->canPause = server_canPause( server );
|
||||
gsi->canUnpause = server_canUnpause( server );
|
||||
}
|
||||
|
@ -535,6 +534,7 @@ game_summarize( const XWGame* game, const CurGameInfo* gi, GameSummary* summary
|
|||
summary->gameOver = server_getGameIsOver( server );
|
||||
summary->nMoves = model_getNMoves( game->model );
|
||||
summary->dupTimerExpires = server_getDupTimerExpires( server );
|
||||
summary->canRematch = server_canRematch( server, NULL );
|
||||
|
||||
for ( int ii = 0; ii < gi->nPlayers; ++ii ) {
|
||||
const LocalPlayer* lp = &gi->players[ii];
|
||||
|
|
|
@ -47,7 +47,6 @@ typedef struct _GameStateInfo {
|
|||
XP_Bool curTurnSelected;
|
||||
XP_Bool canHideRack;
|
||||
XP_Bool canTrade;
|
||||
XP_Bool canRematch;
|
||||
XP_Bool canPause; /* duplicate-mode only */
|
||||
XP_Bool canUnpause; /* duplicate-mode only */
|
||||
} GameStateInfo;
|
||||
|
@ -56,6 +55,7 @@ typedef struct _GameSummary {
|
|||
XP_Bool turnIsLocal;
|
||||
XP_Bool gameOver;
|
||||
XP_Bool quashed;
|
||||
XP_Bool canRematch;
|
||||
XP_S8 turn;
|
||||
XP_U32 lastMoveTime;
|
||||
XP_S32 dupTimerExpires;
|
||||
|
|
Loading…
Reference in a new issue