void aiBehaviorTreeTemplateManager::LoadAll() { Ogre::StringVectorPtr loc = Ogre::ResourceGroupManager::getSingleton().findResourceLocation("BehaviorTemplate", "*Behaviors"); const STRING filename = loc->at(0) + "\\Script\\"; //加载全局黑板xml Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().openResource("RaceGlobal.xml", "BehaviorTemplate"); char* szData = strdup(stream->getAsString().c_str()); rapidxml::xml_document<> XMLDoc; XMLDoc.parse<0>(szData); rapidxml::xml_node<>* pNode = XMLDoc.first_node("Root")->first_node("BlackBoard"); while(pNode) { const STRING raceName = pNode->first_attribute("race")->value(); rapidxml::xml_node<>* pVarNode = pNode->first_node("Variable"); eGameRace race; if(raceName == "Terran") race = eGameRace_Terran; else if(raceName == "Zerg") race = eGameRace_Zerg; else assert(0); aiBlackBoard* bb = new aiBlackBoard; bb->LoadParams(pVarNode); m_globalBBs.insert(std::make_pair(race, bb)); //脚本 const char* szFilename = XMLDoc.first_node("Root")->first_node("Script")->first_attribute("filename")->value(); const STRING filepath = filename + szFilename; SCRIPTNAMAGER.DoFile(filepath); pNode = pNode->next_sibling("BlackBoard"); } free(szData); XMLDoc.clear(); //加载各单位行为树xml Ogre::StringVectorPtr files = Ogre::ResourceGroupManager::getSingleton().findResourceNames("BehaviorTemplate", "*.xml"); auto iter = std::find(files->begin(), files->end(), "RaceGlobal.xml"); files->erase(iter); for (auto iter=files->begin(); iter!=files->end(); ++iter) { aiBehaviorTreeTemplate* pTmpl = new aiBehaviorTreeTemplate; const STRING name = pTmpl->Load(*iter); m_bts.insert(std::make_pair(name, pTmpl)); } }
void SoundManager::startRandomTitle() { Ogre::StringVector filelist; if (mMusicFiles.find(mCurrentPlaylist) == mMusicFiles.end()) { Ogre::StringVector groups = Ogre::ResourceGroupManager::getSingleton().getResourceGroups (); for (Ogre::StringVector::iterator it = groups.begin(); it != groups.end(); ++it) { Ogre::StringVectorPtr resourcesInThisGroup = mResourceMgr.findResourceNames(*it, "Music/"+mCurrentPlaylist+"/*"); filelist.insert(filelist.end(), resourcesInThisGroup->begin(), resourcesInThisGroup->end()); } mMusicFiles[mCurrentPlaylist] = filelist; } else filelist = mMusicFiles[mCurrentPlaylist]; if(!filelist.size()) return; int i = rand()%filelist.size(); // Don't play the same music track twice in a row if (filelist[i] == mLastPlayedMusic) { i = (i+1) % filelist.size(); } streamMusicFull(filelist[i]); }
void LoadingScreen::changeWallpaper () { if (mResources.isNull ()) { mResources = Ogre::StringVectorPtr (new Ogre::StringVector); Ogre::StringVectorPtr resources = Ogre::ResourceGroupManager::getSingleton ().listResourceNames ("General", false); for (Ogre::StringVector::const_iterator it = resources->begin(); it != resources->end(); ++it) { if (it->size() < 6) continue; std::string start = it->substr(0, 6); boost::to_lower(start); if (start == "splash") mResources->push_back (*it); } } if (mResources->size()) { std::string randomSplash = mResources->at (rand() % mResources->size()); Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton ().load (randomSplash, "General"); mBackgroundImage->setImageTexture (randomSplash); } else std::cerr << "No loading screens found!" << std::endl; }
const std::vector<std::string> ModelDefinitionManager::getAllMeshes() const { std::vector<std::string> meshes; Ogre::StringVectorPtr meshesVector = Ogre::ResourceGroupManager::getSingleton().findResourceNames("General", "*.mesh"); for (Ogre::StringVector::iterator I = meshesVector->begin(); I != meshesVector->end(); ++I) { meshes.push_back(std::string(*I)); } meshesVector.setNull(); return meshes; }
void loadAllMaterialControlFiles(MaterialControlsContainer& controlsContainer) { Ogre::StringVectorPtr fileStringVector = Ogre::ResourceGroupManager::getSingleton().findResourceNames( "Popular", "*.controls"); Ogre::StringVector::iterator controlsFileNameIterator = fileStringVector->begin(); while ( controlsFileNameIterator != fileStringVector->end() ) { loadMaterialControlsFile(controlsContainer, *controlsFileNameIterator); ++controlsFileNameIterator; } }
void FontLoader::loadAllFonts(bool exportToFile) { Ogre::StringVector groups = Ogre::ResourceGroupManager::getSingleton().getResourceGroups (); for (Ogre::StringVector::iterator it = groups.begin(); it != groups.end(); ++it) { Ogre::StringVectorPtr resourcesInThisGroup = Ogre::ResourceGroupManager::getSingleton ().findResourceNames (*it, "*.fnt"); for (Ogre::StringVector::iterator resource = resourcesInThisGroup->begin(); resource != resourcesInThisGroup->end(); ++resource) { loadFont(*resource, exportToFile); } } }
ResourceList ResourceManager::list() { ResourceList resourceList; Ogre::StringVectorPtr resources = mRGM.findResourceNames( mGroup, "*" ); for( Ogre::StringVector::const_iterator i = resources->begin(); i != resources->end(); ++i ) { resourceList.push_back( Path( *i ) ); } return resourceList; }
CSMWorld::Resources::Resources (const std::string& baseDirectory, UniversalId::Type type, const char * const *extensions) : mBaseDirectory (baseDirectory), mType (type) { int baseSize = mBaseDirectory.size(); Ogre::StringVector resourcesGroups = Ogre::ResourceGroupManager::getSingleton().getResourceGroups(); for (Ogre::StringVector::iterator iter (resourcesGroups.begin()); iter!=resourcesGroups.end(); ++iter) { if (*iter=="General" || *iter=="Internal" || *iter=="Autodetect") continue; Ogre::StringVectorPtr resources = Ogre::ResourceGroupManager::getSingleton().listResourceNames (*iter); for (Ogre::StringVector::const_iterator iter (resources->begin()); iter!=resources->end(); ++iter) { if (static_cast<int> (iter->size())<baseSize+1 || iter->substr (0, baseSize)!=mBaseDirectory || ((*iter)[baseSize]!='/' && (*iter)[baseSize]!='\\')) continue; if (extensions) { std::string::size_type index = iter->find_last_of ('.'); if (index==std::string::npos) continue; std::string extension = iter->substr (index+1); int i = 0; for (; extensions[i]; ++i) if (extensions[i]==extension) break; if (!extensions[i]) continue; } std::string file = iter->substr (baseSize+1); mFiles.push_back (file); mIndex.insert (std::make_pair (file, static_cast<int> (mFiles.size())-1)); } } }
void SoundManager::startRandomTitle() { Ogre::StringVector filelist; Ogre::StringVector groups = Ogre::ResourceGroupManager::getSingleton().getResourceGroups (); for (Ogre::StringVector::iterator it = groups.begin(); it != groups.end(); ++it) { Ogre::StringVectorPtr resourcesInThisGroup = mResourceMgr.findResourceNames(*it, "Music/"+mCurrentPlaylist+"/*"); filelist.insert(filelist.end(), resourcesInThisGroup->begin(), resourcesInThisGroup->end()); } if(!filelist.size()) return; int i = rand()%filelist.size(); streamMusicFull(filelist[i]); }
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ void ResourceService::getResourceNames(I_ResourceNameVisitor& _visitor, const std::string& _group, const std::string& _pattern) const { _visitor.begin(); Ogre::StringVectorPtr pStringVector = m_groupManager.findResourceNames(_group, _pattern); Ogre::StringVector::iterator iter = pStringVector->begin(); while (iter != pStringVector->end()) { _visitor.visit(*iter); iter++; } _visitor.end(); }
void LoadingScreen::changeWallpaper () { std::vector<std::string> splash; Ogre::StringVectorPtr resources = Ogre::ResourceGroupManager::getSingleton ().listResourceNames ("General", false); for (Ogre::StringVector::const_iterator it = resources->begin(); it != resources->end(); ++it) { if (it->size() < 6) continue; std::string start = it->substr(0, 6); boost::to_lower(start); if (start == "splash") splash.push_back (*it); } std::string randomSplash = splash[rand() % splash.size()]; Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton ().load (randomSplash, "General"); mBackgroundImage->setImageTexture (randomSplash); }
//----------------------------------------------------------------------------// size_t OgreResourceProvider::getResourceGroupFileNames( std::vector<String>& out_vec, const String& file_pattern, const String& resource_group) { // get list of files in the group that match the pattern. Ogre::StringVectorPtr vp = Ogre::ResourceGroupManager::getSingleton().findResourceNames( (resource_group.empty() ? d_defaultResourceGroup.c_str() : resource_group.c_str()), file_pattern.c_str()); size_t entries = 0; Ogre::StringVector::iterator i = vp->begin(); for (; i != vp->end(); ++i) { out_vec.push_back(i->c_str()); ++entries; } return entries; }
void LoadingScreen::changeWallpaper () { if (mResources.empty()) { Ogre::StringVector groups = Ogre::ResourceGroupManager::getSingleton().getResourceGroups (); for (Ogre::StringVector::iterator it = groups.begin(); it != groups.end(); ++it) { Ogre::StringVectorPtr resourcesInThisGroup = Ogre::ResourceGroupManager::getSingleton ().findResourceNames (*it, "Splash_*.tga"); mResources.insert(mResources.end(), resourcesInThisGroup->begin(), resourcesInThisGroup->end()); } } if (!mResources.empty()) { std::string const & randomSplash = mResources.at (rand() % mResources.size()); Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton ().load (randomSplash, Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME); mBackgroundImage->setImageTexture (randomSplash); } else std::cerr << "No loading screens found!" << std::endl; }