void CCharWin::OnSelectCharsFromFile()
{
	if( isGenerating ) return;

	CFileDialog dlg;
	dlg.AddFilter("All files (*.*)", "*.*", true);

	if( dlg.AskForOpenFileName(this) )
	{
		fontGen->SelectCharsFromFile(dlg.GetFileName().c_str());
		int countMissing = fontGen->GetNumFailedChars();
		if( countMissing )
		{
			stringstream s;
			s << countMissing << " characters from the file are not available in the font";

			TCHAR buf[1024];
			ConvertAnsiToTChar(s.str(), buf, 1024);

			MessageBox(hWnd, buf, __TEXT("Warning"), MB_OK);
		}

		UpdateSubsetsSelection();
		Invalidate(FALSE);
	}
}
Example #2
0
void CImageMgr::OnImportImage()
{
	if( fontGen->GetStatus() != 0 ) return;

	CFileDialog dlg;
	dlg.AddFilter("All files (*.*)", "*.*");
	dlg.AddFilter("Supported image files (*.bmp;*.jpg;*.tga;*.dds;*.png)", "*.bmp;*.jpg;*.tga;*.dds;*.png", true);

	if( dlg.AskForOpenFileName(this) )
	{
		CIconImageDlg iconDlg;
		iconDlg.fileName = dlg.GetFileName();
		iconDlg.id = 0;
		iconDlg.xoffset = 0;
		iconDlg.yoffset = 0;
		iconDlg.advance = 0;

		if( iconDlg.DoModal(this) == IDOK )
		{
			// Create the icon image
			int r = fontGen->AddIconImage(iconDlg.fileName.c_str(), 
			                              iconDlg.id,
										  iconDlg.xoffset,
										  iconDlg.yoffset,
										  iconDlg.advance);
			if( r < 0 )
			{
				MessageBox(hWnd, "Failed to load image file", "File error", MB_OK);
				return;
			}

			RefreshList();
		}
	}
}
void CCharWin::OnLoadFontConfiguration()
{
	CFileDialog dlg;
	dlg.AddFilter("All files (*.*)", "*.*");
	dlg.AddFilter("BMFont Font config (*.csv)", "*.csv", true);
	dlg.AddFilter("Text (*.txt)", "*.txt");

	if (dlg.AskForOpenFileName(this))
		LoadFontConfig(dlg.GetFileName());
}
void CChooseFont::OnBrowseFont()
{
	CFileDialog dlg;
	dlg.AddFilter("Windows font files", "*.fon;*.fnt;*.ttf;*.ttc;*.fot;*.otf;", true);
	if( dlg.AskForOpenFileName(this) )
	{
		TCHAR buf[1024];
		ConvertAnsiToTChar(dlg.GetFileName(), buf, 1024);

		SetDlgItemText(hWnd, IDC_FONTFILE, buf);

		EnumFonts();
	}
}
void CCharWin::OnLoadConfiguration()
{
	if( isGenerating ) return;

	CFileDialog dlg;
	dlg.AddFilter("All files (*.*)", "*.*");
	dlg.AddFilter("BMFont config (*.bmfc)", "*.bmfc", true);
	dlg.AddFilter("Text (*.txt)", "*.txt");

	string dir = fontGen->GetLastConfigFile();
	if( dir != GetDefaultConfig() )
	{
		// cut off the filename and last /
		dir = dir.substr(0, dir.find_last_of("/\\"));
		dlg.SetInitialDir(dir.c_str());
	}

	if( dlg.AskForOpenFileName(this) )
		LoadConfig(dlg.GetFileName());
}