bool Localizer::Initialize(const std::vector<std::string>& filePaths, Language language) { int numLocalized = 0; // Clear any previous localization data map.clear(); // Convert the requested language to its string code std::string languageString = LanguageToString(language); // Process file paths for (unsigned int i = 0; i < filePaths.size(); ++ i) { // Build the complete file path std::string localizedFile = filePaths[i] + "_" + languageString + ".txt"; // Load the resource ResourceManager::Get()->AddResource(localizedFile, new TextResource(localizedFile)); TextResource* resource = ResourceManager::Get()->GetText(localizedFile); if (resource) { // Process the lines in the text resource into the map for (unsigned int j = 0; j < resource->GetNumLines(); ++ j) { std::string line = resource->GetLine(j); std::vector<std::string> parts = StringSplit(line, '='); if (parts.size() == 2) map.insert(std::pair<std::string, std::string>(parts[0], parts[1])); } // Unload the resource now we are done with it ResourceManager::Get()->FreeResource(localizedFile); numLocalized ++; } } // Store the language currentLanguage = language; return (numLocalized == filePaths.size()); }
std::string Localizer::GetLanguageString() const { return LanguageToString(currentLanguage); }
void initializeVoiceRecognition() { auto session = senseManager->QuerySession(); // 音声入力デバイスを作成する audioSource = session->CreateAudioSource(); if ( audioSource == 0 ){ throw std::runtime_error( "音声入力デバイスの作成に失敗しました" ); } // 音声入力デバイスを列挙する std::cout << "音声入力デバイス" << std::endl; PXCAudioSource::DeviceInfo device = {}; audioSource->ScanDevices(); for ( int i = 0;; ++i ) { PXCAudioSource::DeviceInfo dinfo = {}; auto sts = audioSource->QueryDeviceInfo( i, &dinfo ); if ( sts < PXC_STATUS_NO_ERROR ) { break; } // 音声入力デバイス名を表示する std::wcout << "\t" << dinfo.name << std::endl; // 最初のデバイスを使う if ( i == 0 ){ device = dinfo; } } // 音声入力デバイスを設定する auto sts = audioSource->SetDevice( &device ); if ( sts < PXC_STATUS_NO_ERROR ) { throw std::runtime_error( "音声入力デバイスの設定に失敗しました" ); } // 音声認識エンジンを列挙する std::cout << "音声認識エンジン" << std::endl; PXCSession::ImplDesc in = {}; PXCSession::ImplDesc out = {}; in.cuids[0] = PXCSpeechRecognition::CUID; for ( int i = 0; ; ++i ) { // 音声認識エンジンを取得する auto sts = session->QueryImpl( &in, i, &out ); if ( sts < PXC_STATUS_NO_ERROR ) { break; } // 音声認識エンジン名称を表示する std::wcout << "\t" << out.friendlyName << std::endl; } // 最初の音声認識エンジンを使う sts = session->QueryImpl( &in, 0, &out ); // 音声認識エンジンオブジェクトを作成する sts = session->CreateImpl<PXCSpeechRecognition>( &out, &recognition ); if ( sts < PXC_STATUS_NO_ERROR ) { throw std::runtime_error( "音声認識エンジンオブジェクトの作成に失敗しました" ); } // 対応言語を列挙する PXCSpeechRecognition::ProfileInfo profile; for ( int j = 0;; ++j ) { // 音声認識エンジンが持っているプロファイルを取得する PXCSpeechRecognition::ProfileInfo pinfo; sts = recognition->QueryProfile( j, &pinfo ); if ( sts < PXC_STATUS_NO_ERROR ) { break; } // 対応言語を表示する std::wcout << "\t\t" << LanguageToString( pinfo.language ) << std::endl; // 英語のエンジンを使う(日本語対応時には日本語に変更する) if ( pinfo.language == PXCSpeechRecognition::LANGUAGE_JP_JAPANESE ){ profile = pinfo; } } if ( profile.language == 0 ){ throw std::runtime_error( "選択した音声認識エンジンが見つかりませんでした" ); } // 使用する言語を設定する sts = recognition->SetProfile( &profile ); if ( sts < PXC_STATUS_NO_ERROR ) { throw std::runtime_error( "音声認識エンジンオブジェクトの設定に失敗しました" ); } // コマンドモードに設定する setCommandMode(); // 音声認識を開始する sts = recognition->StartRec( audioSource, this ); if ( sts < PXC_STATUS_NO_ERROR ) { throw std::runtime_error( "音声認識の開始に失敗しました" ); } }
void CSettings::SaveSettings() { CApplication* app = CApplication::GetInstancePointer(); CRobotMain* main = CRobotMain::GetInstancePointer(); Gfx::CEngine* engine = Gfx::CEngine::GetInstancePointer(); Gfx::CCamera* camera = main->GetCamera(); CSoundInterface* sound = app->GetSound(); GetConfigFile().SetBoolProperty("Setup", "Tooltips", m_tooltips); GetConfigFile().SetBoolProperty("Setup", "InterfaceGlint", m_interfaceGlint); GetConfigFile().SetBoolProperty("Setup", "InterfaceRain", m_interfaceRain); GetConfigFile().SetBoolProperty("Setup", "Soluce4", m_soluce4); GetConfigFile().SetBoolProperty("Setup", "Movies", m_movies); GetConfigFile().SetBoolProperty("Setup", "FocusLostPause", m_focusLostPause); GetConfigFile().SetBoolProperty("Setup", "OldCameraScroll", camera->GetOldCameraScroll()); GetConfigFile().SetBoolProperty("Setup", "CameraInvertX", camera->GetCameraInvertX()); GetConfigFile().SetBoolProperty("Setup", "CameraInvertY", camera->GetCameraInvertY()); GetConfigFile().SetBoolProperty("Setup", "InterfaceEffect", camera->GetEffect()); GetConfigFile().SetBoolProperty("Setup", "Blood", camera->GetBlood()); GetConfigFile().SetBoolProperty("Setup", "Autosave", main->GetAutosave()); GetConfigFile().SetIntProperty("Setup", "AutosaveInterval", main->GetAutosaveInterval()); GetConfigFile().SetIntProperty("Setup", "AutosaveSlots", main->GetAutosaveSlots()); GetConfigFile().SetBoolProperty("Setup", "ObjectDirty", engine->GetDirty()); GetConfigFile().SetBoolProperty("Setup", "FogMode", engine->GetFog()); GetConfigFile().SetBoolProperty("Setup", "LightMode", engine->GetLightMode()); GetConfigFile().SetIntProperty("Setup", "JoystickIndex", app->GetJoystickEnabled() ? app->GetJoystick().index : -1); GetConfigFile().SetFloatProperty("Setup", "ParticleDensity", engine->GetParticleDensity()); GetConfigFile().SetFloatProperty("Setup", "ClippingDistance", engine->GetClippingDistance()); GetConfigFile().SetIntProperty("Setup", "AudioVolume", sound->GetAudioVolume()); GetConfigFile().SetIntProperty("Setup", "MusicVolume", sound->GetMusicVolume()); GetConfigFile().SetBoolProperty("Setup", "EditIndentMode", engine->GetEditIndentMode()); GetConfigFile().SetIntProperty("Setup", "EditIndentValue", engine->GetEditIndentValue()); GetConfigFile().SetIntProperty("Setup", "MipmapLevel", engine->GetTextureMipmapLevel()); GetConfigFile().SetIntProperty("Setup", "Anisotropy", engine->GetTextureAnisotropyLevel()); GetConfigFile().SetFloatProperty("Setup", "ShadowColor", engine->GetShadowColor()); GetConfigFile().SetFloatProperty("Setup", "ShadowRange", engine->GetShadowRange()); GetConfigFile().SetIntProperty("Setup", "MSAA", engine->GetMultiSample()); GetConfigFile().SetIntProperty("Setup", "FilterMode", engine->GetTextureFilterMode()); GetConfigFile().SetBoolProperty("Setup", "ShadowMapping", engine->GetShadowMapping()); GetConfigFile().SetBoolProperty("Setup", "ShadowMappingQuality", engine->GetShadowMappingQuality()); GetConfigFile().SetIntProperty("Setup", "ShadowMappingResolution", engine->GetShadowMappingOffscreen() ? engine->GetShadowMappingOffscreenResolution() : 0); // Experimental settings GetConfigFile().SetBoolProperty("Experimental", "TerrainShadows", engine->GetTerrainShadows()); CInput::GetInstancePointer()->SaveKeyBindings(); GetConfigFile().SetFloatProperty("Edit", "FontSize", m_fontSize); GetConfigFile().SetFloatProperty("Edit", "WindowPosX", m_windowPos.x); GetConfigFile().SetFloatProperty("Edit", "WindowPosY", m_windowPos.y); GetConfigFile().SetFloatProperty("Edit", "WindowDimX", m_windowDim.x); GetConfigFile().SetFloatProperty("Edit", "WindowDimY", m_windowDim.y); GetConfigFile().SetBoolProperty("Edit", "IOPublic", m_IOPublic); GetConfigFile().SetFloatProperty("Edit", "IOPosX", m_IOPos.x); GetConfigFile().SetFloatProperty("Edit", "IOPosY", m_IOPos.y); GetConfigFile().SetFloatProperty("Edit", "IODimX", m_IODim.x); GetConfigFile().SetFloatProperty("Edit", "IODimY", m_IODim.y); std::string lang = ""; LanguageToString(m_language, lang); GetConfigFile().SetStringProperty("Language", "Lang", lang); GetConfigFile().Save(); }