From 5ba99f45d7e440649c1c9fbf303c5c191ca189e1 Mon Sep 17 00:00:00 2001 From: ehouse Date: Fri, 2 Oct 2009 05:48:48 +0000 Subject: [PATCH] warn about need to restart to pick up language change after last opportunity to cancel is passed. Change wording to make sense. --- xwords4/wince/ceginfo.c | 5 +++-- xwords4/wince/ceginfo.h | 1 + xwords4/wince/cemain.c | 25 +++++++++++++++++++++++-- xwords4/wince/ceprefs.c | 10 ++++------ xwords4/wince/ceprefs.h | 4 ++-- xwords4/wince/l10n/xwords4_english.rc | 2 +- 6 files changed, 34 insertions(+), 13 deletions(-) diff --git a/xwords4/wince/ceginfo.c b/xwords4/wince/ceginfo.c index 08943d569..c7499f33c 100755 --- a/xwords4/wince/ceginfo.c +++ b/xwords4/wince/ceginfo.c @@ -310,11 +310,12 @@ raiseForHiddenPlayers( GameInfoState* state, XP_U16 nPlayers ) static void handlePrefsButton( HWND hDlg, CEAppGlobals* globals, GameInfoState* state ) { - XP_Bool colorsChanged; + XP_Bool colorsChanged, langChanged; if ( WrapPrefsDialog( hDlg, globals, &state->prefsPrefs, - state->isNewGame, &colorsChanged ) ) { + state->isNewGame, &colorsChanged, &langChanged ) ) { state->prefsChanged = XP_TRUE; state->colorsChanged = colorsChanged; + state->langChanged = langChanged; /* nothing to do until user finally does confirm the parent dialog */ } } /* handlePrefsButton */ diff --git a/xwords4/wince/ceginfo.h b/xwords4/wince/ceginfo.h index 824b55142..9ab4e8b00 100755 --- a/xwords4/wince/ceginfo.h +++ b/xwords4/wince/ceginfo.h @@ -47,6 +47,7 @@ typedef struct GameInfoState { XP_Bool prefsChanged; XP_Bool colorsChanged; + XP_Bool langChanged; XP_Bool addrChanged; CePrefsPrefs prefsPrefs; diff --git a/xwords4/wince/cemain.c b/xwords4/wince/cemain.c index 97f1dbfd7..0cc7851e7 100755 --- a/xwords4/wince/cemain.c +++ b/xwords4/wince/cemain.c @@ -1737,6 +1737,14 @@ ceDisplayFinalScores( CEAppGlobals* globals ) MB_OK | MB_ICONINFORMATION, XP_TRUE ); } /* ceDisplayFinalScores */ +static void +ceWarnLangChange( CEAppGlobals* globals ) +{ + const wchar_t* msg = ceGetResStringL( globals, + IDS_LANG_CHANGE_RESTART ); + MessageBox( globals->hWnd, msg, NULL, MB_OK | MB_ICONINFORMATION ); +} + static XP_Bool ceDoNewGame( CEAppGlobals* globals ) { @@ -1770,6 +1778,11 @@ ceDoNewGame( CEAppGlobals* globals ) updateForColors( globals ); } } + + if ( giState.prefsChanged ) { + ceWarnLangChange( globals ); + } + #if defined XWFEATURE_RELAY || defined XWFEATURE_BLUETOOTH if ( giState.addrChanged ) { addr = &giState.prefsPrefs.addrRec; @@ -1871,14 +1884,14 @@ static void ceDoPrefsDlg( CEAppGlobals* globals ) { CePrefsPrefs prefsPrefs; - XP_Bool colorsChanged; + XP_Bool colorsChanged, langChanged; loadStateFromCurPrefs( globals, &globals->appPrefs, &globals->gameInfo, &prefsPrefs ); assertOnTop( globals->hWnd ); if ( WrapPrefsDialog( globals->hWnd, globals, &prefsPrefs, - XP_FALSE, &colorsChanged ) ) { + XP_FALSE, &colorsChanged, &langChanged ) ) { loadCurPrefsFromState( globals, &globals->appPrefs, &globals->gameInfo, &prefsPrefs ); @@ -1887,6 +1900,11 @@ ceDoPrefsDlg( CEAppGlobals* globals ) if ( colorsChanged ) { updateForColors( globals ); } + + if ( langChanged ) { + ceWarnLangChange( globals ); + } + /* need to reflect vars set in state into globals, and update/inval as appropriate. */ } @@ -2442,6 +2460,9 @@ WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if ( state.prefsChanged ) { updateForColors( globals ); } + if ( state.langChanged ) { + ceWarnLangChange( globals ); + } draw = server_do( globals->game.server ); } } diff --git a/xwords4/wince/ceprefs.c b/xwords4/wince/ceprefs.c index 004a9a75d..6c9a7b3eb 100755 --- a/xwords4/wince/ceprefs.c +++ b/xwords4/wince/ceprefs.c @@ -41,6 +41,7 @@ typedef struct _CePrefsDlgState { //XP_Bool doGlobalPrefs; /* state of the radio */ XP_Bool isNewGame; XP_Bool colorsChanged; + XP_Bool langChanged; } CePrefsDlgState; /* Stuff the strings for phonies. Why can't I put this in the resource? @@ -338,11 +339,7 @@ PrefsDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) if ( ceChooseResFile( hDlg, globals, pState->langFileName, newFile, VSIZE(newFile)) ) { - const wchar_t* msg - = ceGetResStringL( globals, - IDS_LANG_CHANGE_RESTART ); - MessageBox( hDlg, msg, NULL, - MB_OK | MB_ICONINFORMATION ); + pState->langChanged = XP_TRUE; XP_STRNCPY( pState->langFileName, newFile, VSIZE(pState->langFileName) ); } @@ -394,7 +391,7 @@ PrefsDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) */ XP_Bool WrapPrefsDialog( HWND hDlg, CEAppGlobals* globals, CePrefsPrefs* prefsPrefs, - XP_Bool isNewGame, XP_Bool* colorsChanged ) + XP_Bool isNewGame, XP_Bool* colorsChanged, XP_Bool* langChanged ) { CePrefsDlgState state; XP_Bool result; @@ -417,6 +414,7 @@ WrapPrefsDialog( HWND hDlg, CEAppGlobals* globals, CePrefsPrefs* prefsPrefs, if ( result ) { XP_MEMCPY( prefsPrefs, &state.prefsPrefs, sizeof( *prefsPrefs ) ); *colorsChanged = state.colorsChanged; + *langChanged = state.langChanged; replaceStringIfDifferent( globals->mpool, &globals->langFileName, state.langFileName ); diff --git a/xwords4/wince/ceprefs.h b/xwords4/wince/ceprefs.h index 59ea87314..cb4141136 100755 --- a/xwords4/wince/ceprefs.h +++ b/xwords4/wince/ceprefs.h @@ -56,8 +56,8 @@ typedef struct CePrefsPrefs { } CePrefsPrefs; XP_Bool WrapPrefsDialog( HWND hDlg, CEAppGlobals* globals, - CePrefsPrefs* prefsPrefs, - XP_Bool isNewGame, XP_Bool* colorsChanged ); + CePrefsPrefs* prefsPrefs, XP_Bool isNewGame, + XP_Bool* colorsChanged, XP_Bool* langChanged ); void loadStateFromCurPrefs( CEAppGlobals* globals, const CEAppPrefs* appPrefs, const CurGameInfo* gi, CePrefsPrefs* prefsPrefs ); void loadCurPrefsFromState( CEAppGlobals* globals, CEAppPrefs* appPrefs, diff --git a/xwords4/wince/l10n/xwords4_english.rc b/xwords4/wince/l10n/xwords4_english.rc index 781bd1abb..b7048478a 100755 --- a/xwords4/wince/l10n/xwords4_english.rc +++ b/xwords4/wince/l10n/xwords4_english.rc @@ -955,7 +955,7 @@ BEGIN IDS_NEED_TOUCH "This feature requires a touch screen." IDS_EDITCOLOR_FORMAT "Edit color for %s" - IDS_LANG_CHANGE_RESTART "This change will take effect after you restart Crosswords." + IDS_LANG_CHANGE_RESTART "You will see the new language after you restart Crosswords." #ifndef XWFEATURE_STANDALONE_ONLY IDS_RESEND_STANDALONE "This is a standalone game. There is nothing to resend."