mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-27 09:58:45 +01:00
Turn "Turn done" into "Pass" when the pending score is 0. To do that
I had to pass the score into draw_trayBegin since draw_drawPendingScore() isn't called until the first tile's placed. Note: as long as I'm messinng with this menuitem it should be disabled when it's not the player's turn.
This commit is contained in:
parent
f4b8b2806e
commit
3ec97d5c07
9 changed files with 67 additions and 28 deletions
|
@ -281,15 +281,15 @@ and_draw_vertScrollBoard( DrawCtx* XP_UNUSED(dctx), XP_Rect* XP_UNUSED(rect),
|
|||
|
||||
static XP_Bool
|
||||
and_draw_trayBegin( DrawCtx* dctx, const XP_Rect* rect, XP_U16 owner,
|
||||
DrawFocusState dfs )
|
||||
XP_S16 score, DrawFocusState dfs )
|
||||
{
|
||||
DRAW_CBK_HEADER( "trayBegin", "(Landroid/graphics/Rect;II)Z" );
|
||||
DRAW_CBK_HEADER( "trayBegin", "(Landroid/graphics/Rect;III)Z" );
|
||||
|
||||
jobject jrect = makeJRect( draw, JCACHE_RECT0, rect );
|
||||
|
||||
jboolean result = (*env)->CallBooleanMethod( env, draw->jdraw, mid,
|
||||
jrect, owner, (jint)dfs );
|
||||
|
||||
jrect, owner, score,
|
||||
(jint)dfs );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1774,5 +1774,7 @@
|
|||
<string name="site_spinner_prompt">Pick a site</string>
|
||||
<string name="word_list_label">Tap word to search</string>
|
||||
<string name="pick_url_titlef">Look up %s at</string>
|
||||
|
||||
<string name="pass">Pass</string>
|
||||
</resources>
|
||||
|
||||
|
|
|
@ -144,6 +144,7 @@ public class BoardActivity extends XWActivity
|
|||
private JNIThread m_jniThread;
|
||||
private JNIThread.GameStateInfo m_gsi;
|
||||
private boolean m_blockingDlgPosted = false;
|
||||
private String m_doneOrigTitle = null;
|
||||
|
||||
private String m_room;
|
||||
private String m_toastStr;
|
||||
|
@ -597,12 +598,27 @@ public class BoardActivity extends XWActivity
|
|||
public boolean onPrepareOptionsMenu( Menu menu )
|
||||
{
|
||||
super.onPrepareOptionsMenu( menu );
|
||||
boolean inTrade = false;
|
||||
|
||||
if ( null != m_gsi ) {
|
||||
boolean inTrade = m_gsi.inTrade;
|
||||
inTrade = m_gsi.inTrade;
|
||||
menu.setGroupVisible( R.id.group_done, !inTrade );
|
||||
}
|
||||
|
||||
if ( !inTrade ) {
|
||||
MenuItem item = menu.findItem( R.id.board_menu_done );
|
||||
if ( null == m_doneOrigTitle ) {
|
||||
m_doneOrigTitle = item.getTitle().toString();
|
||||
}
|
||||
String title;
|
||||
if ( 0 >= m_view.curPending() ) {
|
||||
title = getString( R.string.pass );
|
||||
} else {
|
||||
title = m_doneOrigTitle;
|
||||
}
|
||||
item.setTitle( title );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -80,6 +80,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
private int m_dictPtr = 0;
|
||||
private int m_lastSecsLeft;
|
||||
private int m_lastTimerPlayer;
|
||||
private int m_pendingScore;
|
||||
private Handler m_viewHandler;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent( MotionEvent event )
|
||||
{
|
||||
int action = event.getAction();
|
||||
|
@ -336,6 +338,11 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
m_jniThread.handle( JNIThread.JNICmd.CMD_INVALALL );
|
||||
}
|
||||
|
||||
public int curPending()
|
||||
{
|
||||
return m_pendingScore;
|
||||
}
|
||||
|
||||
// DrawCtxt interface implementation
|
||||
public boolean scoreBegin( Rect rect, int numPlayers, int[] scores,
|
||||
int remCount, int dfs )
|
||||
|
@ -582,9 +589,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, int dfs )
|
||||
{
|
||||
m_trayOwner = owner;
|
||||
m_pendingScore = score;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public interface DrawCtx {
|
|||
int owner, int bonus, int hintAtts, int flags );
|
||||
void drawBoardArrow ( Rect rect, int bonus, boolean vert, int hintAtts,
|
||||
int flags );
|
||||
boolean trayBegin ( Rect rect, int owner, int dfs );
|
||||
boolean trayBegin ( Rect rect, int owner, int score, int dfs );
|
||||
void drawTile( Rect rect, String text, int val, int flags );
|
||||
void drawTileMidDrag ( Rect rect, String text, int val, int owner,
|
||||
int flags );
|
||||
|
|
|
@ -129,7 +129,7 @@ typedef struct DrawCtxVTable {
|
|||
XP_S16 dist, DrawFocusState dfs );
|
||||
|
||||
XP_Bool DRAW_VTABLE_NAME(trayBegin) ( DrawCtx* dctx, const XP_Rect* rect,
|
||||
XP_U16 owner,
|
||||
XP_U16 owner, XP_S16 score,
|
||||
DrawFocusState dfs );
|
||||
void DRAW_VTABLE_NAME(measureRemText) ( DrawCtx* dctx, const XP_Rect* r,
|
||||
XP_S16 nTilesLeft,
|
||||
|
@ -257,8 +257,10 @@ struct DrawCtx {
|
|||
#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),\
|
||||
(r),(h),(v),(f))
|
||||
#define draw_objFinished( dc, t, r, d ) CALL_DRAW_NAME3(objFinished, (dc), (t), (r), (d))
|
||||
#define draw_trayBegin( dc, r, o, f ) CALL_DRAW_NAME3(trayBegin,dc, r, o, f)
|
||||
#define draw_objFinished( dc, t, r, d ) \
|
||||
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 ) \
|
||||
CALL_DRAW_NAME3(vertScrollBoard, (dc),(r),(d),(f))
|
||||
#define draw_scoreBegin( dc, r, t, s, c, f ) \
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -29,7 +29,9 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
/****************************** 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 void figureDividerRect( BoardCtxt* board, XP_Rect* rect );
|
||||
|
||||
|
@ -130,8 +132,10 @@ drawTray( BoardCtxt* board )
|
|||
const XP_S16 turn = board->selPlayer;
|
||||
PerTurnInfo* pti = board->selInfo;
|
||||
|
||||
XP_S16 turnScore = figurePendingScore( board );
|
||||
|
||||
if ( draw_trayBegin( board->draw, &board->trayBounds, turn,
|
||||
dfsFor( board, OBJ_TRAY ) ) ) {
|
||||
turnScore, dfsFor( board, OBJ_TRAY ) ) ) {
|
||||
DictionaryCtxt* dictionary = model_getDictionary( board->model );
|
||||
XP_S16 cursorBits = 0;
|
||||
XP_Bool cursorOnDivider = XP_FALSE;
|
||||
|
@ -242,8 +246,7 @@ drawTray( BoardCtxt* board )
|
|||
draw_drawTrayDivider( board->draw, ÷r, flags );
|
||||
board->dividerInvalid = XP_FALSE;
|
||||
}
|
||||
|
||||
drawPendingScore( board,
|
||||
drawPendingScore( board, turnScore,
|
||||
(cursorBits & (1<<(MAX_TRAY_TILES-1))) != 0);
|
||||
}
|
||||
|
||||
|
@ -304,19 +307,25 @@ countTilesToShow( BoardCtxt* board )
|
|||
return numToShow;
|
||||
} /* 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
|
||||
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 */
|
||||
if ( countTilesToShow( board ) < MAX_TRAY_TILES ) {
|
||||
XP_U16 selPlayer = board->selPlayer;
|
||||
XP_S16 turnScore = 0;
|
||||
XP_Rect lastTileR;
|
||||
|
||||
(void)getCurrentMoveScoreIfLegal( board->model, selPlayer,
|
||||
(XWStreamCtxt*)NULL,
|
||||
(WordNotifierInfo*)NULL,
|
||||
&turnScore );
|
||||
figureTrayTileRect( board, MAX_TRAY_TILES-1, &lastTileR );
|
||||
draw_score_pendingScore( board->draw, &lastTileR, turnScore,
|
||||
selPlayer,
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* 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),
|
||||
const XP_Rect* XP_UNUSED(rect),
|
||||
XP_U16 XP_UNUSED(owner),
|
||||
XP_S16 XP_UNUSED(score),
|
||||
DrawFocusState XP_UNUSED(dfs) )
|
||||
{
|
||||
return XP_TRUE;
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* 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
|
||||
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;
|
||||
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,
|
||||
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,
|
||||
flags | CELL_HIGHLIGHT, XP_FALSE );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue