From 3eadd93aa6831e8f9580d3fb218fb8f04a4e8cef Mon Sep 17 00:00:00 2001 From: ehouse Date: Wed, 18 Nov 2009 13:24:56 +0000 Subject: [PATCH] Pass scores and remaining tiles count to draw_scoreBegin so can determine font size based on max length. API change. --- xwords4/common/draw.h | 8 +++++--- xwords4/common/scorebdp.c | 21 +++++++++++---------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/xwords4/common/draw.h b/xwords4/common/draw.h index af0a412ae..861f12d2c 100644 --- a/xwords4/common/draw.h +++ b/xwords4/common/draw.h @@ -135,7 +135,9 @@ typedef struct DrawCtxVTable { XP_S16 nTilesLeft, XP_Bool focussed ); void DRAW_VTABLE_NAME(scoreBegin) ( DrawCtx* dctx, const XP_Rect* rect, - XP_U16 numPlayers, DrawFocusState dfs ); + XP_U16 numPlayers, + const XP_S16* const scores, + XP_S16 remCount, DrawFocusState dfs ); void DRAW_VTABLE_NAME(measureScoreText) ( DrawCtx* dctx, const XP_Rect* r, const DrawScoreInfo* dsi, @@ -252,8 +254,8 @@ struct DrawCtx { #define draw_trayBegin( dc, r, o, f ) CALL_DRAW_NAME3(trayBegin,dc, r, o, f) #define draw_vertScrollBoard( dc, r, d, f ) \ CALL_DRAW_NAME3(vertScrollBoard, (dc),(r),(d),(f)) -#define draw_scoreBegin( dc, r, t, f ) \ - CALL_DRAW_NAME3( scoreBegin,(dc), (r), (t), (f)) +#define draw_scoreBegin( dc, r, t, s, c, f ) \ + CALL_DRAW_NAME5( scoreBegin,(dc), (r), (t), (s), (c), (f)) #define draw_measureRemText( dc, r, n, wp, hp ) \ CALL_DRAW_NAME4(measureRemText, (dc), (r), (n), (wp), (hp) ) #define draw_drawRemText( dc, ri, ro, n, f ) \ diff --git a/xwords4/common/scorebdp.c b/xwords4/common/scorebdp.c index dddd5fcb1..187ab446e 100644 --- a/xwords4/common/scorebdp.c +++ b/xwords4/common/scorebdp.c @@ -93,7 +93,18 @@ drawScoreBoard( BoardCtxt* board ) } } #endif + /* Get the scores from the model or by calculating them based on + the end-of-game state. */ + if ( board->gameOver ) { + model_figureFinalScores( model, &scores, NULL ); + } else { + for ( ii = 0; ii < nPlayers; ++ii ) { + scores.arr[ii] = model_getPlayerScore( model, ii ); + } + } + draw_scoreBegin( board->draw, &board->scoreBdBounds, nPlayers, + scores.arr, nTilesInPool, dfsFor( board, OBJ_SCORE ) ); /* Let platform decide whether the rem: string should be given any @@ -114,16 +125,6 @@ drawScoreBoard( BoardCtxt* board ) } *adjustDim -= remDim; - /* Get the scores from the model or by calculating them based on - the end-of-game state. */ - if ( board->gameOver ) { - model_figureFinalScores( model, &scores, NULL ); - } else { - for ( ii = 0; ii < nPlayers; ++ii ) { - scores.arr[ii] = model_getPlayerScore( model, ii ); - } - } - totalDim = remDim; /* Give as much room as possible to the entry for the player whose