mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
disable juggle button if only one player active; copy all four players when saving game state after dismissal.
This commit is contained in:
parent
46cd6e8536
commit
45979f547a
4 changed files with 38 additions and 15 deletions
|
@ -46,6 +46,7 @@ struct NewGameCtx {
|
|||
Connectedness role;
|
||||
#endif
|
||||
XP_Bool isNewGame;
|
||||
NewGameEnable juggleEnabled;
|
||||
|
||||
MPSLOT
|
||||
};
|
||||
|
@ -55,7 +56,7 @@ static void enableOne( NewGameCtx* ngc, XP_U16 player, NewGameColumn col,
|
|||
static void adjustAllRows( NewGameCtx* ngc, XP_Bool force );
|
||||
static void adjustOneRow( NewGameCtx* ngc, XP_U16 player, XP_Bool force );
|
||||
static void setRoleStrings( NewGameCtx* ngc );
|
||||
|
||||
static void considerEnableJuggle( NewGameCtx* ngc );
|
||||
|
||||
NewGameCtx*
|
||||
newg_make( MPFORMAL XP_Bool isNewGame,
|
||||
|
@ -108,6 +109,7 @@ newg_load( NewGameCtx* ngc, const CurGameInfo* gi )
|
|||
NGEnableEnabled : NGEnableDisabled );
|
||||
#endif
|
||||
setRoleStrings( ngc );
|
||||
considerEnableJuggle( ngc );
|
||||
|
||||
for ( i = 0; i < MAX_NUM_PLAYERS; ++i ) {
|
||||
|
||||
|
@ -169,19 +171,20 @@ cpToGI( NGValue value, const void* cbClosure )
|
|||
void
|
||||
newg_store( NewGameCtx* ngc, CurGameInfo* gi )
|
||||
{
|
||||
XP_U16 nPlayers;
|
||||
void* closure = ngc->closure;
|
||||
NGCopyClosure cpcl;
|
||||
|
||||
cpcl.ngc = ngc;
|
||||
cpcl.gi = gi;
|
||||
|
||||
gi->nPlayers = nPlayers = ngc->nPlayers;
|
||||
gi->nPlayers = ngc->nPlayers;
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
gi->serverRole = ngc->role;
|
||||
#endif
|
||||
|
||||
for ( cpcl.player = 0; cpcl.player < nPlayers; ++cpcl.player ) {
|
||||
for ( cpcl.player = 0;
|
||||
cpcl.player < (sizeof(gi->players)/sizeof(gi->players[0]));
|
||||
++cpcl.player ) {
|
||||
for ( cpcl.col = 0; cpcl.col < NG_NUM_COLS; ++cpcl.col ) {
|
||||
(*ngc->getColProc)( closure, cpcl.player, cpcl.col,
|
||||
cpToGI, &cpcl );
|
||||
|
@ -206,6 +209,7 @@ newg_attrChanged( NewGameCtx* ngc, NewGameAttr attr, NGValue value )
|
|||
XP_LOGF( "%s(%d)", __FUNCTION__ );
|
||||
if ( attr == NG_ATTR_NPLAYERS ) {
|
||||
ngc->nPlayers = value.ng_u16;
|
||||
considerEnableJuggle( ngc );
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
} else if ( NG_ATTR_ROLE == attr ) {
|
||||
ngc->role = value.ng_role;
|
||||
|
@ -422,6 +426,19 @@ setRoleStrings( NewGameCtx* ngc )
|
|||
(*ngc->setAttrProc)( closure, NG_ATTR_NPLAYHEADER, value );
|
||||
} /* setRoleStrings */
|
||||
|
||||
static void
|
||||
considerEnableJuggle( NewGameCtx* ngc )
|
||||
{
|
||||
NewGameEnable newEnable;
|
||||
newEnable = (ngc->isNewGame && ngc->nPlayers > 1)?
|
||||
NGEnableEnabled : NGEnableDisabled;
|
||||
|
||||
if ( newEnable != ngc->juggleEnabled ) {
|
||||
(*ngc->enableAttrProc)( ngc->closure, NG_ATTR_CANJUGGLE, newEnable );
|
||||
ngc->juggleEnabled = newEnable;
|
||||
}
|
||||
} /* considerEnableJuggle */
|
||||
|
||||
#ifdef CPLUS
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -57,6 +57,7 @@ typedef enum {
|
|||
#endif
|
||||
NG_ATTR_NPLAYERS
|
||||
,NG_ATTR_NPLAYHEADER
|
||||
,NG_ATTR_CANJUGGLE
|
||||
} NewGameAttr;
|
||||
|
||||
typedef enum { NGEnableHidden,
|
||||
|
|
|
@ -54,6 +54,7 @@ typedef struct GtkNewGameState {
|
|||
GtkWidget* nPlayersMenu;
|
||||
GtkWidget* roleMenu;
|
||||
GtkWidget* nPlayersLabel;
|
||||
GtkWidget* juggleButton;
|
||||
|
||||
GtkWidget* roleMenuItems[3];
|
||||
} GtkNewGameState;
|
||||
|
@ -212,7 +213,6 @@ makeNewGameDialog( GtkNewGameState* state, XP_Bool isNewGame )
|
|||
GtkWidget* nPlayersMenu;
|
||||
GtkWidget* boardSizeMenu;
|
||||
GtkWidget* opt;
|
||||
GtkWidget* juggleButton;
|
||||
CurGameInfo* gi;
|
||||
short i;
|
||||
char* roles[] = { "Standalone", "Host", "Guest" };
|
||||
|
@ -264,10 +264,10 @@ makeNewGameDialog( GtkNewGameState* state, XP_Bool isNewGame )
|
|||
gtk_widget_show( opt );
|
||||
gtk_box_pack_start( GTK_BOX(hbox), opt, FALSE, TRUE, 0 );
|
||||
|
||||
juggleButton = makeButton( "Juggle", GTK_SIGNAL_FUNC(handle_juggle),
|
||||
state );
|
||||
gtk_box_pack_start( GTK_BOX(hbox), juggleButton, FALSE, TRUE, 0 );
|
||||
gtk_widget_set_sensitive( juggleButton, isNewGame );
|
||||
state->juggleButton = makeButton( "Juggle",
|
||||
GTK_SIGNAL_FUNC(handle_juggle),
|
||||
state );
|
||||
gtk_box_pack_start( GTK_BOX(hbox), state->juggleButton, FALSE, TRUE, 0 );
|
||||
gtk_widget_show( hbox );
|
||||
|
||||
gtk_box_pack_start( GTK_BOX(vbox), hbox, FALSE, TRUE, 0 );
|
||||
|
@ -440,14 +440,17 @@ static void
|
|||
gtk_newgame_attr_enable( void* closure, NewGameAttr attr, NewGameEnable enable )
|
||||
{
|
||||
GtkNewGameState* state = (GtkNewGameState*)closure;
|
||||
GtkWidget* menu = NULL;
|
||||
GtkWidget* widget = NULL;
|
||||
if ( attr == NG_ATTR_NPLAYERS ) {
|
||||
menu = state->nPlayersMenu;
|
||||
widget = state->nPlayersMenu;
|
||||
} else if ( attr == NG_ATTR_ROLE ) {
|
||||
menu = state->roleMenu;
|
||||
widget = state->roleMenu;
|
||||
} else if ( attr == NG_ATTR_CANJUGGLE ) {
|
||||
widget = state->juggleButton;
|
||||
}
|
||||
if ( !!menu ) {
|
||||
gtk_widget_set_sensitive( menu, enable == NGEnableEnabled );
|
||||
|
||||
if ( !!widget ) {
|
||||
gtk_widget_set_sensitive( widget, enable == NGEnableEnabled );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -196,7 +196,6 @@ loadFromGameInfo( HWND hDlg, CEAppGlobals* globals, GameInfoState* giState )
|
|||
|
||||
if ( !giState->isNewGame ) {
|
||||
ceEnOrDisable( hDlg, IDC_DICTCOMBO, XP_FALSE );
|
||||
ceEnOrDisable( hDlg, GIJUGGLE_BUTTON, XP_FALSE );
|
||||
}
|
||||
} /* loadFromGameInfo */
|
||||
|
||||
|
@ -318,6 +317,9 @@ resIDForAttr( NewGameAttr attr )
|
|||
case NG_ATTR_NPLAYHEADER:
|
||||
resID = IDC_TOTAL_LABEL;
|
||||
break;
|
||||
case NG_ATTR_CANJUGGLE:
|
||||
resID = GIJUGGLE_BUTTON;
|
||||
break;
|
||||
}
|
||||
XP_ASSERT( resID != 0 );
|
||||
return resID;
|
||||
|
|
Loading…
Reference in a new issue