mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-16 15:41:16 +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;
|
Connectedness role;
|
||||||
#endif
|
#endif
|
||||||
XP_Bool isNewGame;
|
XP_Bool isNewGame;
|
||||||
|
NewGameEnable juggleEnabled;
|
||||||
|
|
||||||
MPSLOT
|
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 adjustAllRows( NewGameCtx* ngc, XP_Bool force );
|
||||||
static void adjustOneRow( NewGameCtx* ngc, XP_U16 player, XP_Bool force );
|
static void adjustOneRow( NewGameCtx* ngc, XP_U16 player, XP_Bool force );
|
||||||
static void setRoleStrings( NewGameCtx* ngc );
|
static void setRoleStrings( NewGameCtx* ngc );
|
||||||
|
static void considerEnableJuggle( NewGameCtx* ngc );
|
||||||
|
|
||||||
NewGameCtx*
|
NewGameCtx*
|
||||||
newg_make( MPFORMAL XP_Bool isNewGame,
|
newg_make( MPFORMAL XP_Bool isNewGame,
|
||||||
|
@ -108,6 +109,7 @@ newg_load( NewGameCtx* ngc, const CurGameInfo* gi )
|
||||||
NGEnableEnabled : NGEnableDisabled );
|
NGEnableEnabled : NGEnableDisabled );
|
||||||
#endif
|
#endif
|
||||||
setRoleStrings( ngc );
|
setRoleStrings( ngc );
|
||||||
|
considerEnableJuggle( ngc );
|
||||||
|
|
||||||
for ( i = 0; i < MAX_NUM_PLAYERS; ++i ) {
|
for ( i = 0; i < MAX_NUM_PLAYERS; ++i ) {
|
||||||
|
|
||||||
|
@ -169,19 +171,20 @@ cpToGI( NGValue value, const void* cbClosure )
|
||||||
void
|
void
|
||||||
newg_store( NewGameCtx* ngc, CurGameInfo* gi )
|
newg_store( NewGameCtx* ngc, CurGameInfo* gi )
|
||||||
{
|
{
|
||||||
XP_U16 nPlayers;
|
|
||||||
void* closure = ngc->closure;
|
void* closure = ngc->closure;
|
||||||
NGCopyClosure cpcl;
|
NGCopyClosure cpcl;
|
||||||
|
|
||||||
cpcl.ngc = ngc;
|
cpcl.ngc = ngc;
|
||||||
cpcl.gi = gi;
|
cpcl.gi = gi;
|
||||||
|
|
||||||
gi->nPlayers = nPlayers = ngc->nPlayers;
|
gi->nPlayers = ngc->nPlayers;
|
||||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||||
gi->serverRole = ngc->role;
|
gi->serverRole = ngc->role;
|
||||||
#endif
|
#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 ) {
|
for ( cpcl.col = 0; cpcl.col < NG_NUM_COLS; ++cpcl.col ) {
|
||||||
(*ngc->getColProc)( closure, cpcl.player, cpcl.col,
|
(*ngc->getColProc)( closure, cpcl.player, cpcl.col,
|
||||||
cpToGI, &cpcl );
|
cpToGI, &cpcl );
|
||||||
|
@ -206,6 +209,7 @@ newg_attrChanged( NewGameCtx* ngc, NewGameAttr attr, NGValue value )
|
||||||
XP_LOGF( "%s(%d)", __FUNCTION__ );
|
XP_LOGF( "%s(%d)", __FUNCTION__ );
|
||||||
if ( attr == NG_ATTR_NPLAYERS ) {
|
if ( attr == NG_ATTR_NPLAYERS ) {
|
||||||
ngc->nPlayers = value.ng_u16;
|
ngc->nPlayers = value.ng_u16;
|
||||||
|
considerEnableJuggle( ngc );
|
||||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||||
} else if ( NG_ATTR_ROLE == attr ) {
|
} else if ( NG_ATTR_ROLE == attr ) {
|
||||||
ngc->role = value.ng_role;
|
ngc->role = value.ng_role;
|
||||||
|
@ -422,6 +426,19 @@ setRoleStrings( NewGameCtx* ngc )
|
||||||
(*ngc->setAttrProc)( closure, NG_ATTR_NPLAYHEADER, value );
|
(*ngc->setAttrProc)( closure, NG_ATTR_NPLAYHEADER, value );
|
||||||
} /* setRoleStrings */
|
} /* 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
|
#ifdef CPLUS
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -57,6 +57,7 @@ typedef enum {
|
||||||
#endif
|
#endif
|
||||||
NG_ATTR_NPLAYERS
|
NG_ATTR_NPLAYERS
|
||||||
,NG_ATTR_NPLAYHEADER
|
,NG_ATTR_NPLAYHEADER
|
||||||
|
,NG_ATTR_CANJUGGLE
|
||||||
} NewGameAttr;
|
} NewGameAttr;
|
||||||
|
|
||||||
typedef enum { NGEnableHidden,
|
typedef enum { NGEnableHidden,
|
||||||
|
|
|
@ -54,6 +54,7 @@ typedef struct GtkNewGameState {
|
||||||
GtkWidget* nPlayersMenu;
|
GtkWidget* nPlayersMenu;
|
||||||
GtkWidget* roleMenu;
|
GtkWidget* roleMenu;
|
||||||
GtkWidget* nPlayersLabel;
|
GtkWidget* nPlayersLabel;
|
||||||
|
GtkWidget* juggleButton;
|
||||||
|
|
||||||
GtkWidget* roleMenuItems[3];
|
GtkWidget* roleMenuItems[3];
|
||||||
} GtkNewGameState;
|
} GtkNewGameState;
|
||||||
|
@ -212,7 +213,6 @@ makeNewGameDialog( GtkNewGameState* state, XP_Bool isNewGame )
|
||||||
GtkWidget* nPlayersMenu;
|
GtkWidget* nPlayersMenu;
|
||||||
GtkWidget* boardSizeMenu;
|
GtkWidget* boardSizeMenu;
|
||||||
GtkWidget* opt;
|
GtkWidget* opt;
|
||||||
GtkWidget* juggleButton;
|
|
||||||
CurGameInfo* gi;
|
CurGameInfo* gi;
|
||||||
short i;
|
short i;
|
||||||
char* roles[] = { "Standalone", "Host", "Guest" };
|
char* roles[] = { "Standalone", "Host", "Guest" };
|
||||||
|
@ -264,10 +264,10 @@ makeNewGameDialog( GtkNewGameState* state, XP_Bool isNewGame )
|
||||||
gtk_widget_show( opt );
|
gtk_widget_show( opt );
|
||||||
gtk_box_pack_start( GTK_BOX(hbox), opt, FALSE, TRUE, 0 );
|
gtk_box_pack_start( GTK_BOX(hbox), opt, FALSE, TRUE, 0 );
|
||||||
|
|
||||||
juggleButton = makeButton( "Juggle", GTK_SIGNAL_FUNC(handle_juggle),
|
state->juggleButton = makeButton( "Juggle",
|
||||||
|
GTK_SIGNAL_FUNC(handle_juggle),
|
||||||
state );
|
state );
|
||||||
gtk_box_pack_start( GTK_BOX(hbox), juggleButton, FALSE, TRUE, 0 );
|
gtk_box_pack_start( GTK_BOX(hbox), state->juggleButton, FALSE, TRUE, 0 );
|
||||||
gtk_widget_set_sensitive( juggleButton, isNewGame );
|
|
||||||
gtk_widget_show( hbox );
|
gtk_widget_show( hbox );
|
||||||
|
|
||||||
gtk_box_pack_start( GTK_BOX(vbox), hbox, FALSE, TRUE, 0 );
|
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 )
|
gtk_newgame_attr_enable( void* closure, NewGameAttr attr, NewGameEnable enable )
|
||||||
{
|
{
|
||||||
GtkNewGameState* state = (GtkNewGameState*)closure;
|
GtkNewGameState* state = (GtkNewGameState*)closure;
|
||||||
GtkWidget* menu = NULL;
|
GtkWidget* widget = NULL;
|
||||||
if ( attr == NG_ATTR_NPLAYERS ) {
|
if ( attr == NG_ATTR_NPLAYERS ) {
|
||||||
menu = state->nPlayersMenu;
|
widget = state->nPlayersMenu;
|
||||||
} else if ( attr == NG_ATTR_ROLE ) {
|
} 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 ) {
|
if ( !giState->isNewGame ) {
|
||||||
ceEnOrDisable( hDlg, IDC_DICTCOMBO, XP_FALSE );
|
ceEnOrDisable( hDlg, IDC_DICTCOMBO, XP_FALSE );
|
||||||
ceEnOrDisable( hDlg, GIJUGGLE_BUTTON, XP_FALSE );
|
|
||||||
}
|
}
|
||||||
} /* loadFromGameInfo */
|
} /* loadFromGameInfo */
|
||||||
|
|
||||||
|
@ -318,6 +317,9 @@ resIDForAttr( NewGameAttr attr )
|
||||||
case NG_ATTR_NPLAYHEADER:
|
case NG_ATTR_NPLAYHEADER:
|
||||||
resID = IDC_TOTAL_LABEL;
|
resID = IDC_TOTAL_LABEL;
|
||||||
break;
|
break;
|
||||||
|
case NG_ATTR_CANJUGGLE:
|
||||||
|
resID = GIJUGGLE_BUTTON;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
XP_ASSERT( resID != 0 );
|
XP_ASSERT( resID != 0 );
|
||||||
return resID;
|
return resID;
|
||||||
|
|
Loading…
Reference in a new issue