void loadScriptLibrary() { StringVectorPtr names = ResourceGroupManager::getSingleton().listResourceNames("DefaultLuaScripts"); for(int i = 0; i < names->size(); ++i) { loadScript(names->at(i)); } names.setNull(); }
//----------------------------------------------------------------------- StringVectorPtr Utf8Archive::list(bool _recursive, bool _dirs) { StringVectorPtr ret = mBaseArchive->list(_recursive, _dirs); for(size_t i = 0; i != ret->size(); ++i) { String& elem = (*ret)[i]; StringUtil::ansiToUtf8(elem); } return ret; }
void ZipArchiveTests::testFindNonRecursive() { ZipArchive arch(testPath, "Zip"); arch.load(); StringVectorPtr vec = arch.find("*.txt", false); CPPUNIT_ASSERT_EQUAL((size_t)2, vec->size()); CPPUNIT_ASSERT_EQUAL(String("rootfile.txt"), vec->at(0)); CPPUNIT_ASSERT_EQUAL(String("rootfile2.txt"), vec->at(1)); }
vector<vector<string> > findLadders0(string start, string end, unordered_set<string> &dict) { dict.insert(start); StringVectorQ q; q.push_back( StringVectorPtr(new StringVector(1, start)) ); const int L = end.size(); StringVectorQ result; StringSet visitedS = {start}; while( !q.empty() ) { StringVectorPtr pv = q.front(); q.pop_front(); if( pv->size() > shortest ) continue; string s = pv->back(); for(int i=0; i<L; ++i) { string newStr = s; char ch = s[i]; do { ch++; if( ch > 'z') ch = 'a'; if( ch == s[i]) break; newStr[i] = ch; if( newStr == end ) { // found it StringVectorPtr newV(new StringVector(*pv)); newV->push_back(newStr); result.push_back(newV); if( newV->size() < shortest) shortest = newV->size(); } if( dict.end() != dict.find(newStr) && std::find(pv->begin(), pv->end(), newStr) == pv->end() ) { // continue with next search StringVectorPtr newV(new StringVector(*pv)); newV->push_back(newStr); visitedS.insert(newStr); q.push_back(newV); } }while(true); } } struct Smaller{ int x; Smaller(int a):x(a){} bool operator()(StringVectorPtr& v) { return v->size() < x; } }; StringVectorVector vv; // std::copy_if(result.begin(), result.end(), std::back_inserter(vv), Smaller(shortest)); for(StringVectorQ::iterator it=result.begin(); it!=result.end(); ++it) { if( (**it).size() <= shortest ) vv.push_back(std::move(**it)); } return std::move(vv); }
void ZipArchiveTests::testFindRecursive() { ZipArchive arch(testPath, "Zip"); arch.load(); StringVectorPtr vec = arch.find("*.material", true); CPPUNIT_ASSERT_EQUAL((size_t)4, vec->size()); CPPUNIT_ASSERT_EQUAL(String("level1/materials/scripts/file.material"), vec->at(0)); CPPUNIT_ASSERT_EQUAL(String("level1/materials/scripts/file2.material"), vec->at(1)); CPPUNIT_ASSERT_EQUAL(String("level2/materials/scripts/file3.material"), vec->at(2)); CPPUNIT_ASSERT_EQUAL(String("level2/materials/scripts/file4.material"), vec->at(3)); }
//----------------------------------------------------------------------- StringVectorPtr Utf8Archive::find(const String& _pattern, bool _recursive, bool _dirs) { String pattern2 = _pattern; StringUtil::utf8ToAnsi(pattern2); StringVectorPtr ret = mBaseArchive->find(pattern2, _recursive, _dirs); for(size_t i = 0; i != ret->size(); ++i) { String& elem = (*ret)[i]; StringUtil::ansiToUtf8(elem); } return ret; }
void ZipArchiveTests::testListRecursive() { ZipArchive arch(testPath, "Zip"); arch.load(); StringVectorPtr vec = arch.list(true); CPPUNIT_ASSERT_EQUAL((size_t)6, vec->size()); CPPUNIT_ASSERT_EQUAL(String("level1/materials/scripts/file.material"), vec->at(0)); CPPUNIT_ASSERT_EQUAL(String("level1/materials/scripts/file2.material"), vec->at(1)); CPPUNIT_ASSERT_EQUAL(String("level2/materials/scripts/file3.material"), vec->at(2)); CPPUNIT_ASSERT_EQUAL(String("level2/materials/scripts/file4.material"), vec->at(3)); CPPUNIT_ASSERT_EQUAL(String("rootfile.txt"), vec->at(4)); CPPUNIT_ASSERT_EQUAL(String("rootfile2.txt"), vec->at(5)); }
void FileSystemArchiveTests::testListRecursive() { FileSystemArchive arch(testPath, "FileSystem"); arch.load(); StringVectorPtr vec = arch.list(true); CPPUNIT_ASSERT_EQUAL((size_t)48, vec->size()); // 48 including CVS folders! CPPUNIT_ASSERT_EQUAL(String("rootfile.txt"), vec->at(0)); CPPUNIT_ASSERT_EQUAL(String("rootfile2.txt"), vec->at(1)); CPPUNIT_ASSERT_EQUAL(String("level1/materials/scripts/file.material"), vec->at(2)); CPPUNIT_ASSERT_EQUAL(String("level1/materials/scripts/file2.material"), vec->at(3)); CPPUNIT_ASSERT_EQUAL(String("level2/materials/scripts/file3.material"), vec->at(22)); CPPUNIT_ASSERT_EQUAL(String("level2/materials/scripts/file4.material"), vec->at(23)); }
void ContentModule::precreateMeshes() const { StringVectorPtr meshes = ResourceGroupManager::getSingleton() .findResourceNames(getId(), "*.mesh"); for (size_t i = 0; i < meshes->size(); ++i) { ResourcePtr res = MeshManager::getSingleton().getByName((*meshes)[i]); if (res.isNull()) { MeshPtr mesh = MeshManager::getSingleton().create((*meshes)[i], getId()); } } }
void FileSystemArchiveTests::testListNonRecursive() { try { FileSystemArchive arch(testPath, "FileSystem"); arch.load(); StringVectorPtr vec = arch.list(false); CPPUNIT_ASSERT_EQUAL((unsigned int)2, (unsigned int)vec->size()); CPPUNIT_ASSERT_EQUAL(String("rootfile.txt"), vec->at(0)); CPPUNIT_ASSERT_EQUAL(String("rootfile2.txt"), vec->at(1)); } catch (Exception& e) { std::cout << e.getFullDescription(); } }
//----------------------------------------------------------------------------------- String RecursiveArchive::getPath(const String& _filename) { String filepath = _filename; if(!getBaseArchive()->exists(_filename)) { StringVectorPtr vecptr = getBaseArchive()->find(_filename, true, false); if(!vecptr->empty()) { filepath = (*vecptr)[0]; if(vecptr->size() != 1) { GOTHOGRE_LOG(Warning, "RecursiveArchive: Found two files" " with the same name '" << _filename << "'" << ": '" << (*vecptr)[0] << "', '" << (*vecptr)[1] << "'." << "One of these files will be unavailable."); } } } return filepath; }
//----------------------------------------------------------------------- void MaterialService::createStandardMaterial(unsigned int idx, std::string matName, std::string textureName, std::string resourceGroup) { Image tex; bool loaded = false; // indicates we were successful finding the texture StringVectorPtr texnames = ResourceGroupManager::getSingleton().findResourceNames(resourceGroup, textureName + ".*"); if (texnames->size() <= 0) { // no results, try the localised version // prev. path + /language/filename String locresname = mConfigService->getLocalisedResourcePath(textureName); LOG_INFO("Specified resource (%s) was not found, trying localized version: %s", textureName.c_str(), locresname.c_str()); texnames = ResourceGroupManager::getSingleton().findResourceNames(resourceGroup, locresname + ".*"); } String txtfile; // Let's try the extensions from the extensions vector StringVector::iterator it = texnames->begin(); for (; it != texnames->end(); it++) { // Try loading every given try { tex.load((*it), resourceGroup); TextureManager::getSingleton().loadImage(textureName, resourceGroup, tex, TEX_TYPE_2D, 5, 1.0f); txtfile = (*it); loaded = true; break; // we got it! } catch (Ogre::Exception) { // Nothing. We are trying more extensions } } if (!loaded) LOG_ERROR("Image %s was not found, texture will be invalid!", textureName.c_str()); // Construct a material out of this texture. We'll just clone the material upstairs to enable lmap-txture combinations MaterialPtr shadMat = MaterialManager::getSingleton().create(matName, resourceGroup); shadMat->setReceiveShadows(true); Pass *shadPass = shadMat->getTechnique(0)->getPass(0); shadPass->setAmbient(0.5, 0.5, 0.5); shadPass->setDiffuse(1, 1, 1, 1); shadPass->setSpecular(1, 1, 1, 1); TextureUnitState* tus = createAnimatedTextureState(shadPass, txtfile, resourceGroup, 5); // Set replace on all first layer textures for now // tus->setColourOperation(LBO_REPLACE); tus->setTextureAddressingMode(TextureUnitState::TAM_WRAP); tus->setTextureCoordSet(0); tus->setTextureFiltering(TFO_BILINEAR); tus->setTextureUScale(1.0f); tus->setTextureVScale(1.0f); // tus->setTextureFiltering(TFO_NONE); // Set culling mode to none // shadMat->setCullingMode(CULL_ANTICLOCKWISE); // No dynamic lighting shadMat->setLightingEnabled(false); // DYNL: shadMat->load(); // standard size addWorldMaterialTemplate(idx, shadMat); }
bool operator()(StringVectorPtr& v) { return v->size() < x; }