mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
rewrite ceLocateNDicts to do recursive searches from a list of
directories stored in resources. On device this is currently "\Program Files\Crosswords" and "\SD Card". (Just "." for win32.) Later may need to restrict on the card too. Still to do: make "no dicts found" Alert list the places searched.
This commit is contained in:
parent
dc908e52b2
commit
d8ab05a04e
6 changed files with 46 additions and 20 deletions
|
@ -563,11 +563,7 @@ locateOneDir( MPFORMAL wchar_t* path, OnePathCB cb, void* ctxt, XP_U16 nSought,
|
|||
XP_Bool result = XP_FALSE;
|
||||
XP_U16 startLen;
|
||||
|
||||
#if defined TARGET_OS_WINCE
|
||||
lstrcat( path, L"\\" );
|
||||
#elif defined TARGET_OS_WIN32
|
||||
lstrcat( path, L".\\" );
|
||||
#endif
|
||||
startLen = wcslen(path); /* record where we were so can back up */
|
||||
lstrcat( path, L"*" );
|
||||
|
||||
|
@ -583,14 +579,18 @@ locateOneDir( MPFORMAL wchar_t* path, OnePathCB cb, void* ctxt, XP_U16 nSought,
|
|||
for ( ; ; ) {
|
||||
|
||||
if ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0){
|
||||
#if defined TARGET_OS_WINCE
|
||||
/* We don't do recursive search on Win32!!! */
|
||||
lstrcpy( path+startLen, data.cFileName );
|
||||
locateOneDir( MPPARM(mpool) path, cb, ctxt, nSought, nFoundP );
|
||||
if ( *nFoundP == nSought ) {
|
||||
break;
|
||||
|
||||
if ( ( data.cFileName[0] == '.' )
|
||||
&& ( (data.cFileName[1] == '.')
|
||||
|| (data.cFileName[1] == '\0' ) ) ) {
|
||||
/* skip . and .. */
|
||||
} else {
|
||||
lstrcpy( path+startLen, data.cFileName );
|
||||
locateOneDir( MPPARM(mpool) path, cb, ctxt, nSought, nFoundP );
|
||||
if ( *nFoundP == nSought ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} else if ( checkIfDictAndLegal( MPPARM(mpool) path, startLen,
|
||||
data.cFileName ) ) {
|
||||
XP_U16 len;
|
||||
|
@ -619,14 +619,27 @@ locateOneDir( MPFORMAL wchar_t* path, OnePathCB cb, void* ctxt, XP_U16 nSought,
|
|||
} /* locateOneDir */
|
||||
|
||||
XP_U16
|
||||
ceLocateNDicts( MPFORMAL XP_U16 nSought, OnePathCB cb, void* ctxt )
|
||||
ceLocateNDicts( MPFORMAL HINSTANCE hInstance, XP_U16 nSought,
|
||||
OnePathCB cb, void* ctxt )
|
||||
{
|
||||
XP_U16 nFound = 0;
|
||||
wchar_t pathBuf[CE_MAX_PATH_LEN+1];
|
||||
UINT id;
|
||||
|
||||
pathBuf[0] = 0;
|
||||
for ( id = IDS_DICTDIRS; ; ++id ) {
|
||||
wchar_t pathBuf[CE_MAX_PATH_LEN+1];
|
||||
int len = LoadString( hInstance, id, pathBuf, sizeof(pathBuf) );
|
||||
XP_LOGF( "%s: LoadString => %d", __FUNCTION__, len );
|
||||
if ( len == 0 ) {
|
||||
break;
|
||||
}
|
||||
|
||||
locateOneDir( MPPARM(mpool) pathBuf, cb, ctxt, nSought, &nFound );
|
||||
|
||||
if ( nFound >= nSought ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
locateOneDir( MPPARM(mpool) pathBuf, cb, ctxt, nSought, &nFound );
|
||||
return nFound;
|
||||
} /* ceLocateNthDict */
|
||||
|
||||
|
|
|
@ -38,7 +38,8 @@ DictionaryCtxt* ce_dictionary_make_empty( CEAppGlobals* globals );
|
|||
* making sure bufs contains nSought slots.
|
||||
*/
|
||||
typedef XP_Bool (*OnePathCB)( const wchar_t* wPath, XP_U16 index, void* ctxt );
|
||||
XP_U16 ceLocateNDicts( MPFORMAL XP_U16 nSought, OnePathCB cb, void* ctxt );
|
||||
XP_U16 ceLocateNDicts( MPFORMAL HINSTANCE hInstance, XP_U16 nSought,
|
||||
OnePathCB cb, void* ctxt );
|
||||
|
||||
|
||||
XP_UCHAR* bname( XP_UCHAR* in );
|
||||
|
|
|
@ -211,8 +211,8 @@ loadFromGameInfo( HWND hDlg, CEAppGlobals* globals, GameInfoState* giState )
|
|||
(XP_U16)XP_STRLEN(gi->dictName)+1 );
|
||||
}
|
||||
if ( giState->isNewGame ) {
|
||||
(void)ceLocateNDicts( MPPARM(globals->mpool) 32, addDictToMenu,
|
||||
giState );
|
||||
(void)ceLocateNDicts( MPPARM(globals->mpool) globals->hInst, 32,
|
||||
addDictToMenu, giState );
|
||||
if ( !giState->curSelSet ) {
|
||||
SendDlgItemMessage( giState->hDlg, IDC_DICTCOMBO, CB_SETCURSEL,
|
||||
0, 0L );
|
||||
|
|
|
@ -969,7 +969,8 @@ InitInstance(HINSTANCE hInstance, int nCmdShow)
|
|||
|
||||
/* choose one. If none found it's an error. */
|
||||
#ifndef STUBBED_DICT
|
||||
result = 1 == ceLocateNDicts(MPPARM(mpool) 1, ceSetDictName, globals );
|
||||
result = 1 == ceLocateNDicts( MPPARM(mpool) hInstance, 1, ceSetDictName,
|
||||
globals );
|
||||
if ( !result ) {
|
||||
messageBoxChar( globals, "Please install at least one Crosswords "
|
||||
"dictionary.", L"Fatal error" );
|
||||
|
|
|
@ -184,6 +184,10 @@
|
|||
#define IDS_FILE 40002
|
||||
#define IDS_GAME 40003
|
||||
#define IDS_MOVE 40004
|
||||
// Don't use the numbers after 4005: one string needs not to be there
|
||||
// to stop the progression in cedict.c
|
||||
#define IDS_DICTDIRS 40005
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
|
|
|
@ -249,7 +249,8 @@ BEGIN
|
|||
EDITTEXT PASS_EDIT4,GAME_PWD_LEFT,PLAYER_ROW_4,20,ROW_HEIGHT,
|
||||
ES_PASSWORD | ES_AUTOHSCROLL
|
||||
|
||||
LTEXT "Dictionary:",IDC_STATIC,LEFT_COL,DICTPICK_ROW,36,8,SS_NOPREFIX
|
||||
LTEXT "Dictionary:",IDC_STATIC,LEFT_COL,DICTPICK_ROW,36,8,
|
||||
SS_NOPREFIX
|
||||
COMBOBOX IDC_DICTCOMBO,43,DICTPICK_ROW,85,58,
|
||||
CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
|
||||
|
@ -662,6 +663,12 @@ BEGIN
|
|||
IDS_FILE "File"
|
||||
IDS_GAME "Game"
|
||||
IDS_MOVE "Move"
|
||||
#ifdef _WIN32
|
||||
IDS_DICTDIRS "."
|
||||
#else
|
||||
IDS_DICTDIRS "\\Program Files\\Crosswords"
|
||||
IDS_DICTDIRS+1 "\\SD Card\\Crosswords"
|
||||
#endif
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
|
|
Loading…
Reference in a new issue