mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-15 15:41:24 +01:00
rename variables; fix compiler warning.
This commit is contained in:
parent
7e2f2fd38e
commit
270006f47b
2 changed files with 193 additions and 193 deletions
|
@ -24,27 +24,27 @@
|
|||
#include "debhacks.h"
|
||||
|
||||
static void
|
||||
ceControlsToAddrRec( HWND hDlg, CeConnDlgState* cState )
|
||||
ceControlsToAddrRec( HWND hDlg, CeConnDlgState* state )
|
||||
{
|
||||
XP_U16 len;
|
||||
|
||||
if ( cState->addrRec.conType == COMMS_CONN_RELAY ) {
|
||||
if ( state->addrRec.conType == COMMS_CONN_RELAY ) {
|
||||
#ifdef XWFEATURE_RELAY
|
||||
len = sizeof(cState->addrRec.u.ip_relay.hostName);
|
||||
len = sizeof(state->addrRec.u.ip_relay.hostName);
|
||||
ceGetDlgItemText( hDlg, RELAYNAME_EDIT,
|
||||
cState->addrRec.u.ip_relay.hostName, &len );
|
||||
cState->addrRec.u.ip_relay.port =
|
||||
state->addrRec.u.ip_relay.hostName, &len );
|
||||
state->addrRec.u.ip_relay.port =
|
||||
(XP_U16)ceGetDlgItemNum( hDlg, RELAYPORT_EDIT );
|
||||
len = sizeof(cState->addrRec.u.ip_relay.cookie);
|
||||
ceGetDlgItemText( hDlg, COOKIE_EDIT, cState->addrRec.u.ip_relay.cookie,
|
||||
len = sizeof(state->addrRec.u.ip_relay.cookie);
|
||||
ceGetDlgItemText( hDlg, COOKIE_EDIT, state->addrRec.u.ip_relay.cookie,
|
||||
&len );
|
||||
#endif
|
||||
} else if ( cState->addrRec.conType == COMMS_CONN_BT ) {
|
||||
} else if ( state->addrRec.conType == COMMS_CONN_BT ) {
|
||||
#ifdef XWFEATURE_BLUETOOTH
|
||||
if ( cState->role == SERVER_ISCLIENT ) {
|
||||
len = sizeof(cState->addrRec.u.bt.hostName);
|
||||
if ( state->role == SERVER_ISCLIENT ) {
|
||||
len = sizeof(state->addrRec.u.bt.hostName);
|
||||
ceGetDlgItemText( hDlg, IDC_BLUET_ADDR_EDIT,
|
||||
cState->addrRec.u.bt.hostName, &len );
|
||||
state->addrRec.u.bt.hostName, &len );
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
|
@ -53,7 +53,7 @@ ceControlsToAddrRec( HWND hDlg, CeConnDlgState* cState )
|
|||
} /* ceControlsToAddrRec */
|
||||
|
||||
static void
|
||||
adjustForConnType( HWND hDlg, const CeConnDlgState* cState )
|
||||
adjustForConnType( HWND hDlg, const CeConnDlgState* state )
|
||||
{
|
||||
XP_U16 relayIds[] = {
|
||||
IDC_COOKIE_LAB,
|
||||
|
@ -72,12 +72,12 @@ adjustForConnType( HWND hDlg, const CeConnDlgState* cState )
|
|||
XP_U16* on = NULL;
|
||||
XP_U16 i;
|
||||
|
||||
if ( cState->addrRec.conType == COMMS_CONN_RELAY ) {
|
||||
if ( state->addrRec.conType == COMMS_CONN_RELAY ) {
|
||||
on = relayIds;
|
||||
} else if ( cState->addrRec.conType == COMMS_CONN_BT ) {
|
||||
} else if ( state->addrRec.conType == COMMS_CONN_BT ) {
|
||||
on =
|
||||
#ifdef XWFEATURE_BLUETOOTH
|
||||
cState->role != SERVER_ISCLIENT ? NULL:
|
||||
state->role != SERVER_ISCLIENT ? NULL:
|
||||
#endif
|
||||
btIds; /* we want the "disabled" message */
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ indexToConType( XP_U16 index )
|
|||
}
|
||||
|
||||
static void
|
||||
ceControlsFromAddrRec( HWND hDlg, const CeConnDlgState* cState )
|
||||
ceControlsFromAddrRec( HWND hDlg, const CeConnDlgState* state )
|
||||
{
|
||||
XP_U16 i;
|
||||
wchar_t* strs[] = {
|
||||
|
@ -138,22 +138,22 @@ ceControlsFromAddrRec( HWND hDlg, const CeConnDlgState* cState )
|
|||
}
|
||||
|
||||
SendDlgItemMessage( hDlg, IDC_CONNECTCOMBO, CB_SETCURSEL,
|
||||
conTypeToIndex(cState->addrRec.conType), 0L );
|
||||
conTypeToIndex(state->addrRec.conType), 0L );
|
||||
|
||||
if ( cState->addrRec.conType == COMMS_CONN_RELAY ) {
|
||||
if ( state->addrRec.conType == COMMS_CONN_RELAY ) {
|
||||
#ifdef XWFEATURE_RELAY
|
||||
ceSetDlgItemText( hDlg, RELAYNAME_EDIT,
|
||||
cState->addrRec.u.ip_relay.hostName );
|
||||
state->addrRec.u.ip_relay.hostName );
|
||||
ceSetDlgItemNum( hDlg, RELAYPORT_EDIT,
|
||||
cState->addrRec.u.ip_relay.port );
|
||||
state->addrRec.u.ip_relay.port );
|
||||
ceSetDlgItemText( hDlg, COOKIE_EDIT,
|
||||
cState->addrRec.u.ip_relay.cookie );
|
||||
state->addrRec.u.ip_relay.cookie );
|
||||
#endif
|
||||
} else if ( cState->addrRec.conType == COMMS_CONN_BT ) {
|
||||
} else if ( state->addrRec.conType == COMMS_CONN_BT ) {
|
||||
#ifdef XWFEATURE_BLUETOOTH
|
||||
if ( cState->role == SERVER_ISCLIENT ) {
|
||||
if ( state->role == SERVER_ISCLIENT ) {
|
||||
ceSetDlgItemText( hDlg, IDC_BLUET_ADDR_EDIT,
|
||||
cState->addrRec.u.bt.hostName );
|
||||
state->addrRec.u.bt.hostName );
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
|
@ -166,23 +166,23 @@ ConnsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
|||
{
|
||||
LRESULT result = FALSE;
|
||||
|
||||
CeConnDlgState* cState;
|
||||
CeConnDlgState* state;
|
||||
|
||||
if ( message == WM_INITDIALOG ) {
|
||||
SetWindowLongPtr( hDlg, GWL_USERDATA, lParam );
|
||||
cState = (CeConnDlgState*)lParam;
|
||||
state = (CeConnDlgState*)lParam;
|
||||
|
||||
adjustForConnType( hDlg, cState );
|
||||
adjustForConnType( hDlg, state );
|
||||
|
||||
ceControlsFromAddrRec( hDlg, cState );
|
||||
ceControlsFromAddrRec( hDlg, state );
|
||||
|
||||
ceDlgSetup( &cState->dlgState, hDlg, DLG_STATE_NONE );
|
||||
ceDlgSetup( &state->dlgState, hDlg, DLG_STATE_NONE );
|
||||
|
||||
result = TRUE;
|
||||
} else {
|
||||
cState = (CeConnDlgState*)GetWindowLongPtr( hDlg, GWL_USERDATA );
|
||||
if ( !!cState ) {
|
||||
CEAppGlobals* globals = cState->dlgHdr.globals;
|
||||
state = (CeConnDlgState*)GetWindowLongPtr( hDlg, GWL_USERDATA );
|
||||
if ( !!state ) {
|
||||
CEAppGlobals* globals = state->dlgHdr.globals;
|
||||
|
||||
if ( message == WM_COMMAND ) {
|
||||
XP_U16 id = LOWORD(wParam);
|
||||
|
@ -194,17 +194,17 @@ ConnsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
|||
XP_S16 sel;
|
||||
sel = SendDlgItemMessage( hDlg, IDC_CONNECTCOMBO,
|
||||
CB_GETCURSEL, 0, 0L );
|
||||
cState->addrRec.conType = indexToConType( sel );
|
||||
adjustForConnType( hDlg, cState );
|
||||
state->addrRec.conType = indexToConType( sel );
|
||||
adjustForConnType( hDlg, state );
|
||||
result = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case IDOK:
|
||||
ceControlsToAddrRec( hDlg, cState );
|
||||
ceControlsToAddrRec( hDlg, state );
|
||||
case IDCANCEL:
|
||||
EndDialog(hDlg, id);
|
||||
cState->userCancelled = id == IDCANCEL;
|
||||
state->userCancelled = id == IDCANCEL;
|
||||
result = TRUE;
|
||||
}
|
||||
} else if ( message == WM_VSCROLL ) {
|
||||
|
|
|
@ -65,105 +65,105 @@ findInsertPoint( const wchar_t* wPath, wchar_t** menuDicts,
|
|||
static XP_Bool
|
||||
addDictToState( const wchar_t* wPath, XP_U16 XP_UNUSED(index), void* ctxt )
|
||||
{
|
||||
GameInfoState* giState = (GameInfoState*)ctxt;
|
||||
GameInfoState* state = (GameInfoState*)ctxt;
|
||||
/* Let's display only the short form, but save the whole path */
|
||||
wchar_t* wstr;
|
||||
XP_U16 len;
|
||||
XP_S16 loc; /* < 0 means skip it */
|
||||
|
||||
loc = findInsertPoint( wPath, giState->menuDicts,
|
||||
giState->nMenuDicts );
|
||||
loc = findInsertPoint( wPath, state->menuDicts,
|
||||
state->nMenuDicts );
|
||||
|
||||
if ( loc >= 0 ) {
|
||||
/* make a copy of the long name */
|
||||
len = wcslen( wPath ) + 1;
|
||||
wstr = (wchar_t*)XP_MALLOC( giState->dlgHdr.globals->mpool,
|
||||
wstr = (wchar_t*)XP_MALLOC( state->dlgHdr.globals->mpool,
|
||||
len * sizeof(wstr[0]) );
|
||||
|
||||
XP_MEMCPY( wstr, wPath, len*sizeof(wstr[0]) );
|
||||
if ( !giState->menuDicts ) {
|
||||
XP_ASSERT( giState->nMenuDicts == 0 );
|
||||
XP_ASSERT( giState->capMenuDicts == 0 );
|
||||
giState->capMenuDicts = MENUDICTS_INCR;
|
||||
giState->menuDicts
|
||||
= (wchar_t**)XP_MALLOC( giState->dlgHdr.globals->mpool,
|
||||
giState->capMenuDicts
|
||||
* sizeof(giState->menuDicts[0]) );
|
||||
} else if ( giState->nMenuDicts == giState->capMenuDicts ) {
|
||||
giState->capMenuDicts += MENUDICTS_INCR;
|
||||
giState->menuDicts
|
||||
= (wchar_t**)XP_REALLOC( giState->dlgHdr.globals->mpool,
|
||||
giState->menuDicts,
|
||||
giState->capMenuDicts
|
||||
* sizeof(giState->menuDicts[0]) );
|
||||
if ( !state->menuDicts ) {
|
||||
XP_ASSERT( state->nMenuDicts == 0 );
|
||||
XP_ASSERT( state->capMenuDicts == 0 );
|
||||
state->capMenuDicts = MENUDICTS_INCR;
|
||||
state->menuDicts
|
||||
= (wchar_t**)XP_MALLOC( state->dlgHdr.globals->mpool,
|
||||
state->capMenuDicts
|
||||
* sizeof(state->menuDicts[0]) );
|
||||
} else if ( state->nMenuDicts == state->capMenuDicts ) {
|
||||
state->capMenuDicts += MENUDICTS_INCR;
|
||||
state->menuDicts
|
||||
= (wchar_t**)XP_REALLOC( state->dlgHdr.globals->mpool,
|
||||
state->menuDicts,
|
||||
state->capMenuDicts
|
||||
* sizeof(state->menuDicts[0]) );
|
||||
}
|
||||
|
||||
if ( loc < giState->nMenuDicts ) {
|
||||
XP_MEMMOVE( &giState->menuDicts[loc+1], &giState->menuDicts[loc],
|
||||
(giState->nMenuDicts - loc)
|
||||
* sizeof(giState->menuDicts[0]) );
|
||||
if ( loc < state->nMenuDicts ) {
|
||||
XP_MEMMOVE( &state->menuDicts[loc+1], &state->menuDicts[loc],
|
||||
(state->nMenuDicts - loc)
|
||||
* sizeof(state->menuDicts[0]) );
|
||||
}
|
||||
giState->menuDicts[loc] = wstr;
|
||||
++giState->nMenuDicts;
|
||||
state->menuDicts[loc] = wstr;
|
||||
++state->nMenuDicts;
|
||||
}
|
||||
|
||||
return XP_FALSE;
|
||||
} /* addDictToState */
|
||||
|
||||
static void
|
||||
addDictsToMenu( GameInfoState* giState )
|
||||
addDictsToMenu( GameInfoState* state )
|
||||
{
|
||||
wchar_t* shortname;
|
||||
wchar_t shortPath[CE_MAX_PATH_LEN+1];
|
||||
XP_U16 i, nMenuDicts = giState->nMenuDicts;
|
||||
XP_U16 i, nMenuDicts = state->nMenuDicts;
|
||||
XP_S16 sel = 0;
|
||||
CEAppGlobals* globals = giState->dlgHdr.globals;
|
||||
CEAppGlobals* globals = state->dlgHdr.globals;
|
||||
|
||||
/* insert the short names in the menu */
|
||||
for ( i = 0; i < nMenuDicts; ++i ) {
|
||||
wchar_t* wPath = giState->menuDicts[i];
|
||||
wchar_t* wPath = state->menuDicts[i];
|
||||
shortname = wbname( shortPath, sizeof(shortPath), wPath );
|
||||
SendDlgItemMessage( giState->dlgHdr.hDlg, giState->dictListId,
|
||||
SendDlgItemMessage( state->dlgHdr.hDlg, state->dictListId,
|
||||
ADDSTRING(globals), 0, (long)shortname );
|
||||
|
||||
if ( giState->newDictName[0] != 0 && sel == 0 ) {
|
||||
if ( state->newDictName[0] != 0 && sel == 0 ) {
|
||||
XP_UCHAR buf[CE_MAX_PATH_LEN+1];
|
||||
WideCharToMultiByte( CP_ACP, 0, wPath, -1, buf, sizeof(buf),
|
||||
NULL, NULL );
|
||||
if ( 0 == XP_STRCMP( buf, giState->newDictName ) ) {
|
||||
if ( 0 == XP_STRCMP( buf, state->newDictName ) ) {
|
||||
sel = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SendDlgItemMessage( giState->dlgHdr.hDlg, giState->dictListId,
|
||||
SendDlgItemMessage( state->dlgHdr.hDlg, state->dictListId,
|
||||
SETCURSEL(globals), sel, 0L );
|
||||
} /* addDictsToMenu */
|
||||
|
||||
static void
|
||||
cleanupGameInfoState( GameInfoState* giState )
|
||||
cleanupGameInfoState( GameInfoState* state )
|
||||
{
|
||||
if ( !!giState->menuDicts ) {
|
||||
XP_U16 nMenuDicts = giState->nMenuDicts;
|
||||
if ( !!state->menuDicts ) {
|
||||
XP_U16 nMenuDicts = state->nMenuDicts;
|
||||
XP_U16 i;
|
||||
for ( i = 0; i < nMenuDicts; ++i ) {
|
||||
XP_FREE( giState->dlgHdr.globals->mpool, giState->menuDicts[i] );
|
||||
XP_FREE( state->dlgHdr.globals->mpool, state->menuDicts[i] );
|
||||
}
|
||||
XP_FREE( giState->dlgHdr.globals->mpool, giState->menuDicts );
|
||||
giState->menuDicts = NULL;
|
||||
XP_FREE( state->dlgHdr.globals->mpool, state->menuDicts );
|
||||
state->menuDicts = NULL;
|
||||
}
|
||||
|
||||
if ( !!giState->moveIds ) {
|
||||
XP_FREE( giState->dlgHdr.globals->mpool, giState->moveIds );
|
||||
giState->moveIds = NULL;
|
||||
if ( !!state->moveIds ) {
|
||||
XP_FREE( state->dlgHdr.globals->mpool, state->moveIds );
|
||||
state->moveIds = NULL;
|
||||
}
|
||||
} /* cleanupGameInfoState */
|
||||
|
||||
static void
|
||||
loadFromGameInfo( GameInfoState* giState )
|
||||
loadFromGameInfo( GameInfoState* state )
|
||||
{
|
||||
XP_U16 i;
|
||||
CEAppGlobals* globals = giState->dlgHdr.globals;
|
||||
CEAppGlobals* globals = state->dlgHdr.globals;
|
||||
CurGameInfo* gi = &globals->gameInfo;
|
||||
|
||||
#if defined XWFEATURE_RELAY || defined XWFEATURE_BLUETOOTH
|
||||
|
@ -178,57 +178,57 @@ loadFromGameInfo( GameInfoState* giState )
|
|||
wchar_t widebuf[8];
|
||||
/* put a string in the moronic combobox */
|
||||
swprintf( widebuf, L"%d", i + 1 );
|
||||
SendDlgItemMessage( giState->dlgHdr.hDlg, giState->nPlayersId,
|
||||
SendDlgItemMessage( state->dlgHdr.hDlg, state->nPlayersId,
|
||||
ADDSTRING(globals), 0,
|
||||
(long)widebuf );
|
||||
}
|
||||
|
||||
newg_load( giState->newGameCtx, gi );
|
||||
newg_load( state->newGameCtx, gi );
|
||||
|
||||
#ifndef STUBBED_DICT
|
||||
if ( !!gi->dictName ) {
|
||||
XP_MEMCPY( giState->newDictName, gi->dictName,
|
||||
XP_MEMCPY( state->newDictName, gi->dictName,
|
||||
(XP_U16)XP_STRLEN(gi->dictName)+1 );
|
||||
}
|
||||
if ( giState->isNewGame ) {
|
||||
(void)ceLocateNDicts( globals, CE_MAXDICTS, addDictToState, giState );
|
||||
if ( state->isNewGame ) {
|
||||
(void)ceLocateNDicts( globals, CE_MAXDICTS, addDictToState, state );
|
||||
} else {
|
||||
wchar_t wPath[CE_MAX_PATH_LEN+1];
|
||||
XP_ASSERT( gi->dictName[0] != '\0' );
|
||||
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, gi->dictName, -1,
|
||||
wPath, VSIZE(wPath) );
|
||||
(void)addDictToState( wPath, 0, giState );
|
||||
(void)addDictToState( wPath, 0, state );
|
||||
}
|
||||
addDictsToMenu( giState );
|
||||
addDictsToMenu( state );
|
||||
#endif
|
||||
|
||||
if ( !giState->isNewGame ) {
|
||||
ceEnOrDisable( giState->dlgHdr.hDlg, giState->dictListId, XP_FALSE );
|
||||
if ( !state->isNewGame ) {
|
||||
ceEnOrDisable( state->dlgHdr.hDlg, state->dictListId, XP_FALSE );
|
||||
}
|
||||
} /* loadFromGameInfo */
|
||||
|
||||
static XP_Bool
|
||||
stateToGameInfo( GameInfoState* giState )
|
||||
stateToGameInfo( GameInfoState* state )
|
||||
{
|
||||
CEAppGlobals* globals = giState->dlgHdr.globals;
|
||||
CEAppGlobals* globals = state->dlgHdr.globals;
|
||||
CurGameInfo* gi = &globals->gameInfo;
|
||||
HWND hDlg = giState->dlgHdr.hDlg;
|
||||
HWND hDlg = state->dlgHdr.hDlg;
|
||||
XP_Bool timerOn;
|
||||
XP_Bool success = newg_store( giState->newGameCtx, gi, XP_TRUE );
|
||||
XP_Bool success = newg_store( state->newGameCtx, gi, XP_TRUE );
|
||||
|
||||
if ( success ) {
|
||||
|
||||
/* dictionary */ {
|
||||
int sel;
|
||||
sel = SendDlgItemMessage( hDlg, giState->dictListId,
|
||||
sel = SendDlgItemMessage( hDlg, state->dictListId,
|
||||
GETCURSEL(globals), 0, 0L );
|
||||
if ( sel >= 0 ) {
|
||||
WideCharToMultiByte( CP_ACP, 0, giState->menuDicts[sel], -1,
|
||||
giState->newDictName,
|
||||
sizeof(giState->newDictName), NULL, NULL );
|
||||
WideCharToMultiByte( CP_ACP, 0, state->menuDicts[sel], -1,
|
||||
state->newDictName,
|
||||
sizeof(state->newDictName), NULL, NULL );
|
||||
}
|
||||
replaceStringIfDifferent( globals->mpool, &gi->dictName,
|
||||
giState->newDictName );
|
||||
state->newDictName );
|
||||
}
|
||||
|
||||
/* timer */
|
||||
|
@ -245,9 +245,9 @@ stateToGameInfo( GameInfoState* giState )
|
|||
}
|
||||
|
||||
/* preferences */
|
||||
if ( giState->prefsChanged ) {
|
||||
if ( state->prefsChanged ) {
|
||||
loadCurPrefsFromState( globals, &globals->appPrefs, gi,
|
||||
&giState->prefsPrefs );
|
||||
&state->prefsPrefs );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -260,14 +260,14 @@ stateToGameInfo( GameInfoState* giState )
|
|||
#endif
|
||||
|
||||
static void
|
||||
raiseForHiddenPlayers( GameInfoState* giState, XP_U16 nPlayers )
|
||||
raiseForHiddenPlayers( GameInfoState* state, XP_U16 nPlayers )
|
||||
{
|
||||
HWND hDlg = giState->dlgHdr.hDlg;
|
||||
HWND hDlg = state->dlgHdr.hDlg;
|
||||
XP_U16 ii;
|
||||
XP_S16 moveY;
|
||||
|
||||
if ( nPlayers != giState->prevNPlayers ) {
|
||||
if ( !giState->moveIds ) {
|
||||
if ( nPlayers != state->prevNPlayers ) {
|
||||
if ( !state->moveIds ) {
|
||||
XP_S16 ids[32];
|
||||
HWND child;
|
||||
RECT rect;
|
||||
|
@ -276,7 +276,7 @@ raiseForHiddenPlayers( GameInfoState* giState, XP_U16 nPlayers )
|
|||
ceGetItemRect( hDlg, NAME_EDIT4, &rect );
|
||||
playersBottom = rect.bottom;
|
||||
ceGetItemRect( hDlg, NAME_EDIT3, &rect );
|
||||
giState->playersSpacing = playersBottom - rect.bottom;
|
||||
state->playersSpacing = playersBottom - rect.bottom;
|
||||
|
||||
for ( child = GetWindow( hDlg, GW_CHILD ), ii = 0;
|
||||
!!child;
|
||||
|
@ -291,21 +291,21 @@ raiseForHiddenPlayers( GameInfoState* giState, XP_U16 nPlayers )
|
|||
}
|
||||
}
|
||||
}
|
||||
giState->moveIds = XP_MALLOC( giState->dlgHdr.globals->mpool,
|
||||
sizeof(giState->moveIds[0]) * ii );
|
||||
XP_MEMCPY( giState->moveIds, ids,
|
||||
sizeof(giState->moveIds[0]) * ii );
|
||||
giState->nMoveIds = ii;
|
||||
state->moveIds = XP_MALLOC( state->dlgHdr.globals->mpool,
|
||||
sizeof(state->moveIds[0]) * ii );
|
||||
XP_MEMCPY( state->moveIds, ids,
|
||||
sizeof(state->moveIds[0]) * ii );
|
||||
state->nMoveIds = ii;
|
||||
}
|
||||
|
||||
moveY = giState->playersSpacing * (nPlayers - giState->prevNPlayers);
|
||||
for ( ii = 0; ii < giState->nMoveIds; ++ii ) {
|
||||
ceMoveItem( hDlg, giState->moveIds[ii], 0, moveY );
|
||||
moveY = state->playersSpacing * (nPlayers - state->prevNPlayers);
|
||||
for ( ii = 0; ii < state->nMoveIds; ++ii ) {
|
||||
ceMoveItem( hDlg, state->moveIds[ii], 0, moveY );
|
||||
}
|
||||
giState->prevNPlayers = nPlayers;
|
||||
state->prevNPlayers = nPlayers;
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
if ( IS_SMARTPHONE(giState->dlgHdr.globals) ) {
|
||||
if ( IS_SMARTPHONE(state->dlgHdr.globals) ) {
|
||||
SendMessage( hDlg, DM_RESETSCROLL, (WPARAM)FALSE, (LPARAM)TRUE );
|
||||
}
|
||||
#endif
|
||||
|
@ -313,18 +313,18 @@ raiseForHiddenPlayers( GameInfoState* giState, XP_U16 nPlayers )
|
|||
}
|
||||
|
||||
static void
|
||||
handlePrefsButton( HWND hDlg, CEAppGlobals* globals, GameInfoState* giState )
|
||||
handlePrefsButton( HWND hDlg, CEAppGlobals* globals, GameInfoState* state )
|
||||
{
|
||||
CePrefsDlgState state;
|
||||
CePrefsDlgState prefsState;
|
||||
|
||||
/* need to keep my stuff in a temporary place and to read back out of it
|
||||
if launched a second time before the user's cancelled or not out of
|
||||
the calling dlg.*/
|
||||
|
||||
if ( WrapPrefsDialog( hDlg, globals, &state, &giState->prefsPrefs,
|
||||
giState->isNewGame ) ) {
|
||||
giState->prefsChanged = XP_TRUE;
|
||||
giState->colorsChanged = state.colorsChanged;
|
||||
if ( WrapPrefsDialog( hDlg, globals, &prefsState, &state->prefsPrefs,
|
||||
state->isNewGame ) ) {
|
||||
state->prefsChanged = XP_TRUE;
|
||||
state->colorsChanged = prefsState.colorsChanged;
|
||||
/* nothing to do until user finally does confirm the parent dialog */
|
||||
}
|
||||
} /* handlePrefsButton */
|
||||
|
@ -332,15 +332,15 @@ handlePrefsButton( HWND hDlg, CEAppGlobals* globals, GameInfoState* giState )
|
|||
#if defined XWFEATURE_RELAY || defined XWFEATURE_BLUETOOTH
|
||||
static void
|
||||
handleConnOptionsButton( HWND hDlg, CEAppGlobals* globals,
|
||||
DeviceRole role, GameInfoState* giState )
|
||||
DeviceRole role, GameInfoState* state )
|
||||
{
|
||||
CeConnDlgState state;
|
||||
|
||||
if ( WrapConnsDlg( hDlg, globals, &giState->prefsPrefs.addrRec,
|
||||
if ( WrapConnsDlg( hDlg, globals, &state->prefsPrefs.addrRec,
|
||||
role, &state ) ) {
|
||||
XP_MEMCPY( &giState->prefsPrefs.addrRec, &state.addrRec,
|
||||
sizeof(giState->prefsPrefs.addrRec) );
|
||||
giState->addrChanged = XP_TRUE;
|
||||
XP_MEMCPY( &state->prefsPrefs.addrRec, &state.addrRec,
|
||||
sizeof(state->prefsPrefs.addrRec) );
|
||||
state->addrChanged = XP_TRUE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -412,17 +412,17 @@ static void
|
|||
ceEnableColProc( void* closure, XP_U16 player, NewGameColumn col,
|
||||
XP_TriEnable enable )
|
||||
{
|
||||
GameInfoState* giState = (GameInfoState*)closure;
|
||||
GameInfoState* state = (GameInfoState*)closure;
|
||||
XP_U16 resID = resIDForCol( player, col );
|
||||
doForNWEnable( giState->dlgHdr.hDlg, resID, enable );
|
||||
doForNWEnable( state->dlgHdr.hDlg, resID, enable );
|
||||
}
|
||||
|
||||
static void
|
||||
ceEnableAttrProc( void* closure, NewGameAttr attr, XP_TriEnable enable )
|
||||
{
|
||||
GameInfoState* giState = (GameInfoState*)closure;
|
||||
XP_U16 resID = resIDForAttr( giState, attr );
|
||||
doForNWEnable( giState->dlgHdr.hDlg, resID, enable );
|
||||
GameInfoState* state = (GameInfoState*)closure;
|
||||
XP_U16 resID = resIDForAttr( state, attr );
|
||||
doForNWEnable( state->dlgHdr.hDlg, resID, enable );
|
||||
} /* ceEnableAttrProc */
|
||||
|
||||
static void
|
||||
|
@ -430,7 +430,7 @@ ceGetColProc( void* closure, XP_U16 player, NewGameColumn col,
|
|||
NgCpCallbk cpcb, const void* cpClosure )
|
||||
{
|
||||
NGValue value;
|
||||
GameInfoState* giState = (GameInfoState*)closure;
|
||||
GameInfoState* state = (GameInfoState*)closure;
|
||||
XP_U16 resID = resIDForCol( player, col );
|
||||
XP_UCHAR txt[128];
|
||||
XP_U16 len;
|
||||
|
@ -440,12 +440,12 @@ ceGetColProc( void* closure, XP_U16 player, NewGameColumn col,
|
|||
case NG_COL_REMOTE:
|
||||
#endif
|
||||
case NG_COL_ROBOT:
|
||||
value.ng_bool = ceGetChecked( giState->dlgHdr.hDlg, resID );
|
||||
value.ng_bool = ceGetChecked( state->dlgHdr.hDlg, resID );
|
||||
break;
|
||||
case NG_COL_NAME:
|
||||
case NG_COL_PASSWD:
|
||||
len = sizeof(txt);
|
||||
ceGetDlgItemText( giState->dlgHdr.hDlg, resID, txt, &len );
|
||||
ceGetDlgItemText( state->dlgHdr.hDlg, resID, txt, &len );
|
||||
value.ng_cp = &txt[0];
|
||||
break;
|
||||
default:
|
||||
|
@ -459,7 +459,7 @@ static void
|
|||
ceSetColProc( void* closure, XP_U16 player, NewGameColumn col,
|
||||
const NGValue value )
|
||||
{
|
||||
GameInfoState* giState = (GameInfoState*)closure;
|
||||
GameInfoState* state = (GameInfoState*)closure;
|
||||
XP_U16 resID = resIDForCol( player, col );
|
||||
const XP_UCHAR* cp;
|
||||
XP_UCHAR buf[16];
|
||||
|
@ -470,18 +470,18 @@ ceSetColProc( void* closure, XP_U16 player, NewGameColumn col,
|
|||
if ( NULL != value.ng_cp ) {
|
||||
cp = value.ng_cp;
|
||||
} else if ( col == NG_COL_NAME ) {
|
||||
snprintf( buf, sizeof(buf), "Player %d", player + 1 );
|
||||
cp = buf;
|
||||
snprintf( cp, sizeof(buf), "Player %d", player + 1 );
|
||||
} else {
|
||||
cp = "";
|
||||
}
|
||||
ceSetDlgItemText( giState->dlgHdr.hDlg, resID, cp );
|
||||
ceSetDlgItemText( state->dlgHdr.hDlg, resID, cp );
|
||||
break;
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
case NG_COL_REMOTE:
|
||||
#endif
|
||||
case NG_COL_ROBOT:
|
||||
ceSetChecked( giState->dlgHdr.hDlg, resID, value.ng_bool );
|
||||
ceSetChecked( state->dlgHdr.hDlg, resID, value.ng_bool );
|
||||
break;
|
||||
default:
|
||||
XP_ASSERT(0);
|
||||
|
@ -491,25 +491,25 @@ ceSetColProc( void* closure, XP_U16 player, NewGameColumn col,
|
|||
static void
|
||||
ceSetAttrProc(void* closure, NewGameAttr attr, const NGValue value )
|
||||
{
|
||||
GameInfoState* giState = (GameInfoState*)closure;
|
||||
XP_U16 resID = resIDForAttr( giState, attr );
|
||||
CEAppGlobals* globals = giState->dlgHdr.globals;
|
||||
GameInfoState* state = (GameInfoState*)closure;
|
||||
XP_U16 resID = resIDForAttr( state, attr );
|
||||
CEAppGlobals* globals = state->dlgHdr.globals;
|
||||
|
||||
switch ( attr ) {
|
||||
case NG_ATTR_NPLAYERS:
|
||||
SendDlgItemMessage( giState->dlgHdr.hDlg, resID,
|
||||
SendDlgItemMessage( state->dlgHdr.hDlg, resID,
|
||||
SETCURSEL(globals),
|
||||
value.ng_u16 - 1, 0L );
|
||||
raiseForHiddenPlayers( giState, value.ng_u16 );
|
||||
raiseForHiddenPlayers( state, value.ng_u16 );
|
||||
break;
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
case NG_ATTR_ROLE:
|
||||
SendDlgItemMessage( giState->dlgHdr.hDlg, resID, SETCURSEL(globals),
|
||||
SendDlgItemMessage( state->dlgHdr.hDlg, resID, SETCURSEL(globals),
|
||||
value.ng_role, 0L );
|
||||
break;
|
||||
#endif
|
||||
case NG_ATTR_NPLAYHEADER:
|
||||
ceSetDlgItemText( giState->dlgHdr.hDlg, resID, value.ng_cp );
|
||||
ceSetDlgItemText( state->dlgHdr.hDlg, resID, value.ng_cp );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -525,14 +525,14 @@ playerFromID( XP_U16 id, XP_U16 base )
|
|||
}
|
||||
|
||||
static void
|
||||
handleColChecked( GameInfoState* giState, XP_U16 id, XP_U16 base )
|
||||
handleColChecked( GameInfoState* state, XP_U16 id, XP_U16 base )
|
||||
{
|
||||
NGValue value;
|
||||
XP_U16 player = playerFromID( id, base );
|
||||
|
||||
value.ng_bool = ceGetChecked( giState->dlgHdr.hDlg, id );
|
||||
value.ng_bool = ceGetChecked( state->dlgHdr.hDlg, id );
|
||||
|
||||
newg_colChanged( giState->newGameCtx, player );
|
||||
newg_colChanged( state->newGameCtx, player );
|
||||
}
|
||||
|
||||
/* It's too much work at this point to get the icon button looking good,
|
||||
|
@ -554,20 +554,20 @@ ceDrawIconButton( CEAppGlobals* globals, DRAWITEMSTRUCT* dis )
|
|||
#endif
|
||||
|
||||
static void
|
||||
checkUpdateCombo( GameInfoState* giState, XP_U16 id )
|
||||
checkUpdateCombo( GameInfoState* state, XP_U16 id )
|
||||
{
|
||||
if ( (id == giState->nPlayersId)
|
||||
&& giState->isNewGame ) { /* ignore if in info mode */
|
||||
if ( (id == state->nPlayersId)
|
||||
&& state->isNewGame ) { /* ignore if in info mode */
|
||||
NGValue value;
|
||||
XP_U16 nPlayers = 1 + (XP_U16)
|
||||
SendDlgItemMessage( giState->dlgHdr.hDlg, id,
|
||||
GETCURSEL(giState->dlgHdr.globals), 0, 0L);
|
||||
SendDlgItemMessage( state->dlgHdr.hDlg, id,
|
||||
GETCURSEL(state->dlgHdr.globals), 0, 0L);
|
||||
value.ng_u16 = nPlayers;
|
||||
XP_ASSERT( !!giState->newGameCtx );
|
||||
newg_attrChanged( giState->newGameCtx,
|
||||
XP_ASSERT( !!state->newGameCtx );
|
||||
newg_attrChanged( state->newGameCtx,
|
||||
NG_ATTR_NPLAYERS, value );
|
||||
|
||||
raiseForHiddenPlayers( giState, nPlayers );
|
||||
raiseForHiddenPlayers( state, nPlayers );
|
||||
}
|
||||
} /* checkUpdateCombo */
|
||||
|
||||
|
@ -576,51 +576,51 @@ GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
{
|
||||
CEAppGlobals* globals;
|
||||
XP_U16 id;
|
||||
GameInfoState* giState;
|
||||
GameInfoState* state;
|
||||
LRESULT result = FALSE;
|
||||
|
||||
/* XP_LOGF( "%s: %s(%d)", __func__, messageToStr( message ), message ); */
|
||||
|
||||
if ( message == WM_INITDIALOG ) {
|
||||
SetWindowLongPtr( hDlg, GWL_USERDATA, lParam );
|
||||
giState = (GameInfoState*)lParam;
|
||||
globals = giState->dlgHdr.globals;
|
||||
state = (GameInfoState*)lParam;
|
||||
globals = state->dlgHdr.globals;
|
||||
|
||||
giState->nPlayersId = LB_IF_PPC(globals,IDC_NPLAYERSCOMBO);
|
||||
giState->dictListId = LB_IF_PPC(globals,IDC_DICTLIST);
|
||||
giState->prevNPlayers = MAX_NUM_PLAYERS;
|
||||
state->nPlayersId = LB_IF_PPC(globals,IDC_NPLAYERSCOMBO);
|
||||
state->dictListId = LB_IF_PPC(globals,IDC_DICTLIST);
|
||||
state->prevNPlayers = MAX_NUM_PLAYERS;
|
||||
|
||||
ceDlgSetup( &giState->dlgHdr, hDlg, DLG_STATE_TRAPBACK );
|
||||
ceDlgComboShowHide( &giState->dlgHdr, IDC_NPLAYERSCOMBO );
|
||||
ceDlgComboShowHide( &giState->dlgHdr, IDC_DICTLIST );
|
||||
ceDlgSetup( &state->dlgHdr, hDlg, DLG_STATE_TRAPBACK );
|
||||
ceDlgComboShowHide( &state->dlgHdr, IDC_NPLAYERSCOMBO );
|
||||
ceDlgComboShowHide( &state->dlgHdr, IDC_DICTLIST );
|
||||
|
||||
giState->newGameCtx = newg_make( MPPARM(globals->mpool)
|
||||
giState->isNewGame,
|
||||
state->newGameCtx = newg_make( MPPARM(globals->mpool)
|
||||
state->isNewGame,
|
||||
&globals->util,
|
||||
ceEnableColProc,
|
||||
ceEnableAttrProc,
|
||||
ceGetColProc,
|
||||
ceSetColProc,
|
||||
ceSetAttrProc,
|
||||
giState );
|
||||
state );
|
||||
|
||||
loadFromGameInfo( giState );
|
||||
loadFromGameInfo( state );
|
||||
loadStateFromCurPrefs( globals, &globals->appPrefs, &globals->gameInfo,
|
||||
&giState->prefsPrefs );
|
||||
&state->prefsPrefs );
|
||||
|
||||
if ( giState->isNewGame ) {
|
||||
if ( state->isNewGame ) {
|
||||
(void)SetWindowText( hDlg, L"New game" );
|
||||
}
|
||||
|
||||
result = TRUE;
|
||||
|
||||
} else {
|
||||
giState = (GameInfoState*)GetWindowLongPtr( hDlg, GWL_USERDATA );
|
||||
if ( !!giState ) {
|
||||
globals = giState->dlgHdr.globals;
|
||||
state = (GameInfoState*)GetWindowLongPtr( hDlg, GWL_USERDATA );
|
||||
if ( !!state ) {
|
||||
globals = state->dlgHdr.globals;
|
||||
|
||||
XP_ASSERT( hDlg == giState->dlgHdr.hDlg );
|
||||
result = ceDoDlgHandle( &giState->dlgHdr, message, wParam, lParam );
|
||||
XP_ASSERT( hDlg == state->dlgHdr.hDlg );
|
||||
result = ceDoDlgHandle( &state->dlgHdr, message, wParam, lParam );
|
||||
if ( !result ) {
|
||||
switch (message) {
|
||||
|
||||
|
@ -632,17 +632,17 @@ GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
#endif
|
||||
|
||||
case WM_NOTIFY:
|
||||
if ( !!giState->newGameCtx ) {
|
||||
checkUpdateCombo( giState, LOWORD(wParam)-1 );
|
||||
if ( !!state->newGameCtx ) {
|
||||
checkUpdateCombo( state, LOWORD(wParam)-1 );
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
result = TRUE;
|
||||
id = LOWORD(wParam);
|
||||
if ( id == giState->nPlayersId ) {
|
||||
if ( id == state->nPlayersId ) {
|
||||
if ( HIWORD(wParam) == CBN_SELCHANGE ) {
|
||||
checkUpdateCombo( giState, id );
|
||||
checkUpdateCombo( state, id );
|
||||
}
|
||||
} else {
|
||||
switch( id ) {
|
||||
|
@ -650,7 +650,7 @@ GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
case ROBOT_CHECK2:
|
||||
case ROBOT_CHECK3:
|
||||
case ROBOT_CHECK4:
|
||||
handleColChecked( giState, id, ROBOT_CHECK1 );
|
||||
handleColChecked( state, id, ROBOT_CHECK1 );
|
||||
break;
|
||||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
|
@ -658,14 +658,14 @@ GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
case REMOTE_CHECK2:
|
||||
case REMOTE_CHECK3:
|
||||
case REMOTE_CHECK4:
|
||||
handleColChecked( giState, id, REMOTE_CHECK1 );
|
||||
handleColChecked( state, id, REMOTE_CHECK1 );
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined XWFEATURE_RELAY || defined XWFEATURE_BLUETOOTH
|
||||
case IDC_ROLECOMBO:
|
||||
if ( HIWORD(wParam) == CBN_SELCHANGE ) {
|
||||
if ( giState->isNewGame ) { /* ignore if in info
|
||||
if ( state->isNewGame ) { /* ignore if in info
|
||||
mode */
|
||||
NGValue value;
|
||||
value.ng_role =
|
||||
|
@ -673,21 +673,21 @@ GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
IDC_ROLECOMBO,
|
||||
CB_GETCURSEL, 0,
|
||||
0L);
|
||||
newg_attrChanged( giState->newGameCtx,
|
||||
newg_attrChanged( state->newGameCtx,
|
||||
NG_ATTR_ROLE, value );
|
||||
/* If we've switched to a state where we'll be
|
||||
connecting */
|
||||
if ( value.ng_role != SERVER_STANDALONE ) {
|
||||
handleConnOptionsButton( hDlg, globals,
|
||||
value.ng_role,
|
||||
giState );
|
||||
state );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case GIJUGGLE_BUTTON:
|
||||
XP_ASSERT( giState->isNewGame );
|
||||
XP_ASSERT( state->isNewGame );
|
||||
/* Juggle vs switch. On Win32, updates are
|
||||
coalesced so you don't see anything on screen
|
||||
if you change a field then change it back. In
|
||||
|
@ -700,24 +700,24 @@ GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
done. So for now, we switch rather than
|
||||
juggle: call juggle until something actually
|
||||
happens. */
|
||||
while ( !newg_juggle( giState->newGameCtx ) ) {
|
||||
while ( !newg_juggle( state->newGameCtx ) ) {
|
||||
}
|
||||
break;
|
||||
|
||||
case OPTIONS_BUTTON:
|
||||
handlePrefsButton( hDlg, globals, giState );
|
||||
handlePrefsButton( hDlg, globals, state );
|
||||
break;
|
||||
|
||||
case IDOK:
|
||||
if ( !stateToGameInfo( giState ) ) {
|
||||
if ( !stateToGameInfo( state ) ) {
|
||||
break;
|
||||
}
|
||||
case IDCANCEL:
|
||||
EndDialog(hDlg, id);
|
||||
giState->userCancelled = id == IDCANCEL;
|
||||
cleanupGameInfoState( giState );
|
||||
newg_destroy( giState->newGameCtx );
|
||||
giState->newGameCtx = NULL;
|
||||
state->userCancelled = id == IDCANCEL;
|
||||
cleanupGameInfoState( state );
|
||||
newg_destroy( state->newGameCtx );
|
||||
state->newGameCtx = NULL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Reference in a new issue