move playerNum into dsi so can be used in formatting score

This commit is contained in:
ehouse 2005-03-15 03:27:24 +00:00
parent f280b6755d
commit 670f5d8673
3 changed files with 10 additions and 14 deletions

View file

@ -1176,6 +1176,7 @@ drawScoreBoard( BoardCtxt* board )
dp->dsi.lsc = board_ScoreCallback; dp->dsi.lsc = board_ScoreCallback;
dp->dsi.lscClosure = model; dp->dsi.lscClosure = model;
dp->dsi.playerNum = i;
dp->dsi.score = scores[i]; dp->dsi.score = scores[i];
dp->dsi.isTurn = (i == curTurn); dp->dsi.isTurn = (i == curTurn);
dp->dsi.name = emptyStringIfNull(lp->name); dp->dsi.name = emptyStringIfNull(lp->name);
@ -1232,7 +1233,7 @@ drawScoreBoard( BoardCtxt* board )
innerRect.top = scoreRect.top + innerRect.top = scoreRect.top +
((scoreRect.height - innerRect.height) / 2); ((scoreRect.height - innerRect.height) / 2);
draw_score_drawPlayer( board->draw, i, &innerRect, &scoreRect, draw_score_drawPlayer( board->draw, &innerRect, &scoreRect,
&dp->dsi ); &dp->dsi );
*adjustPt += *adjustDim; *adjustPt += *adjustDim;
} }

View file

@ -34,6 +34,7 @@ typedef struct DrawScoreInfo {
LastScoreCallback lsc; LastScoreCallback lsc;
void* lscClosure; void* lscClosure;
XP_UCHAR* name; XP_UCHAR* name;
XP_U16 playerNum;
XP_S16 score; XP_S16 score;
XP_S16 nTilesLeft; /* < 0 means don't use */ XP_S16 nTilesLeft; /* < 0 means don't use */
XP_Bool isTurn; XP_Bool isTurn;
@ -91,7 +92,6 @@ typedef struct DrawCtxVTable {
DrawScoreInfo* dsi, DrawScoreInfo* dsi,
XP_U16* width, XP_U16* height ); XP_U16* width, XP_U16* height );
void (*m_draw_score_drawPlayer)( DrawCtx* dctx, void (*m_draw_score_drawPlayer)( DrawCtx* dctx,
XP_S16 playerNum, /* -1: don't use */
XP_Rect* rInner, XP_Rect* rOuter, XP_Rect* rInner, XP_Rect* rOuter,
DrawScoreInfo* dsi ); DrawScoreInfo* dsi );
@ -175,8 +175,8 @@ struct DrawCtx {
#define draw_measureScoreText(dc,r,dsi,wp,hp) \ #define draw_measureScoreText(dc,r,dsi,wp,hp) \
(dc)->vtable->m_draw_measureScoreText((dc),(r),(dsi),(wp),(hp)) (dc)->vtable->m_draw_measureScoreText((dc),(r),(dsi),(wp),(hp))
#define draw_score_drawPlayer(dc, i, ri, ro, dsi) \ #define draw_score_drawPlayer(dc, ri, ro, dsi) \
(dc)->vtable->m_draw_score_drawPlayer((dc),(i),(ri),(ro),(dsi)) (dc)->vtable->m_draw_score_drawPlayer((dc),(ri),(ro),(dsi))
#define draw_score_pendingScore(dc, r, s, p ) \ #define draw_score_pendingScore(dc, r, s, p ) \
(dc)->vtable->m_draw_score_pendingScore((dc), (r), (s), (p)) (dc)->vtable->m_draw_score_pendingScore((dc), (r), (s), (p))

View file

@ -602,23 +602,18 @@ gtk_draw_measureScoreText( DrawCtx* p_dctx, XP_Rect* r,
} /* gtk_draw_measureScoreText */ } /* gtk_draw_measureScoreText */
static void static void
gtk_draw_score_drawPlayer( DrawCtx* p_dctx, XP_S16 playerNum, gtk_draw_score_drawPlayer( DrawCtx* p_dctx, XP_Rect* rInner, XP_Rect* rOuter,
XP_Rect* rInner, XP_Rect* rOuter, DrawScoreInfo* dsi )
DrawScoreInfo* dsi )
{ {
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx; GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
char scoreBuf[20]; char scoreBuf[20];
XP_U16 x; XP_U16 x;
GdkFont* font = /* dsi->selected? dctx->gdkBoldFont : */dctx->gdkFont; GdkFont* font = /* dsi->selected? dctx->gdkBoldFont : */dctx->gdkFont;
widthAndText( scoreBuf, font, dsi, NULL, NULL ); widthAndText( scoreBuf, font, dsi, NULL, NULL );
x = rInner->left;// + ((rect->width - width) /2); x = rInner->left;// + ((rect->width - width) /2);
gdk_gc_set_foreground( dctx->drawGC, gdk_gc_set_foreground( dctx->drawGC, &dctx->playerColors[dsi->playerNum] );
playerNum >= 0? &dctx->playerColors[playerNum]:
&dctx->black
/*selected? &dctx->red:&dctx->black*/ );
if ( dsi->selected ) { if ( dsi->selected ) {
gdk_draw_rectangle( DRAW_WHAT(dctx), dctx->drawGC, gdk_draw_rectangle( DRAW_WHAT(dctx), dctx->drawGC,
@ -633,7 +628,7 @@ gtk_draw_score_drawPlayer( DrawCtx* p_dctx, XP_S16 playerNum,
static void static void
gtk_draw_score_pendingScore( DrawCtx* p_dctx, XP_Rect* rect, XP_S16 score, gtk_draw_score_pendingScore( DrawCtx* p_dctx, XP_Rect* rect, XP_S16 score,
XP_U16 playerNum ) XP_U16 playerNum )
{ {
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx; GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
char buf[5]; char buf[5];