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