Esempio n. 1
0
void COptionsPage::OnButtonSource(void)
{
	CString strPrompt;

	strPrompt.LoadString(IDS_CHOOSE_SOURCE);
	CFolderDialog dlgFolder(strPrompt, m_strSource, this, BIF_NEWDIALOGSTYLE);
	if (dlgFolder.DoModal() == IDOK)
	{
		m_strSource = dlgFolder.GetFolderPath();
		SetDlgItemText(IDC_EDIT_SOURCE, m_strSource);
#if (_MFC_VER < 0x0700)
		CWinApp* pApp = AfxGetApp();
		ASSERT_VALID(pApp);
		if ((m_timeWrite = pApp->GetProfileInt(SZ_REGK_TIMES, m_strSource, -1)) != -1)
#else
		CUpdateItApp* pApp = DYNAMIC_DOWNCAST(CUpdateItApp, AfxGetApp());
		ASSERT_VALID(pApp);
		if ((m_timeWrite = pApp->GetProfileTime(SZ_REGK_TIMES, m_strSource, -1)) != -1)
#endif   // _MFC_VER
		{
			m_dtpWrite.SetTime(&m_timeWrite);
		}
		CString strDefTarget = m_strSource + _T(".Update");
		SetDlgItemText(IDC_EDIT_TARGET, pApp->GetProfileString(SZ_REGK_TARGETS, m_strSource, strDefTarget));
	}
}
Esempio n. 2
0
void COptionsPage::OnButtonTarget(void)
{
	CString strPrompt;

	strPrompt.LoadString(IDS_CHOOSE_TARGET);
	CFolderDialog dlgFolder(strPrompt, m_strTarget, this, BIF_NEWDIALOGSTYLE);
	if (dlgFolder.DoModal() == IDOK)
	{
		m_strTarget = dlgFolder.GetFolderPath();
		SetDlgItemText(IDC_EDIT_TARGET, m_strTarget);
	}
}
Esempio n. 3
0
void CSubstDialog::OnButtonBrowse(void)
{
	CString strPrompt;
	CString strPath;

	strPrompt.LoadString(IDS_CHOOSE_PATH);
	m_editPath.GetWindowText(strPath);
	CFolderDialog dlgFolder(strPrompt, strPath, this);
	if (dlgFolder.DoModal() == IDOK)
	{
		m_editPath.SetWindowText(dlgFolder.GetFolderPath());
	}
}
Esempio n. 4
0
void CBaseConfigPage::OnBnClickedButton2()
{
	char szBuffer[1024];
	CString strIniDir;
	CString strSelectDir;
	GetCurrentDirectory (1024,szBuffer);
    strIniDir=szBuffer;
  CFolderDlg dlgFolder(TRUE, strIniDir, NULL);
  if(IDCANCEL==dlgFolder.DoModal())
	  return;
  strSelectDir=dlgFolder.GetFolderName();
  strSelectDir.TrimRight('\\');
  SetDlgItemText(IDC_LOGPATH,strSelectDir);
}
Esempio n. 5
0
LRESULT CPlayList::OnBnClickedBtnAddfolder(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	static _TCHAR strFolderPath[MAX_PATH] = { 0 };
	// TODO: Add your control notification handler code here
	CFolderDialog dlgFolder(m_hWnd, _T("Add files recoursively from folder..."),
		BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS);

	if (!::PathIsDirectory(strFolderPath))
		::GetCurrentDirectory(MAX_PATH, strFolderPath);
	dlgFolder.SetInitialFolder(strFolderPath);
	if ( IDOK == dlgFolder.DoModal()) {
		_tcscpy(strFolderPath, dlgFolder.GetFolderPath());
		//EnumerateFolder(strFolderPath, _T("\\*.prg"));
		//EnumerateFolder(strFolderPath, _T("\\*.c8m"));
		EnumerateFolder(strFolderPath, _T("\\*"));
	}
	return 0;
}
void CFREDDoc::OnFileImportFSM() {
	char fs1_mission_path[MAX_PATH_LEN];
	char fs2_mission_path[MAX_PATH_LEN];
	char dest_directory[MAX_PATH + 1];

	// path stuff
	{
		char *ch;

		// get base paths
		strcpy_s(fs1_mission_path, Fred_exe_dir);
		ch = strrchr(fs1_mission_path, DIR_SEPARATOR_CHAR);
		if (ch != NULL)
			*ch = '\0';
		strcpy_s(fs2_mission_path, Fred_exe_dir);
		ch = strrchr(fs2_mission_path, DIR_SEPARATOR_CHAR);
		if (ch != NULL)
			*ch = '\0';

		// estimate the mission path for FS1
		if ((ch = stristr(fs1_mission_path, "FreeSpace2")) != NULL) {
			strcpy(ch, "FreeSpace\\Data\\Missions");
		}

		// estimate the mission path for FS2
		strcat_s(fs2_mission_path, "\\Data\\Missions");
	}

	// if mission has been modified, offer to save before continuing.
	if (!SaveModified())
		return;


	// get location to import from
	CFileDialog dlgFile(TRUE, "fsm", NULL, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_ALLOWMULTISELECT, "FreeSpace Missions (*.fsm)|*.fsm|All files (*.*)|*.*||");
	dlgFile.m_ofn.lpstrTitle = "Select one or more missions to import";
	dlgFile.m_ofn.lpstrInitialDir = fs1_mission_path;

	// get FSM files
	if (dlgFile.DoModal() != IDOK)
		return;

	memset(dest_directory, 0, sizeof(dest_directory));

	// get location to save to    
#if ( _MFC_VER >= 0x0700 )
	//ITEMIDLIST fs2_mission_pidl = {0};

	//SHParseDisplayName(A2CW(fs2_mission_path), NULL, fs2_mission_pidl, 0, 0);

	BROWSEINFO bi;
	bi.hwndOwner = theApp.GetMainWnd()->GetSafeHwnd();
	//bi.pidlRoot = &fs2_mission_pidl;
	bi.pidlRoot = NULL;
	bi.pszDisplayName = dest_directory;
	bi.lpszTitle = "Select a location to save in";
	bi.ulFlags = 0;
	bi.lpfn = NULL;
	bi.lParam = NULL;
	bi.iImage = NULL;

	LPCITEMIDLIST ret_val = SHBrowseForFolder(&bi);

	if (ret_val == NULL)
		return;

	SHGetPathFromIDList(ret_val, dest_directory);
#else
	CFolderDialog dlgFolder(_T("Select a location to save in"), fs2_mission_path, NULL);
	if (dlgFolder.DoModal() != IDOK)
		return;

	strcpy_s(dest_directory, dlgFolder.GetFolderPath());
#endif

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

	clear_mission();

	// process all missions
	POSITION pos(dlgFile.GetStartPosition());
	while (pos) {
		char *ch;
		char filename[1024];
		char fs1_path[MAX_PATH_LEN];
		char dest_path[MAX_PATH_LEN];

		CString fs1_path_mfc(dlgFile.GetNextPathName(pos));
		CFred_mission_save save;

		DWORD attrib;
		FILE *fp;


		// path name too long?
		if (strlen(fs1_path_mfc) > MAX_PATH_LEN - 1)
			continue;

		// nothing here?
		if (!strlen(fs1_path_mfc))
			continue;

		// get our mission
		strcpy_s(fs1_path, fs1_path_mfc);

		// load mission into memory
		if (load_mission(fs1_path, MPF_IMPORT_FSM))
			continue;

		// get filename
		ch = strrchr(fs1_path, DIR_SEPARATOR_CHAR) + 1;
		if (ch != NULL)
			strcpy_s(filename, ch);
		else
			strcpy_s(filename, fs1_path);

		// truncate extension
		ch = strrchr(filename, '.');
		if (ch != NULL)
			*ch = '\0';

		// add new extension
		strcat_s(filename, ".fs2");

		strcpy_s(Mission_filename, filename);

		// get new path
		strcpy_s(dest_path, dest_directory);
		strcat_s(dest_path, "\\");
		strcat_s(dest_path, filename);

		// check attributes
		fp = fopen(dest_path, "r");
		if (fp) {
			fclose(fp);
			attrib = GetFileAttributes(dest_path);
			if (attrib & FILE_ATTRIBUTE_READONLY)
				continue;
		}

		// try to save it
		if (save.save_mission_file(dest_path))
			continue;

		// success
	}

	create_new_mission();

	MessageBox(NULL, "Import complete.  Please check the destination folder to verify all missions were imported successfully.", "Status", MB_OK);
	recreate_dialogs();
}