Пример #1
0
BOOL CVoiceSetup::OnInitDialog(void)
{
	
	CDialog::OnInitDialog();
	
	HRESULT                             hr = S_OK;

	/*hr = SpEnumTokens(SPCAT_VOICES, NULL, NULL, &cpEnum);
	
	if(SUCCEEDED(hr)){

		hr = cpEnum->GetCount(&ulCount);

	}

	while(SUCCEEDED(hr) && ulCount -- ){
    
		cpVoiceToken.Release();
		if(SUCCEEDED(hr))
			hr = cpEnum->Next( 1, &cpVoiceToken, NULL );
		if(SUCCEEDED(hr))
	        hr = cpVoice->SetVoice(cpVoiceToken);
	    if(SUCCEEDED(hr))
			hr = cpVoice->Speak( L"How are you?", SPF_DEFAULT, NULL);

		m_cbMaleVoice.AddString(
	}  */


	hr = SpInitTokenComboBox(GetDlgItem(IDC_MALE_VOICE)->m_hWnd, SPCAT_VOICES);
	if(FAILED(hr)){

		AfxMessageBox("Error enumerating voices", MB_ICONSTOP);
	}

	hr = SpInitTokenComboBox(GetDlgItem(IDC_FEMALE_VOICE)->m_hWnd, SPCAT_VOICES);
	if(FAILED(hr)){

		AfxMessageBox("Error enumerating voices", MB_ICONSTOP);
	}


	CFileFind finder;

	BOOL bFound = finder.FindFile(g_sSettings.GetWorkingDir() + "\\gfx\\char_*.bmp");
	CString strChar, strTmp;
	while(finder.FindNextFile()){

		strChar = finder.GetFileTitle();
		strChar = strChar.Mid(5);
		m_cbMaleChar.AddString(strChar);
		m_cbFemChar.AddString(strChar);
	}


	CIni ini;
	ini.SetIniFileName(g_sSettings.GetIniFile());

	int nCnt = ini.GetValue("Voice", "MaleCount", 0);
	for(int i = 0; i < nCnt; i++){

		strTmp.Format("Male_%d", i);
		m_lbMales.AddString(ini.GetValue("Voice", strTmp, ""));
	}

	nCnt = ini.GetValue("Voice", "FemaleCount", 0);
	for(int i = 0; i < nCnt; i++){

		strTmp.Format("Female_%d", i);
		m_lbFemales.AddString(ini.GetValue("Voice", strTmp, ""));
	}



	return TRUE;
}
Пример #2
0
BOOL CI18n::LoadLanguage(CString strLanguage)
{

	ENTRY_TRACE(_T("CI18n::LoadLanguage(%s)"), strLanguage);

	CString strFilepath;

	strFilepath.Format(_T("%s\\%s.txt"), g_sSettings.GetWorkingDir() + "\\languages", strLanguage);

	CStdioFile fFile;
	CFileException e;
	CString strText	= "";
	sections  sMode = COMMENT;
	
	TRY{

		if(!fFile.Open(strFilepath, CFile::modeRead|CFile::shareDenyWrite|CFile::typeText, &e)){

			LTRACE(_T("Failed to open language file %s"), strFilepath);
			return FALSE;
		}
		fFile.SeekToBegin();
		
		while(fFile.ReadString(strText)){

			strText.TrimLeft();
			strText.TrimRight();
			
			if(strText == _T("START"))      sMode = DIALOG_SEC;
			else if(strText == _T("END"))        sMode = COMMENT;
			else if(strText == _T("INFO_START")) sMode = LANGUAGE_HEADER;
			else if(strText == _T("INFO_END"))   sMode = COMMENT;
			
			if(!strText.IsEmpty() && (strText.Left(1) == _T("#"))){


				switch(sMode){

				case DIALOG_SEC:
					m_viItems.push_back(GetI18nItem(Ascii2Unicode(strText)));
					break;
				case LANGUAGE_HEADER:

					if(strText.Left(10) == _T("#LANGUAGE#")){

						m_strLanguageName = strText.Mid(11, strText.GetLength() - 11);
						m_strLanguageName.TrimLeft();
						m_strLanguageName.TrimRight();
						m_strLanguageName = m_strLanguageName.Mid(1, m_strLanguageName.GetLength() - 2);
					}
					else if(strText.Left(10) == _T("#CODEPAGE#")){

						m_strCodepage = strText.Mid(11, strText.GetLength() - 11);
						m_strCodepage.TrimLeft();
						m_strCodepage.TrimRight();						
						m_strCodepage = m_strCodepage.Mid(1, m_strCodepage.GetLength() - 2);
						m_dwCodePageID = _ttoi(m_strCodepage);
						
					}
					else if(strText.Left(8) == _T("#AUTHOR#")){

						m_strAuthor = strText.Mid(8, strText.GetLength() - 8);
						m_strAuthor.TrimLeft();
						m_strAuthor.TrimRight();						
						m_strAuthor = m_strAuthor.Mid(1, m_strAuthor.GetLength() - 2);
					}
					break;
				}
			}
		}

		fFile.Close();
	}
	CATCH( CFileException, e )
	{

	   #ifdef _DEBUG
		  afxDump << "File could not be opened " << e->m_cause << "\n";
	   #endif

	   m_bLoaded = FALSE;
	   m_strLoadedLang = "";
	}