diff --git a/wince/cecondlg.c b/wince/cecondlg.c new file mode 100755 index 000000000..d5c141b21 --- /dev/null +++ b/wince/cecondlg.c @@ -0,0 +1,122 @@ +/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ +/* + * Copyright 2005 by Eric House (fixin@peak.org). All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef XWFEATURE_STANDALONE_ONLY + +#include "cecondlg.h" +#include "ceutil.h" + +static void +ceControlsToAddrRec( HWND hDlg, CeConnDlgState* cState ) +{ + XP_U16 len; + + len = sizeof(cState->addrRec.u.ip_relay.hostName); + ceGetDlgItemText( hDlg, RELAYNAME_EDIT, + cState->addrRec.u.ip_relay.hostName, &len ); + cState->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 ); + +} + +static void +ceControlsFromAddrRec( HWND hDlg, const CeConnDlgState* cState ) +{ + XP_UCHAR* str; + + switch( cState->addrRec.conType ) { + case COMMS_CONN_RELAY: + str = L"WiFi/Cellular data"; + break; + default: + XP_LOGF( "conType is %d", cState->addrRec.conType ); + XP_ASSERT( 0 ); + str = L"bad conType"; + break; + } + SendDlgItemMessage( hDlg, IDC_CONNECTCOMBO, CB_ADDSTRING, 0, str ); + SendDlgItemMessage( hDlg, IDC_CONNECTCOMBO, CB_SETCURSEL, 0, 0L ); + + ceSetDlgItemText( hDlg, RELAYNAME_EDIT, cState->addrRec.u.ip_relay.hostName ); + ceSetDlgItemNum( hDlg, RELAYPORT_EDIT, cState->addrRec.u.ip_relay.port ); + ceSetDlgItemText( hDlg, COOKIE_EDIT, cState->addrRec.u.ip_relay.cookie ); +} + +static LRESULT CALLBACK +ConnsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) +{ + LRESULT result = FALSE; + + CeConnDlgState* cState; + CEAppGlobals* globals; + + if ( message == WM_INITDIALOG ) { + SetWindowLong( hDlg, GWL_USERDATA, lParam ); + cState = (CeConnDlgState*)lParam; + globals = cState->globals; + + ceControlsFromAddrRec( hDlg, cState ); + result = TRUE; + } else { + cState = (CeConnDlgState*)GetWindowLong( hDlg, GWL_USERDATA ); + if ( !!cState ) { + globals = cState->globals; + + if ( message == WM_COMMAND ) { + XP_U16 id = LOWORD(wParam); + + switch( id ) { + case IDOK: + ceControlsToAddrRec( hDlg, cState ); + case IDCANCEL: + EndDialog(hDlg, id); + cState->userCancelled = id == IDCANCEL; + result = TRUE; + } + } + } + } + + return result; +} /* ConnsDlg */ + +XP_Bool +WrapConnsDlg( HWND hDlg, CEAppGlobals* globals, const CommsAddrRec* addrRec, + CeConnDlgState* state ) +{ + XP_Bool result; + XP_MEMSET( state, 0, sizeof( *state ) ); + + XP_LOGF( "WrapConnsDlg" ); + + state->globals = globals; + + XP_MEMCPY( &state->addrRec, addrRec, sizeof(state->addrRec) ); + + DialogBoxParam( globals->hInst, (LPCTSTR)IDD_CONNSSDLG, hDlg, + (DLGPROC)ConnsDlg, (long)state ); + + result = !state->userCancelled; + return result; +} /* WrapConnsDlg */ + +#endif diff --git a/wince/cecondlg.h b/wince/cecondlg.h new file mode 100755 index 000000000..435ef25bf --- /dev/null +++ b/wince/cecondlg.h @@ -0,0 +1,35 @@ +/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ +/* + * Copyright 2005 by Eric House (fixin@peak.org). All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef _CECONDLG_H_ +#define _CECONDLG_H_ + +#include "comms.h" +#include "cemain.h" + +typedef struct CeConnDlgState { + CommsAddrRec addrRec; + CEAppGlobals* globals; + XP_Bool userCancelled; +} CeConnDlgState; + +XP_Bool WrapConnsDlg( HWND hDlg, CEAppGlobals* globals, + const CommsAddrRec* addrRec, CeConnDlgState* state ); + +#endif diff --git a/wince/ceginfo.c b/wince/ceginfo.c index acfa4f571..0f80dbcc2 100755 --- a/wince/ceginfo.c +++ b/wince/ceginfo.c @@ -21,10 +21,12 @@ #include "cemain.h" #include "ceutil.h" #include "cedict.h" +#include "cecondlg.h" #include "strutils.h" #define NUM_COLS 4 +#if 0 static XP_U16 ceCountLocalIn( HWND hDlg, XP_U16 nPlayers ) { @@ -39,6 +41,7 @@ ceCountLocalIn( HWND hDlg, XP_U16 nPlayers ) return nLocal; } /* ceCountLocalIn */ +#endif static void loadFromGameInfo( HWND hDlg, CEAppGlobals* globals, GameInfoState* giState ) @@ -63,9 +66,18 @@ loadFromGameInfo( HWND hDlg, CEAppGlobals* globals, GameInfoState* giState ) idToCheck = lp->isRobot? resID : 0; CheckRadioButton( hDlg, resID, resID, idToCheck ); +#ifndef XWFEATURE_STANDALONE_ONLY + /* set the remote checkbox */ + resID = REMOTE_CHECK1 + (NUM_COLS*i); + idToCheck = lp->isLocal? 0 : resID; + CheckRadioButton( hDlg, resID, resID, idToCheck ); +#endif + /* set the player name */ - resID = NAME_EDIT1 + (NUM_COLS*i); - ceSetDlgItemText( hDlg, resID, lp->name ); + if ( lp->name != NULL ) { + resID = NAME_EDIT1 + (NUM_COLS*i); + ceSetDlgItemText( hDlg, resID, lp->name ); + } /* set the password, if any */ @@ -81,12 +93,12 @@ loadFromGameInfo( HWND hDlg, CEAppGlobals* globals, GameInfoState* giState ) gi->nPlayers-1, 0L ); #ifndef XWFEATURE_STANDALONE_ONLY - for ( i = 0; i < 3; ++i ) { + for ( i = 0; i < (sizeof(roles)/sizeof(roles[0])); ++i ) { SendDlgItemMessage( hDlg, IDC_ROLECOMBO, CB_ADDSTRING, 0, (long)roles[i] ); } SendDlgItemMessage( hDlg, IDC_ROLECOMBO, CB_SETCURSEL, - gi->serverRole, 0L ); + giState->curServerHilite, 0L ); #endif /* set the dictionary name */ @@ -114,6 +126,7 @@ loadFromGameInfo( HWND hDlg, CEAppGlobals* globals, GameInfoState* giState ) if ( !giState->isNewGame ) { XP_U16 disableIDs[] = { IDC_NPLAYERSCOMBO, + IDC_ROLECOMBO, IDC_DICTBUTTON}; XP_U16 i; for( i = 0; i < sizeof(disableIDs)/sizeof(disableIDs[0]); ++i ) { @@ -195,6 +208,7 @@ countAndSetRemote( HWND hDlg, XP_U16 nPlayers, XP_Bool counterWins, static XP_Bool ceAdjustVisibility( HWND hDlg, GameInfoState* giState, XP_Bool counterWins ) { + XP_Bool result; Connectedness serverRole = (Connectedness) SendDlgItemMessage( hDlg, IDC_ROLECOMBO, CB_GETCURSEL, 0, 0L ); XP_U16 nToDraw = MAX_NUM_PLAYERS; @@ -256,12 +270,17 @@ ceAdjustVisibility( HWND hDlg, GameInfoState* giState, XP_Bool counterWins ) if ( !counterWins ) { (void)SendDlgItemMessage( hDlg, IDC_NPLAYERSCOMBO, CB_SETCURSEL, nDrawn - 1, 0L ); - return XP_TRUE; + result = XP_TRUE; } else { XP_ASSERT( nDrawn <= nToDraw ); - return nDrawn == nToDraw; + result = nDrawn == nToDraw; } - + +#ifndef XWFEATURE_STANDALONE_ONLY + ceShowOrHide( hDlg, IDC_CONNBUTTON, serverRole != SERVER_STANDALONE ); +#endif + + return result; } /* ceAdjustVisibility */ static void @@ -288,6 +307,8 @@ stateToGameInfo( HWND hDlg, CEAppGlobals* globals, GameInfoState* giState ) Connectedness curServerHilite = (Connectedness )SendDlgItemMessage( hDlg, IDC_ROLECOMBO, CB_GETCURSEL, 0, 0L ); + XP_ASSERT( curServerHilite == giState->curServerHilite ); + gi->serverRole = curServerHilite; nPlayers = 1 + (XP_U16)SendDlgItemMessage( hDlg, IDC_NPLAYERSCOMBO, CB_GETCURSEL, 0, 0 ); @@ -299,12 +320,14 @@ stateToGameInfo( HWND hDlg, CEAppGlobals* globals, GameInfoState* giState ) XP_Bool checked; LocalPlayer* lp = &gi->players[i]; +#ifndef XWFEATURE_STANDALONE_ONLY if ( curServerHilite == SERVER_ISSERVER ) { id = REMOTE_CHECK1 + offset; lp->isLocal = !ceGetChecked( hDlg, id ); } else { lp->isLocal = XP_TRUE; } +#endif /* robot */ id = ROBOT_CHECK1 + offset; @@ -339,7 +362,8 @@ stateToGameInfo( HWND hDlg, CEAppGlobals* globals, GameInfoState* giState ) /* preferences */ if ( giState->prefsChanged ) { - loadCurPrefsFromState( &globals->appPrefs, gi, &giState->prefsPrefs ); + loadCurPrefsFromState( globals, &globals->appPrefs, gi, + &giState->prefsPrefs ); } } /* stateToGameInfo */ @@ -361,6 +385,21 @@ handleOptionsButton( HWND hDlg, CEAppGlobals* globals, GameInfoState* giState ) } } /* handleOptionsButton */ +#ifndef XWFEATURE_STANDALONE_ONLY +static void +handleConnOptionsButton( HWND hDlg, CEAppGlobals* globals, + GameInfoState* giState ) +{ + CeConnDlgState state; + + if ( WrapConnsDlg( hDlg, globals, &giState->prefsPrefs.addrRec, &state ) ) { + XP_MEMCPY( &giState->prefsPrefs.addrRec, &state.addrRec, + sizeof(giState->prefsPrefs.addrRec) ); + giState->addrChanged = XP_TRUE; + } +} +#endif + /* playersFollowCounts: * Force the data on players into sync with the counts. This is really only * an issue if a local/remote change has happened. Meant to be called after @@ -413,7 +452,7 @@ GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) globals = giState->globals; loadFromGameInfo( hDlg, globals, giState ); - loadStateFromCurPrefs( &globals->appPrefs, &globals->gameInfo, + loadStateFromCurPrefs( globals, &globals->appPrefs, &globals->gameInfo, &giState->prefsPrefs ); ceAdjustVisibility( hDlg, giState, XP_FALSE ); @@ -453,15 +492,18 @@ GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case IDC_NPLAYERSCOMBO: if ( HIWORD(wParam) == CBN_SELCHANGE ) { - if ( giState->isNewGame ) { /* ignore if in info mode */ + if ( giState->isNewGame ) { /* ignore if in info mode */ XP_U16 role; XP_U16 sel; sel = (XP_U16)SendDlgItemMessage( hDlg, IDC_NPLAYERSCOMBO, - CB_GETCURSEL, 0, 0L); + CB_GETCURSEL, + 0, 0L); ++sel; - role = (XP_U16)SendDlgItemMessage( hDlg, IDC_ROLECOMBO, - CB_GETCURSEL, 0, 0L); + role = (XP_U16)SendDlgItemMessage( hDlg, + IDC_ROLECOMBO, + CB_GETCURSEL, + 0, 0L); ceAdjustVisibility( hDlg, giState, XP_TRUE ); } } @@ -469,16 +511,24 @@ GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case IDC_ROLECOMBO: if ( HIWORD(wParam) == CBN_SELCHANGE ) { - if ( giState->isNewGame ) { /* ignore if in info mode */ + if ( giState->isNewGame ) { /* ignore if in info mode */ XP_U16 sel; sel = (XP_U16)SendDlgItemMessage( hDlg, IDC_ROLECOMBO, - CB_GETCURSEL, 0, 0L); + CB_GETCURSEL, 0, + 0L); giState->curServerHilite = (Connectedness)sel; ceAdjustVisibility( hDlg, giState, XP_FALSE ); } } break; +#ifndef XWFEATURE_STANDALONE_ONLY + case IDC_CONNBUTTON: + XP_LOGF( "calling handleConnOptionsButton" ); + handleConnOptionsButton( hDlg, globals, giState ); + break; +#endif + #ifndef STUBBED_DICT case IDC_DICTBUTTON: if ( giState->isNewGame ) { /* ignore if in info mode */ diff --git a/wince/ceginfo.h b/wince/ceginfo.h index 7767f5417..2796c4d9d 100755 --- a/wince/ceginfo.h +++ b/wince/ceginfo.h @@ -33,6 +33,7 @@ typedef struct GameInfoState { XP_Bool prefsChanged; XP_Bool colorsChanged; + XP_Bool addrChanged; Connectedness curServerHilite; CePrefsPrefs prefsPrefs; } GameInfoState; diff --git a/wince/cemain.c b/wince/cemain.c index ce8ea772c..42f2dbae2 100755 --- a/wince/cemain.c +++ b/wince/cemain.c @@ -73,6 +73,9 @@ typedef struct FileWriteState { } FileWriteState; /* forward util function decls */ +static XP_S16 ce_send_proc( XP_U8* buf, XP_U16 len, CommsAddrRec* addr, + void* closure ); + static VTableMgr* ce_util_getVTManager( XW_UtilCtxt* uc ); static void ce_util_userError( XW_UtilCtxt* uc, UtilErrID id ); static XP_Bool ce_util_userQuery( XW_UtilCtxt* uc, UtilQueryID id, @@ -104,6 +107,11 @@ static XWStreamCtxt* ce_util_makeStreamFromAddr( XW_UtilCtxt* uc, static XP_UCHAR* ce_util_getUserString( XW_UtilCtxt* uc, XP_U16 stringCode ); static XP_Bool ce_util_warnIllegalWord( XW_UtilCtxt* uc, BadWordInfo* bwi, XP_U16 turn, XP_Bool turnLost ); +#ifdef BEYOND_IR +static void ce_util_addrChange( XW_UtilCtxt* uc, const CommsAddrRec* oldAddr, + const CommsAddrRec* newAddr ); +#endif + #ifdef XWFEATURE_SEARCHLIMIT static XP_Bool ce_util_getTraySearchLimits( XW_UtilCtxt* uc, XP_U16* min, XP_U16* max ); @@ -247,6 +255,9 @@ ceInitUtilFuncs( CEAppGlobals* globals ) vtable->m_util_makeEmptyDict = ce_util_makeEmptyDict; vtable->m_util_getUserString = ce_util_getUserString; vtable->m_util_warnIllegalWord = ce_util_warnIllegalWord; +#ifdef BEYOND_IR + vtable->m_util_addrChange = ce_util_addrChange; +#endif #ifdef XWFEATURE_SEARCHLIMIT vtable->m_util_getTraySearchLimits = ce_util_getTraySearchLimits; #endif @@ -484,7 +495,8 @@ ceSetTitleFromName( CEAppGlobals* globals ) } /* ceSetTitleFromName */ static void -ceInitAndStartBoard( CEAppGlobals* globals, XP_Bool newGame, CeGamePrefs* gp ) +ceInitAndStartBoard( CEAppGlobals* globals, XP_Bool newGame, CeGamePrefs* gp, + const CommsAddrRec* addr ) { DictionaryCtxt* dict; XP_UCHAR* newDictName = globals->gameInfo.dictName; @@ -522,13 +534,19 @@ ceInitAndStartBoard( CEAppGlobals* globals, XP_Bool newGame, CeGamePrefs* gp ) if ( newGame ) { XP_U16 newGameID = 0; game_reset( MEMPOOL &globals->game, &globals->gameInfo, &globals->util, - newGameID, &globals->appPrefs.cp, (TransportSend)NULL, + newGameID, &globals->appPrefs.cp, ce_send_proc, globals ); if ( !!gp ) { globals->gameInfo.hintsNotAllowed = gp->hintsNotAllowed; globals->gameInfo.robotSmartness = gp->robotSmartness; } + +#ifndef XWFEATURE_STANDALONE_ONLY + if ( !!addr ) { + comms_setAddr( globals->game.comms, addr ); + } +#endif } XP_ASSERT( !!globals->game.board ); @@ -747,7 +765,7 @@ ceLoadSavedGame( CEAppGlobals* globals ) game_makeFromStream( MEMPOOL stream, &globals->game, &globals->gameInfo, dict, &globals->util, globals->draw, - &globals->appPrefs.cp, ce_ir_send, globals ); + &globals->appPrefs.cp, ce_send_proc, globals ); } stream_destroy( stream ); @@ -756,15 +774,6 @@ ceLoadSavedGame( CEAppGlobals* globals ) return success; } /* ceLoadSavedGame */ -#ifndef XWFEATURE_STANDALONE_ONLY -XP_S16 -ce_ir_send( XP_U8* buf, XP_U16 len, CommsAddrRec* addr, void* closure ) -{ - XP_DEBUGF( "ce_ir_send called" ); - return -1; -} /* ce_ir_send */ -#endif - static void colorsFromRsrc( CEAppGlobals* globals ) { @@ -911,7 +920,7 @@ InitInstance(HINSTANCE hInstance, int nCmdShow) game_makeNewGame( MPPARM(mpool) &globals->game, &globals->gameInfo, &globals->util, globals->draw, gameID, &globals->appPrefs.cp, - (TransportSend)NULL, globals ); + ce_send_proc, globals ); newDone = doNewGame( globals, XP_TRUE ); /* calls ceInitAndStartBoard */ if ( !newDone ) { @@ -926,7 +935,7 @@ InitInstance(HINSTANCE hInstance, int nCmdShow) } if ( result && !newDone ) { - ceInitAndStartBoard( globals, !oldGameLoaded, NULL ); + ceInitAndStartBoard( globals, !oldGameLoaded, NULL, NULL ); } return result; @@ -1051,6 +1060,7 @@ static XP_Bool doNewGame( CEAppGlobals* globals, XP_Bool silent ) { GameInfoState giState; + CommsAddrRec* addr = NULL; XP_Bool changed = XP_FALSE; /* What happens if user cancels below? I'm hosed without a name, no? @@ -1074,13 +1084,19 @@ doNewGame( CEAppGlobals* globals, XP_Bool silent ) ) { if ( giState.prefsChanged ) { - loadCurPrefsFromState( &globals->appPrefs, &globals->gameInfo, - &giState.prefsPrefs ); + loadCurPrefsFromState( globals, &globals->appPrefs, + &globals->gameInfo, &giState.prefsPrefs ); if ( giState.colorsChanged ) { updateForColors( globals ); } } - ceInitAndStartBoard( globals, XP_TRUE, NULL ); +#ifndef XWFEATURE_STANDALONE_ONLY + if ( giState.addrChanged ) { + addr = &giState.prefsPrefs.addrRec; + } +#endif + + ceInitAndStartBoard( globals, XP_TRUE, NULL, addr ); changed = XP_TRUE; } @@ -1130,7 +1146,7 @@ ceChooseAndOpen( CEAppGlobals* globals ) globals->curGameName = name; ceLoadSavedGame( globals ); - ceInitAndStartBoard( globals, XP_FALSE, NULL ); + ceInitAndStartBoard( globals, XP_FALSE, NULL, NULL ); ceSetTitleFromName( globals ); } } @@ -1153,7 +1169,7 @@ ceDoPrefsDlg( CEAppGlobals* globals ) XP_MEMSET( &state, 0, sizeof(state) ); - loadStateFromCurPrefs( &globals->appPrefs, &globals->gameInfo, + loadStateFromCurPrefs( globals, &globals->appPrefs, &globals->gameInfo, &prefsPrefs ); (void)WrapPrefsDialog( globals->hWnd, globals, &state, &prefsPrefs, @@ -1161,7 +1177,7 @@ ceDoPrefsDlg( CEAppGlobals* globals ) if ( !state.userCancelled ) { - loadCurPrefsFromState( &globals->appPrefs, &globals->gameInfo, + loadCurPrefsFromState( globals, &globals->appPrefs, &globals->gameInfo, &prefsPrefs ); (void)cePositionBoard( globals ); @@ -1928,6 +1944,13 @@ wince_snprintf( XP_UCHAR* buf, XP_U16 len, XP_UCHAR* format, ... ) return strlen(buf); } /* wince_snprintf */ +static XP_S16 +ce_send_proc( XP_U8* buf, XP_U16 len, CommsAddrRec* addr, void* closure ) +{ + XP_LOGF( "ce_send_proc called" ); + return 0; +} /* ce_send_proc */ + /* I can't believe the stupid compiler's making me implement this */ void p_ignore(XP_UCHAR* c, ...){} @@ -2314,6 +2337,15 @@ ce_util_warnIllegalWord( XW_UtilCtxt* uc, BadWordInfo* bwi, return isOk; } /* ce_util_warnIllegalWord */ +#ifdef BEYOND_IR +static void +ce_util_addrChange( XW_UtilCtxt* uc, const CommsAddrRec* oldAddr, + const CommsAddrRec* newAddr ) +{ + XP_LOGF( "ce_util_addrChange called; DO SOMETHING." ); +} /* ce_util_addrChange */ +#endif + #ifdef XWFEATURE_SEARCHLIMIT static XP_Bool ce_util_getTraySearchLimits( XW_UtilCtxt* uc, XP_U16* min, XP_U16* max ) diff --git a/wince/ceprefs.c b/wince/ceprefs.c index e868b9914..3c09ed8fc 100755 --- a/wince/ceprefs.c +++ b/wince/ceprefs.c @@ -106,8 +106,8 @@ adjustForChoice( HWND hDlg, CePrefsDlgState* state ) * committing should user cancel. */ void -loadStateFromCurPrefs( const CEAppPrefs* appPrefs, const CurGameInfo* gi, - CePrefsPrefs* prefsPrefs ) +loadStateFromCurPrefs( CEAppGlobals* globals, const CEAppPrefs* appPrefs, + const CurGameInfo* gi, CePrefsPrefs* prefsPrefs ) { prefsPrefs->gp.hintsNotAllowed = gi->hintsNotAllowed; prefsPrefs->gp.robotSmartness = gi->robotSmartness; @@ -125,11 +125,19 @@ loadStateFromCurPrefs( const CEAppPrefs* appPrefs, const CurGameInfo* gi, XP_MEMCPY( &prefsPrefs->cp, &appPrefs->cp, sizeof(prefsPrefs->cp) ); XP_MEMCPY( &prefsPrefs->colors, &appPrefs->colors, sizeof(prefsPrefs->colors) ); + +#ifndef XWFEATURE_STANDALONE_ONLY + if ( globals->game.comms != NULL ) { + comms_getAddr( globals->game.comms, &prefsPrefs->addrRec ); + } else { + comms_getInitialAddr( &prefsPrefs->addrRec ); + } +#endif } /* loadStateFromCurPrefs */ void -loadCurPrefsFromState( CEAppPrefs* appPrefs, CurGameInfo* gi, - const CePrefsPrefs* prefsPrefs ) +loadCurPrefsFromState( CEAppGlobals* globals, CEAppPrefs* appPrefs, + CurGameInfo* gi, const CePrefsPrefs* prefsPrefs ) { gi->hintsNotAllowed = prefsPrefs->gp.hintsNotAllowed; gi->robotSmartness = prefsPrefs->gp.robotSmartness; @@ -147,6 +155,15 @@ loadCurPrefsFromState( CEAppPrefs* appPrefs, CurGameInfo* gi, XP_MEMCPY( &appPrefs->cp, &prefsPrefs->cp, sizeof(appPrefs->cp) ); XP_MEMCPY( &appPrefs->colors, &prefsPrefs->colors, sizeof(prefsPrefs->colors) ); + +#ifndef XWFEATURE_STANDALONE_ONLY + /* I don't think this'll work... */ + if ( globals->game.comms != NULL ) { + comms_setAddr( globals->game.comms, &prefsPrefs->addrRec ); + } else { + XP_LOGF( "no comms to set addr on!!!" ); + } +#endif } /* loadCurPrefsFromState */ /* Reflect local state into the controls user will see. diff --git a/wince/ceprefs.h b/wince/ceprefs.h index f0f9ef437..b2bc46476 100755 --- a/wince/ceprefs.h +++ b/wince/ceprefs.h @@ -43,6 +43,10 @@ typedef struct CePrefsPrefs { /* per-game */ CeGamePrefs gp; +#ifndef XWFEATURE_STANDALONE_ONLY + CommsAddrRec addrRec; +#endif + /* global */ CommonPrefs cp; XP_Bool showColors; @@ -63,10 +67,10 @@ typedef struct CePrefsDlgState { XP_Bool WrapPrefsDialog( HWND hDlg, CEAppGlobals* globals, CePrefsDlgState* state, CePrefsPrefs* prefsPrefs, XP_Bool isNewGame ); -void loadStateFromCurPrefs( const CEAppPrefs* appPrefs, const CurGameInfo* gi, - CePrefsPrefs* prefsPrefs ); -void loadCurPrefsFromState( CEAppPrefs* appPrefs, CurGameInfo* gi, - const CePrefsPrefs* prefsPrefs ); +void loadStateFromCurPrefs( CEAppGlobals* globals, const CEAppPrefs* appPrefs, + const CurGameInfo* gi, CePrefsPrefs* prefsPrefs ); +void loadCurPrefsFromState( CEAppGlobals* globals, CEAppPrefs* appPrefs, + CurGameInfo* gi, const CePrefsPrefs* prefsPrefs ); LRESULT CALLBACK PrefsDlg(HWND, UINT, WPARAM, LPARAM); diff --git a/wince/resource.h b/wince/resource.h index 23871a181..2a544324d 100755 --- a/wince/resource.h +++ b/wince/resource.h @@ -3,7 +3,6 @@ // Used by xwords4.rc // #define IDS_APP_TITLE 1 -#define IDS_HELLO 2 #define IDC_XWORDS4 3 #define IDI_XWORDS4 101 #define IDM_MENU 102 @@ -26,6 +25,9 @@ #ifdef XWFEATURE_SEARCHLIMIT # define IDD_ASKHINTLIMTS 125 #endif +#ifndef XWFEATURE_STANDALONE_ONLY +# define IDD_CONNSSDLG 126 +#endif #define FLIP_BUTTON_ID 1001 #define VALUE_BUTTON_ID 1002 @@ -78,59 +80,75 @@ #define IDC_PREFCOLORS 1044 #define PHONIES_LABEL 1045 #define IDC_ROLECOMBO 1046 -#define IDC_LOCALP_LABEL 1047 -#define IDC_TOTAL_LABEL 1048 -#define IDC_REMOTE_LABEL 1049 -#define IDC_PICKTILES 1050 -#define IDC_BPICK 1051 -#define IDC_PICKMSG 1052 +#define IDC_CONNBUTTON 1047 +#define IDC_LOCALP_LABEL 1048 +#define IDC_TOTAL_LABEL 1049 +#define IDC_REMOTE_LABEL 1050 +#define IDC_PICKTILES 1051 +#define IDC_BPICK 1052 +#define IDC_PICKMSG 1053 #ifdef FEATURE_TRAY_EDIT -# define IDC_CPICK 1053 -# define IDC_PICKALL 1054 -# define IDC_BACKUP 1055 +# define IDC_CPICK 1054 +# define IDC_PICKALL 1055 +# define IDC_BACKUP 1056 #endif #ifdef XWFEATURE_SEARCHLIMIT -# define IDC_CHECKHINTSLIMITS 1056 +# define IDC_CHECKHINTSLIMITS 1057 #endif -#define DLBLTR_BUTTON 1056 -#define DBLWRD_BUTTON 1057 -#define TPLLTR_BUTTON 1058 -#define TPLWRD_BUTTON 1059 -#define EMPCELL_BUTTON 1060 -#define TBACK_BUTTON 1061 -#define PLAYER1_BUTTON 1062 -#define PLAYER2_BUTTON 1063 -#define PLAYER3_BUTTON 1064 -#define PLAYER4_BUTTON 1065 -#define PLAYER1_LABEL 1066 -#define PLAYER2_LABEL 1067 -#define PLAYER3_LABEL 1068 -#define PLAYER4_LABEL 1069 -#define DLBLTR_LABEL 1070 -#define DBLWRD_LABEL 1071 -#define TPLLTR_LABEL 1072 -#define TPLWRD_LABEL 1073 -#define EMPTYCELL_LABEL 1074 -#define TILEBACK_LABEL 1075 +#define DLBLTR_BUTTON 1058 +#define DBLWRD_BUTTON 1059 +#define TPLLTR_BUTTON 1060 +#define TPLWRD_BUTTON 1061 +#define EMPCELL_BUTTON 1062 +#define TBACK_BUTTON 1063 +#define PLAYER1_BUTTON 1064 +#define PLAYER2_BUTTON 1065 +#define PLAYER3_BUTTON 1066 +#define PLAYER4_BUTTON 1067 +#define PLAYER1_LABEL 1068 +#define PLAYER2_LABEL 1069 +#define PLAYER3_LABEL 1070 +#define PLAYER4_LABEL 1071 +#define DLBLTR_LABEL 1072 +#define DBLWRD_LABEL 1073 +#define TPLLTR_LABEL 1074 +#define TPLWRD_LABEL 1075 +#define EMPTYCELL_LABEL 1076 +#define TILEBACK_LABEL 1077 /* editor dlg: assumption is that the edit field's ID is one more than the corresponding slider's */ #ifdef MY_COLOR_SEL -# define CLREDT_SLIDER1 1076 -# define RED_EDIT 1077 -# define CLREDT_SLIDER2 1078 -# define GREEN_EDIT 1079 -# define CLREDT_SLIDER3 1080 -# define BLUE_EDIT 1081 +# define CLREDT_SLIDER1 1078 +# define RED_EDIT 1079 +# define CLREDT_SLIDER2 1080 +# define GREEN_EDIT 1081 +# define CLREDT_SLIDER3 1082 +# define BLUE_EDIT 1083 -# define RED_LABEL 1082 -# define GREEN_LABEL 1083 -# define BLUE_LABEL 1084 +# define RED_LABEL 1084 +# define GREEN_LABEL 1085 +# define BLUE_LABEL 1086 #endif // MY_COLOR_SEL -#define HC_MIN_COMBO 1085 -#define HC_MAX_COMBO 1086 +#define HC_MIN_COMBO 1087 +#define HC_MAX_COMBO 1088 + +#define IDC_CCONVIA_LAB 1089 +#define IDC_CRELAYNAME_LAB 1090 +#define IDC_CRELAYPORT_LAB 1091 +#define IDC_COOKIE_LAB 1092 + +#ifndef XWFEATURE_STANDALONE_ONLY +# define IDC_CONNECTCOMBO 1093 +# define RELAYNAME_EDIT 1094 +# define RELAYPORT_EDIT 1095 +# define COOKIE_EDIT 1096 + +#endif + + #define IDM_FILE_EXIT 40002 #define IDM_HELP_ABOUT 40003 diff --git a/wince/shared.mk b/wince/shared.mk index 927b4f863..6aa77bd1c 100755 --- a/wince/shared.mk +++ b/wince/shared.mk @@ -14,6 +14,7 @@ PLATOBJ = \ $(PLATFORM)/cedict.o \ $(PLATFORM)/cedraw.o \ $(PLATFORM)/ceginfo.o \ + $(PLATFORM)/cecondlg.o \ $(PLATFORM)/cemain.o \ $(PLATFORM)/ceprefs.o \ $(PLATFORM)/cestrbx.o \ diff --git a/wince/xptypes.h b/wince/xptypes.h index eb6b2f809..4aaa84c64 100755 --- a/wince/xptypes.h +++ b/wince/xptypes.h @@ -111,6 +111,8 @@ XP_U16 wince_snprintf( XP_UCHAR* buf, XP_U16 len, XP_UCHAR* format, ... ); #define XP_HTONL(l) htonl(l) #define XP_HTONS(s) htons(s) +#define XP_LD "%ld" + #ifdef CPLUS } #endif diff --git a/wince/xwords4.rc b/wince/xwords4.rc index 3758f53fc..172540906 100755 --- a/wince/xwords4.rc +++ b/wince/xwords4.rc @@ -164,15 +164,15 @@ END # define GAME_ROBOT_LEFT 81 # define GAME_PWD_LEFT 105 # define NPLAYERS_ROW 3 -# define GAME_NAMELABEL_LEFT GAME_NAME_LEFT +# define GAME_NAMELABEL_LEFT GAME_NAME_LEFT+10 #else # define SERVERROLE_ROW 3 # define NPLAYERS_ROW (SERVERROLE_ROW+ROW_SPACE+3) -# define GAME_REMOTE_LEFT 0 -# define GAME_NAME_LEFT 20 +# define GAME_REMOTE_LEFT 2 +# define GAME_NAME_LEFT 15 # define GAME_ROBOT_LEFT 92 # define GAME_PWD_LEFT 110 -# define GAME_NAMELABEL_LEFT (GAME_NAME_LEFT + 10) +# define GAME_NAMELABEL_LEFT (GAME_NAME_LEFT + 20) #endif @@ -186,6 +186,8 @@ END #define BUTTON_HT 12 #define GAMEINFO_HEIGHT (BUTTONS_ROW + BUTTON_HT + 4) +#define CHECK_WIDTH 10 + IDD_GAMEINFO DIALOG DISCARDABLE 0, 0, 133, GAMEINFO_HEIGHT STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | DS_CENTER CAPTION "Game info" @@ -195,6 +197,9 @@ BEGIN LTEXT "Role:",IDC_STATIC,25,SERVERROLE_ROW,20,8 COMBOBOX IDC_ROLECOMBO,45,SERVERROLE_ROW,50,58,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "Conn...",IDC_CONNBUTTON,45+50+2,SERVERROLE_ROW, + 35, ROW_SPACE + #endif LTEXT "local players",IDC_LOCALP_LABEL,LEFT_COL,NPLAYERS_ROW,40,8 /* capitalizing total truncates the things!!! */ @@ -205,26 +210,26 @@ BEGIN LTEXT "Remote",IDC_REMOTE_LABEL,LEFT_COL,LABELS_ROW,25,8,SS_NOPREFIX LTEXT "Name",IDC_STATIC,GAME_NAMELABEL_LEFT, LABELS_ROW,19,8,SS_NOPREFIX - LTEXT "Robot",IDC_STATIC,77,LABELS_ROW,20,8 - LTEXT "Pwd",IDC_STATIC,109,LABELS_ROW,16,8 + LTEXT "Robot",IDC_STATIC,87,LABELS_ROW,20,8 + LTEXT "Pwd",IDC_STATIC,112,LABELS_ROW,16,8 #ifndef XWFEATURE_STANDALONE_ONLY CONTROL "",REMOTE_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, - GAME_REMOTE_LEFT, PLAYER_ROW_1,16,ROW_HEIGHT + GAME_REMOTE_LEFT, PLAYER_ROW_1,CHECK_WIDTH,ROW_HEIGHT CONTROL "",REMOTE_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, - GAME_REMOTE_LEFT, PLAYER_ROW_2,16,ROW_HEIGHT + GAME_REMOTE_LEFT, PLAYER_ROW_2,CHECK_WIDTH,ROW_HEIGHT CONTROL "",REMOTE_CHECK3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, - GAME_REMOTE_LEFT, PLAYER_ROW_3,16,ROW_HEIGHT + GAME_REMOTE_LEFT, PLAYER_ROW_3,CHECK_WIDTH,ROW_HEIGHT CONTROL "",REMOTE_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, - GAME_REMOTE_LEFT, PLAYER_ROW_4,16,ROW_HEIGHT + GAME_REMOTE_LEFT, PLAYER_ROW_4,CHECK_WIDTH,ROW_HEIGHT #endif CONTROL "",ROBOT_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, - GAME_ROBOT_LEFT,PLAYER_ROW_1,16,ROW_HEIGHT + GAME_ROBOT_LEFT,PLAYER_ROW_1,CHECK_WIDTH,ROW_HEIGHT CONTROL "",ROBOT_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, - GAME_ROBOT_LEFT,PLAYER_ROW_2,16,ROW_HEIGHT + GAME_ROBOT_LEFT,PLAYER_ROW_2,CHECK_WIDTH,ROW_HEIGHT CONTROL "",ROBOT_CHECK3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, - GAME_ROBOT_LEFT,PLAYER_ROW_3,16,ROW_HEIGHT + GAME_ROBOT_LEFT,PLAYER_ROW_3,CHECK_WIDTH,ROW_HEIGHT CONTROL "",ROBOT_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, - GAME_ROBOT_LEFT, PLAYER_ROW_4,16,ROW_HEIGHT + GAME_ROBOT_LEFT, PLAYER_ROW_4,CHECK_WIDTH,ROW_HEIGHT EDITTEXT NAME_EDIT1,GAME_NAME_LEFT,PLAYER_ROW_1,70,ROW_HEIGHT, ES_AUTOHSCROLL @@ -235,13 +240,13 @@ BEGIN EDITTEXT NAME_EDIT4,GAME_NAME_LEFT,PLAYER_ROW_4,70,ROW_HEIGHT, ES_AUTOHSCROLL | NOT WS_VISIBLE - EDITTEXT PASS_EDIT1,GAME_PWD_LEFT,PLAYER_ROW_1,23,ROW_HEIGHT, + EDITTEXT PASS_EDIT1,GAME_PWD_LEFT,PLAYER_ROW_1,20,ROW_HEIGHT, ES_PASSWORD | ES_AUTOHSCROLL - EDITTEXT PASS_EDIT2,GAME_PWD_LEFT,PLAYER_ROW_2,23,ROW_HEIGHT, + EDITTEXT PASS_EDIT2,GAME_PWD_LEFT,PLAYER_ROW_2,20,ROW_HEIGHT, ES_PASSWORD | ES_AUTOHSCROLL - EDITTEXT PASS_EDIT3,GAME_PWD_LEFT,PLAYER_ROW_3,23,ROW_HEIGHT, + EDITTEXT PASS_EDIT3,GAME_PWD_LEFT,PLAYER_ROW_3,20,ROW_HEIGHT, ES_PASSWORD | ES_AUTOHSCROLL - EDITTEXT PASS_EDIT4,GAME_PWD_LEFT,PLAYER_ROW_4,23,ROW_HEIGHT, + EDITTEXT PASS_EDIT4,GAME_PWD_LEFT,PLAYER_ROW_4,20,ROW_HEIGHT, ES_PASSWORD | ES_AUTOHSCROLL LTEXT "Dictionary:",IDC_STATIC,LEFT_COL,DICTPICK_ROW,36,8,SS_NOPREFIX @@ -358,6 +363,44 @@ BEGIN PUSHBUTTON "Cancel",IDCANCEL,70,98,39,14 END +#ifndef XWFEATURE_STANDALONE_ONLY + +# define LAB_COL 8 +# define LAB_COL_WIDTH 40 +# define CTRL_COL 50 +# define CTRL_COL_WIDTH 60 +# define CONN_ROW_1 10 +# define CONN_ROW_2 25 +# define CONN_ROW_3 40 +# define CONN_ROW_4 55 + /* #This is a comment???? */ +IDD_CONNSSDLG DIALOG DISCARDABLE 0, 20, 120, 115 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | DS_CENTER +CAPTION "Connection" +FONT 8, "System" +BEGIN + + LTEXT "Connect via",IDC_CCONVIA_LAB,LAB_COL,CONN_ROW_1,40,12 + COMBOBOX IDC_CONNECTCOMBO,CTRL_COL,CONN_ROW_1,CTRL_COL_WIDTH,58,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + + LTEXT "Relay name",IDC_CRELAYNAME_LAB,LAB_COL,CONN_ROW_2,40,12 + EDITTEXT RELAYNAME_EDIT,CTRL_COL,CONN_ROW_2,CTRL_COL_WIDTH,12, + ES_AUTOHSCROLL + LTEXT "Relay port",IDC_CRELAYPORT_LAB,LAB_COL,CONN_ROW_3,40,12 + EDITTEXT RELAYPORT_EDIT,CTRL_COL,CONN_ROW_3,CTRL_COL_WIDTH,12, + ES_AUTOHSCROLL | ES_NUMBER + + LTEXT "Cookie",IDC_COOKIE_LAB,LAB_COL,CONN_ROW_4,40,12 + EDITTEXT COOKIE_EDIT,CTRL_COL,CONN_ROW_4,CTRL_COL_WIDTH,12, + ES_AUTOHSCROLL + + + DEFPUSHBUTTON "OK",IDOK,9,98,38,14 + PUSHBUTTON "Cancel",IDCANCEL,70,98,39,14 +END +#endif + #define CLR_LAB_WIDTH 40 #define CLR_LAB_HT 14 #define CLR_BUT_WIDTH 12