Merge branch 'android_branch' into send_in_background

This commit is contained in:
eehouse@eehouse.org 2011-10-05 07:10:52 -07:00 committed by Andy2
commit 471a9d988d
25 changed files with 113 additions and 80 deletions

View file

@ -107,12 +107,11 @@ makeDSI( AndDraw* draw, int indx, const DrawScoreInfo* dsi )
static XP_Bool static XP_Bool
and_draw_scoreBegin( DrawCtx* dctx, const XP_Rect* rect, and_draw_scoreBegin( DrawCtx* dctx, const XP_Rect* rect,
XP_U16 numPlayers, XP_U16 numPlayers, const XP_S16* const scores,
const XP_S16* const scores, XP_S16 remCount, DrawFocusState XP_UNUSED(dfs) )
XP_S16 remCount, DrawFocusState dfs )
{ {
jboolean result; jboolean result;
DRAW_CBK_HEADER("scoreBegin", "(Landroid/graphics/Rect;I[III)Z" ); DRAW_CBK_HEADER("scoreBegin", "(Landroid/graphics/Rect;I[II)Z" );
jint jarr[numPlayers]; jint jarr[numPlayers];
int ii; int ii;
@ -123,8 +122,7 @@ and_draw_scoreBegin( DrawCtx* dctx, const XP_Rect* rect,
jobject jrect = makeJRect( draw, JCACHE_RECT0, rect ); jobject jrect = makeJRect( draw, JCACHE_RECT0, rect );
result = (*env)->CallBooleanMethod( env, draw->jdraw, mid, result = (*env)->CallBooleanMethod( env, draw->jdraw, mid,
jrect, numPlayers, jscores, remCount, jrect, numPlayers, jscores, remCount );
dfs );
(*env)->DeleteLocalRef( env, jscores ); (*env)->DeleteLocalRef( env, jscores );
return result; return result;
@ -220,15 +218,15 @@ and_draw_drawTimer( DrawCtx* dctx, const XP_Rect* rect, XP_U16 player,
static XP_Bool static XP_Bool
and_draw_boardBegin( DrawCtx* dctx, const XP_Rect* rect, and_draw_boardBegin( DrawCtx* dctx, const XP_Rect* rect,
XP_U16 cellWidth, XP_U16 cellHeight, DrawFocusState dfs ) XP_U16 cellWidth, XP_U16 cellHeight,
DrawFocusState XP_UNUSED(dfs) )
{ {
DRAW_CBK_HEADER( "boardBegin", "(Landroid/graphics/Rect;III)Z" ); DRAW_CBK_HEADER( "boardBegin", "(Landroid/graphics/Rect;II)Z" );
jobject jrect = makeJRect( draw, JCACHE_RECT0, rect ); jobject jrect = makeJRect( draw, JCACHE_RECT0, rect );
jboolean result = (*env)->CallBooleanMethod( env, draw->jdraw, mid, jboolean result = (*env)->CallBooleanMethod( env, draw->jdraw, mid,
jrect, cellWidth, cellHeight, jrect, cellWidth, cellHeight );
(jint)dfs );
return result; return result;
} }
@ -281,15 +279,14 @@ and_draw_vertScrollBoard( DrawCtx* XP_UNUSED(dctx), XP_Rect* XP_UNUSED(rect),
static XP_Bool static XP_Bool
and_draw_trayBegin( DrawCtx* dctx, const XP_Rect* rect, XP_U16 owner, and_draw_trayBegin( DrawCtx* dctx, const XP_Rect* rect, XP_U16 owner,
DrawFocusState dfs ) XP_S16 score, DrawFocusState XP_UNUSED(dfs) )
{ {
DRAW_CBK_HEADER( "trayBegin", "(Landroid/graphics/Rect;II)Z" ); DRAW_CBK_HEADER( "trayBegin", "(Landroid/graphics/Rect;II)Z" );
jobject jrect = makeJRect( draw, JCACHE_RECT0, rect ); jobject jrect = makeJRect( draw, JCACHE_RECT0, rect );
jboolean result = (*env)->CallBooleanMethod( env, draw->jdraw, mid, jboolean result = (*env)->CallBooleanMethod( env, draw->jdraw, mid,
jrect, owner, (jint)dfs ); jrect, owner, score );
return result; return result;
} }
@ -373,13 +370,13 @@ and_draw_score_pendingScore( DrawCtx* dctx, const XP_Rect* rect,
static void static void
and_draw_objFinished( DrawCtx* dctx, BoardObjectType typ, and_draw_objFinished( DrawCtx* dctx, BoardObjectType typ,
const XP_Rect* rect, const XP_Rect* rect,
DrawFocusState dfs ) DrawFocusState XP_UNUSED(dfs) )
{ {
DRAW_CBK_HEADER( "objFinished", "(ILandroid/graphics/Rect;I)V" ); DRAW_CBK_HEADER( "objFinished", "(ILandroid/graphics/Rect;)V" );
jobject jrect = makeJRect( draw, JCACHE_RECT0, rect ); jobject jrect = makeJRect( draw, JCACHE_RECT0, rect );
(*env)->CallVoidMethod( env, draw->jdraw, mid, (*env)->CallVoidMethod( env, draw->jdraw, mid,
(jint)typ, jrect, (jint)dfs ); (jint)typ, jrect );
} }
static void static void

View file

@ -216,8 +216,7 @@ and_util_turnChanged(XW_UtilCtxt* uc)
#endif #endif
static void static void
and_util_informMove( XW_UtilCtxt* uc, XWStreamCtxt* expl, and_util_informMove( XW_UtilCtxt* uc, XWStreamCtxt* expl, XWStreamCtxt* words )
XWStreamCtxt* words, XP_U16 wordCount )
{ {
UTIL_CBK_HEADER( "informMove", "(Ljava/lang/String;Ljava/lang/String;)V" ); UTIL_CBK_HEADER( "informMove", "(Ljava/lang/String;Ljava/lang/String;)V" );
jstring jexpl = streamToJString( MPPARM(util->util.mpool) env, expl ); jstring jexpl = streamToJString( MPPARM(util->util.mpool) env, expl );
@ -227,8 +226,6 @@ and_util_informMove( XW_UtilCtxt* uc, XWStreamCtxt* expl,
(*env)->DeleteLocalRef( env, jexpl ); (*env)->DeleteLocalRef( env, jexpl );
if ( !!jwords ) { if ( !!jwords ) {
(*env)->DeleteLocalRef( env, jwords ); (*env)->DeleteLocalRef( env, jwords );
} else {
XP_ASSERT( 0 == wordCount );
} }
UTIL_CBK_TAIL(); UTIL_CBK_TAIL();
} }

View file

@ -1199,6 +1199,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1getState
setBool( env, jgsi, "tradeTilesSelected", info.tradeTilesSelected ); setBool( env, jgsi, "tradeTilesSelected", info.tradeTilesSelected );
setBool( env, jgsi, "gameIsConnected", info.gameIsConnected ); setBool( env, jgsi, "gameIsConnected", info.gameIsConnected );
setBool( env, jgsi, "canShuffle", info.canShuffle ); setBool( env, jgsi, "canShuffle", info.canShuffle );
setBool( env, jgsi, "curTurnSelected", info.curTurnSelected );
XWJNI_END(); XWJNI_END();
} }

View file

@ -3,8 +3,8 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:id="@+id/group_done"> <group android:id="@+id/group_done">
<!-- title set in BoardActivity -->
<item android:id="@+id/board_menu_done" <item android:id="@+id/board_menu_done"
android:title="@string/board_menu_done"
android:alphabeticShortcut="D" android:alphabeticShortcut="D"
/> />
<item android:id="@+id/board_menu_trade" <item android:id="@+id/board_menu_trade"

View file

@ -197,13 +197,21 @@
<string-array name="lookup_urls"> <string-array name="lookup_urls">
<!-- --> <!-- -->
<item>Dictionary.com</item> <item>Dictionary.com</item>
<item>:en:</item> <!-- means all supported --> <item>:en:</item>
<item>http://dictionary.com/browse/%2$s</item> --> <item>http://dictionary.com/browse/%2$s</item> -->
<!-- --> <!-- -->
<item>TheFreeDictionary.com</item> <item>TheFreeDictionary.com</item>
<item>:en:es:</item> <!-- means all supported --> <item>:en:es:</item>
<item>http://%1$s.thefreedictionary.com/_/dict.aspx?word=%2$s</item> <item>http://%1$s.thefreedictionary.com/_/dict.aspx?word=%2$s</item>
<!-- --> <!-- -->
<item>Larousse.com</item>
<item>:fr:</item>
<item>http://www.larousse.com/%1$s/dictionaries/french/%2$s</item>
<!-- -->
<item>Littre.reverso.net</item>
<item>:fr:</item>
<item>http://littre.reverso.net/dictionnaire-francais/definition/%2$s</item>
<!-- -->
<item>Google</item> <item>Google</item>
<item></item> <!-- means all supported --> <item></item> <!-- means all supported -->
<item>http://www.google.com/search?nl=%1$s\u0026q=%2$s</item> <item>http://www.google.com/search?nl=%1$s\u0026q=%2$s</item>

View file

@ -1774,5 +1774,7 @@
<string name="site_spinner_prompt">Pick a site</string> <string name="site_spinner_prompt">Pick a site</string>
<string name="word_list_label">Tap word to search</string> <string name="word_list_label">Tap word to search</string>
<string name="pick_url_titlef">Look up %s at</string> <string name="pick_url_titlef">Look up %s at</string>
<string name="board_menu_pass">Pass</string>
</resources> </resources>

View file

@ -597,12 +597,25 @@ public class BoardActivity extends XWActivity
public boolean onPrepareOptionsMenu( Menu menu ) public boolean onPrepareOptionsMenu( Menu menu )
{ {
super.onPrepareOptionsMenu( menu ); super.onPrepareOptionsMenu( menu );
boolean inTrade = false;
if ( null != m_gsi ) { if ( null != m_gsi ) {
boolean inTrade = m_gsi.inTrade; inTrade = m_gsi.inTrade;
menu.setGroupVisible( R.id.group_done, !inTrade ); menu.setGroupVisible( R.id.group_done, !inTrade );
} }
if ( !inTrade ) {
MenuItem item = menu.findItem( R.id.board_menu_done );
int strId;
if ( 0 >= m_view.curPending() ) {
strId = R.string.board_menu_pass;
} else {
strId = R.string.board_menu_done;
}
item.setTitle( strId );
item.setEnabled( null == m_gsi || m_gsi.curTurnSelected );
}
return true; return true;
} }

View file

@ -80,6 +80,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
private int m_dictPtr = 0; private int m_dictPtr = 0;
private int m_lastSecsLeft; private int m_lastSecsLeft;
private int m_lastTimerPlayer; private int m_lastTimerPlayer;
private int m_pendingScore;
private Handler m_viewHandler; private Handler m_viewHandler;
// FontDims: exists to translate space available to the largest // FontDims: exists to translate space available to the largest
@ -169,6 +170,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
m_viewHandler = new Handler(); m_viewHandler = new Handler();
} }
@Override
public boolean onTouchEvent( MotionEvent event ) public boolean onTouchEvent( MotionEvent event )
{ {
int action = event.getAction(); int action = event.getAction();
@ -336,9 +338,14 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
m_jniThread.handle( JNIThread.JNICmd.CMD_INVALALL ); m_jniThread.handle( JNIThread.JNICmd.CMD_INVALALL );
} }
public int curPending()
{
return m_pendingScore;
}
// DrawCtxt interface implementation // DrawCtxt interface implementation
public boolean scoreBegin( Rect rect, int numPlayers, int[] scores, public boolean scoreBegin( Rect rect, int numPlayers, int[] scores,
int remCount, int dfs ) int remCount )
{ {
fillRectOther( rect, CommonPrefs.COLOR_BACKGRND ); fillRectOther( rect, CommonPrefs.COLOR_BACKGRND );
m_canvas.save( Canvas.CLIP_SAVE_FLAG ); m_canvas.save( Canvas.CLIP_SAVE_FLAG );
@ -465,8 +472,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
} }
} }
public boolean boardBegin( Rect rect, int cellWidth, int cellHeight, public boolean boardBegin( Rect rect, int cellWidth, int cellHeight )
int dfs )
{ {
return true; return true;
} }
@ -582,9 +588,10 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
} }
} }
public boolean trayBegin ( Rect rect, int owner, int dfs ) public boolean trayBegin ( Rect rect, int owner, int score )
{ {
m_trayOwner = owner; m_trayOwner = owner;
m_pendingScore = score;
return true; return true;
} }
@ -638,7 +645,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
drawCentered( getResources().getString( R.string.pts ), rect, null ); drawCentered( getResources().getString( R.string.pts ), rect, null );
} }
public void objFinished( /*BoardObjectType*/int typ, Rect rect, int dfs ) public void objFinished( /*BoardObjectType*/int typ, Rect rect )
{ {
if ( DrawCtx.OBJ_SCORE == typ ) { if ( DrawCtx.OBJ_SCORE == typ ) {
m_canvas.restoreToCount(1); // in case new canvas... m_canvas.restoreToCount(1); // in case new canvas...

View file

@ -43,21 +43,19 @@ public interface DrawCtx {
static final int OBJ_TRAY = 3; static final int OBJ_TRAY = 3;
boolean scoreBegin( Rect rect, int numPlayers, int[] scores, int remCount, boolean scoreBegin( Rect rect, int numPlayers, int[] scores, int remCount );
int dfs );
void measureRemText( Rect r, int nTilesLeft, int[] width, int[] height ); void measureRemText( Rect r, int nTilesLeft, int[] width, int[] height );
void measureScoreText( Rect r, DrawScoreInfo dsi, int[] width, int[] height ); void measureScoreText( Rect r, DrawScoreInfo dsi, int[] width, int[] height );
void drawRemText( Rect rInner, Rect rOuter, int nTilesLeft, boolean focussed ); void drawRemText( Rect rInner, Rect rOuter, int nTilesLeft, boolean focussed );
void score_drawPlayer( Rect rInner, Rect rOuter, DrawScoreInfo dsi ); void score_drawPlayer( Rect rInner, Rect rOuter, DrawScoreInfo dsi );
void drawTimer( Rect rect, int player, int secondsLeft ); void drawTimer( Rect rect, int player, int secondsLeft );
boolean boardBegin( Rect rect, int cellWidth, int cellHeight, boolean boardBegin( Rect rect, int cellWidth, int cellHeight );
int dfs );
boolean drawCell( Rect rect, String text, int tile, boolean drawCell( Rect rect, String text, int tile,
int owner, int bonus, int hintAtts, int flags ); int owner, int bonus, int hintAtts, int flags );
void drawBoardArrow ( Rect rect, int bonus, boolean vert, int hintAtts, void drawBoardArrow ( Rect rect, int bonus, boolean vert, int hintAtts,
int flags ); int flags );
boolean trayBegin ( Rect rect, int owner, int dfs ); boolean trayBegin ( Rect rect, int owner, int score );
void drawTile( Rect rect, String text, int val, int flags ); void drawTile( Rect rect, String text, int val, int flags );
void drawTileMidDrag ( Rect rect, String text, int val, int owner, void drawTileMidDrag ( Rect rect, String text, int val, int owner,
int flags ); int flags );
@ -72,7 +70,7 @@ public interface DrawCtx {
public static final int BONUS_TRIPLE_WORD = 4; public static final int BONUS_TRIPLE_WORD = 4;
public static final int INTRADE_MW_TEXT = 5; public static final int INTRADE_MW_TEXT = 5;
void objFinished( /*BoardObjectType*/int typ, Rect rect, int dfs ); void objFinished( /*BoardObjectType*/int typ, Rect rect );
void dictChanged( int dictPtr ); void dictChanged( int dictPtr );

View file

@ -99,6 +99,7 @@ public class JNIThread extends Thread {
public boolean tradeTilesSelected; public boolean tradeTilesSelected;
public boolean gameIsConnected; public boolean gameIsConnected;
public boolean canShuffle; public boolean canShuffle;
public boolean curTurnSelected;
public GameStateInfo clone() { public GameStateInfo clone() {
GameStateInfo obj = null; GameStateInfo obj = null;
try { try {

View file

@ -541,6 +541,12 @@ board_getYOffset( const BoardCtxt* board )
return vsd->offset; return vsd->offset;
} /* board_getYOffset */ } /* board_getYOffset */
XP_Bool
board_curTurnSelected( const BoardCtxt* board )
{
return MY_TURN( board );
}
XP_U16 XP_U16
board_visTileCount( const BoardCtxt* board ) board_visTileCount( const BoardCtxt* board )
{ {

View file

@ -78,6 +78,7 @@ void board_reset( BoardCtxt* board );
XP_Bool board_setYOffset( BoardCtxt* board, XP_U16 newOffset ); XP_Bool board_setYOffset( BoardCtxt* board, XP_U16 newOffset );
XP_U16 board_getYOffset( const BoardCtxt* board ); XP_U16 board_getYOffset( const BoardCtxt* board );
XP_Bool board_curTurnSelected( const BoardCtxt* board );
XP_U16 board_visTileCount( const BoardCtxt* board ); XP_U16 board_visTileCount( const BoardCtxt* board );
XP_Bool board_canShuffle( const BoardCtxt* board ); XP_Bool board_canShuffle( const BoardCtxt* board );
XP_Bool board_canTogglePending( const BoardCtxt* board ); XP_Bool board_canTogglePending( const BoardCtxt* board );

View file

@ -129,7 +129,7 @@ typedef struct DrawCtxVTable {
XP_S16 dist, DrawFocusState dfs ); XP_S16 dist, DrawFocusState dfs );
XP_Bool DRAW_VTABLE_NAME(trayBegin) ( DrawCtx* dctx, const XP_Rect* rect, XP_Bool DRAW_VTABLE_NAME(trayBegin) ( DrawCtx* dctx, const XP_Rect* rect,
XP_U16 owner, XP_U16 owner, XP_S16 score,
DrawFocusState dfs ); DrawFocusState dfs );
void DRAW_VTABLE_NAME(measureRemText) ( DrawCtx* dctx, const XP_Rect* r, void DRAW_VTABLE_NAME(measureRemText) ( DrawCtx* dctx, const XP_Rect* r,
XP_S16 nTilesLeft, XP_S16 nTilesLeft,
@ -257,8 +257,10 @@ struct DrawCtx {
#define draw_dictChanged( dc, n, d ) CALL_DRAW_NAME2(dictChanged, (dc), (n), (d)) #define draw_dictChanged( dc, n, d ) CALL_DRAW_NAME2(dictChanged, (dc), (n), (d))
#define draw_boardBegin( dc,r,h,v,f ) CALL_DRAW_NAME4(boardBegin, (dc),\ #define draw_boardBegin( dc,r,h,v,f ) CALL_DRAW_NAME4(boardBegin, (dc),\
(r),(h),(v),(f)) (r),(h),(v),(f))
#define draw_objFinished( dc, t, r, d ) CALL_DRAW_NAME3(objFinished, (dc), (t), (r), (d)) #define draw_objFinished( dc, t, r, d ) \
#define draw_trayBegin( dc, r, o, f ) CALL_DRAW_NAME3(trayBegin,dc, r, o, f) CALL_DRAW_NAME3(objFinished, (dc), (t), (r), (d))
#define draw_trayBegin( dc, r, o, s, f ) \
CALL_DRAW_NAME4(trayBegin, dc, r, o, s, f)
#define draw_vertScrollBoard( dc, r, d, f ) \ #define draw_vertScrollBoard( dc, r, d, f ) \
CALL_DRAW_NAME3(vertScrollBoard, (dc),(r),(d),(f)) CALL_DRAW_NAME3(vertScrollBoard, (dc),(r),(d),(f))
#define draw_scoreBegin( dc, r, t, s, c, f ) \ #define draw_scoreBegin( dc, r, t, s, c, f ) \

View file

@ -280,6 +280,7 @@ game_saveToStream( const XWGame* game, const CurGameInfo* gi,
void void
game_getState( const XWGame* game, GameStateInfo* gsi ) game_getState( const XWGame* game, GameStateInfo* gsi )
{ {
gsi->curTurnSelected = board_curTurnSelected( game->board );
gsi->visTileCount = board_visTileCount( game->board ); gsi->visTileCount = board_visTileCount( game->board );
gsi->canHint = board_canHint( game->board ); gsi->canHint = board_canHint( game->board );
gsi->canRedo = board_canTogglePending( game->board ); gsi->canRedo = board_canTogglePending( game->board );

View file

@ -97,6 +97,7 @@ typedef struct _GameStateInfo {
XP_Bool tradeTilesSelected; XP_Bool tradeTilesSelected;
XP_Bool gameIsConnected; XP_Bool gameIsConnected;
XP_Bool canShuffle; XP_Bool canShuffle;
XP_Bool curTurnSelected;
} GameStateInfo; } GameStateInfo;
typedef struct XWGame { typedef struct XWGame {

View file

@ -2045,19 +2045,15 @@ recordWord( const XP_UCHAR* word, XP_Bool isLegal, void* closure )
stream_putU8( stream, '\n' ); stream_putU8( stream, '\n' );
} }
stream_catString( stream, word ); stream_catString( stream, word );
if ( NULL != info->nWordsP ) {
*info->nWordsP = info->nWords;
}
return XP_TRUE; return XP_TRUE;
} }
WordNotifierInfo* WordNotifierInfo*
model_initWordCounter( ModelCtxt* model, XWStreamCtxt* stream, XP_U16* nWords ) model_initWordCounter( ModelCtxt* model, XWStreamCtxt* stream )
{ {
XP_ASSERT( model->vol.wni.proc == recordWord ); XP_ASSERT( model->vol.wni.proc == recordWord );
XP_ASSERT( model->vol.wni.closure == &model->vol.rwi ); XP_ASSERT( model->vol.wni.closure == &model->vol.rwi );
model->vol.rwi.stream = stream; model->vol.rwi.stream = stream;
model->vol.rwi.nWordsP = nWords;
model->vol.rwi.nWords = 0; model->vol.rwi.nWords = 0;
return &model->vol.wni; return &model->vol.wni;
} }
@ -2077,7 +2073,7 @@ model_getWordsPlayed( ModelCtxt* model, XP_U16 nTurns, XWStreamCtxt* stream )
} }
if ( model_undoLatestMoves( model, NULL, nTurns, NULL, NULL ) ) { if ( model_undoLatestMoves( model, NULL, nTurns, NULL, NULL ) ) {
WordNotifierInfo* ni = model_initWordCounter( model, stream, NULL ); WordNotifierInfo* ni = model_initWordCounter( model, stream );
/* Now push the undone moves back into the model one at a time. /* Now push the undone moves back into the model one at a time.
recordWord() will add each played word to the stream as it's recordWord() will add each played word to the stream as it's
scored */ scored */

View file

@ -272,8 +272,7 @@ XP_U16 figureMoveScore( const ModelCtxt* model, XP_U16 turn, MoveInfo* mvInfo,
WordNotifierInfo* notifyInfo ); WordNotifierInfo* notifyInfo );
/* tap into internal WordNotifierInfo */ /* tap into internal WordNotifierInfo */
WordNotifierInfo* model_initWordCounter( ModelCtxt* model, XWStreamCtxt* stream, WordNotifierInfo* model_initWordCounter( ModelCtxt* model, XWStreamCtxt* stream );
XP_U16* nWords );
/********************* persistence ********************/ /********************* persistence ********************/
#ifdef INCLUDE_IO_SUPPORT #ifdef INCLUDE_IO_SUPPORT

View file

@ -45,7 +45,6 @@ typedef struct PlayerCtxt {
typedef struct _RecordWordsInfo { typedef struct _RecordWordsInfo {
XWStreamCtxt* stream; XWStreamCtxt* stream;
XP_U16* nWordsP;
XP_U16 nWords; XP_U16 nWords;
} RecordWordsInfo; } RecordWordsInfo;

View file

@ -93,7 +93,6 @@ typedef struct ServerNonvolatiles {
RemoteAddress addresses[MAX_NUM_PLAYERS]; RemoteAddress addresses[MAX_NUM_PLAYERS];
XWStreamCtxt* prevMoveStream; /* save it to print later */ XWStreamCtxt* prevMoveStream; /* save it to print later */
XWStreamCtxt* prevWordsStream; XWStreamCtxt* prevWordsStream;
XP_U16 prevWordCount;
} ServerNonvolatiles; } ServerNonvolatiles;
struct ServerCtxt { struct ServerCtxt {
@ -758,8 +757,7 @@ makeRobotMove( ServerCtxt* server )
if ( !!stream ) { if ( !!stream ) {
XWStreamCtxt* wordsStream = mkServerStream( server ); XWStreamCtxt* wordsStream = mkServerStream( server );
WordNotifierInfo* ni = WordNotifierInfo* ni =
model_initWordCounter( model, wordsStream, model_initWordCounter( model, wordsStream );
&server->nv.prevWordCount );
(void)model_checkMoveLegal( model, turn, stream, ni ); (void)model_checkMoveLegal( model, turn, stream, ni );
XP_ASSERT( !server->nv.prevMoveStream ); XP_ASSERT( !server->nv.prevMoveStream );
server->nv.prevMoveStream = stream; server->nv.prevMoveStream = stream;
@ -870,8 +868,7 @@ showPrevScore( ServerCtxt* server )
stream_destroy( prevStream ); stream_destroy( prevStream );
} }
util_informMove( util, stream, server->nv.prevWordsStream, util_informMove( util, stream, server->nv.prevWordsStream );
server->nv.prevWordCount );
stream_destroy( stream ); stream_destroy( stream );
stream_destroy( server->nv.prevWordsStream ); stream_destroy( server->nv.prevWordsStream );
server->nv.prevWordsStream = NULL; server->nv.prevWordsStream = NULL;
@ -1885,9 +1882,7 @@ makeMoveReportIf( ServerCtxt* server, XWStreamCtxt** wordsStream )
ModelCtxt* model = server->vol.model; ModelCtxt* model = server->vol.model;
stream = mkServerStream( server ); stream = mkServerStream( server );
*wordsStream = mkServerStream( server ); *wordsStream = mkServerStream( server );
WordNotifierInfo* ni = WordNotifierInfo* ni = model_initWordCounter( model, *wordsStream );
model_initWordCounter( model, *wordsStream,
&server->nv.prevWordCount );
(void)model_checkMoveLegal( model, server->nv.currentTurn, stream, ni ); (void)model_checkMoveLegal( model, server->nv.currentTurn, stream, ni );
} }
return stream; return stream;

View file

@ -1,6 +1,6 @@
/* -*- compile-command: "cd ../linux && make MEMDEBUG=TRUE"; -*- */ /* -*- compile-command: "cd ../linux && make MEMDEBUG=TRUE -j3"; -*- */
/* /*
* Copyright 1997 - 2009 by Eric House (xwords@eehouse.org). All rights * Copyright 1997 - 2011 by Eric House (xwords@eehouse.org). All rights
* reserved. * reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -29,7 +29,9 @@ extern "C" {
#endif #endif
/****************************** prototypes ******************************/ /****************************** prototypes ******************************/
static void drawPendingScore( BoardCtxt* board, XP_Bool hasCursor ); static void drawPendingScore( BoardCtxt* board, XP_S16 turnScore,
XP_Bool hasCursor );
static XP_S16 figurePendingScore( const BoardCtxt* board );
static XP_U16 countTilesToShow( BoardCtxt* board ); static XP_U16 countTilesToShow( BoardCtxt* board );
static void figureDividerRect( BoardCtxt* board, XP_Rect* rect ); static void figureDividerRect( BoardCtxt* board, XP_Rect* rect );
@ -130,8 +132,10 @@ drawTray( BoardCtxt* board )
const XP_S16 turn = board->selPlayer; const XP_S16 turn = board->selPlayer;
PerTurnInfo* pti = board->selInfo; PerTurnInfo* pti = board->selInfo;
XP_S16 turnScore = figurePendingScore( board );
if ( draw_trayBegin( board->draw, &board->trayBounds, turn, if ( draw_trayBegin( board->draw, &board->trayBounds, turn,
dfsFor( board, OBJ_TRAY ) ) ) { turnScore, dfsFor( board, OBJ_TRAY ) ) ) {
DictionaryCtxt* dictionary = model_getDictionary( board->model ); DictionaryCtxt* dictionary = model_getDictionary( board->model );
XP_S16 cursorBits = 0; XP_S16 cursorBits = 0;
XP_Bool cursorOnDivider = XP_FALSE; XP_Bool cursorOnDivider = XP_FALSE;
@ -242,8 +246,7 @@ drawTray( BoardCtxt* board )
draw_drawTrayDivider( board->draw, &divider, flags ); draw_drawTrayDivider( board->draw, &divider, flags );
board->dividerInvalid = XP_FALSE; board->dividerInvalid = XP_FALSE;
} }
drawPendingScore( board, turnScore,
drawPendingScore( board,
(cursorBits & (1<<(MAX_TRAY_TILES-1))) != 0); (cursorBits & (1<<(MAX_TRAY_TILES-1))) != 0);
} }
@ -304,19 +307,25 @@ countTilesToShow( BoardCtxt* board )
return numToShow; return numToShow;
} /* countTilesToShow */ } /* countTilesToShow */
static XP_S16
figurePendingScore( const BoardCtxt* board )
{
XP_S16 turnScore;
(void)getCurrentMoveScoreIfLegal( board->model, board->selPlayer,
(XWStreamCtxt*)NULL,
(WordNotifierInfo*)NULL,
&turnScore );
return turnScore;
}
static void static void
drawPendingScore( BoardCtxt* board, XP_Bool hasCursor ) drawPendingScore( BoardCtxt* board, XP_S16 turnScore, XP_Bool hasCursor )
{ {
/* Draw the pending score down in the last tray's rect */ /* Draw the pending score down in the last tray's rect */
if ( countTilesToShow( board ) < MAX_TRAY_TILES ) { if ( countTilesToShow( board ) < MAX_TRAY_TILES ) {
XP_U16 selPlayer = board->selPlayer; XP_U16 selPlayer = board->selPlayer;
XP_S16 turnScore = 0;
XP_Rect lastTileR; XP_Rect lastTileR;
(void)getCurrentMoveScoreIfLegal( board->model, selPlayer,
(XWStreamCtxt*)NULL,
(WordNotifierInfo*)NULL,
&turnScore );
figureTrayTileRect( board, MAX_TRAY_TILES-1, &lastTileR ); figureTrayTileRect( board, MAX_TRAY_TILES-1, &lastTileR );
draw_score_pendingScore( board->draw, &lastTileR, turnScore, draw_score_pendingScore( board->draw, &lastTileR, turnScore,
selPlayer, selPlayer,

View file

@ -131,7 +131,7 @@ typedef struct UtilVtable {
void (*m_util_turnChanged)(XW_UtilCtxt* uc); void (*m_util_turnChanged)(XW_UtilCtxt* uc);
#endif #endif
void (*m_util_informMove)( XW_UtilCtxt* uc, XWStreamCtxt* expl, void (*m_util_informMove)( XW_UtilCtxt* uc, XWStreamCtxt* expl,
XWStreamCtxt* words, XP_U16 wordCount ); XWStreamCtxt* words );
void (*m_util_notifyGameOver)( XW_UtilCtxt* uc ); void (*m_util_notifyGameOver)( XW_UtilCtxt* uc );
XP_Bool (*m_util_hiliteCell)( XW_UtilCtxt* uc, XP_U16 col, XP_U16 row ); XP_Bool (*m_util_hiliteCell)( XW_UtilCtxt* uc, XP_U16 col, XP_U16 row );
@ -228,8 +228,8 @@ struct XW_UtilCtxt {
# define util_turnChanged( uc ) # define util_turnChanged( uc )
#endif #endif
#define util_informMove(uc,e,w,wc) \ #define util_informMove(uc,e,w) \
(uc)->vtable->m_util_informMove( (uc),(e),(w),(wc) ) (uc)->vtable->m_util_informMove( (uc),(e),(w))
#define util_notifyGameOver( uc ) \ #define util_notifyGameOver( uc ) \
(uc)->vtable->m_util_notifyGameOver((uc)) (uc)->vtable->m_util_notifyGameOver((uc))

View file

@ -1,6 +1,6 @@
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; compile-command: "make MEMDEBUG=TRUE"; -*- */ /* -*- compile-command: "make MEMDEBUG=TRUE -j3"; -*- */
/* /*
* Copyright 1997-2008 by Eric House (xwords@eehouse.org). All rights * Copyright 1997-2011 by Eric House (xwords@eehouse.org). All rights
* reserved. * reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -91,6 +91,7 @@ static XP_Bool
curses_draw_trayBegin( DrawCtx* XP_UNUSED(p_dctx), curses_draw_trayBegin( DrawCtx* XP_UNUSED(p_dctx),
const XP_Rect* XP_UNUSED(rect), const XP_Rect* XP_UNUSED(rect),
XP_U16 XP_UNUSED(owner), XP_U16 XP_UNUSED(owner),
XP_S16 XP_UNUSED(score),
DrawFocusState XP_UNUSED(dfs) ) DrawFocusState XP_UNUSED(dfs) )
{ {
return XP_TRUE; return XP_TRUE;

View file

@ -334,8 +334,7 @@ cursesShowFinalScores( CursesAppGlobals* globals )
static void static void
curses_util_informMove( XW_UtilCtxt* uc, XWStreamCtxt* expl, curses_util_informMove( XW_UtilCtxt* uc, XWStreamCtxt* expl,
XWStreamCtxt* XP_UNUSED(words), XWStreamCtxt* XP_UNUSED(words))
XP_U16 XP_UNUSED(wordCount) )
{ {
CursesAppGlobals* globals = (CursesAppGlobals*)uc->closure; CursesAppGlobals* globals = (CursesAppGlobals*)uc->closure;
char* question = strFromStream( expl ); char* question = strFromStream( expl );

View file

@ -1,6 +1,6 @@
/* -*- mode: C; fill-column: 78; c-basic-offset: 4; compile-command: "make MEMDEBUG=TRUE"; -*- */ /* -*- compile-command: "make MEMDEBUG=TRUE -j3"; -*- */
/* /*
* Copyright 1997-2008 by Eric House (xwords@eehouse.org). All rights * Copyright 1997-2011 by Eric House (xwords@eehouse.org). All rights
* reserved. * reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -634,7 +634,8 @@ gtk_draw_invertCell( DrawCtx* XP_UNUSED(p_dctx),
static XP_Bool static XP_Bool
gtk_draw_trayBegin( DrawCtx* p_dctx, const XP_Rect* XP_UNUSED(rect), gtk_draw_trayBegin( DrawCtx* p_dctx, const XP_Rect* XP_UNUSED(rect),
XP_U16 owner, DrawFocusState XP_UNUSED(dfs) ) XP_U16 owner, XP_S16 XP_UNUSED(owner),
DrawFocusState XP_UNUSED(dfs) )
{ {
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx; GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
dctx->trayOwner = owner; dctx->trayOwner = owner;
@ -729,7 +730,7 @@ gtk_draw_drawTileMidDrag( DrawCtx* p_dctx, const XP_Rect* rect,
const XP_UCHAR* textP, const XP_Bitmaps* bitmaps, const XP_UCHAR* textP, const XP_Bitmaps* bitmaps,
XP_U16 val, XP_U16 owner, CellFlags flags ) XP_U16 val, XP_U16 owner, CellFlags flags )
{ {
gtk_draw_trayBegin( p_dctx, rect, owner, DFS_NONE ); gtk_draw_trayBegin( p_dctx, rect, owner, 0, DFS_NONE );
gtkDrawTileImpl( p_dctx, rect, textP, bitmaps, val, gtkDrawTileImpl( p_dctx, rect, textP, bitmaps, val,
flags | CELL_HIGHLIGHT, XP_FALSE ); flags | CELL_HIGHLIGHT, XP_FALSE );
} }

View file

@ -1388,9 +1388,8 @@ gtkShowFinalScores( const CommonGlobals* cGlobals )
static void static void
gtk_util_informMove( XW_UtilCtxt* XP_UNUSED(uc), XWStreamCtxt* XP_UNUSED(expl), gtk_util_informMove( XW_UtilCtxt* XP_UNUSED(uc), XWStreamCtxt* XP_UNUSED(expl),
XWStreamCtxt* words, XP_U16 wordCount ) XWStreamCtxt* words )
{ {
XP_LOGF( "%s(wordCount=%d)", __func__, wordCount );
char* question = strFromStream( words/*expl*/ ); char* question = strFromStream( words/*expl*/ );
(void)gtkask( question, GTK_BUTTONS_OK ); (void)gtkask( question, GTK_BUTTONS_OK );
free( question ); free( question );