Specify relative height of scoreboard and tray in board_figureLayout,

and allow those to be 0.
This commit is contained in:
Eric House 2013-11-04 06:19:33 -08:00
parent f0b554213b
commit 9f1b0c5121
7 changed files with 67 additions and 45 deletions

View file

@ -648,7 +648,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1figureLayout
bounds.height = getInt( env, jbounds, "bottom" ) - bounds.top; bounds.height = getInt( env, jbounds, "bottom" ) - bounds.top;
BoardDims dims; BoardDims dims;
board_figureLayout( state->game.board, gi, fontHt, fontWidth, board_figureLayout( state->game.board, gi, 150, 200, fontHt, fontWidth,
squareTiles, &bounds, ((!!jdims) ? &dims : NULL) ); squareTiles, &bounds, ((!!jdims) ? &dims : NULL) );
destroyGI( MPPARM(mpool) &gi ); destroyGI( MPPARM(mpool) &gi );

View file

@ -392,6 +392,7 @@ board_reset( BoardCtxt* board )
#ifdef COMMON_LAYOUT #ifdef COMMON_LAYOUT
void void
board_figureLayout( BoardCtxt* board, const CurGameInfo* gi, board_figureLayout( BoardCtxt* board, const CurGameInfo* gi,
XP_U16 scorePct, XP_U16 trayPct,
XP_U16 fontHt, XP_U16 fontWidth, XP_Bool squareTiles, XP_U16 fontHt, XP_U16 fontWidth, XP_Bool squareTiles,
const XP_Rect* bounds, BoardDims* dimsp ) const XP_Rect* bounds, BoardDims* dimsp )
{ {
@ -426,8 +427,8 @@ board_figureLayout( BoardCtxt* board, const CurGameInfo* gi,
// fit them and all cells no scrolling's needed. Otherwise // fit them and all cells no scrolling's needed. Otherwise
// determine the minimum number that must be hidden to fit. // determine the minimum number that must be hidden to fit.
// Finally grow scoreboard and tray to use whatever's left. // Finally grow scoreboard and tray to use whatever's left.
trayHt = 2 * cellSize; scoreHt = (scorePct * cellSize) / 100;
scoreHt = (cellSize * 3) / 2; trayHt = (trayPct * cellSize) / 100;
wantHt = trayHt + scoreHt + (cellSize * nCells); wantHt = trayHt + scoreHt + (cellSize * nCells);
if ( wantHt <= bounds->height ) { if ( wantHt <= bounds->height ) {
nToScroll = 0; nToScroll = 0;
@ -452,9 +453,13 @@ board_figureLayout( BoardCtxt* board, const CurGameInfo* gi,
heightLeft = cellSize * 3 / 2; heightLeft = cellSize * 3 / 2;
} }
heightLeft /= 3; heightLeft /= 3;
scoreHt += heightLeft; if ( 0 < scorePct ) {
scoreHt += heightLeft;
}
trayHt += heightLeft * 2; if ( 0 < trayPct ) {
trayHt += heightLeft * 2;
}
if ( squareTiles && trayHt > (bounds->width / 7) ) { if ( squareTiles && trayHt > (bounds->width / 7) ) {
trayHt = bounds->width / 7; trayHt = bounds->width / 7;
} }

View file

@ -86,6 +86,7 @@ typedef struct _BoardDims {
} BoardDims; } BoardDims;
void board_figureLayout( BoardCtxt* board, const CurGameInfo* gi, void board_figureLayout( BoardCtxt* board, const CurGameInfo* gi,
XP_U16 scorePct, XP_U16 trayPct,
XP_U16 fontHt, XP_U16 fontWidth, XP_U16 fontHt, XP_U16 fontWidth,
XP_Bool squareTiles, const XP_Rect* bounds, XP_Bool squareTiles, const XP_Rect* bounds,
/* out */ BoardDims* dims ); /* out */ BoardDims* dims );

View file

@ -280,51 +280,55 @@ drawScoreBoard( BoardCtxt* board )
totalDim += isVertical ? dp->height : dp->width; totalDim += isVertical ? dp->height : dp->width;
} }
gotPct = (*adjustDim * 100) / totalDim; if ( 0 < totalDim ) {
for ( dp = datum, ii = 0; ii < nPlayers; ++ii, ++dp ) { gotPct = (*adjustDim * 100) / totalDim;
if ( isVertical ) { for ( dp = datum, ii = 0; ii < nPlayers; ++ii, ++dp ) {
dp->height = (dp->height * gotPct) / 100; if ( isVertical ) {
} else { dp->height = (dp->height * gotPct) / 100;
dp->width = (dp->width * gotPct) / 100; } else {
dp->width = (dp->width * gotPct) / 100;
}
} }
}
scoreRect = board->scoreBdBounds; /* reset */ scoreRect = board->scoreBdBounds; /* reset */
/* at this point, the scoreRect should be anchored at the /* at this point, the scoreRect should be anchored at the
scoreboard rect's upper left. */ scoreboard rect's upper left. */
if ( remDim > 0 ) { if ( remDim > 0 ) {
XP_Rect innerRect; XP_Rect innerRect;
*adjustDim = remDim; *adjustDim = remDim;
centerIn( &innerRect, &scoreRect, remWidth, remHeight ); centerIn( &innerRect, &scoreRect, remWidth, remHeight );
draw_drawRemText( board->draw, &innerRect, &scoreRect, draw_drawRemText( board->draw, &innerRect, &scoreRect,
nTilesInPool, focusAll || remFocussed ); nTilesInPool,
*adjustPt += remDim; focusAll || remFocussed );
*adjustPt += remDim;
#ifdef KEYBOARD_NAV #ifdef KEYBOARD_NAV
board->remRect = scoreRect; board->remRect = scoreRect;
/* Hack: don't let the cursor disappear if Rem: goes /* Hack: don't let the cursor disappear if Rem: goes
away */ away */
} else if ( board->scoreCursorLoc == CURSOR_LOC_REM ) { } else if ( board->scoreCursorLoc == CURSOR_LOC_REM ) {
board->scoreCursorLoc = selPlayer + 1; board->scoreCursorLoc = selPlayer + 1;
#endif #endif
} }
board->remDim = remDim; board->remDim = remDim;
for ( dp = datum, ii = 0; ii < nPlayers; ++dp, ++ii ) { for ( dp = datum, ii = 0; ii < nPlayers; ++dp, ++ii ) {
XP_Rect innerRect; XP_Rect innerRect;
XP_U16 dim = isVertical? dp->height:dp->width; XP_U16 dim = isVertical? dp->height:dp->width;
*adjustDim = board->pti[ii].scoreDims = dim; *adjustDim = board->pti[ii].scoreDims = dim;
centerIn( &innerRect, &scoreRect, dp->width, dp->height ); centerIn( &innerRect, &scoreRect, dp->width,
draw_score_drawPlayer( board->draw, &innerRect, &scoreRect, dp->height );
gotPct, &dp->dsi ); draw_score_drawPlayer( board->draw, &innerRect,
&scoreRect, gotPct, &dp->dsi );
#ifdef KEYBOARD_NAV #ifdef KEYBOARD_NAV
XP_MEMCPY( &board->pti[ii].scoreRects, &scoreRect, XP_MEMCPY( &board->pti[ii].scoreRects, &scoreRect,
sizeof(scoreRect) ); sizeof(scoreRect) );
#endif #endif
*adjustPt += *adjustDim; *adjustPt += *adjustDim;
}
} }
draw_objFinished( board->draw, OBJ_SCORE, draw_objFinished( board->draw, OBJ_SCORE,

View file

@ -328,9 +328,11 @@ drawPendingScore( BoardCtxt* board, XP_S16 turnScore, XP_Bool hasCursor )
XP_Rect lastTileR; XP_Rect lastTileR;
figureTrayTileRect( board, MAX_TRAY_TILES-1, &lastTileR ); figureTrayTileRect( board, MAX_TRAY_TILES-1, &lastTileR );
draw_score_pendingScore( board->draw, &lastTileR, turnScore, if ( 0 < lastTileR.width && 0 < lastTileR.height ) {
selPlayer, curTurn, draw_score_pendingScore( board->draw, &lastTileR, turnScore,
hasCursor?CELL_ISCURSOR:CELL_NONE ); selPlayer, curTurn,
hasCursor?CELL_ISCURSOR:CELL_NONE );
}
} }
} /* drawPendingScore */ } /* drawPendingScore */
@ -509,7 +511,9 @@ dividerMoved( BoardCtxt* board, XP_U8 newLoc )
void void
board_invalTrayTiles( BoardCtxt* board, TileBit what ) board_invalTrayTiles( BoardCtxt* board, TileBit what )
{ {
board->trayInvalBits |= what; if ( 0 < board->trayBounds.width && 0 < board->trayBounds.height ) {
board->trayInvalBits |= what;
}
} /* invalTrayTiles */ } /* invalTrayTiles */
void void

View file

@ -116,6 +116,7 @@ DEFINES += -DXWFEATURE_COMMSACK
#DEFINES += -DXWFEATURE_ACTIVERECT #DEFINES += -DXWFEATURE_ACTIVERECT
DEFINES += -DCOMMS_XPORT_FLAGSPROC DEFINES += -DCOMMS_XPORT_FLAGSPROC
DEFINES += -DINITIAL_CLIENT_VERS=2 DEFINES += -DINITIAL_CLIENT_VERS=2
DEFINES += -DCOMMON_LAYOUT
# MAX_ROWS controls STREAM_VERS_BIGBOARD and with it move hashing # MAX_ROWS controls STREAM_VERS_BIGBOARD and with it move hashing
DEFINES += -DMAX_ROWS=32 DEFINES += -DMAX_ROWS=32

View file

@ -617,7 +617,14 @@ configure_event( GtkWidget* widget, GdkEventConfigure* XP_UNUSED(event),
.width = bdWidth, .height = bdHeight .width = bdWidth, .height = bdHeight
}; };
BoardDims dims; BoardDims dims;
board_figureLayout( board, cGlobals->gi, 16, 16, XP_FALSE, &rect, &dims ); board_figureLayout( board, cGlobals->gi,
#if 1
150, 200,
#else
0, 0,
#endif
16, 16,
XP_FALSE, &rect, &dims );
board_applyLayout( board, &dims ); board_applyLayout( board, &dims );
#else #else