///////////////////////////////////////////////////////////////// // TMainClient // ----------- // void TMainClient::CmFileOpenWad () { // save current working directory (of windeu32.exe) // the TFileOpenDialog below is going to set // it to the folder of the file being opened... char workdir[256]; GetCurrentDirectory(256, workdir); SET_HELP_CONTEXT(Open_WAD_file); // // Display standard Open dialog box to select a file name. // *FileData.FileName = 0; if (TFileOpenDialog(this, FileData).Execute() == IDOK) { // restore workingdirectory to folder of windeu32.exe SetCurrentDirectory(workdir); #if 0 OpenPatchWad(FileData.FileName); CloseUnusedWadFiles(); #endif // Sets a new client window (the editor) and destroy // the old one (the main client) TMainFrame *MainFrame = TYPESAFE_DOWNCAST (GetApplication()->GetMainWindow(), TMainFrame); MainFrame->EditLevel (FileData.FileName, FALSE) ; } RESTORE_HELP_CONTEXT(); }
// /// Opens a new file after determining that it is OK to clear the text of the /// Editor. Calls CanClear, and if true is returned, brings up a file dialog box to /// retrieve the name of a new file from the user. Calls ReplaceWith to pass the /// name of the new file. // /// Same as selecting File|Open from the menus // void TEditFile::Open() { if (CanClear()) { *FileData.FileName = 0; if (TFileOpenDialog(this, FileData).Execute() == IDOK) ReplaceWith(FileData.FileName); } }
void ReadSignalDialog::EvFileName () { TOpenSaveDialog::TData FileData ; FileData.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY ; FileData.SetFilter("Data files (*.DAT)|*.DAT|All Files (*.*)|*.*|") ; *FileData.FileName = 0 ; if (TFileOpenDialog ( this , FileData ).Execute() == IDOK) strcpy ( file_name , FileData.FileName ) ; }
///////////////////////////////////////////////////////////////// // TMainClient // ----------- // void TMainClient::CmFileInsertRaw () { static char ObjectName[12]; char input[MAX_PATH]; MDirPtr entry; FILE *raw; FILE *file; WadPtr wad; SET_HELP_CONTEXT(Insert_RAW_file); // // Display standard Open dialog box to select a file name. // *FileData.FileName = 0; if (TFileOpenDialog(this, FileData).Execute() != IDOK) goto End; // Get objet name //TODO: Stupid InputDialog box, would be better with a list box if ( TInputDialog (this, "Enter object name", "Object :", ObjectName, 12).Execute() != IDOK ) goto End; // Check the name of the object exists for (entry = MasterDir ; entry != NULL ; entry = entry->next) if ( strnicmp (entry->dir.name, ObjectName, 8) == 0 ) break; if ( entry == NULL ) { Notify ("The object \"%s\" doesn't exist", ObjectName); goto End; } // Check WAD file isn't opened raw = fopen(FileData.FileName, "rb"); if (raw == NULL) { Notify ("Error opening input file \"%s\"", FileData.FileName); goto End; } // kluge: Check WAD isn't opened strcpy (input, ObjectName); strcat (input, ".WAD"); for (wad = WadFileList; wad; wad = wad->next) if (!stricmp( input, wad->filename)) break; if (wad) { Notify ("The Wad file \"%s\" is already in use. You may not " "overwrite it.", input); goto End; } // Opening .RAW file in .WAD entry WorkMessage ("Including new object %s in \"%s\".", ObjectName, input); file = fopen (input, "wb"); if (file == NULL) Notify ("Error opening output file \"%s\"", input); SaveEntryFromRawFile (file, raw, ObjectName); fclose(raw); fclose(file); End: RESTORE_HELP_CONTEXT(); }