mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-15 20:48:00 +01:00
Make ceprefs.c state struct private to that file
This commit is contained in:
parent
3a6e7013b6
commit
105ba00929
4 changed files with 34 additions and 36 deletions
|
@ -317,16 +317,14 @@ raiseForHiddenPlayers( GameInfoState* giState, XP_U16 nPlayers )
|
|||
static void
|
||||
handlePrefsButton( HWND hDlg, CEAppGlobals* globals, GameInfoState* giState )
|
||||
{
|
||||
CePrefsDlgState state;
|
||||
|
||||
/* 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
|
||||
the calling dlg.*/
|
||||
|
||||
if ( WrapPrefsDialog( hDlg, globals, &state, &giState->prefsPrefs,
|
||||
giState->isNewGame ) ) {
|
||||
XP_Bool colorsChanged;
|
||||
if ( WrapPrefsDialog( hDlg, globals, &giState->prefsPrefs,
|
||||
giState->isNewGame, &colorsChanged ) ) {
|
||||
giState->prefsChanged = XP_TRUE;
|
||||
giState->colorsChanged = state.colorsChanged;
|
||||
giState->colorsChanged = colorsChanged;
|
||||
/* nothing to do until user finally does confirm the parent dialog */
|
||||
}
|
||||
} /* handlePrefsButton */
|
||||
|
|
|
@ -1765,24 +1765,21 @@ updateForColors( CEAppGlobals* globals )
|
|||
static void
|
||||
ceDoPrefsDlg( CEAppGlobals* globals )
|
||||
{
|
||||
CePrefsDlgState state;
|
||||
CePrefsPrefs prefsPrefs;
|
||||
XP_Bool colorsChanged;
|
||||
|
||||
loadStateFromCurPrefs( globals, &globals->appPrefs, &globals->gameInfo,
|
||||
&prefsPrefs );
|
||||
|
||||
assertOnTop( globals->hWnd );
|
||||
(void)WrapPrefsDialog( globals->hWnd, globals, &state, &prefsPrefs,
|
||||
XP_FALSE );
|
||||
|
||||
if ( !state.userCancelled ) {
|
||||
|
||||
if ( WrapPrefsDialog( globals->hWnd, globals, &prefsPrefs,
|
||||
XP_FALSE, &colorsChanged ) ) {
|
||||
loadCurPrefsFromState( globals, &globals->appPrefs, &globals->gameInfo,
|
||||
&prefsPrefs );
|
||||
|
||||
(void)cePositionBoard( globals );
|
||||
|
||||
if ( state.colorsChanged ) {
|
||||
if ( colorsChanged ) {
|
||||
updateForColors( globals );
|
||||
}
|
||||
/* need to reflect vars set in state into globals, and update/inval
|
||||
|
|
|
@ -28,6 +28,18 @@
|
|||
#include "cefonts.h"
|
||||
#include "ceresstr.h"
|
||||
|
||||
typedef struct _CePrefsDlgState {
|
||||
CeDlgHdr dlgHdr;
|
||||
CePrefsPrefs prefsPrefs;
|
||||
|
||||
XP_U16 phonComboId;
|
||||
|
||||
XP_Bool userCancelled;
|
||||
//XP_Bool doGlobalPrefs; /* state of the radio */
|
||||
XP_Bool isNewGame;
|
||||
XP_Bool colorsChanged;
|
||||
} CePrefsDlgState;
|
||||
|
||||
/* Stuff the strings for phonies. Why can't I put this in the resource?
|
||||
*/
|
||||
static void
|
||||
|
@ -361,23 +373,26 @@ PrefsDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
state, put up the dialog and return whether it was cancelled.
|
||||
*/
|
||||
XP_Bool
|
||||
WrapPrefsDialog( HWND hDlg, CEAppGlobals* globals, CePrefsDlgState* state,
|
||||
CePrefsPrefs* prefsPrefs, XP_Bool isNewGame )
|
||||
WrapPrefsDialog( HWND hDlg, CEAppGlobals* globals, CePrefsPrefs* prefsPrefs,
|
||||
XP_Bool isNewGame, XP_Bool* colorsChanged )
|
||||
{
|
||||
CePrefsDlgState state;
|
||||
XP_Bool result;
|
||||
XP_MEMSET( state, 0, sizeof(*state) );
|
||||
|
||||
state->dlgHdr.globals = globals;
|
||||
state->isNewGame = isNewGame;
|
||||
XP_MEMCPY( &state->prefsPrefs, prefsPrefs, sizeof( state->prefsPrefs ) );
|
||||
XP_MEMSET( &state, 0, sizeof(state) );
|
||||
|
||||
state.dlgHdr.globals = globals;
|
||||
state.isNewGame = isNewGame;
|
||||
XP_MEMCPY( &state.prefsPrefs, prefsPrefs, sizeof( state.prefsPrefs ) );
|
||||
|
||||
DialogBoxParam( globals->locInst, (LPCTSTR)IDD_OPTIONSDLG, hDlg,
|
||||
(DLGPROC)PrefsDlg, (long)state );
|
||||
(DLGPROC)PrefsDlg, (long)&state );
|
||||
|
||||
result = !state->userCancelled;
|
||||
result = !state.userCancelled;
|
||||
|
||||
if ( result ) {
|
||||
XP_MEMCPY( prefsPrefs, &state->prefsPrefs, sizeof( *prefsPrefs ) );
|
||||
XP_MEMCPY( prefsPrefs, &state.prefsPrefs, sizeof( *prefsPrefs ) );
|
||||
*colorsChanged = state.colorsChanged;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -55,21 +55,9 @@ typedef struct CePrefsPrefs {
|
|||
COLORREF colors[CE_NUM_EDITABLE_COLORS];
|
||||
} CePrefsPrefs;
|
||||
|
||||
typedef struct CePrefsDlgState {
|
||||
CeDlgHdr dlgHdr;
|
||||
CePrefsPrefs prefsPrefs;
|
||||
|
||||
XP_U16 phonComboId;
|
||||
|
||||
XP_Bool userCancelled;
|
||||
//XP_Bool doGlobalPrefs; /* state of the radio */
|
||||
XP_Bool isNewGame;
|
||||
XP_Bool colorsChanged;
|
||||
} CePrefsDlgState;
|
||||
|
||||
XP_Bool WrapPrefsDialog( HWND hDlg, CEAppGlobals* globals,
|
||||
CePrefsDlgState* state, CePrefsPrefs* prefsPrefs,
|
||||
XP_Bool isNewGame );
|
||||
CePrefsPrefs* prefsPrefs,
|
||||
XP_Bool isNewGame, XP_Bool* colorsChanged );
|
||||
void loadStateFromCurPrefs( CEAppGlobals* globals, const CEAppPrefs* appPrefs,
|
||||
const CurGameInfo* gi, CePrefsPrefs* prefsPrefs );
|
||||
void loadCurPrefsFromState( CEAppGlobals* globals, CEAppPrefs* appPrefs,
|
||||
|
|
Loading…
Add table
Reference in a new issue