Exemplo n.º 1
0
void	CLODConvertApp::FileOpen(CString FileName)
{

		EditList[ModelSelected].Name="";
		// Ok... Load the model
		CFile File;
		File.Open(FileName, CFile::modeRead, &CFileException(CFileException::generic, NULL));
		DWORD	FileSize=(DWORD)File.GetLength();
		void *FileBuffer=malloc(FileSize);
		File.Read(FileBuffer, FileSize);
		FileTitle=File.GetFileTitle();
		File.Close();
		TheModelPath=FileName;
		
		while(RenderPhase) Delay(5);
		// Eventually clear the model
		ClearModel(&EditList[ModelSelected]);
		// Linearize the model and assign to selected item
		DeIndexModel(FileBuffer, &EditList[ModelSelected]);
		E_FixModelFeatures(&EditList[ModelSelected]);
		EditList[ModelSelected].Name=FileTitle;
	
		SetupModel();
		AddToRecentFileList(FileName);

}
Exemplo n.º 2
0
// read in a new mission file from disk
BOOL CFREDDoc::OnOpenDocument(LPCTSTR pathname)
{
	char name[1024];
	int i, len;

	if (pathname)
		strcpy(mission_pathname, pathname);

	if (Briefing_dialog)
		Briefing_dialog->icon_select(-1);  // clean things up first

	len = strlen(mission_pathname);
	strcpy(name, mission_pathname);
	if (name[len - 4] == '.')
		len -= 4;

	name[len] = 0;  // drop extension
	i = len;
	while (i--)
		if ((name[i] == '\\') || (name[i] == ':'))
			break;

	strcpy(Mission_filename, name + i + 1);
//	for (i=1; i<=BACKUP_DEPTH; i++) {
//		sprintf(name + len, ".%.3d", i);
//		unlink(name);
//	}

	

	if (load_mission(mission_pathname)) {
		*Mission_filename = 0;
		return FALSE;
	}

	Fred_view_wnd->global_error_check();
	autosave("nothing");
	Undo_count = 0;

	AddToRecentFileList(pathname);

	return TRUE;
}
Exemplo n.º 3
0
// save mission to a file
BOOL CFREDDoc::OnSaveDocument(LPCTSTR pathname)
{
	CFred_mission_save save;
	char name[1024];
	int len;
	DWORD attrib;
	FILE *fp;

	len = strlen(pathname);
	strcpy(name, pathname);
	if (name[len - 4] == '.')
		len -= 4;

	name[len] = 0;  // drop extension
	while (len--)
		if ((name[len] == '\\') || (name[len] == ':'))
			break;

	strcpy(Mission_filename, name + len + 1);
	Fred_view_wnd->global_error_check();
	if (Briefing_dialog) {
		Briefing_dialog->update_data(1);
		Briefing_dialog->save_editor_state();
	}
	
	if (Event_editor_dlg)
		Fred_main_wnd->MessageBox("Event editor dialog is still open, so changes there won't be saved");

	if (Message_editor_dlg)
		Fred_main_wnd->MessageBox("Message editor dialog is still open, so changes there won't be saved");

	fp = fopen(pathname, "r");
	if (fp) {
		fclose(fp);
		attrib = GetFileAttributes(pathname);
		if (attrib & FILE_ATTRIBUTE_READONLY) {
			Fred_main_wnd->MessageBox("File is read-only.  You need to check it out before saving to it");
			return FALSE;
		}
	}	

	if (save.save_mission_file((char *) pathname)) {
		Fred_main_wnd->MessageBox("An error occured while saving!", NULL, MB_OK | MB_ICONEXCLAMATION);
		return FALSE;
	}

	SetModifiedFlag(FALSE);
	if (load_mission((char *) pathname))
		Fred_main_wnd->MessageBox("Failed attempted to reload mission after saving.  Report this bug now!");
		//	Error(LOCATION, "Failed attempting to reload mission after saving.  Report this bug now!");

	if (Briefing_dialog) {
		Briefing_dialog->restore_editor_state();
		Briefing_dialog->update_data(1);
	}

	AddToRecentFileList(pathname);

	return TRUE;
//	return CDocument::OnSaveDocument(pathname);
}