mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
Refer to players as "remote" rather than "not local" to be consistent
with Palm and PPC; fix juggle bug by adjusting lines after moving them.
This commit is contained in:
parent
e58d397c2b
commit
956c169d08
3 changed files with 43 additions and 50 deletions
|
@ -91,35 +91,34 @@ void
|
|||
newg_load( NewGameCtx* ngc, const CurGameInfo* gi )
|
||||
{
|
||||
void* closure = ngc->closure;
|
||||
NGValue cValue;
|
||||
NGValue aValue;
|
||||
NGValue value;
|
||||
XP_U16 i;
|
||||
|
||||
ngc->nPlayers = gi->nPlayers;
|
||||
aValue.ng_u16 = ngc->nPlayers;
|
||||
(*ngc->setAttrProc)( closure, NG_ATTR_NPLAYERS, aValue );
|
||||
value.ng_u16 = ngc->nPlayers;
|
||||
(*ngc->setAttrProc)( closure, NG_ATTR_NPLAYERS, value );
|
||||
(*ngc->enableAttrProc)( closure, NG_ATTR_NPLAYERS, ngc->isNewGame );
|
||||
|
||||
ngc->role = gi->serverRole;
|
||||
aValue.ng_role = ngc->role;
|
||||
(*ngc->setAttrProc)( closure, NG_ATTR_ROLE, aValue );
|
||||
value.ng_role = ngc->role;
|
||||
(*ngc->setAttrProc)( closure, NG_ATTR_ROLE, value );
|
||||
(*ngc->enableAttrProc)( closure, NG_ATTR_ROLE, ngc->isNewGame );
|
||||
|
||||
for ( i = 0; i < MAX_NUM_PLAYERS; ++i ) {
|
||||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
cValue.ng_bool = gi->players[i].isLocal;
|
||||
(*ngc->setColProc)(closure, i, NG_COL_LOCAL, cValue );
|
||||
value.ng_bool = !gi->players[i].isLocal;
|
||||
(*ngc->setColProc)(closure, i, NG_COL_REMOTE, value );
|
||||
#endif
|
||||
|
||||
cValue.ng_cp = gi->players[i].name;
|
||||
(*ngc->setColProc)(closure, i, NG_COL_NAME, cValue );
|
||||
value.ng_cp = gi->players[i].name;
|
||||
(*ngc->setColProc)(closure, i, NG_COL_NAME, value );
|
||||
|
||||
cValue.ng_cp = gi->players[i].password;
|
||||
(*ngc->setColProc)(closure, i, NG_COL_PASSWD, cValue );
|
||||
value.ng_cp = gi->players[i].password;
|
||||
(*ngc->setColProc)(closure, i, NG_COL_PASSWD, value );
|
||||
|
||||
cValue.ng_bool = gi->players[i].isRobot;
|
||||
(*ngc->setColProc)(closure, i, NG_COL_ROBOT, cValue );
|
||||
value.ng_bool = gi->players[i].isRobot;
|
||||
(*ngc->setColProc)(closure, i, NG_COL_ROBOT, value );
|
||||
}
|
||||
|
||||
adjustAllRows( ngc, XP_TRUE );
|
||||
|
@ -141,7 +140,7 @@ cpToGI( NGValue value, const void* cbClosure )
|
|||
|
||||
switch ( cpcl->col ) {
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
case NG_COL_LOCAL:
|
||||
case NG_COL_REMOTE:
|
||||
pl->isLocal = value.ng_bool;
|
||||
break;
|
||||
#endif
|
||||
|
@ -189,8 +188,11 @@ void
|
|||
newg_colChanged( NewGameCtx* ngc, XP_U16 player, NewGameColumn col,
|
||||
NGValue value )
|
||||
{
|
||||
XP_ASSERT( player < ngc->nPlayers );
|
||||
adjustOneRow( ngc, player, XP_FALSE );
|
||||
/* Sometimes we'll get this notification for inactive rows, e.g. when
|
||||
setting default values. */
|
||||
if ( player < ngc->nPlayers ) {
|
||||
adjustOneRow( ngc, player, XP_FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -240,7 +242,7 @@ deepCopy( NGValue value, const void* closure )
|
|||
DeepValue* dvp = (DeepValue*)closure;
|
||||
switch ( dvp->col ) {
|
||||
case NG_COL_ROBOT:
|
||||
case NG_COL_LOCAL:
|
||||
case NG_COL_REMOTE:
|
||||
dvp->value.ng_bool = value.ng_bool;
|
||||
break;
|
||||
case NG_COL_NAME:
|
||||
|
@ -302,18 +304,12 @@ newg_juggle( NewGameCtx* ngc )
|
|||
(*ngc->getColProc)(closure, pos[0], col, deepCopy, &tmpValues[col] );
|
||||
}
|
||||
|
||||
/* Strings must be copied */
|
||||
/* for ( col = 0; col < sizeof(strCols)/sizeof(strCols[0]); ++col ) { */
|
||||
/* NewGameColumn strCol = strCols[col]; */
|
||||
/* tmpValues[strCol].ng_cp = copyString( MPPARM(ngc->mpool) */
|
||||
/* tmpValues[strCol].ng_cp ); */
|
||||
/* } */
|
||||
|
||||
cur = 0;
|
||||
while ( ++cur < nPlayers ) {
|
||||
XP_LOGF( "%s: copying player %d to player %d", __FUNCTION__,
|
||||
pos[cur], pos[cur-1] );
|
||||
copyFromTo( ngc, pos[cur], pos[cur-1] );
|
||||
adjustOneRow( ngc, pos[cur-1], XP_FALSE );
|
||||
}
|
||||
|
||||
--cur;
|
||||
|
@ -323,11 +319,7 @@ newg_juggle( NewGameCtx* ngc )
|
|||
(*ngc->setColProc)(closure, pos[cur], col, tmpValues[col].value );
|
||||
deepFree( &tmpValues[col] );
|
||||
}
|
||||
/* copied strings must be freed */
|
||||
/* for ( col = 0; col < sizeof(strCols)/sizeof(strCols[0]); ++col ) { */
|
||||
/* NewGameColumn strCol = strCols[col]; */
|
||||
/* XP_FREE( ngc->mpool, (void*)tmpValues[strCol].ng_cp ); */
|
||||
/* } */
|
||||
adjustOneRow( ngc, pos[cur], XP_FALSE );
|
||||
}
|
||||
} /* newg_juggle */
|
||||
|
||||
|
@ -359,7 +351,6 @@ adjustOneRow( NewGameCtx* ngc, XP_U16 player, XP_Bool force )
|
|||
XP_MEMSET( enable, 0, sizeof(enable) );
|
||||
XP_Bool isLocal = XP_TRUE;
|
||||
DeepValue dValue;
|
||||
/* NGValue value; */
|
||||
|
||||
/* If there aren't this many players, all are disabled */
|
||||
if ( player >= ngc->nPlayers ) {
|
||||
|
@ -368,12 +359,13 @@ adjustOneRow( NewGameCtx* ngc, XP_U16 player, XP_Bool force )
|
|||
} else {
|
||||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
/* If standalone or client, local is disabled */
|
||||
/* If standalone or client, remote is disabled */
|
||||
if ( ngc->role == SERVER_ISSERVER ) {
|
||||
enable[NG_COL_LOCAL] = XP_TRUE;
|
||||
dValue.col = NG_COL_LOCAL;
|
||||
(*ngc->getColProc)( ngc->closure, player, NG_COL_LOCAL, deepCopy, &dValue );
|
||||
isLocal = dValue.value.ng_bool;
|
||||
enable[NG_COL_REMOTE] = XP_TRUE;
|
||||
dValue.col = NG_COL_REMOTE;
|
||||
(*ngc->getColProc)( ngc->closure, player, NG_COL_REMOTE,
|
||||
deepCopy, &dValue );
|
||||
isLocal = !dValue.value.ng_bool;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ typedef struct NewGameCtx NewGameCtx;
|
|||
|
||||
typedef enum {
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
NG_COL_LOCAL
|
||||
NG_COL_REMOTE
|
||||
#endif
|
||||
,NG_COL_NAME
|
||||
,NG_COL_ROBOT
|
||||
|
|
|
@ -44,7 +44,7 @@ typedef struct GtkNewGameState {
|
|||
short nCols; /* for board size */
|
||||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
GtkWidget* localChecks[MAX_NUM_PLAYERS];
|
||||
GtkWidget* remoteChecks[MAX_NUM_PLAYERS];
|
||||
#endif
|
||||
GtkWidget* robotChecks[MAX_NUM_PLAYERS];
|
||||
GtkWidget* nameFields[MAX_NUM_PLAYERS];
|
||||
|
@ -129,9 +129,9 @@ handle_juggle( GtkWidget* item, GtkNewGameState* state )
|
|||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
static void
|
||||
handle_local_toggled( GtkWidget* item, GtkNewGameState* state )
|
||||
handle_remote_toggled( GtkWidget* item, GtkNewGameState* state )
|
||||
{
|
||||
callChangedWithIndex( state, item, state->localChecks, NG_COL_LOCAL );
|
||||
callChangedWithIndex( state, item, state->remoteChecks, NG_COL_REMOTE );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -271,15 +271,15 @@ makeNewGameDialog( GtkNewGameState* state )
|
|||
for ( i = 0; i < MAX_NUM_PLAYERS; ++i ) {
|
||||
GtkWidget* label = gtk_label_new("Name:");
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
GtkWidget* localCheck = gtk_check_button_new_with_label( "Local" );
|
||||
GtkWidget* remoteCheck = gtk_check_button_new_with_label( "Remote" );
|
||||
#endif
|
||||
GtkWidget* nameField = gtk_entry_new();
|
||||
GtkWidget* passwdField = gtk_entry_new_with_max_length( 6 );
|
||||
GtkWidget* robotCheck = gtk_check_button_new_with_label( "Robot" );
|
||||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
g_signal_connect( GTK_OBJECT(localCheck), "toggled",
|
||||
GTK_SIGNAL_FUNC(handle_local_toggled), state );
|
||||
g_signal_connect( GTK_OBJECT(remoteCheck), "toggled",
|
||||
GTK_SIGNAL_FUNC(handle_remote_toggled), state );
|
||||
#endif
|
||||
g_signal_connect( GTK_OBJECT(robotCheck), "toggled",
|
||||
GTK_SIGNAL_FUNC(handle_robot_toggled), state );
|
||||
|
@ -287,9 +287,9 @@ makeNewGameDialog( GtkNewGameState* state )
|
|||
hbox = gtk_hbox_new( FALSE, 0 );
|
||||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
gtk_box_pack_start( GTK_BOX(hbox), localCheck, FALSE, TRUE, 0 );
|
||||
gtk_widget_show( localCheck );
|
||||
state->localChecks[i] = localCheck;
|
||||
gtk_box_pack_start( GTK_BOX(hbox), remoteCheck, FALSE, TRUE, 0 );
|
||||
gtk_widget_show( remoteCheck );
|
||||
state->remoteChecks[i] = remoteCheck;
|
||||
#endif
|
||||
|
||||
gtk_box_pack_start( GTK_BOX(hbox), label, FALSE, TRUE, 0 );
|
||||
|
@ -385,8 +385,8 @@ widgetForCol( const GtkNewGameState* state, XP_U16 player, NewGameColumn col )
|
|||
} else if ( col == NG_COL_PASSWD ) {
|
||||
widget = state->passwdFields[player];
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
} else if ( col == NG_COL_LOCAL ) {
|
||||
widget = state->localChecks[player];
|
||||
} else if ( col == NG_COL_REMOTE ) {
|
||||
widget = state->remoteChecks[player];
|
||||
#endif
|
||||
} else if ( col == NG_COL_ROBOT ) {
|
||||
widget = state->robotChecks[player];
|
||||
|
@ -432,7 +432,7 @@ gtk_newgame_col_set( void* closure, XP_U16 player, NewGameColumn col,
|
|||
gtk_entry_set_text( GTK_ENTRY(widget), cp );
|
||||
break;
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
case NG_COL_LOCAL:
|
||||
case NG_COL_REMOTE:
|
||||
#endif
|
||||
case NG_COL_ROBOT:
|
||||
gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(widget),
|
||||
|
@ -451,7 +451,7 @@ gtk_newgame_col_get( void* closure, XP_U16 player, NewGameColumn col,
|
|||
GtkWidget* widget = widgetForCol( state, player, col );
|
||||
switch ( col ) {
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
case NG_COL_LOCAL:
|
||||
case NG_COL_REMOTE:
|
||||
#endif
|
||||
case NG_COL_ROBOT:
|
||||
value.ng_bool =
|
||||
|
@ -510,6 +510,7 @@ newGameDialog( GtkAppGlobals* globals/* , GtkGameInfo* gameInfo */ )
|
|||
newg_store( state.newGameCtxt, &globals->cGlobals.params->gi );
|
||||
}
|
||||
|
||||
newg_destroy( state.newGameCtxt );
|
||||
gtk_widget_destroy( dialog );
|
||||
} while ( state.revert );
|
||||
|
||||
|
|
Loading…
Reference in a new issue