Merge branch 'android_branch' into send_in_background

This commit is contained in:
eehouse@eehouse.org 2011-12-02 19:04:12 -08:00 committed by Andy2
commit e1e8516e1b
14 changed files with 58 additions and 39 deletions

View file

@ -232,11 +232,12 @@ and_draw_boardBegin( DrawCtx* dctx, const XP_Rect* rect,
static XP_Bool static XP_Bool
and_draw_drawCell( DrawCtx* dctx, const XP_Rect* rect, const XP_UCHAR* text, and_draw_drawCell( DrawCtx* dctx, const XP_Rect* rect, const XP_UCHAR* text,
const XP_Bitmaps* bitmaps, Tile tile, XP_S16 owner, const XP_Bitmaps* bitmaps, Tile tile, XP_U16 value,
XWBonusType bonus, HintAtts hintAtts, CellFlags flags ) XP_S16 owner, XWBonusType bonus, HintAtts hintAtts,
CellFlags flags )
{ {
DRAW_CBK_HEADER("drawCell", DRAW_CBK_HEADER("drawCell",
"(Landroid/graphics/Rect;Ljava/lang/String;IIIII)Z" ); "(Landroid/graphics/Rect;Ljava/lang/String;IIIIII)Z" );
jobject jrect = makeJRect( draw, JCACHE_RECT0, rect ); jobject jrect = makeJRect( draw, JCACHE_RECT0, rect );
jstring jtext = NULL; jstring jtext = NULL;
if ( !!text ) { if ( !!text ) {
@ -247,7 +248,7 @@ and_draw_drawCell( DrawCtx* dctx, const XP_Rect* rect, const XP_UCHAR* text,
} }
jboolean result = (*env)->CallBooleanMethod( env, draw->jdraw, mid, jboolean result = (*env)->CallBooleanMethod( env, draw->jdraw, mid,
jrect, jtext, tile, jrect, jtext, tile, value,
owner, bonus, hintAtts, owner, bonus, hintAtts,
flags ); flags );
if ( !!jtext ) { if ( !!jtext ) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View file

@ -60,6 +60,10 @@
style="@style/toolbar_button" style="@style/toolbar_button"
android:src="@drawable/zoom" android:src="@drawable/zoom"
/> />
<ImageButton android:id="@+id/values_button_horizontal"
style="@style/toolbar_button"
android:src="@drawable/values"
/>
<ImageButton android:id="@+id/undo_button_horizontal" <ImageButton android:id="@+id/undo_button_horizontal"
style="@style/toolbar_button" style="@style/toolbar_button"
android:src="@drawable/undo" android:src="@drawable/undo"

View file

@ -23,11 +23,6 @@
android:alphabeticShortcut="H" android:alphabeticShortcut="H"
/> />
<item android:id="@+id/board_menu_values"
android:title="@string/board_menu_values"
android:alphabeticShortcut="V"
/>
<item android:title="@string/board_submenu_game"> <item android:title="@string/board_submenu_game">
<menu> <menu>
<item android:id="@+id/board_menu_game_counts" <item android:id="@+id/board_menu_game_counts"

View file

@ -76,6 +76,7 @@
<string name="key_notagain_trading">key_notagain_trading</string> <string name="key_notagain_trading">key_notagain_trading</string>
<string name="key_na_lookup">key_na_lookup</string> <string name="key_na_lookup">key_na_lookup</string>
<string name="key_na_browse">key_na_browse</string> <string name="key_na_browse">key_na_browse</string>
<string name="key_na_values">key_na_values</string>
<!-- Name is not localized --> <!-- Name is not localized -->
<string name="app_name">Crosswords</string> <string name="app_name">Crosswords</string>

View file

@ -658,12 +658,6 @@
games.--> games.-->
<string name="board_menu_undo_last">Undo last</string> <string name="board_menu_undo_last">Undo last</string>
<!-- Toggles the board between displaying tiles' letters and their
values. This is intended to allow players to remind
themselves how much played tiles are worth while planning a
move. -->
<string name="board_menu_values">Show values</string>
<!-- Title of submenu --> <!-- Title of submenu -->
<string name="board_submenu_game">Game</string> <string name="board_submenu_game">Game</string>
@ -1622,8 +1616,13 @@
<string name="not_again_chat">This button opens the screen for <string name="not_again_chat">This button opens the screen for
messaging between devices in this game. Messages will be kept messaging between devices in this game. Messages will be kept
until you delete the game that contains them.</string> until you delete the game that contains them.</string>
<!-- Shown when you tap the values button on the toolbar of the
main Board screen. This is intended to allow players to
remind themselves how much played tiles are worth while
planning a move. -->
<string name="not_again_values">This button changes whether the
board shows letters on placed tiles or their point values.
Use it to remind yourself what a tile is worth.</string>
<!-- This is shown when you choose the board_menu_done menu item. <!-- This is shown when you choose the board_menu_done menu item.
It's to let you know that there's a shortcut that does almost It's to let you know that there's a shortcut that does almost
the same thing. --> the same thing. -->

View file

@ -93,6 +93,7 @@ public class BoardActivity extends XWActivity
private static final int START_TRADE_ACTION = 13; private static final int START_TRADE_ACTION = 13;
private static final int LOOKUP_ACTION = 14; private static final int LOOKUP_ACTION = 14;
private static final int BUTTON_BROWSE_ACTION = 15; private static final int BUTTON_BROWSE_ACTION = 15;
private static final int VALUES_ACTION = 16;
private static final String DLG_TITLE = "DLG_TITLE"; private static final String DLG_TITLE = "DLG_TITLE";
private static final String DLG_TITLESTR = "DLG_TITLESTR"; private static final String DLG_TITLESTR = "DLG_TITLESTR";
@ -610,9 +611,6 @@ public class BoardActivity extends XWActivity
case R.id.board_menu_undo_last: case R.id.board_menu_undo_last:
showConfirmThen( R.string.confirm_undo_last, UNDO_LAST_ACTION ); showConfirmThen( R.string.confirm_undo_last, UNDO_LAST_ACTION );
break; break;
case R.id.board_menu_values:
cmd = JNIThread.JNICmd.CMD_VALUES;
break;
case R.id.board_menu_game_counts: case R.id.board_menu_game_counts:
m_jniThread.handle( JNIThread.JNICmd.CMD_COUNTS_VALUES, m_jniThread.handle( JNIThread.JNICmd.CMD_COUNTS_VALUES,
R.string.counts_values_title ); R.string.counts_values_title );
@ -715,6 +713,9 @@ public class BoardActivity extends XWActivity
case UNDO_ACTION: case UNDO_ACTION:
cmd = JNIThread.JNICmd.CMD_UNDO_CUR; cmd = JNIThread.JNICmd.CMD_UNDO_CUR;
break; break;
case VALUES_ACTION:
cmd = JNIThread.JNICmd.CMD_VALUES;
break;
case CHAT_ACTION: case CHAT_ACTION:
startChatActivity(); startChatActivity();
break; break;
@ -1440,6 +1441,10 @@ public class BoardActivity extends XWActivity
R.string.not_again_zoom, R.string.not_again_zoom,
R.string.key_notagain_zoom, R.string.key_notagain_zoom,
ZOOM_ACTION ); ZOOM_ACTION );
m_toolbar.setListener( Toolbar.BUTTON_VALUES,
R.string.not_again_values,
R.string.key_na_values,
VALUES_ACTION );
m_toolbar.setListener( Toolbar.BUTTON_UNDO, m_toolbar.setListener( Toolbar.BUTTON_UNDO,
R.string.not_again_undo, R.string.not_again_undo,
R.string.key_notagain_undo, R.string.key_notagain_undo,
@ -1568,7 +1573,8 @@ public class BoardActivity extends XWActivity
private void updateToolbar() private void updateToolbar()
{ {
m_toolbar.update( Toolbar.BUTTON_FLIP, m_gsi.visTileCount > 1 ); m_toolbar.update( Toolbar.BUTTON_FLIP, m_gsi.visTileCount >= 1 );
m_toolbar.update( Toolbar.BUTTON_VALUES, m_gsi.visTileCount >= 1 );
m_toolbar.update( Toolbar.BUTTON_JUGGLE, m_gsi.canShuffle ); m_toolbar.update( Toolbar.BUTTON_JUGGLE, m_gsi.canShuffle );
m_toolbar.update( Toolbar.BUTTON_UNDO, m_gsi.canRedo ); m_toolbar.update( Toolbar.BUTTON_UNDO, m_gsi.canRedo );
m_toolbar.update( Toolbar.BUTTON_HINT_PREV, m_gsi.canHint ); m_toolbar.update( Toolbar.BUTTON_HINT_PREV, m_gsi.canHint );

View file

@ -529,8 +529,9 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
return true; return true;
} }
public boolean drawCell( final Rect rect, String text, int tile, int owner, public boolean drawCell( final Rect rect, String text, int tile, int value,
int bonus, int hintAtts, final int flags ) int owner, int bonus, int hintAtts,
final int flags )
{ {
boolean canDraw = figureFontDims(); boolean canDraw = figureFontDims();
if ( canDraw ) { if ( canDraw ) {
@ -819,7 +820,8 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
if ( val >= 0 ) { if ( val >= 0 ) {
if ( null == m_valRect ) { if ( null == m_valRect ) {
m_valRect = new Rect( 0, 0, rect.width() / 4, rect.height() / 4 ); m_valRect = new Rect( 0, 0, rect.width() / 4,
rect.height() / 4 );
m_valRect.inset( 2, 2 ); m_valRect.inset( 2, 2 );
} }
m_valRect.offsetTo( rect.right - (rect.width() / 4), m_valRect.offsetTo( rect.right - (rect.width() / 4),

View file

@ -47,6 +47,7 @@ public class Toolbar {
public static final int BUTTON_ZOOM = 5; public static final int BUTTON_ZOOM = 5;
public static final int BUTTON_UNDO = 6; public static final int BUTTON_UNDO = 6;
public static final int BUTTON_CHAT = 7; public static final int BUTTON_CHAT = 7;
public static final int BUTTON_VALUES = 8;
private static TBButtonInfo[] s_buttonInfo = { private static TBButtonInfo[] s_buttonInfo = {
// BUTTON_BROWSE_DICT // BUTTON_BROWSE_DICT
@ -65,6 +66,8 @@ public class Toolbar {
new TBButtonInfo( R.id.undo_button_horizontal ), new TBButtonInfo( R.id.undo_button_horizontal ),
// BUTTON_CHAT // BUTTON_CHAT
new TBButtonInfo( R.id.chat_button_horizontal ), new TBButtonInfo( R.id.chat_button_horizontal ),
// BUTTON_VALUES
new TBButtonInfo( R.id.values_button_horizontal ),
}; };
private XWActivity m_activity; private XWActivity m_activity;

View file

@ -51,7 +51,7 @@ public interface DrawCtx {
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 );
boolean drawCell( Rect rect, String text, int tile, boolean drawCell( Rect rect, String text, int tile, int value,
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 );

View file

@ -397,6 +397,7 @@ drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks )
HintAtts hintAtts; HintAtts hintAtts;
CellFlags flags = CELL_NONE; CellFlags flags = CELL_NONE;
XP_Bool isOrigin; XP_Bool isOrigin;
XP_U16 value = 0;
isEmpty = !model_getTile( model, modelCol, modelRow, showPending, isEmpty = !model_getTile( model, modelCol, modelRow, showPending,
selPlayer, &tile, &isBlank, selPlayer, &tile, &isBlank,
@ -416,6 +417,9 @@ drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks )
} else if ( isBlank && skipBlanks ) { } else if ( isBlank && skipBlanks ) {
break; break;
} else { } else {
Tile valTile = isBlank? dict_getBlankTile( dict ) : tile;
value = dict_getTileValue( dict, valTile );
if ( board->showColors ) { if ( board->showColors ) {
owner = (XP_S16)model_getCellOwner( model, modelCol, owner = (XP_S16)model_getCellOwner( model, modelCol,
modelRow ); modelRow );
@ -424,9 +428,7 @@ drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks )
invert = showPending? pending : recent; invert = showPending? pending : recent;
if ( board->showCellValues ) { if ( board->showCellValues ) {
Tile valTile = isBlank? dict_getBlankTile( dict ) : tile; XP_SNPRINTF( ch, VSIZE(ch), "%d", value );
XP_U16 val = dict_getTileValue( dict, valTile );
XP_SNPRINTF( ch, VSIZE(ch), "%d", val );
textP = ch; textP = ch;
} else { } else {
if ( dict_faceIsBitmap( dict, tile ) ) { if ( dict_faceIsBitmap( dict, tile ) ) {
@ -458,7 +460,8 @@ drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks )
#endif #endif
success = draw_drawCell( board->draw, &cellRect, textP, bptr, success = draw_drawCell( board->draw, &cellRect, textP, bptr,
tile, owner, bonus, hintAtts, flags ); tile, value, owner, bonus, hintAtts,
flags );
break; break;
} }
} }

View file

@ -165,7 +165,7 @@ typedef struct DrawCtxVTable {
null */ null */
const XP_UCHAR* text, const XP_UCHAR* text,
const XP_Bitmaps* bitmaps, const XP_Bitmaps* bitmaps,
Tile tile, Tile tile, XP_U16 value,
XP_S16 owner, /* -1 means don't use */ XP_S16 owner, /* -1 means don't use */
XWBonusType bonus, HintAtts hintAtts, XWBonusType bonus, HintAtts hintAtts,
CellFlags flags ); CellFlags flags );
@ -229,6 +229,8 @@ struct DrawCtx {
linked##_draw_##name(dc,(p1),(p2),(p3),(p4),(p5),(p6)) linked##_draw_##name(dc,(p1),(p2),(p3),(p4),(p5),(p6))
# define CALL_DRAW_NAME8(name,dc,p1,p2,p3,p4,p5,p6,p7,p8) \ # define CALL_DRAW_NAME8(name,dc,p1,p2,p3,p4,p5,p6,p7,p8) \
linked##_draw_##name(dc,(p1),(p2),(p3),(p4),(p5),(p6),(p7),(p8)) linked##_draw_##name(dc,(p1),(p2),(p3),(p4),(p5),(p6),(p7),(p8))
# define CALL_DRAW_NAME9(name,dc,p1,p2,p3,p4,p5,p6,p7,p8,p9) \
linked##_draw_##name(dc,(p1),(p2),(p3),(p4),(p5),(p6),(p7),(p8),(p9))
# define CALL_DRAW_NAME10(name,dc,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) \ # define CALL_DRAW_NAME10(name,dc,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) \
linked##_draw_##name(dc,(p1),(p2),(p3),(p4),(p5),(p6),(p7),\ linked##_draw_##name(dc,(p1),(p2),(p3),(p4),(p5),(p6),(p7),\
(p8),(p9),(p10)) (p8),(p9),(p10))
@ -246,8 +248,11 @@ struct DrawCtx {
# define CALL_DRAW_NAME6(name,dc,p1,p2,p3,p4,p5,p6) \ # define CALL_DRAW_NAME6(name,dc,p1,p2,p3,p4,p5,p6) \
((dc)->vtable->m_draw_##name)(dc,(p1),(p2),(p3),(p4),(p5),(p6)) ((dc)->vtable->m_draw_##name)(dc,(p1),(p2),(p3),(p4),(p5),(p6))
# define CALL_DRAW_NAME8(name,dc,p1,p2,p3,p4,p5,p6,p7,p8) \ # define CALL_DRAW_NAME8(name,dc,p1,p2,p3,p4,p5,p6,p7,p8) \
((dc)->vtable->m_draw_##name)(dc,(p1),(p2),(p3),(p4),(p5),(p6),(p7),\ ((dc)->vtable->m_draw_##name)(dc,(p1),(p2),(p3),(p4),(p5),(p6),(p7), \
(p8)) (p8))
# define CALL_DRAW_NAME9(name,dc,p1,p2,p3,p4,p5,p6,p7,p8,p9) \
((dc)->vtable->m_draw_##name)(dc,(p1),(p2),(p3),(p4),(p5),(p6),(p7), \
(p8),(p9))
# define CALL_DRAW_NAME10(name,dc,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) \ # define CALL_DRAW_NAME10(name,dc,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) \
((dc)->vtable->m_draw_##name)(dc,(p1),(p2),(p3),(p4),(p5),(p6),(p7),\ ((dc)->vtable->m_draw_##name)(dc,(p1),(p2),(p3),(p4),(p5),(p6),(p7),\
(p8),(p9),(p10)) (p8),(p9),(p10))
@ -277,8 +282,8 @@ struct DrawCtx {
CALL_DRAW_NAME4(score_pendingScore,(dc), (r), (s), (p), (f)) CALL_DRAW_NAME4(score_pendingScore,(dc), (r), (s), (p), (f))
#define draw_drawTimer( dc, r, plyr, sec ) \ #define draw_drawTimer( dc, r, plyr, sec ) \
CALL_DRAW_NAME3(drawTimer,(dc),(r),(plyr),(sec)) CALL_DRAW_NAME3(drawTimer,(dc),(r),(plyr),(sec))
#define draw_drawCell( dc, rect, txt, bmap, t, o, bon, hi, f ) \ #define draw_drawCell( dc, rect, txt, bmap, t, v,o, bon, hi, f ) \
CALL_DRAW_NAME8(drawCell,(dc),(rect),(txt),(bmap),(t),(o),(bon),(hi),\ CALL_DRAW_NAME9(drawCell,(dc),(rect),(txt),(bmap),(t),(v),(o),(bon),(hi), \
(f)) (f))
#define draw_invertCell( dc, rect ) CALL_DRAW_NAME1(invertCell,(dc),(rect)) #define draw_invertCell( dc, rect ) CALL_DRAW_NAME1(invertCell,(dc),(rect))
#define draw_drawTile( dc, rect, text, bmp, val, hil ) \ #define draw_drawTile( dc, rect, text, bmp, val, hil ) \

View file

@ -298,9 +298,9 @@ static XP_Bool
curses_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, curses_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect,
const XP_UCHAR* letter, const XP_UCHAR* letter,
const XP_Bitmaps* XP_UNUSED(bitmaps), const XP_Bitmaps* XP_UNUSED(bitmaps),
Tile XP_UNUSED(tile), XP_S16 XP_UNUSED(owner), Tile XP_UNUSED(tile), XP_U16 XP_UNUSED(value),
XWBonusType bonus, HintAtts XP_UNUSED(hintAtts), XP_S16 XP_UNUSED(owner), XWBonusType bonus,
CellFlags flags ) HintAtts XP_UNUSED(hintAtts), CellFlags flags )
{ {
CursesDrawCtx* dctx = (CursesDrawCtx*)p_dctx; CursesDrawCtx* dctx = (CursesDrawCtx*)p_dctx;
XP_Bool highlight = (flags & (CELL_HIGHLIGHT|CELL_ISCURSOR)) != 0; XP_Bool highlight = (flags & (CELL_HIGHLIGHT|CELL_ISCURSOR)) != 0;

View file

@ -506,8 +506,8 @@ drawCrosshairs( GtkDrawCtx* dctx, const XP_Rect* rect, CellFlags flags )
static XP_Bool static XP_Bool
gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter, gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter,
const XP_Bitmaps* bitmaps, Tile XP_UNUSED(tile), const XP_Bitmaps* bitmaps, Tile XP_UNUSED(tile),
XP_S16 owner, XWBonusType bonus, HintAtts hintAtts, XP_U16 XP_UNUSED(value), XP_S16 owner, XWBonusType bonus,
CellFlags flags ) HintAtts hintAtts, CellFlags flags )
{ {
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx; GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
XP_Rect rectInset = *rect; XP_Rect rectInset = *rect;