Don't let smartphone users set hintlimits checkbox, and explain

why. Fix bug calling MessageBox with main window ptr from dialog.
Include name of preexisting file when warning user who enters it while
saving/renaming.
This commit is contained in:
ehouse 2008-12-07 01:30:18 +00:00
parent e37cfa6ce8
commit c791010603
6 changed files with 46 additions and 36 deletions

View file

@ -1115,7 +1115,7 @@ ceLoadSavedGame( CEAppGlobals* globals )
snprintf( buf, VSIZE(buf), "Unable to open dictionary: %s",
dictName );
buf[VSIZE(buf)-1] = '\0';
messageBoxChar( globals, buf, L"Oops!", MB_OK );
ceMessageBoxChar( globals, NULL, buf, L"Oops!", MB_OK );
}
XP_FREE( globals->mpool, dictName );
#endif
@ -2644,31 +2644,6 @@ ceMsgFromStream( CEAppGlobals* globals, XWStreamCtxt* stream,
return saidYes;
} /* ceMsgFromStream */
int
messageBoxChar( CEAppGlobals* globals, XP_UCHAR* str, wchar_t* title,
XP_U16 buttons )
{
wchar_t* widebuf;
XP_U32 len, wsize;
int result;
/* first get the length required, then alloc and go */
len = MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, str, strlen(str),
NULL, 0 );
wsize = (len+1) * sizeof( wchar_t );
widebuf = XP_MALLOC( globals->mpool, wsize );
XP_MEMSET( widebuf, 0, wsize );
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, str, strlen(str),
widebuf, len );
result = MessageBox( globals->hWnd, widebuf, title, buttons );
XP_FREE( globals->mpool, widebuf );
return result;
} /* messageBoxChar */
static XP_UCHAR*
ceStreamToStrBuf( MPFORMAL XWStreamCtxt* stream )
{
@ -2686,7 +2661,7 @@ messageBoxStream( CEAppGlobals* globals, XWStreamCtxt* stream, wchar_t* title,
{
XP_UCHAR* buf = ceStreamToStrBuf( MPPARM(globals->mpool) stream );
int result = messageBoxChar( globals, buf, title, buttons );
int result = ceMessageBoxChar( globals, NULL, buf, title, buttons );
XP_FREE( globals->mpool, buf );
return result;
@ -2986,7 +2961,7 @@ ce_util_userError( XW_UtilCtxt* uc, UtilErrID id )
break;
}
messageBoxChar( globals, message, L"Oops!", MB_OK );
ceMessageBoxChar( globals, NULL, message, L"Oops!", MB_OK );
} /* ce_util_userError */
static XP_Bool
@ -3354,7 +3329,7 @@ ce_util_warnIllegalWord( XW_UtilCtxt* uc, BadWordInfo* bwi,
sprintf( msgBuf, "Word[s] %s not found in dictionary.", wordsBuf );
if ( turnLost ) {
messageBoxChar( globals, msgBuf, L"Illegal word", MB_OK );
ceMessageBoxChar( globals, NULL, msgBuf, L"Illegal word", MB_OK );
isOk = XP_TRUE;
} else {
strcat( msgBuf, " Use it anyway?" );

View file

@ -195,8 +195,6 @@ enum {
#define CE_NUM_EDITABLE_COLORS CE_BLACK_COLOR
int messageBoxChar( CEAppGlobals* globals, XP_UCHAR* str, wchar_t* title,
XP_U16 buttons );
XP_Bool queryBoxChar( CEAppGlobals* globals, const XP_UCHAR* msg );
/* These allow LISTBOX and COMBOBOX to be used by the same code */

View file

@ -201,7 +201,9 @@ loadControlsFromState( CePrefsDlgState* pState )
ceSetChecked( hDlg, IDC_PICKTILES, prefsPrefs->gp.allowPickTiles );
#endif
#ifdef XWFEATURE_SEARCHLIMIT
ceSetChecked( hDlg, IDC_CHECKHINTSLIMITS, prefsPrefs->gp.allowHintRect );
if ( !IS_SMARTPHONE(globals) ) {
ceSetChecked( hDlg, IDC_CHECKHINTSLIMITS, prefsPrefs->gp.allowHintRect );
}
#endif
/* timer */
ceSetDlgItemNum( hDlg, TIMER_EDIT, prefsPrefs->gp.gameSeconds / 60 );
@ -231,6 +233,7 @@ ceControlsToPrefs( CePrefsDlgState* state )
XP_S16 selIndex;
CePrefsPrefs* prefsPrefs = &state->prefsPrefs;
HWND hDlg = state->dlgHdr.hDlg;
CEAppGlobals* globals = state->dlgHdr.globals;
prefsPrefs->showColors = ceGetChecked( hDlg, IDC_CHECKCOLORPLAYED );
prefsPrefs->gp.robotSmartness
@ -238,7 +241,7 @@ ceControlsToPrefs( CePrefsDlgState* state )
prefsPrefs->gp.hintsNotAllowed = !ceGetChecked( hDlg, IDC_CHECKHINTSOK );
selIndex = (XP_U16)SendDlgItemMessage( hDlg, state->phonComboId,
GETCURSEL(state->dlgHdr.globals),
GETCURSEL(globals),
0, 0 );
if ( selIndex != LB_ERR ) {
prefsPrefs->gp.phoniesAction = (XWPhoniesChoice)selIndex;
@ -260,7 +263,9 @@ ceControlsToPrefs( CePrefsDlgState* state )
prefsPrefs->gp.allowPickTiles = ceGetChecked( hDlg, IDC_PICKTILES );
#endif
#ifdef XWFEATURE_SEARCHLIMIT
prefsPrefs->gp.allowHintRect = ceGetChecked( hDlg, IDC_CHECKHINTSLIMITS );
if ( !IS_SMARTPHONE(globals) ) {
prefsPrefs->gp.allowHintRect = ceGetChecked( hDlg, IDC_CHECKHINTSLIMITS );
}
#endif
} /* ceControlsToPrefs */
@ -326,6 +331,13 @@ PrefsDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
BM_GETCHECK, 0, 0 );
ceShowOrHide( hDlg, IDC_CHECKHINTSLIMITS, timerOn );
break;
case IDC_CHECKHINTSLIMITS:
if ( IS_SMARTPHONE(globals) ) {
ceMessageBoxChar( globals, hDlg, "This feature requires a "
"touch screen.", L"Sorry", MB_OK );
ceSetChecked( hDlg, IDC_CHECKHINTSLIMITS, XP_FALSE );
}
break;
#endif
case IDOK:

View file

@ -119,8 +119,11 @@ SaveNameDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
(void)GetDlgItemText( hDlg, IDC_SVGN_EDIT, buf,
VSIZE(buf) );
if ( ceFileExists( globals, buf ) ) {
messageBoxChar( globals,
"File exists", L"Oops!", MB_OK );
wchar_t widebuf[128];
snwprintf( widebuf, VSIZE(widebuf),
L"File \"%s\" already exists.", buf );
result = MessageBox( hDlg, widebuf, L"Oops!", MB_OK );
(void)SetDlgItemText( hDlg, IDC_SVGN_EDIT, state->buf );
break;
}
len = ceGetPath( globals, DEFAULT_DIR_PATH_L,

View file

@ -870,3 +870,22 @@ ceGetPath( CEAppGlobals* globals, CePathType typ,
}
return len;
} /* ceGetPath */
int
ceMessageBoxChar( CEAppGlobals* globals, HWND parent, XP_UCHAR* str,
wchar_t* title, XP_U16 buttons )
{
/* Get the length required, then alloc and go. This is technically
correct, but everywhere else I assume a 2:1 ratio for wchar_t:char. */
XP_U16 clen = 1 + strlen(str);
XP_U32 wlen = 1 + MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, str,
clen, NULL, 0 );
wchar_t widebuf[wlen];
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, str, clen, widebuf, wlen );
if ( !parent ) {
parent = globals->hWnd;
}
return MessageBox( parent, widebuf, title, buttons );
} /* ceMessageBoxChar */

View file

@ -47,6 +47,9 @@ void ceCheckMenus( const CEAppGlobals* globals );
void ceGetItemRect( HWND hDlg, XP_U16 resID, RECT* rect );
void ceMoveItem( HWND hDlg, XP_U16 resID, XP_S16 byX, XP_S16 byY );
int ceMessageBoxChar( CEAppGlobals* globals, HWND parent, XP_UCHAR* str,
wchar_t* title, XP_U16 buttons );
typedef enum {
PREFS_FILE_PATH_L
,DEFAULT_DIR_PATH_L