Hide tray on turn transitions when more than one non-robot local player present in game.

This commit is contained in:
ehouse 2007-05-20 20:46:29 +00:00
parent 7795068a40
commit 41b81f463e
4 changed files with 21 additions and 10 deletions

View file

@ -624,13 +624,15 @@ board_commitTurn( BoardCtxt* board )
* cursor and tray traySelBits. Others, such as the miniwindow stuff, are * cursor and tray traySelBits. Others, such as the miniwindow stuff, are
* singletons that may have to be hidden or shown. * singletons that may have to be hidden or shown.
*/ */
void static void
board_selectPlayer( BoardCtxt* board, XP_U16 newPlayer ) selectPlayerImpl( BoardCtxt* board, XP_U16 newPlayer, XP_Bool reveal )
{ {
if ( !board->gameOver && server_getCurrentTurn(board->server) < 0 ) { if ( !board->gameOver && server_getCurrentTurn(board->server) < 0 ) {
/* game not started yet; do nothing */ /* game not started yet; do nothing */
} else if ( board->selPlayer == newPlayer ) { } else if ( board->selPlayer == newPlayer ) {
checkRevealTray( board ); if ( reveal ) {
checkRevealTray( board );
}
} else { } else {
XP_U16 oldPlayer = board->selPlayer; XP_U16 oldPlayer = board->selPlayer;
model_foreachPendingCell( board->model, newPlayer, model_foreachPendingCell( board->model, newPlayer,
@ -677,6 +679,12 @@ board_selectPlayer( BoardCtxt* board, XP_U16 newPlayer )
} }
board->scoreBoardInvalid = XP_TRUE; /* if only one player, number of board->scoreBoardInvalid = XP_TRUE; /* if only one player, number of
tiles remaining may have changed*/ tiles remaining may have changed*/
} /* selectPlayerImpl */
void
board_selectPlayer( BoardCtxt* board, XP_U16 newPlayer )
{
selectPlayerImpl( board, newPlayer, XP_TRUE );
} /* board_selectPlayer */ } /* board_selectPlayer */
void void
@ -3349,7 +3357,8 @@ boardTurnChanged( void* p_board )
nextPlayer = chooseBestSelPlayer( board ); nextPlayer = chooseBestSelPlayer( board );
if ( nextPlayer >= 0 ) { if ( nextPlayer >= 0 ) {
board_selectPlayer( board, nextPlayer ); XP_U16 nHumans = gi_countLocalHumans( board->gi );
selectPlayerImpl( board, nextPlayer, nHumans <= 1 );
} }
setTimerIf( board ); setTimerIf( board );

View file

@ -346,17 +346,19 @@ gi_copy( MPFORMAL CurGameInfo* destGI, CurGameInfo* srcGI )
} /* gi_copy */ } /* gi_copy */
XP_U16 XP_U16
gi_countHumans( const CurGameInfo* gi ) gi_countLocalHumans( const CurGameInfo* gi )
{ {
XP_U16 count = 0; XP_U16 count = 0;
XP_U16 nPlayers = gi->nPlayers; XP_U16 nPlayers = gi->nPlayers;
const LocalPlayer* lp = gi->players;
while ( nPlayers-- ) { while ( nPlayers-- ) {
if ( !gi->players[nPlayers].isRobot ) { if ( lp->isLocal && !lp->isRobot ) {
++count; ++count;
} }
++lp;
} }
return count; return count;
} /* gi_countHumans */ } /* gi_countLocalHumans */
void void
gi_readFromStream( MPFORMAL XWStreamCtxt* stream, CurGameInfo* gi ) gi_readFromStream( MPFORMAL XWStreamCtxt* stream, CurGameInfo* gi )

View file

@ -101,7 +101,7 @@ void gi_disposePlayerInfo( MPFORMAL CurGameInfo* gi );
void gi_writeToStream( XWStreamCtxt* stream, const CurGameInfo* gi ); void gi_writeToStream( XWStreamCtxt* stream, const CurGameInfo* gi );
void gi_readFromStream( MPFORMAL XWStreamCtxt* stream, CurGameInfo* gi ); void gi_readFromStream( MPFORMAL XWStreamCtxt* stream, CurGameInfo* gi );
void gi_copy( MPFORMAL CurGameInfo* destGI, CurGameInfo* srcGi ); void gi_copy( MPFORMAL CurGameInfo* destGI, CurGameInfo* srcGi );
XP_U16 gi_countHumans( const CurGameInfo* gi ); XP_U16 gi_countLocalHumans( const CurGameInfo* gi );
XP_Bool player_hasPasswd( LocalPlayer* player ); XP_Bool player_hasPasswd( LocalPlayer* player );
XP_Bool player_passwordMatches( LocalPlayer* player, XP_U8* buf, XP_U16 len ); XP_Bool player_passwordMatches( LocalPlayer* player, XP_U8* buf, XP_U16 len );

View file

@ -1246,7 +1246,7 @@ saveOpenGame( PalmAppGlobals* globals )
const XP_UCHAR* dictName; const XP_UCHAR* dictName;
char namebuf[MAX_GAMENAME_LENGTH]; char namebuf[MAX_GAMENAME_LENGTH];
if ( gi_countHumans( &globals->gameInfo ) > 1 ) { if ( gi_countLocalHumans( &globals->gameInfo ) > 1 ) {
board_hideTray( globals->game.board ); /* so won't be visible when board_hideTray( globals->game.board ); /* so won't be visible when
next opened */ next opened */
} }
@ -1456,7 +1456,7 @@ eventLoop( PalmAppGlobals* globals )
&& !!globals->game.board ) { && !!globals->game.board ) {
if ( !globals->menuIsDown /* hi Marcus :-) */ if ( !globals->menuIsDown /* hi Marcus :-) */
&& closeNonMainForms(globals) && closeNonMainForms(globals)
&& gi_countHumans( &globals->gameInfo ) > 1 && gi_countLocalHumans( &globals->gameInfo ) > 1
&& board_hideTray( globals->game.board ) ) { && board_hideTray( globals->game.board ) ) {
board_draw( globals->game.board ); board_draw( globals->game.board );
} }