mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
Update to use modified newg_store
This commit is contained in:
parent
08da013d4d
commit
b333476d48
6 changed files with 92 additions and 58 deletions
|
@ -31,6 +31,8 @@
|
|||
{ "STR_SERVER_DICT_WINS",
|
||||
"Conflict between Host and Guest dictionaries; Host wins." },
|
||||
{ "STR_REG_UNEXPECTED_USER", "Attempt to register unexpected user refused" },
|
||||
{ "STR_REG_NEED_REMOTE", "Please make one or more players Remote when "
|
||||
"playing as Host." },
|
||||
{ "STR_RESEND_STANDALONE", "This is a standalone game. There is nothing "
|
||||
"to resend." },
|
||||
#endif
|
||||
|
|
|
@ -34,6 +34,9 @@
|
|||
{ "STR_SERVER_DICT_WINS",
|
||||
"Conflit entre les dictionnaires Hôte et Invité ; l'hôte gagne." },
|
||||
{ "STR_REG_UNEXPECTED_USER", "Essai refusé de l'enregistrement de l'utilisateur" },
|
||||
/* Needs translation */
|
||||
{ "STR_REG_NEED_REMOTE", "Please make one or more players Remote when "
|
||||
"playing as Host." },
|
||||
{ "STR_RESEND_STANDALONE", "C'est une partie en solo. Il n'y a rien "
|
||||
"à renvoyer." },
|
||||
#endif
|
||||
|
|
|
@ -41,10 +41,11 @@
|
|||
#include "palmir.h"
|
||||
#include "prefsdlg.h"
|
||||
#include "connsdlg.h"
|
||||
#include "LocalizedStrIncludes.h"
|
||||
|
||||
static void handlePasswordTrigger( PalmAppGlobals* globals,
|
||||
UInt16 controlID );
|
||||
static void updatePlayerInfo( PalmAppGlobals* globals );
|
||||
static XP_Bool updatePlayerInfo( PalmAppGlobals* globals );
|
||||
static void loadNewGameState( PalmAppGlobals* globals );
|
||||
static void unloadNewGameState( PalmAppGlobals* globals );
|
||||
static void setNameThatFits( PalmNewGameState* state );
|
||||
|
@ -211,26 +212,26 @@ newGameHandleEvent( EventPtr event )
|
|||
break;
|
||||
|
||||
case XW_OK_BUTTON_ID:
|
||||
if ( updatePlayerInfo( globals ) ) {
|
||||
/* if we put up the prefs form from within this one and the user
|
||||
clicked ok, we need to make sure the main form gets the
|
||||
notification so it can make use of any changes. This event
|
||||
needs to arrive before the newGame event so any changes will
|
||||
be incorporated. */
|
||||
if ( state->forwardChange ) {
|
||||
postEmptyEvent( prefsChangedEvent );
|
||||
state->forwardChange = false;
|
||||
}
|
||||
|
||||
/* if we put up the prefs form from within this one and the user
|
||||
clicked ok, we need to make sure the main form gets the
|
||||
notification so it can make use of any changes. This event
|
||||
needs to arrive before the newGame event so any changes will
|
||||
be incorporated. */
|
||||
if ( state->forwardChange ) {
|
||||
postEmptyEvent( prefsChangedEvent );
|
||||
state->forwardChange = false;
|
||||
if ( globals->isNewGame ) {
|
||||
postEmptyEvent( newGameOkEvent );
|
||||
globals->postponeDraw = true;
|
||||
}
|
||||
|
||||
unloadNewGameState( globals );
|
||||
|
||||
FrmReturnToForm( 0 );
|
||||
}
|
||||
|
||||
updatePlayerInfo( globals );
|
||||
if ( globals->isNewGame ) {
|
||||
postEmptyEvent( newGameOkEvent );
|
||||
globals->postponeDraw = true;
|
||||
}
|
||||
|
||||
unloadNewGameState( globals );
|
||||
|
||||
FrmReturnToForm( 0 );
|
||||
break;
|
||||
|
||||
case XW_CANCEL_BUTTON_ID:
|
||||
|
@ -308,19 +309,22 @@ setNameThatFits( PalmNewGameState* state )
|
|||
/*
|
||||
* Copy the local state into global state.
|
||||
*/
|
||||
static void
|
||||
static XP_Bool
|
||||
updatePlayerInfo( PalmAppGlobals* globals )
|
||||
{
|
||||
CurGameInfo* gi;
|
||||
PalmNewGameState* state = &globals->newGameState;
|
||||
XP_Bool success;
|
||||
|
||||
gi = &globals->gameInfo;
|
||||
newg_store( state->ngc, gi );
|
||||
success = newg_store( state->ngc, gi, XP_TRUE );
|
||||
if ( success ) {
|
||||
gi->boardSize = globals->prefsDlgState->curBdSize;
|
||||
|
||||
gi->boardSize = globals->prefsDlgState->curBdSize;
|
||||
|
||||
replaceStringIfDifferent( globals->mpool, &gi->dictName,
|
||||
globals->newGameState.dictName );
|
||||
replaceStringIfDifferent( globals->mpool, &gi->dictName,
|
||||
globals->newGameState.dictName );
|
||||
}
|
||||
return success;
|
||||
} /* updatePlayerInfo */
|
||||
|
||||
/* Frame 'em, draw their text, and highlight the one that's selected
|
||||
|
|
|
@ -3645,6 +3645,9 @@ palm_util_userError( XW_UtilCtxt* uc, UtilErrID id )
|
|||
case ERR_REG_UNEXPECTED_USER:
|
||||
strID = STR_REG_UNEXPECTED_USER;
|
||||
break;
|
||||
case ERR_REG_SERVER_SANS_REMOTE:
|
||||
strID = STR_REG_NEED_REMOTE;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case ERR_CANT_TRADE_MID_MOVE:
|
||||
|
|
|
@ -199,46 +199,50 @@ loadFromGameInfo( HWND hDlg, CEAppGlobals* globals, GameInfoState* giState )
|
|||
}
|
||||
} /* loadFromGameInfo */
|
||||
|
||||
static void
|
||||
static XP_Bool
|
||||
stateToGameInfo( HWND hDlg, CEAppGlobals* globals, GameInfoState* giState )
|
||||
{
|
||||
CurGameInfo* gi = &globals->gameInfo;
|
||||
XP_Bool timerOn;
|
||||
XP_Bool success = newg_store( giState->newGameCtx, gi, XP_TRUE );
|
||||
|
||||
newg_store( giState->newGameCtx, gi );
|
||||
if ( success ) {
|
||||
|
||||
/* dictionary */ {
|
||||
int sel;
|
||||
sel = SendDlgItemMessage( hDlg, IDC_DICTCOMBO, CB_GETCURSEL, 0, 0L );
|
||||
if ( sel >= 0 ) {
|
||||
WideCharToMultiByte( CP_ACP, 0, giState->menuDicts[sel], -1,
|
||||
giState->newDictName,
|
||||
sizeof(giState->newDictName), NULL, NULL );
|
||||
/* dictionary */ {
|
||||
int sel;
|
||||
sel = SendDlgItemMessage( hDlg, IDC_DICTCOMBO, CB_GETCURSEL,
|
||||
0, 0L );
|
||||
if ( sel >= 0 ) {
|
||||
WideCharToMultiByte( CP_ACP, 0, giState->menuDicts[sel], -1,
|
||||
giState->newDictName,
|
||||
sizeof(giState->newDictName), NULL, NULL );
|
||||
}
|
||||
replaceStringIfDifferent( globals->mpool, &gi->dictName,
|
||||
giState->newDictName );
|
||||
}
|
||||
replaceStringIfDifferent( globals->mpool, &gi->dictName,
|
||||
giState->newDictName );
|
||||
}
|
||||
|
||||
/* timer */
|
||||
timerOn = ceGetChecked( hDlg, TIMER_CHECK );
|
||||
gi->timerEnabled = timerOn;
|
||||
if ( timerOn ) {
|
||||
XP_UCHAR numBuf[10];
|
||||
XP_U16 len = sizeof(numBuf);
|
||||
ceGetDlgItemText( hDlg, TIMER_EDIT, numBuf, &len );
|
||||
if ( len > 0 ) {
|
||||
XP_U16 num = atoi( numBuf );
|
||||
gi->gameSeconds = num * 60;
|
||||
/* timer */
|
||||
timerOn = ceGetChecked( hDlg, TIMER_CHECK );
|
||||
gi->timerEnabled = timerOn;
|
||||
if ( timerOn ) {
|
||||
XP_UCHAR numBuf[10];
|
||||
XP_U16 len = sizeof(numBuf);
|
||||
ceGetDlgItemText( hDlg, TIMER_EDIT, numBuf, &len );
|
||||
if ( len > 0 ) {
|
||||
XP_U16 num = atoi( numBuf );
|
||||
gi->gameSeconds = num * 60;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* preferences */
|
||||
if ( giState->prefsChanged ) {
|
||||
loadCurPrefsFromState( globals, &globals->appPrefs, gi,
|
||||
&giState->prefsPrefs );
|
||||
/* preferences */
|
||||
if ( giState->prefsChanged ) {
|
||||
loadCurPrefsFromState( globals, &globals->appPrefs, gi,
|
||||
&giState->prefsPrefs );
|
||||
}
|
||||
}
|
||||
|
||||
LOG_RETURN_VOID();
|
||||
LOG_RETURNF( "%d", (int)success );
|
||||
return success;
|
||||
} /* stateToGameInfo */
|
||||
|
||||
static void
|
||||
|
@ -612,7 +616,9 @@ GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
break;
|
||||
|
||||
case IDOK:
|
||||
stateToGameInfo( hDlg, globals, giState );
|
||||
if ( !stateToGameInfo( hDlg, globals, giState ) ) {
|
||||
break;
|
||||
}
|
||||
case IDCANCEL:
|
||||
EndDialog(hDlg, id);
|
||||
giState->userCancelled = id == IDCANCEL;
|
||||
|
|
|
@ -123,7 +123,7 @@ static XP_U32 ce_util_getCurSeconds( XW_UtilCtxt* uc );
|
|||
static DictionaryCtxt* ce_util_makeEmptyDict( XW_UtilCtxt* uc );
|
||||
#ifdef XWFEATURE_RELAY
|
||||
static XWStreamCtxt* ce_util_makeStreamFromAddr( XW_UtilCtxt* uc,
|
||||
XP_U16 channelNo );
|
||||
XP_PlayerAddr channelNo );
|
||||
#endif
|
||||
static const XP_UCHAR* ce_util_getUserString( XW_UtilCtxt* uc,
|
||||
XP_U16 stringCode );
|
||||
|
@ -2554,6 +2554,23 @@ ce_util_userError( XW_UtilCtxt* uc, UtilErrID id )
|
|||
message = "Tile assignment can't be undone.";
|
||||
break;
|
||||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
case ERR_NO_PEEK_REMOTE_TILES:
|
||||
message = "No peeking at remote players' tiles!";
|
||||
break;
|
||||
case ERR_REG_UNEXPECTED_USER:
|
||||
message = "Refused attempt to register unexpected user[s].";
|
||||
break;
|
||||
case ERR_SERVER_DICT_WINS:
|
||||
message = "Conflict between Host and Guest dictionaries; Host wins.";
|
||||
XP_WARNF( "GTK may have problems here." );
|
||||
break;
|
||||
case ERR_REG_SERVER_SANS_REMOTE:
|
||||
message = "At least one player must be marked remote for a game "
|
||||
"started as Host.";
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef XWFEATURE_RELAY
|
||||
case ERR_RELAY_BASE + XWRELAY_ERROR_TIMEOUT:
|
||||
message = "The relay timed you out; usually that means "
|
||||
|
@ -2743,8 +2760,7 @@ ce_util_engineProgressCallback( XW_UtilCtxt* XP_UNUSED(uc) )
|
|||
|
||||
static void
|
||||
ce_util_setTimer( XW_UtilCtxt* uc, XWTimerReason why,
|
||||
XP_U16 XP_UNUSED_RELAY(when),
|
||||
XWTimerProc proc, void* closure)
|
||||
XP_U16 when, XWTimerProc proc, void* closure )
|
||||
{
|
||||
CEAppGlobals* globals = (CEAppGlobals*)uc->closure;
|
||||
XP_U32 timerID;
|
||||
|
@ -2802,7 +2818,7 @@ ce_util_makeEmptyDict( XW_UtilCtxt* uc )
|
|||
|
||||
#ifdef XWFEATURE_RELAY
|
||||
static XWStreamCtxt*
|
||||
ce_util_makeStreamFromAddr( XW_UtilCtxt* uc, XP_U16 channelNo )
|
||||
ce_util_makeStreamFromAddr( XW_UtilCtxt* uc, XP_PlayerAddr channelNo )
|
||||
{
|
||||
XWStreamCtxt* stream;
|
||||
CEAppGlobals* globals = (CEAppGlobals*)uc->closure;
|
||||
|
|
Loading…
Reference in a new issue