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