int ShowSaveDlg(HWND hWnd, std::wstring title, std::wstring filter, std::wstring defext, std::wstring *retfilepath, std::wstring *retfiletitle)
{

	OPENFILENAME ofn;
	wchar_t szFileName[MAX_PATH] = L"";
	wchar_t szFileTitle[MAX_PATH] = L"";
	size_t fillen = filter.size();
	wchar_t *szFilter = new wchar_t[fillen + 1];
	
	//memcpy(szFilter, filter.c_str(), fillen);
	for (unsigned int x = 0; x < fillen; x++)
	{
		szFilter[x] = (filter.c_str())[x];
	}
	szFilter[fillen] = 0;
	//MessageBox(NULL,szFilter,filter.c_str(),MB_OK);
	wcscpy(szFileName, defext.c_str());
	//memset(szFileName,0,maxsize);
	ConvertFilter(szFilter);
	ZeroMemory(&ofn, sizeof(ofn));
	ofn.lStructSize = sizeof(ofn);
	ofn.hwndOwner = hWnd;
	ofn.lpstrFilter = szFilter;
	ofn.lpstrFile = szFileName;
	ofn.lpstrFileTitle = szFileTitle;
	ofn.nMaxFile = MAX_PATH;
	ofn.nMaxFileTitle = MAX_PATH;
	//ofn.lpstrInitialDir = szMSKIDSPath;
	ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
	ofn.lpstrDefExt = defext.c_str();
	ofn.lpstrTitle = title.c_str();
	if(GetSaveFileName(&ofn))
	{
		//memcpy(output, szFileName, maxsize);
		if (retfilepath != NULL)
		{
			*retfilepath = szFileName;
		}
		if (retfiletitle != NULL)
		{
			*retfiletitle = szFileTitle;
		}
		return 1;
	}
	return 0;
}
Example #2
0
BOOL Cfg::GetFilterStr(const char *key, char *tmpbuf, WCHAR *wbuf)
{
	ini.GetStr(key, tmpbuf, MAX_HISTORY_CHAR_BUF, "");
	IniStrToW(tmpbuf, wbuf);

	if (needIniConvert) {
		PathArray pa;

		pa.RegisterMultiPath(wbuf);

		for (int i=0; i < pa.Num(); i++) {
			ConvertFilter(pa.Path(i), wbuf);
			pa.ReplacePath(i, wbuf);
		}
		pa.GetMultiPath(wbuf, MAX_HISTORY_CHAR_BUF);
	}

	return	TRUE;
}
Example #3
0
VOID STDMETHODCALLTYPE CTexture9::GenerateMipSubLevels()
{
	mDevice->BeginRecordingUtilityCommands();
	{
		vk::PipelineStageFlags sourceStages = vk::PipelineStageFlagBits::eTopOfPipe;
		vk::PipelineStageFlags destinationStages = vk::PipelineStageFlagBits::eTopOfPipe;
		vk::Filter realFilter = ConvertFilter(mMipFilter);

		vk::ImageMemoryBarrier imageMemoryBarrier;
		//imageMemoryBarrier.srcAccessMask = 0;
		//imageMemoryBarrier.dstAccessMask = 0;

		vk::ImageSubresourceRange mipSubRange;
		mipSubRange.aspectMask = vk::ImageAspectFlagBits::eColor;
		mipSubRange.levelCount = 1;
		mipSubRange.layerCount = 1;

		//Transition zero mip level to transfer source
		mipSubRange.baseMipLevel = 0;

		imageMemoryBarrier.oldLayout = vk::ImageLayout::eShaderReadOnlyOptimal;
		imageMemoryBarrier.newLayout = vk::ImageLayout::eTransferSrcOptimal;
		imageMemoryBarrier.image = mImage.get();
		imageMemoryBarrier.subresourceRange = mipSubRange;
		mDevice->mCurrentUtilityCommandBuffer.pipelineBarrier(sourceStages, destinationStages, vk::DependencyFlags(), 0, nullptr, 0, nullptr, 1, &imageMemoryBarrier);

		for (UINT i = 1; i < mLevels; i++) //Changed to match mLevels datatype
		{
			vk::ImageBlit imageBlit;

			// Source
			imageBlit.srcSubresource.aspectMask = vk::ImageAspectFlagBits::eColor;
			imageBlit.srcSubresource.layerCount = 1;
			imageBlit.srcSubresource.mipLevel = 0;
			imageBlit.srcOffsets[1].x = int32_t(mWidth);
			imageBlit.srcOffsets[1].y = int32_t(mHeight);
			imageBlit.srcOffsets[1].z = 1;

			// Destination
			imageBlit.dstSubresource.aspectMask = vk::ImageAspectFlagBits::eColor;
			imageBlit.dstSubresource.layerCount = 1;
			imageBlit.dstSubresource.mipLevel = i;
			imageBlit.dstOffsets[1].x = int32_t(mWidth >> i);
			imageBlit.dstOffsets[1].y = int32_t(mHeight >> i);
			imageBlit.dstOffsets[1].z = 1;

			//Transition current mip level to transfer dest
			mipSubRange.baseMipLevel = i;

			imageMemoryBarrier.oldLayout = vk::ImageLayout::eShaderReadOnlyOptimal;
			imageMemoryBarrier.newLayout = vk::ImageLayout::eTransferDstOptimal;
			imageMemoryBarrier.image = mImage.get();
			imageMemoryBarrier.subresourceRange = mipSubRange;
			mDevice->mCurrentUtilityCommandBuffer.pipelineBarrier(sourceStages, destinationStages, vk::DependencyFlags(), 0, nullptr, 0, nullptr, 1, &imageMemoryBarrier);

			// Blit from zero level
			mDevice->mCurrentUtilityCommandBuffer.blitImage(mImage.get(), vk::ImageLayout::eTransferSrcOptimal, mImage.get(), vk::ImageLayout::eTransferDstOptimal, 1, &imageBlit, realFilter /*vk::Filter::eLinear*/);

			//Transition back
			imageMemoryBarrier.oldLayout = vk::ImageLayout::eTransferDstOptimal;
			imageMemoryBarrier.newLayout = vk::ImageLayout::eShaderReadOnlyOptimal;
			imageMemoryBarrier.image = mImage.get();
			imageMemoryBarrier.subresourceRange = mipSubRange;
			mDevice->mCurrentUtilityCommandBuffer.pipelineBarrier(sourceStages, destinationStages, vk::DependencyFlags(), 0, nullptr, 0, nullptr, 1, &imageMemoryBarrier);
		}

		imageMemoryBarrier.oldLayout = vk::ImageLayout::eTransferSrcOptimal;
		imageMemoryBarrier.newLayout = vk::ImageLayout::eShaderReadOnlyOptimal;
		imageMemoryBarrier.image = mImage.get();
		imageMemoryBarrier.subresourceRange = mipSubRange;
		mDevice->mCurrentUtilityCommandBuffer.pipelineBarrier(sourceStages, destinationStages, vk::DependencyFlags(), 0, nullptr, 0, nullptr, 1, &imageMemoryBarrier);
	}
	mDevice->StopRecordingUtilityCommands();
}
Example #4
0
/**
 * @brief Helper function for selecting folder or file.
 * This function shows standard Windows file selection dialog for selecting
 * file or folder to open or file to save. The last parameter @p is_open selects
 * between open or save modes. Biggest difference is that in save-mode Windows
 * asks if user wants to override existing file.
 * @param [in] parent Handle to parent window. Can be a NULL, but then
 *     CMainFrame is used which can cause modality problems.
 * @param [out] path Selected path is returned in this string
 * @param [in] initialPath Initial path (and file) shown when dialog is opened
 * @param [in] titleid Resource string ID for dialog title.
 * @param [in] filterid 0 or STRING ID for filter string
 *     - 0 means "All files (*.*)". Note the string formatting!
 * @param [in] is_open Selects Open/Save -dialog (mode).
 * @note Be careful when setting @p parent to NULL as there are potential
 * modality problems with this. Dialog can be lost behind other windows!
 * @param [in] defaultExtension Extension to append if user doesn't provide one
 */
BOOL SelectFile(HWND parent, CString& path, LPCTSTR initialPath /*=NULL*/,
		UINT titleid /*=0*/, UINT filterid /*=0*/,
		BOOL is_open /*=TRUE*/, LPCTSTR defaultExtension /*=NULL*/)
{
	path.Empty(); // Clear output param

	// This will tell common file dialog what to show
	// and also this will hold its return value
	CString sSelectedFile;

	// check if specified path is a file
	if (initialPath && initialPath[0])
	{
		// If initial path info includes a file
		// we put the bare filename into sSelectedFile
		// so the common file dialog will start up with that file selected
		if (paths_DoesPathExist(initialPath) == IS_EXISTING_FILE)
		{
			String temp;
			SplitFilename(initialPath, 0, &temp, 0);
			sSelectedFile = temp.c_str();
		}
	}

	if (parent == NULL)
		parent = AfxGetMainWnd()->GetSafeHwnd();
	
	if (!filterid)
		filterid = IDS_ALLFILES;
	String title = theApp.LoadString(titleid);
	String filters = theApp.LoadString(filterid);

	// Convert extension mask from MFC style separators ('|')
	//  to Win32 style separators ('\0')
	LPTSTR filtersStr = &*filters.begin();
	ConvertFilter(filtersStr);

	OPENFILENAME_NT4 ofn;
	memset(&ofn, 0, sizeof(ofn));
	ofn.lStructSize = sizeof(ofn);
	ofn.hwndOwner = parent;
	ofn.lpstrFilter = filtersStr;
	ofn.lpstrCustomFilter = NULL;
	ofn.nFilterIndex = 1;
	ofn.lpstrFile = sSelectedFile.GetBuffer(MAX_PATH);
	ofn.nMaxFile = MAX_PATH;
	ofn.lpstrInitialDir = initialPath;
	ofn.lpstrTitle = title.c_str();
	ofn.lpstrFileTitle = NULL;
	if (defaultExtension)
		ofn.lpstrDefExt = defaultExtension;
	ofn.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST;

	BOOL bRetVal = FALSE;
	if (is_open)
		bRetVal = GetOpenFileName((OPENFILENAME *)&ofn);
	else
		bRetVal = GetSaveFileName((OPENFILENAME *)&ofn);
	// common file dialog populated sSelectedFile variable's buffer
	sSelectedFile.ReleaseBuffer();
	SetCurrentDirectory(env_GetWindowsDirectory().c_str()); // Free handle held by GetOpenFileName

	if (bRetVal)
		path = sSelectedFile;
	
	return bRetVal;
}
Example #5
0
/** 
 * @brief Shows file/folder selection dialog.
 *
 * We need this custom function so we can select files and folders with the
 * same dialog.
 * - If existing filename is selected return it
 * - If filename in (CFileDialog) editbox and current folder doesn't form
 * a valid path to file, return current folder.
 * @param [in] parent Handle to parent window. Can be a NULL, but then
 *     CMainFrame is used which can cause modality problems.
 * @param [out] path Selected folder/filename
 * @param [in] initialPath Initial file or folder shown/selected.
 * @return TRUE if user choosed a file/folder, FALSE if user canceled dialog.
 */
BOOL SelectFileOrFolder(HWND parent, CString& path, LPCTSTR initialPath /*=NULL*/)
{
	String title = theApp.LoadString(IDS_OPEN_TITLE);

	// This will tell common file dialog what to show
	// and also this will hold its return value
	CString sSelectedFile;

	// check if specified path is a file
	if (initialPath && initialPath[0])
	{
		// If initial path info includes a file
		// we put the bare filename into sSelectedFile
		// so the common file dialog will start up with that file selected
		if (paths_DoesPathExist(initialPath) == IS_EXISTING_FILE)
		{
			String temp;
			SplitFilename(initialPath, 0, &temp, 0);
			sSelectedFile = temp.c_str();
		}
	}

	if (parent == NULL)
		parent = AfxGetMainWnd()->GetSafeHwnd();

	int filterid = IDS_ALLFILES;

	if (!filterid)
		filterid = IDS_ALLFILES;

	String filters = theApp.LoadString(filterid);

	// Convert extension mask from MFC style separators ('|')
	//  to Win32 style separators ('\0')
	LPTSTR filtersStr = &*filters.begin();
	ConvertFilter(filtersStr);

	String dirSelTag = theApp.LoadString(IDS_DIRSEL_TAG);

	// Set initial filename to folder selection tag
	dirSelTag += _T("."); // Treat it as filename
	sSelectedFile = dirSelTag.c_str(); // What is assignment above good for?

	OPENFILENAME_NT4 ofn;
	memset(&ofn, 0, sizeof(ofn));
	ofn.lStructSize = sizeof(ofn);
	ofn.hwndOwner = parent;
	ofn.lpstrFilter = filtersStr;
	ofn.lpstrCustomFilter = NULL;
	ofn.nFilterIndex = 1;
	ofn.lpstrFile = sSelectedFile.GetBuffer(MAX_PATH);
	ofn.nMaxFile = MAX_PATH;
	ofn.lpstrInitialDir = initialPath;
	ofn.lpstrTitle = title.c_str();
	ofn.lpstrFileTitle = NULL;
	ofn.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_NOTESTFILECREATE;

	BOOL bRetVal = GetOpenFileName((OPENFILENAME *)&ofn);
	// common file dialog populated sSelectedFile variable's buffer
	sSelectedFile.ReleaseBuffer();
	SetCurrentDirectory(env_GetWindowsDirectory().c_str()); // Free handle held by GetOpenFileName

	if (bRetVal)
	{
		path = sSelectedFile;
		struct _stati64 statBuffer;
		int nRetVal = _tstati64(path, &statBuffer);
		if (nRetVal == -1)
		{
			// We have a valid folder name, but propably garbage as a filename.
			// Return folder name
			String folder = GetPathOnly(sSelectedFile);
			path.Format(_T("%s\\"), folder.c_str());
		}
	}
	return bRetVal;
}