示例#1
0
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));
        }
    }
}
示例#2
0
    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;
    }
示例#3
0
    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);
    }