void CDialogParticleEditor::OnBnClickedButtonNew() { DialogName dlg("New Particle"); if (dlg.DoModal() == IDOK) { CFileDialog dlgSave( TRUE, "prt", NULL, OFN_CREATEPROMPT, "Particle Files (*.prt)|*.prt||All Files (*.*)|*.*||", AfxGetMainWnd() ); if ( dlgSave.DoModal() == IDOK ) { if ( declManager->FindType( DECL_PARTICLE, dlg.m_strName, false ) ) { MessageBox( "Particle already exists!", "Particle exists", MB_OK ); return; } idStr fileName; fileName = fileSystem->OSPathToRelativePath( dlgSave.m_ofn.lpstrFile ); idDecl *decl = declManager->CreateNewDecl( DECL_PARTICLE, dlg.m_strName, fileName ); if ( decl ) { if ( MessageBox( "Copy current particle?", "Copy current", MB_YESNO | MB_ICONQUESTION ) == IDYES ) { MessageBox( "Copy current particle not implemented yet.. Stay tuned" ); } EnumParticles(); int index = comboParticle.FindStringExact( -1, dlg.m_strName ); if ( index >= 0 ) { comboParticle.SetCurSel( index ); } OnBnClickedButtonSave(); OnCbnSelchangeComboParticles(); } } } }
void CDialogSound::OnBtnSavemapas() { CFileDialog dlgSave(FALSE,"map",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"Map Files (*.map)|*.map||",AfxGetMainWnd()); if (dlgSave.DoModal() == IDOK) { OnBtnApply(); idStr work; work = fileSystem->OSPathToRelativePath( dlgSave.m_ofn.lpstrFile ); gameEdit->MapSave( work ); } }
void CDialogParticleEditor::OnBnClickedButtonSave() { idDeclParticle *idp = GetCurParticle(); if ( idp == NULL ) { return; } if ( strstr( idp->GetFileName(), "implicit" ) ) { // defaulted, need to choose a file CFileDialog dlgSave( FALSE, "prt", NULL, OFN_OVERWRITEPROMPT, "Particle Files (*.prt)|*.prt||All Files (*.*)|*.*||", AfxGetMainWnd() ); if ( dlgSave.DoModal() == IDOK ) { idStr fileName; fileName = fileSystem->OSPathToRelativePath( dlgSave.m_ofn.lpstrFile ); idp->Save( fileName ); EnumParticles(); } } else { idp->Save(); } }
/* ================ DialogAF::OnBnClickedButtonAfNew ================ */ void DialogAF::OnBnClickedButtonAfNew() { DialogAFName nameDlg; CString name; idStr fileName; nameDlg.SetComboBox( &AFList ); if( nameDlg.DoModal() != IDOK ) { return; } nameDlg.GetName( name ); CFileDialog dlgSave( FALSE, "map", NULL, OFN_OVERWRITEPROMPT, "AF Files (*.af)|*.af|All Files (*.*)|*.*||", AfxGetMainWnd() ); if( dlgSave.DoModal() != IDOK ) { return; } fileName = fileSystem->OSPathToRelativePath( dlgSave.m_ofn.lpstrFile ); // create a new .af file AFList.AddString( name ); AFList.SetCurSel( AFList.FindString( -1, name ) ); idDeclAF *decl = static_cast<idDeclAF *>( declManager->CreateNewDecl( DECL_AF, name, fileName ) ); LoadFile( decl ); AFDialogSetFileModified(); }
void CDialogParticleEditor::OnBnClickedButtonSaveAs() { idDeclParticle *idp = GetCurParticle(); if ( idp == NULL ) { return; } DialogName dlg("New Particle"); if (dlg.DoModal() == IDOK) { if ( declManager->FindType( DECL_PARTICLE, dlg.m_strName, false ) ) { MessageBox( "Particle already exists!", "Particle exists", MB_OK ); return; } CFileDialog dlgSave( TRUE, "prt", NULL, OFN_CREATEPROMPT, "Particle Files (*.prt)|*.prt||All Files (*.*)|*.*||", AfxGetMainWnd() ); if ( dlgSave.DoModal() == IDOK ) { idStr fileName; fileName = fileSystem->OSPathToRelativePath( dlgSave.m_ofn.lpstrFile ); idDeclParticle *decl = dynamic_cast<idDeclParticle*>( declManager->CreateNewDecl( DECL_PARTICLE, dlg.m_strName, fileName ) ); if ( decl ) { decl->stages.DeleteContents( true ); decl->depthHack = idp->depthHack; for ( int i = 0; i < idp->stages.Num(); i++ ) { idParticleStage *stage = new idParticleStage(); *stage = *idp->stages[i]; decl->stages.Append( stage ); } EnumParticles(); int index = comboParticle.FindStringExact( -1, dlg.m_strName ); if ( index >= 0 ) { comboParticle.SetCurSel( index ); } OnBnClickedButtonSave(); OnCbnSelchangeComboParticles(); OnBnClickedButtonUpdate(); } } } }
void CResizeView::SavePic() { if(procNew != 0) { CFileDialog dlgSave(FALSE,_T("*.bmp"),"",OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST|OFN_HIDEREADONLY ,"image files(*.bmp;*.jpg;*.png;*.gif)|*.bmp;*.jpg;*.png;*.gif|ALLFiles(*.*)||" ,NULL); char title[] = { "Save Image" }; dlgSave.m_ofn.lpstrTitle = title; if(IDOK == dlgSave.DoModal()) { CString path = dlgSave.GetPathName(); cvSaveImage(path,procNew->getImg()); } } else { MessageBox("请先处理图片"); } }
//保存到一副Bmp 文件 void BinImg::OnSaveToBmp() { static char BASED_CODE szFilter[] = "Bmp File (*.bmp)|*.bmp|"; CStatic *pImg = (CStatic *)GetDlgItem(IDC_BINIMG); HBITMAP hbm = pImg->GetBitmap(); if (hbm == NULL) return; CFileDialog dlgSave( FALSE, "*.bmp", "", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter, NULL ); dlgSave.DoModal(); CString sFileName; sFileName = dlgSave.GetFileName(); if (sFileName.IsEmpty()) { return; } /* OPENFILENAME ofn; // common dialog box structure char szFile[260]; // buffer for file name HWND hwnd; // owner window HANDLE hf; // file handle // Initialize OPENFILENAME ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwnd; ofn.lpstrFile = szFile; // // Set lpstrFile[0] to '\0' so that GetOpenFileName does not // use the contents of szFile to initialize itself. // ofn.lpstrFile[0] = '\0'; ofn.nMaxFile = sizeof(szFile); ofn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0"; ofn.nFilterIndex = 1; ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = NULL; ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; // Display the Save dialog box. GetSaveFileName(&ofn); // ofn.lpstrFile Store the Filename. MessageBox(NULL,ofn.lpstrFile,NULL,MB_OK); */ SaveToFile(hbm,sFileName); //保存到文件 }
/* ======================================================================================================================= Map_SaveFile ======================================================================================================================= */ bool Map_SaveFile(const char *filename, bool use_region, bool autosave) { entity_t *e, *next; idStr temp; int count; brush_t *b; idStr status; int len = strlen(filename); WIN32_FIND_DATA FileData; if (FindFirstFile(filename, &FileData) != INVALID_HANDLE_VALUE) { // the file exists; if (len > 0 && GetFileAttributes(filename) & FILE_ATTRIBUTE_READONLY) { g_pParentWnd->MessageBox("File is read only", "Read Only", MB_OK); return false; } } if (filename == NULL || len == 0 || (filename && stricmp(filename, "unnamed.map") == 0)) { CFileDialog dlgSave(FALSE,"map",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"Map Files (*.map)|*.map||",AfxGetMainWnd()); if (dlgSave.DoModal() == IDOK) { filename = dlgSave.m_ofn.lpstrFile; strcpy(currentmap, filename); } else { return false; } } MEMORYSTATUSEX statex; statex.dwLength = sizeof (statex); GlobalMemoryStatusEx (&statex); if ( statex.dwMemoryLoad > 95 ) { g_pParentWnd->MessageBox("Physical memory is over 95% utilized. Consider saving and restarting", "Memory"); } CWaitDlg dlg; Pointfile_Clear(); temp = filename; temp.BackSlashesToSlashes(); if ( !use_region ) { idStr backup; backup = temp; backup.StripFileExtension(); backup.SetFileExtension( ".bak" ); if ( _unlink(backup) != 0 && errno != 2 ) { // errno 2 means the file doesn't exist, which we don't care about g_pParentWnd->MessageBox( va("Unable to delete %s: %s", backup.c_str(), strerror(errno) ), "File Error" ); } if ( rename(filename, backup) != 0 ) { g_pParentWnd->MessageBox( va("Unable to rename %s to %s: %s", filename, backup.c_str(), strerror(errno) ), "File Error" ); } } common->Printf("Map_SaveFile: %s\n", filename); idStr mapFile; bool localFile = (strstr(filename, ":") != NULL); if (autosave || localFile) { mapFile = filename; } else { mapFile = fileSystem->OSPathToRelativePath( filename ); } if (use_region) { AddRegionBrushes(); } idMapFile map; world_entity->origin.Zero(); idMapEntity *mapentity = EntityToMapEntity(world_entity, use_region, &dlg); dlg.SetText("Saving worldspawn..."); map.AddEntity(mapentity); if ( use_region ) { idStr buf; sprintf( buf, "{\n\"classname\" \"info_player_start\"\n\"origin\"\t \"%i %i %i\"\n\"angle\"\t \"%i\"\n}\n", (int)g_pParentWnd->GetCamera()->Camera().origin[0], (int)g_pParentWnd->GetCamera()->Camera().origin[1], (int)g_pParentWnd->GetCamera()->Camera().origin[2], (int)g_pParentWnd->GetCamera()->Camera().angles[YAW] ); idLexer src( LEXFL_NOSTRINGCONCAT | LEXFL_NOSTRINGESCAPECHARS | LEXFL_ALLOWPATHNAMES ); src.LoadMemory( buf, buf.Length(), "regionbuf" ); idMapEntity *playerstart = idMapEntity::Parse( src ); map.AddEntity( playerstart ); } count = -1; for ( e = entities.next; e != &entities; e = next ) { count++; next = e->next; if (e->brushes.onext == &e->brushes) { Entity_Free(e); // no brushes left, so remove it } else { if (use_region) { for (b = e->brushes.onext; b != &e->brushes; b = b->onext) { if (!Map_IsBrushFiltered(b)) { break; // got one } } if (b == &e->brushes) { continue; // nothing visible } } idVec3 origin; if (!GetVectorForKey(e, "origin", origin)) { idStr text; VectorSubtract(e->brushes.onext->mins, e->eclass->mins, origin); sprintf(text, "%i %i %i", (int)origin[0], (int)origin[1], (int)origin[2]); SetKeyValue(e, "origin", text); } if (use_region && !idStr::Icmp(ValueForKey(e, "classname"), "info_player_start")) { continue; } idStr classname = e->epairs.GetString("classname"); sprintf(status, "Saving entity %i (%s)...", count, classname.c_str()); dlg.SetText(status); map.AddEntity(EntityToMapEntity(e, use_region, &dlg)); count++; } } mapFile.StripFileExtension(); idStr mapExt = (use_region) ? ".reg" : ".map"; sprintf(status, "Writing file %s.%s...", mapFile.c_str(), mapExt.c_str()); dlg.SetText(status); map.Write(mapFile, mapExt, !(autosave || localFile)); mapModified = 0; if (use_region) { RemoveRegionBrushes(); } if (!strstr(temp, "autosave")) { Sys_SetTitle(temp); } Sys_Status("Saved.\n", 0); return true; }
DWORD CSetupCheckUpdate::OnTaskStart() { CDownloadBindStatusCallback* pBSC = new CDownloadBindStatusCallback(m_pSetupUI); NDUPDATE_UPDATE_INFO_V2 updateinfo = {0}; CString strURL; BOOL fSuccess = strURL.LoadString(IDS_UPDATE_URL); if (!fSuccess) { m_pSetupUI->NotifyTaskDone(); pBSC->Release(); return ERROR_SUCCESS; } while (TRUE) { fSuccess = ::NdasUpdateGetUpdateInfo( pBSC, m_szUpdateURL, &m_SysInfo, &updateinfo); DWORD dwError = ::GetLastError(); if (!fSuccess) { INT_PTR iResponse = m_pSetupUI->PostErrorMessageBox( dwError, IDS_ERR_CHECK_UPDATE, MB_ICONERROR | MB_ABORTRETRYIGNORE); if (IDABORT == iResponse) { m_pSetupUI->NotifyFatalExit(ERROR_INSTALL_USEREXIT); } else if (IDIGNORE == iResponse) { m_pSetupUI->NotifyTaskDone(); pBSC->Release(); return ERROR_SUCCESS; } continue; } break; } if (!updateinfo.fNeedUpdate) { m_pSetupUI->NotifyTaskDone(); pBSC->Release(); return ERROR_SUCCESS; } CString str, strVersion; strVersion.Format( _T("%d.%d.%d"), updateinfo.ProductVersion.wMajor, updateinfo.ProductVersion.wMinor, updateinfo.ProductVersion.wBuild); str.FormatMessage(IDS_UPDATE_AVAILABLE_FMT, (LPCTSTR) strVersion); INT_PTR iResponse = m_pSetupUI->PostMessageBox( str, MB_YESNO | MB_ICONQUESTION); if (IDYES != iResponse) { m_pSetupUI->NotifyTaskDone(); pBSC->Release(); return ERROR_SUCCESS; } CString strFilter; fSuccess = strFilter.LoadString(IDS_EXE_FILES); ATLASSERT(fSuccess); TCHAR szFilter[MAX_PATH] = _T("Executable Files\0*.exe\0\0"); //HRESULT hr = CopyMemory( // szFilter, // MAX_PATH, // _T("%s\0*.exe\0\0"), // (LPCTSTR)strFilter); //ATLASSERT(SUCCEEDED(hr)); WTL::CFileDialog dlgSave( FALSE, _T("*.exe"), updateinfo.szFullSetupFileURL, OFN_OVERWRITEPROMPT, szFilter, NULL); while (TRUE) { // // Save As // iResponse = dlgSave.DoModal( m_pSetupUI->GetCurrentWindow()); if (IDOK != iResponse) { m_pSetupUI->NotifyTaskDone(); pBSC->Release(); return ERROR_INSTALL_USEREXIT; } HRESULT hr = ::URLDownloadToFile( NULL, updateinfo.szFullSetupFileURL, dlgSave.m_szFileName, 0, pBSC); if (m_pSetupUI->HasUserCanceled()) { m_pSetupUI->NotifyTaskDone(); pBSC->Release(); return ERROR_INSTALL_USEREXIT; } if (FAILED(hr)) { INT_PTR iResponse = m_pSetupUI->PostErrorMessageBox( hr, IDS_ERR_DOWNLOAD_UPDATE, MB_ABORTRETRYIGNORE | MB_ICONERROR); if (IDABORT == iResponse) { m_pSetupUI->NotifyFatalExit(hr); pBSC->Release(); return ERROR_INSTALL_USEREXIT; } else if (IDRETRY == iResponse) { continue; } else if (IDIGNORE == iResponse) { m_pSetupUI->NotifyTaskDone(); pBSC->Release(); return ERROR_SUCCESS; } } break; } pBSC->Release(); m_pSetupUI->SetPostExecuteFile(dlgSave.m_szFileName); m_pSetupUI->NotifyTaskDone(TASKRET_EXIT); return ERROR_SUCCESS; }
/* =========== Map_SaveFile =========== */ void Map_SaveFile (char *filename, qboolean use_region ) { entity_t *e, *next; FILE *f; char temp[1024]; int count; if (filename == NULL || strlen(filename) == 0) { CFileDialog dlgSave(FALSE, "map", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Map Files (*.map)|*.map||", AfxGetMainWnd()); if (dlgSave.DoModal() == IDOK) filename = strdup(dlgSave.m_ofn.lpstrFile); else return; } Pointfile_Clear (); QE_ConvertDOSToUnixName( temp, filename ); if (!use_region) { char backup[1024]; // rename current to .bak strcpy (backup, filename); StripExtension (backup); strcat (backup, ".bak"); _unlink (backup); rename (filename, backup); } Sys_Printf ("Map_SaveFile: %s\n", filename); f = fopen(filename, "w"); if (!f) { Sys_Printf ("ERROR!!!! Couldn't open %s\n", filename); return; } if (use_region) { AddRegionBrushes (); } // write world entity first Entity_Write (world_entity, f, use_region); // then write all other ents count = 1; for (e=entities.next ; e != &entities ; e=next) { next = e->next; if (e->brushes.onext == &e->brushes) { Entity_Free (e); // no brushes left, so remove it } else { fprintf (f, "// entity %i\n", count); count++; Entity_Write (e, f, use_region); } } // save the group info stuff Group_Save(f); fclose (f); if (use_region) RemoveRegionBrushes (); Sys_Printf ("Saved.\n"); modified = false; if ( !strstr( temp, "autosave" ) ) Sys_SetTitle (temp); if (!use_region) { time_t timer; FILE *f; time (&timer); MessageBeep (MB_ICONEXCLAMATION); f = fopen ("c:/tstamps.log", "a"); if (f) { fprintf (f, "%s", filename); //fprintf (f, "%4i : %35s : %s", g_qeglobals.d_workcount, filename, ctime(&timer)); fclose (f); g_qeglobals.d_workcount = 0; } fclose (f); Sys_Status ("Saved.\n", 0); } //Curve_WriteFile (filename); //.trinity //Patch_WriteFile (filename); }