complete implementation of java part of one-pass scoreboard draw. Now

looks pretty much identical to what the old code draws except that
rather than having width allocated in proportion to requested size all
get the same width except the one whose score it is which gets 2x.
This commit is contained in:
Eric House 2012-07-01 17:24:50 -07:00
parent c41c877ae7
commit 2e6b64a4e4
2 changed files with 62 additions and 15 deletions

View file

@ -505,11 +505,13 @@ and_draw_objFinished( DrawCtx* dctx, BoardObjectType typ,
const XP_Rect* rect, const XP_Rect* rect,
DrawFocusState XP_UNUSED(dfs) ) DrawFocusState XP_UNUSED(dfs) )
{ {
#ifndef XWFEATURE_SCOREONEPASS
DRAW_CBK_HEADER( "objFinished", "(ILandroid/graphics/Rect;)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)typ, jrect );
#endif
} }
static void static void

View file

@ -471,8 +471,8 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
int remCount ) 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 );
m_canvas.clipRect(rect); // m_canvas.clipRect(rect);
m_scores = new String[numPlayers][]; m_scores = new String[numPlayers][];
return true; return true;
} }
@ -609,30 +609,75 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
// } // }
// rect.right = rect.left + width; // rect.right = rect.left + width;
// // rect.bottom = rect.top + height;
// if ( 0 < nTilesLeft ) { // if ( 0 < nTilesLeft ) {
// Rect drawRect = new Rect( rect );
// if ( height < drawRect.height() ) {
// drawRect.inset( 0, (drawRect.height() - height) / 2 );
// }
// int indx = focussed ? CommonPrefs.COLOR_FOCUS // int indx = focussed ? CommonPrefs.COLOR_FOCUS
// : CommonPrefs.COLOR_TILE_BACK; // : CommonPrefs.COLOR_TILE_BACK;
// fillRectOther( rect, indx ); // fillRectOther( rect, indx );
// m_fillPaint.setColor( adjustColor(BLACK) ); // m_fillPaint.setColor( adjustColor(BLACK) );
// drawCentered( remText, rect, null ); // drawCentered( remText, drawRect, null );
// } // }
// } // }
// public void score_drawPlayers( Rect scoreRect, DrawScoreInfo[] playerData, // public void score_drawPlayers( Rect scoreRect, DrawScoreInfo[] playerData,
// Rect[] playerRects ) // Rect[] playerRects )
// { // {
// // To measure // Rect tmp = new Rect();
// int nPlayers = playerRects.length;
// int width = scoreRect.width() / playerRects.length; // int width = scoreRect.width() / (nPlayers + 1);
// int left = scoreRect.left; // int left = scoreRect.left;
// for ( int ii = 0; ii < playerRects.length; ++ii ) { // int right;
// playerRects[ii].set( left, scoreRect.top, left + width, // StringBuffer sb = new StringBuffer();
// scoreRect.bottom ); // String[] scoreStrings = new String[2];
// drawCentered( playerData[ii].name, playerRects[ii], null ); // for ( int ii = 0; ii < nPlayers; ++ii ) {
// left += width; // DrawScoreInfo dsi = playerData[ii];
// boolean isTurn = dsi.isTurn;
// int indx = 0;
// sb.delete( 0, sb.length() );
// if ( isTurn ) {
// sb.append( dsi.name );
// sb.append( ":" );
// } else {
// scoreStrings[indx++] = dsi.name;
// }
// sb.append( dsi.totalScore );
// if ( dsi.nTilesLeft >= 0 ) {
// sb.append( ":" );
// sb.append( dsi.nTilesLeft );
// }
// scoreStrings[indx] = sb.toString();
// int color = m_playerColors[dsi.playerNum];
// if ( !m_prefs.allowPeek ) {
// color = adjustColor( color );
// }
// m_fillPaint.setColor( color );
// right = left + (width * (isTurn? 2 : 1) );
// playerRects[ii].set( left, scoreRect.top, right, scoreRect.bottom );
// left = right;
// tmp.set( playerRects[ii] );
// tmp.inset( 2, 2 );
// int height = tmp.height() / (isTurn? 1 : 2);
// tmp.bottom = tmp.top + height;
// for ( String str : scoreStrings ) {
// drawCentered( str, tmp, null );
// if ( isTurn ) {
// break;
// }
// tmp.offset( 0, height );
// }
// if ( DEBUG_DRAWFRAMES ) {
// m_canvas.drawRect( playerRects[ii], m_strokePaint );
// }
// } // }
// } // }
@ -835,9 +880,9 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
public void objFinished( /*BoardObjectType*/int typ, Rect rect ) 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...
} // }
} }
public void dictChanged( int dictPtr ) public void dictChanged( int dictPtr )