mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-28 07:58:08 +01:00
move showColors into CommonPrefs, removing separate storage in linux
and wince and removing setter from board and jni APIs. Palm change pending.
This commit is contained in:
parent
b3dba204c6
commit
4425eaa99e
12 changed files with 40 additions and 42 deletions
|
@ -132,8 +132,6 @@ public class JNIThread extends Thread {
|
|||
trayHt, // height
|
||||
4 );
|
||||
|
||||
XwJNI.board_setShowColors( m_jniGamePtr, true ); // get from prefs!
|
||||
|
||||
XwJNI.board_invalAll( m_jniGamePtr );
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@ public class XwJNI {
|
|||
public static native void board_setPos( int gamePtr, int left, int top,
|
||||
boolean lefty );
|
||||
public static native void board_setScale( int gamePtr, int hscale, int vscale );
|
||||
public static native boolean board_setShowColors( int gamePtr, boolean on );
|
||||
public static native void board_setScoreboardLoc( int gamePtr, int left,
|
||||
int top, int width,
|
||||
int height,
|
||||
|
|
|
@ -415,15 +415,6 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1setScale
|
|||
XWJNI_END();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1setShowColors
|
||||
( JNIEnv *env, jclass C, jint gamePtr, jboolean on )
|
||||
{
|
||||
XWJNI_START();
|
||||
board_setShowColors( state->game.board, on );
|
||||
XWJNI_END();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1setScoreboardLoc
|
||||
( JNIEnv *env, jclass C, jint gamePtr, jint left, jint top,
|
||||
|
|
|
@ -90,6 +90,8 @@ static void setArrowFor( BoardCtxt* board, XP_U16 player, XP_U16 col,
|
|||
static XP_Bool setArrowVisible( BoardCtxt* board, XP_Bool visible );
|
||||
|
||||
static void invalTradeWindow( BoardCtxt* board, XP_S16 turn, XP_Bool redraw );
|
||||
static XP_Bool invalCellsWithTiles( BoardCtxt* board );
|
||||
|
||||
static void setTimerIf( BoardCtxt* board );
|
||||
static XP_Bool p_board_timerFired( void* closure, XWTimerReason why );
|
||||
|
||||
|
@ -388,13 +390,16 @@ board_prefsChanged( BoardCtxt* board, CommonPrefs* cp )
|
|||
{
|
||||
XP_Bool showArrowChanged;
|
||||
XP_Bool hideValChanged;
|
||||
XP_Bool showColorsChanged;
|
||||
|
||||
showArrowChanged = cp->showBoardArrow == board->disableArrow;
|
||||
hideValChanged = cp->hideTileValues != board->hideValsInTray;
|
||||
showColorsChanged = board->showColors != cp->showColors;
|
||||
|
||||
board->disableArrow = !cp->showBoardArrow;
|
||||
board->hideValsInTray = cp->hideTileValues;
|
||||
board->skipCommitConfirm = cp->skipCommitConfirm;
|
||||
board->showColors = cp->showColors;
|
||||
|
||||
if ( showArrowChanged ) {
|
||||
showArrowChanged = setArrowVisible( board, XP_FALSE );
|
||||
|
@ -402,6 +407,10 @@ board_prefsChanged( BoardCtxt* board, CommonPrefs* cp )
|
|||
if ( hideValChanged ) {
|
||||
board_invalTrayTiles( board, ALLTILES );
|
||||
}
|
||||
if ( showColorsChanged ) {
|
||||
board->scoreBoardInvalid = XP_TRUE;
|
||||
showColorsChanged = invalCellsWithTiles( board );
|
||||
}
|
||||
|
||||
#ifdef XWFEATURE_SEARCHLIMIT
|
||||
if ( !board->gi->allowHintRect && board->selInfo->hasHintRect ) {
|
||||
|
@ -416,7 +425,7 @@ board_prefsChanged( BoardCtxt* board, CommonPrefs* cp )
|
|||
}
|
||||
#endif
|
||||
|
||||
return showArrowChanged || hideValChanged;
|
||||
return showArrowChanged || hideValChanged || showColorsChanged;
|
||||
} /* board_prefsChanged */
|
||||
|
||||
XP_Bool
|
||||
|
@ -1399,14 +1408,6 @@ board_toggle_showValues( BoardCtxt* board )
|
|||
return invalCellsWithTiles( board ) || changed;
|
||||
} /* board_toggle_showValues */
|
||||
|
||||
XP_Bool
|
||||
board_setShowColors( BoardCtxt* board, XP_Bool showColors )
|
||||
{
|
||||
board->showColors = showColors;
|
||||
board->scoreBoardInvalid = XP_TRUE;
|
||||
return invalCellsWithTiles( board );
|
||||
} /* board_setShowColors */
|
||||
|
||||
XP_Bool
|
||||
board_replaceTiles( BoardCtxt* board )
|
||||
{
|
||||
|
|
|
@ -93,8 +93,6 @@ XP_Bool board_get_flipped( const BoardCtxt* board );
|
|||
XP_Bool board_flip( BoardCtxt* board );
|
||||
XP_Bool board_get_showValues( const BoardCtxt* board );
|
||||
XP_Bool board_toggle_showValues( BoardCtxt* board );
|
||||
XP_Bool board_getShowColors( BoardCtxt* board );
|
||||
XP_Bool board_setShowColors( BoardCtxt* board, XP_Bool showColors );
|
||||
XP_Bool board_replaceTiles( BoardCtxt* board );
|
||||
|
||||
XP_Bool board_requestHint( BoardCtxt* board,
|
||||
|
|
|
@ -133,6 +133,7 @@ typedef struct CommonPrefs {
|
|||
#ifdef XWFEATURE_SLOW_ROBOT
|
||||
XP_U16 robotThinkMin, robotThinkMax;
|
||||
#endif
|
||||
XP_Bool showColors; /* applies to all games */
|
||||
} CommonPrefs;
|
||||
|
||||
#ifdef XWFEATURE_BLUETOOTH
|
||||
|
|
|
@ -543,7 +543,6 @@ configure_event( GtkWidget* widget, GdkEventConfigure* XP_UNUSED(event),
|
|||
board_setPos( globals->cGlobals.game.board, GTK_BOARD_LEFT, boardTop,
|
||||
XP_FALSE );
|
||||
board_setScale( globals->cGlobals.game.board, hscale, vscale );
|
||||
board_setShowColors( globals->cGlobals.game.board, XP_TRUE );
|
||||
globals->gridOn = XP_TRUE;
|
||||
|
||||
if ( !!globals->cGlobals.game.comms ) {
|
||||
|
@ -2014,6 +2013,7 @@ gtkmain( LaunchParams* params, int argc, char *argv[] )
|
|||
globals.cp.showBoardArrow = XP_TRUE;
|
||||
globals.cp.hideTileValues = params->hideValues;
|
||||
globals.cp.skipCommitConfirm = params->skipCommitConfirm;
|
||||
globals.cp.showColors = params->showColors;
|
||||
globals.cp.showRobotScores = params->showRobotScores;
|
||||
#ifdef XWFEATURE_SLOW_ROBOT
|
||||
globals.cp.robotThinkMin = params->robotThinkMin;
|
||||
|
|
|
@ -778,6 +778,7 @@ main( int argc, char** argv )
|
|||
mainParams.allowHintRect = XP_TRUE;
|
||||
#endif
|
||||
mainParams.skipCommitConfirm = XP_TRUE;
|
||||
mainParams.showColors = XP_TRUE;
|
||||
|
||||
/* serverName = mainParams.info.clientInfo.serverName = "localhost"; */
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ typedef struct LaunchParams {
|
|||
XP_Bool undoWhenDone;
|
||||
XP_Bool verticalScore;
|
||||
XP_Bool hideValues;
|
||||
XP_Bool showColors;
|
||||
XP_Bool skipCommitConfirm;
|
||||
XP_Bool needsNewGame;
|
||||
// XP_Bool mainParams;
|
||||
|
|
|
@ -812,7 +812,6 @@ cePositionBoard( CEAppGlobals* globals )
|
|||
board_setScoreboardLoc( globals->game.board, bparms.adjLeft, bparms.adjTop,
|
||||
bparms.scoreWidth,
|
||||
bparms.scoreHeight, bparms.horiz );
|
||||
board_setShowColors( globals->game.board, globals->appPrefs.showColors );
|
||||
board_setYOffset( globals->game.board, 0 );
|
||||
|
||||
board_prefsChanged( globals->game.board, &globals->appPrefs.cp );
|
||||
|
@ -1042,23 +1041,17 @@ canUpdatePrefs( CEAppGlobals* globals, HANDLE fileH, XP_U16 curVersion,
|
|||
CEAppPrefs* prefs )
|
||||
{
|
||||
XP_Bool success = XP_FALSE;
|
||||
LOG_FUNC();
|
||||
if ( (curVersion == 0x0002) && (CUR_CE_PREFS_FLAGS == 0x0003) ) {
|
||||
CEAppPrefs0002 oldPrefs;
|
||||
if ( curVersion == 0x0003 && CUR_CE_PREFS_FLAGS == 0x0004 ) {
|
||||
/* common prefs has gotten bigger, pushing colors down. */
|
||||
CEAppPrefs0003 oldPrefs;
|
||||
XP_U32 nRead;
|
||||
if ( ReadFile( fileH, &oldPrefs, sizeof(oldPrefs), &nRead, NULL ) ) {
|
||||
ceInitPrefs( globals, prefs );
|
||||
|
||||
XP_MEMCPY( &prefs->cp, &oldPrefs.cp, sizeof(prefs->cp) );
|
||||
prefs->showColors = oldPrefs.showColors;
|
||||
XP_MEMCPY( &prefs->cp, &oldPrefs.cp, sizeof(oldPrefs.cp) );
|
||||
prefs->cp.showColors = oldPrefs.showColors;
|
||||
prefs->fullScreen = oldPrefs.fullScreen;
|
||||
|
||||
XP_MEMCPY( &prefs->colors[0], &oldPrefs.colors[0],
|
||||
CE_FOCUS_COLOR*sizeof(prefs->colors[0]));
|
||||
XP_ASSERT( CE_PLAYER0_COLOR - 1 == CE_FOCUS_COLOR );
|
||||
XP_MEMCPY( &prefs->colors[CE_PLAYER0_COLOR],
|
||||
&oldPrefs.colors[CE_FOCUS_COLOR],
|
||||
(CE_NUM_COLORS-CE_PLAYER0_COLOR)
|
||||
* sizeof(prefs->colors[0]));
|
||||
success = XP_TRUE;
|
||||
} else {
|
||||
XP_LOGF( "%s: ReadFile bad", __func__ );
|
||||
|
@ -1269,11 +1262,11 @@ static void
|
|||
ceInitPrefs( CEAppGlobals* globals, CEAppPrefs* prefs )
|
||||
{
|
||||
prefs->versionFlags = CUR_CE_PREFS_FLAGS;
|
||||
prefs->showColors = XP_TRUE;
|
||||
prefs->fullScreen = XP_FALSE;
|
||||
|
||||
prefs->cp.showBoardArrow = XP_TRUE;
|
||||
prefs->cp.showRobotScores = XP_FALSE;
|
||||
prefs->cp.showColors = XP_TRUE;
|
||||
|
||||
colorsFromRsrc( globals, prefs );
|
||||
} /* ceInitPrefs */
|
||||
|
|
|
@ -80,7 +80,8 @@ enum { CE_BONUS0_COLOR,
|
|||
CE_NUM_COLORS /* last */
|
||||
};
|
||||
|
||||
#define CUR_CE_PREFS_FLAGS 0x0003 /* adds CE_FOCUS_COLOR */
|
||||
// #define CUR_CE_PREFS_FLAGS 0x0003 /* adds CE_FOCUS_COLOR */
|
||||
#define CUR_CE_PREFS_FLAGS 0x0004 /* moves showColors into CommonPrefs */
|
||||
|
||||
/* This is what CEAppPrefs looked like for CUR_CE_PREFS_FLAGS == 0x0002 */
|
||||
typedef struct CEAppPrefs0002 {
|
||||
|
@ -90,6 +91,23 @@ typedef struct CEAppPrefs0002 {
|
|||
XP_Bool showColors;
|
||||
} CEAppPrefs0002;
|
||||
|
||||
/* This is what CEAppPrefs looked like for CUR_CE_PREFS_FLAGS == 0x0003 */
|
||||
typedef struct _CEAppPrefs0003 {
|
||||
XP_U16 versionFlags;
|
||||
struct {
|
||||
XP_Bool showBoardArrow; /* applies to all games */
|
||||
XP_Bool showRobotScores; /* applies to all games */
|
||||
XP_Bool hideTileValues;
|
||||
XP_Bool skipCommitConfirm; /* applies to all games */
|
||||
#ifdef XWFEATURE_SLOW_ROBOT
|
||||
XP_U16 robotThinkMin, robotThinkMax;
|
||||
#endif
|
||||
} cp;
|
||||
COLORREF colors[13];
|
||||
XP_Bool showColors;
|
||||
XP_Bool fullScreen;
|
||||
} CEAppPrefs0003;
|
||||
|
||||
typedef enum {
|
||||
SAB_NONE = 0
|
||||
,SAB_PHONEOFF = 1 << 0
|
||||
|
@ -105,7 +123,6 @@ typedef struct CEAppPrefs {
|
|||
XP_U16 versionFlags;
|
||||
CommonPrefs cp;
|
||||
COLORREF colors[CE_NUM_COLORS];
|
||||
XP_Bool showColors;
|
||||
XP_Bool fullScreen;
|
||||
} CEAppPrefs;
|
||||
|
||||
|
|
|
@ -153,7 +153,6 @@ loadStateFromCurPrefs( CEAppGlobals* XP_UNUSED_STANDALONE(globals),
|
|||
#ifdef XWFEATURE_SEARCHLIMIT
|
||||
prefsPrefs->gp.allowHintRect = gi->allowHintRect;
|
||||
#endif
|
||||
prefsPrefs->showColors = appPrefs->showColors;
|
||||
|
||||
XP_MEMCPY( &prefsPrefs->cp, &appPrefs->cp, sizeof(prefsPrefs->cp) );
|
||||
XP_MEMCPY( &prefsPrefs->colors, &appPrefs->colors,
|
||||
|
@ -184,7 +183,6 @@ loadCurPrefsFromState( CEAppGlobals* XP_UNUSED_STANDALONE(globals),
|
|||
#ifdef XWFEATURE_SEARCHLIMIT
|
||||
gi->allowHintRect = prefsPrefs->gp.allowHintRect;
|
||||
#endif
|
||||
appPrefs->showColors = prefsPrefs->showColors;
|
||||
|
||||
XP_MEMCPY( &appPrefs->cp, &prefsPrefs->cp, sizeof(appPrefs->cp) );
|
||||
XP_MEMCPY( &appPrefs->colors, &prefsPrefs->colors,
|
||||
|
|
Loading…
Add table
Reference in a new issue