//dnl ch36 200909 BOOLEAN ExtractFilenameFromFields(void) { Get16BitStringFromField(0, gzFilename, FILENAME_BUFLEN); size_t len = wcslen(gzFilename); if(gzFilename[len-4] != L'.' && len < (FILENAME_BUFLEN-4)) wcscat(gzFilename, L".dat"); return(ValidFilename()); }
//The callback calls this function passing the relative y position of where //the user clicked on the hot spot. void SelectFileDialogYPos( UINT16 usRelativeYPos ) { INT16 sSelName; INT32 x; FDLG_LIST *FListNode; sSelName = usRelativeYPos / 15; //This is a field in the text editmode, but clicked via mouse. SetActiveField( 1 ); // Skip to first filename FListNode = FileList; for(x=0;x<iTopFileShown && x<iTotalFiles && FListNode != NULL;x++) { FListNode = FListNode->pNext; } for(x=iTopFileShown;x<(iTopFileShown+8) && x<iTotalFiles && FListNode != NULL; x++) { if( (INT32)sSelName == (x-iTopFileShown) ) { INT32 iCurrClickTime; iCurrFileShown = x; FListNode->FileInfo.zFileName[30] = 0; swprintf( gzFilename, L"%S", FListNode->FileInfo.zFileName ); if( ValidFilename() ) { SetInputFieldStringWith16BitString( 0, gzFilename ); } else { SetInputFieldStringWith16BitString( 0, L"" ); wcscpy( gzFilename, L"" ); } RenderInactiveTextField( 0 ); //Calculate and process any double clicking... iCurrClickTime = GetJA2Clock(); if( iCurrClickTime - iLastClickTime < 400 && x == iLastFileClicked ) { //Considered a double click, so activate load/save this filename. gfDestroyFDlg = TRUE; iFDlgState = iCurrentAction == ACTION_SAVE_MAP ? DIALOG_SAVE : DIALOG_LOAD; } iLastClickTime = iCurrClickTime; iLastFileClicked = x; } FListNode = FListNode->pNext; } }
bool Security::CanExecute(const string& file) { if(disabled) return true; if(!ValidFilename(file)) return false; list<string>::const_iterator i; for(i=execute.begin(); i!=execute.end(); i++) if(MatchString(*i,file)) return true; return false; }
BOOLEAN ExternalLoadMap( UINT16 *szFilename ) { Assert( szFilename ); if( !wcslen( szFilename ) ) return FALSE; wcscpy( gzFilename, szFilename ); if( !ValidFilename() ) return FALSE; gbCurrentFileIOStatus = INITIATE_MAP_LOAD; ProcessFileIO(); //always returns loadsave_screen and changes iostatus to loading_map. ExecuteBaseDirtyRectQueue(); EndFrameBufferRender(); RefreshScreen( NULL ); if( ProcessFileIO() == EDIT_SCREEN ) return TRUE; return FALSE; }
BOOLEAN ExternalSaveMap( UINT16 *szFilename ) { Assert( szFilename ); if( !wcslen( szFilename ) ) return FALSE; wcscpy( gzFilename, szFilename ); if( !ValidFilename() ) return FALSE; gbCurrentFileIOStatus = INITIATE_MAP_SAVE; if( ProcessFileIO() == ERROR_SCREEN ) return FALSE; ExecuteBaseDirtyRectQueue(); EndFrameBufferRender(); RefreshScreen( NULL ); if( ProcessFileIO() == EDIT_SCREEN ) return TRUE; return FALSE; }
bool Security::CanOpenDir(const string& _dir) { if(disabled) return true; if(!ValidFilename(_dir)) return false; string dir=_dir; if(dir.length() && dir[dir.length()-1]=='/') dir=dir.substr(0,dir.length()-1); list<string>::const_iterator i; for(i=open_dir.begin(); i!=open_dir.end(); i++) if(MatchString(*i,dir)) return true; return false; }
//dnl ch37 200909 BOOLEAN ExternalLoadMap(STR16 szFilename) { gfLoadError = FALSE; Assert(szFilename); if(!wcslen( szFilename)) return(FALSE); wcscpy(gzFilename, szFilename); if(!ValidFilename()) return(FALSE); gbCurrentFileIOStatus = INITIATE_MAP_LOAD; ProcessFileIO(); ExecuteBaseDirtyRectQueue(); EndFrameBufferRender(); RefreshScreen(NULL); ProcessFileIO(); if(gfLoadError) return(FALSE); return(TRUE); }
UINT32 ProcessLoadSaveScreenMessageBoxResult() { FDLG_LIST *curr, *temp; gfRenderWorld = TRUE; RemoveMessageBox(); if( gfIllegalName ) { fEnteringLoadSaveScreen = TRUE; RemoveFileDialog(); MarkWorldDirty(); return gfMessageBoxResult ? LOADSAVE_SCREEN : EDIT_SCREEN; } if( gfDeleteFile ) { if( gfMessageBoxResult ) { //delete file INT32 x; curr = FileList; for( x = 0; x < iCurrFileShown && x < iTotalFiles && curr; x++ ) { curr = curr->pNext; } if( curr ) { if( gfReadOnly ) { FileClearAttributes( gszCurrFilename ); gfReadOnly = FALSE; } FileDelete( gszCurrFilename ); //File is deleted so redo the text fields so they show the //next file in the list. temp = curr->pNext; if( !temp ) temp = curr->pPrev; if( !temp ) wcscpy( gzFilename, L"" ); else swprintf( gzFilename, L"%S", temp->FileInfo.zFileName ); if( ValidFilename() ) { SetInputFieldStringWith16BitString( 0, gzFilename ); } else { SetInputFieldStringWith16BitString( 0, L"" ); wcscpy( gzFilename, L"" ); } RemoveFromFDlgList( &FileList, curr ); iTotalFiles--; if( !iTotalFiles ) { gfNoFiles = TRUE; if( iCurrentAction == ACTION_LOAD_MAP ) DisableButton( iFileDlgButtons[0] ); } if( iCurrFileShown >= iTotalFiles ) iCurrFileShown--; if( iCurrFileShown < iTopFileShown ) iTopFileShown -= 8; if( iTopFileShown < 0 ) iTopFileShown = 0; } } MarkWorldDirty(); RenderWorld(); gfDeleteFile = FALSE; iFDlgState = DIALOG_NONE; return LOADSAVE_SCREEN; } if(gfLoadError || gfSaveError)//dnl ch37 200909 { MarkWorldDirty(); RenderWorld(); fEnteringLoadSaveScreen = TRUE; return(gfMessageBoxResult ? LOADSAVE_SCREEN : EDIT_SCREEN); } if( gfReadOnly ) { //file is readonly. Result will determine if the file dialog stays up. fEnteringLoadSaveScreen = TRUE; RemoveFileDialog(); return gfMessageBoxResult ? LOADSAVE_SCREEN : EDIT_SCREEN; } if( gfFileExists ) { if( gfMessageBoxResult ) { //okay to overwrite file RemoveFileDialog(); gbCurrentFileIOStatus = INITIATE_MAP_SAVE; return LOADSAVE_SCREEN; } fEnteringLoadSaveScreen = TRUE; RemoveFileDialog(); return(LOADSAVE_SCREEN);//dnl ch36 210909 } // Assert( 0 ); return LOADSAVE_SCREEN; }
BOOLEAN ExtractFilenameFromFields() { Get16BitStringFromField( 0, gzFilename ); return ValidFilename(); }