mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
Hide tray on turn transitions when more than one non-robot local player present in game.
This commit is contained in:
parent
7795068a40
commit
41b81f463e
4 changed files with 21 additions and 10 deletions
|
@ -624,13 +624,15 @@ board_commitTurn( BoardCtxt* board )
|
|||
* cursor and tray traySelBits. Others, such as the miniwindow stuff, are
|
||||
* singletons that may have to be hidden or shown.
|
||||
*/
|
||||
void
|
||||
board_selectPlayer( BoardCtxt* board, XP_U16 newPlayer )
|
||||
static void
|
||||
selectPlayerImpl( BoardCtxt* board, XP_U16 newPlayer, XP_Bool reveal )
|
||||
{
|
||||
if ( !board->gameOver && server_getCurrentTurn(board->server) < 0 ) {
|
||||
/* game not started yet; do nothing */
|
||||
} else if ( board->selPlayer == newPlayer ) {
|
||||
checkRevealTray( board );
|
||||
if ( reveal ) {
|
||||
checkRevealTray( board );
|
||||
}
|
||||
} else {
|
||||
XP_U16 oldPlayer = board->selPlayer;
|
||||
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
|
||||
tiles remaining may have changed*/
|
||||
} /* selectPlayerImpl */
|
||||
|
||||
void
|
||||
board_selectPlayer( BoardCtxt* board, XP_U16 newPlayer )
|
||||
{
|
||||
selectPlayerImpl( board, newPlayer, XP_TRUE );
|
||||
} /* board_selectPlayer */
|
||||
|
||||
void
|
||||
|
@ -3349,7 +3357,8 @@ boardTurnChanged( void* p_board )
|
|||
|
||||
nextPlayer = chooseBestSelPlayer( board );
|
||||
if ( nextPlayer >= 0 ) {
|
||||
board_selectPlayer( board, nextPlayer );
|
||||
XP_U16 nHumans = gi_countLocalHumans( board->gi );
|
||||
selectPlayerImpl( board, nextPlayer, nHumans <= 1 );
|
||||
}
|
||||
|
||||
setTimerIf( board );
|
||||
|
|
|
@ -346,17 +346,19 @@ gi_copy( MPFORMAL CurGameInfo* destGI, CurGameInfo* srcGI )
|
|||
} /* gi_copy */
|
||||
|
||||
XP_U16
|
||||
gi_countHumans( const CurGameInfo* gi )
|
||||
gi_countLocalHumans( const CurGameInfo* gi )
|
||||
{
|
||||
XP_U16 count = 0;
|
||||
XP_U16 nPlayers = gi->nPlayers;
|
||||
const LocalPlayer* lp = gi->players;
|
||||
while ( nPlayers-- ) {
|
||||
if ( !gi->players[nPlayers].isRobot ) {
|
||||
if ( lp->isLocal && !lp->isRobot ) {
|
||||
++count;
|
||||
}
|
||||
++lp;
|
||||
}
|
||||
return count;
|
||||
} /* gi_countHumans */
|
||||
} /* gi_countLocalHumans */
|
||||
|
||||
void
|
||||
gi_readFromStream( MPFORMAL XWStreamCtxt* stream, CurGameInfo* gi )
|
||||
|
|
|
@ -101,7 +101,7 @@ void gi_disposePlayerInfo( MPFORMAL CurGameInfo* gi );
|
|||
void gi_writeToStream( XWStreamCtxt* stream, const CurGameInfo* gi );
|
||||
void gi_readFromStream( MPFORMAL XWStreamCtxt* stream, CurGameInfo* gi );
|
||||
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_passwordMatches( LocalPlayer* player, XP_U8* buf, XP_U16 len );
|
||||
|
|
|
@ -1246,7 +1246,7 @@ saveOpenGame( PalmAppGlobals* globals )
|
|||
const XP_UCHAR* dictName;
|
||||
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
|
||||
next opened */
|
||||
}
|
||||
|
@ -1456,7 +1456,7 @@ eventLoop( PalmAppGlobals* globals )
|
|||
&& !!globals->game.board ) {
|
||||
if ( !globals->menuIsDown /* hi Marcus :-) */
|
||||
&& closeNonMainForms(globals)
|
||||
&& gi_countHumans( &globals->gameInfo ) > 1
|
||||
&& gi_countLocalHumans( &globals->gameInfo ) > 1
|
||||
&& board_hideTray( globals->game.board ) ) {
|
||||
board_draw( globals->game.board );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue