예제 #1
0
void Config::GameSettings::validatePaths()
{
    QStringList paths = mSettings.values(QString("data"));
    Files::PathContainer dataDirs;

    foreach (const QString &path, paths) {
        QByteArray bytes = path.toUtf8();
        dataDirs.push_back(Files::PathContainer::value_type(std::string(bytes.constData(), bytes.length())));
    }
예제 #2
0
void Launcher::GameSettings::validatePaths()
{
    if (mSettings.isEmpty() || !mDataDirs.isEmpty())
        return; // Don't re-validate paths if they are already parsed

    QStringList paths = mSettings.values(QString("data"));
    Files::PathContainer dataDirs;

    foreach (const QString &path, paths) {
        dataDirs.push_back(Files::PathContainer::value_type(path.toStdString()));
    }
예제 #3
0
    MultiDirCollection::MultiDirCollection(const Files::PathContainer& directories,
        const std::string& extension, bool foldCase)
    : mFiles (NameLess (!foldCase))
    {
        NameEqual equal (!foldCase);

        for (PathContainer::const_iterator iter = directories.begin();
            iter!=directories.end(); ++iter)
        {
            if (!boost::filesystem::is_directory(*iter))
            {
                std::cout << "Skipping invalid directory: " << (*iter).string() << std::endl;
                continue;
            }

            for (boost::filesystem::directory_iterator dirIter(*iter);
                    dirIter != boost::filesystem::directory_iterator(); ++dirIter)
            {
                boost::filesystem::path path = *dirIter;

                if (!equal (extension, path.extension().string()))
                    continue;

                std::string filename = path.filename().string();

                TIter result = mFiles.find (filename);

                if (result==mFiles.end())
                {
                    mFiles.insert (std::make_pair (filename, path));
                }
                else if (result->first==filename)
                {
                    mFiles[filename] = path;
                }
                else
                {
                    // handle case folding
                    mFiles.erase (result->first);
                    mFiles.insert (std::make_pair (filename, path));
                }
            }
        }
    }
예제 #4
0
    SoundManager::SoundManager(Ogre::Root *root, Ogre::Camera *camera,
        const Files::PathContainer& dataDirs,
        bool useSound, bool fsstrict, MWWorld::Environment& environment)
        : mFSStrict(fsstrict)
        , mEnvironment(environment)
        , mgr(new OEManager(SoundFactoryPtr(new SOUND_FACTORY)))
        , updater(mgr)
        , cameraTracker(mgr)
        , mCurrentPlaylist(NULL)
    {
        if(useSound)
        {
            // The music library will accept these filetypes
            // If none is given then it will accept all filetypes
            std::vector<std::string> acceptableExtensions;
            acceptableExtensions.push_back(".mp3");
            acceptableExtensions.push_back(".wav");
            acceptableExtensions.push_back(".ogg");
            acceptableExtensions.push_back(".flac");

            // Makes a list of all sound files, searches in reverse for priority reasons
            for (Files::PathContainer::const_reverse_iterator it = dataDirs.rbegin(); it != dataDirs.rend(); ++it)
            {
                Files::FileLister(*it / std::string("Sound"), mSoundFiles, true);
            }

            // Makes a FileLibrary of all music files, searches in reverse for priority reasons
            for (Files::PathContainer::const_reverse_iterator it = dataDirs.rbegin(); it != dataDirs.rend(); ++it)
            {
                mMusicLibrary.add(*it / std::string("Music"), true, mFSStrict, acceptableExtensions);
            }

            std::string anything = "anything";      // anything is better that a segfault
            mCurrentPlaylist = mMusicLibrary.section(anything, mFSStrict); // now points to an empty path

            std::cout << "Sound output:  " << SOUND_OUT << std::endl;
            std::cout << "Sound decoder: " << SOUND_IN << std::endl;
            // Attach the camera to the camera tracker
            cameraTracker.followCamera(camera);

            // Tell Ogre to update the sound system each frame
            root->addFrameListener(&updater);
        }
      }
예제 #5
0
bool DataFilesList::setupDataFiles(Files::PathContainer dataDirs, const QString encoding)
{
    // Set the charset for reading the esm/esp files
    if (!encoding.isEmpty() && encoding != QLatin1String("win1252")) {
        mMastersModel->setEncoding(encoding);
        mPluginsModel->setEncoding(encoding);
    }

    // Add the paths to the respective models
    for (Files::PathContainer::iterator it = dataDirs.begin(); it != dataDirs.end(); ++it) {
        QString path = QString::fromStdString(it->string());
        path.remove(QChar('\"'));
        mMastersModel->addMasters(path);
        mPluginsModel->addPlugins(path);
    }

    mMastersModel->sort(0);
    mPluginsModel->sort(0);
//    mMastersTable->sortByColumn(3, Qt::AscendingOrder);
//    mPluginsTable->sortByColumn(3, Qt::AscendingOrder);

    return true;
}
예제 #6
0
void ConfigurationManager::processPaths(Files::PathContainer& dataDirs, bool create)
{
    std::string path;
    for (Files::PathContainer::iterator it = dataDirs.begin(); it != dataDirs.end(); ++it)
    {
        path = it->string();
        boost::erase_all(path, "\"");
        *it = boost::filesystem::path(path);

        // Check if path contains a token
        if (!path.empty() && *path.begin() == '?')
        {
            std::string::size_type pos = path.find('?', 1);
            if (pos != std::string::npos && pos != 0)
            {
                TokensMappingContainer::iterator tokenIt = mTokensMapping.find(path.substr(0, pos + 1));
                if (tokenIt != mTokensMapping.end())
                {
                    boost::filesystem::path tempPath(((mFixedPath).*(tokenIt->second))());
                    if (pos < path.length() - 1)
                    {
                        // There is something after the token, so we should
                        // append it to the path
                        tempPath /= path.substr(pos + 1, path.length() - pos);
                    }

                    *it = tempPath;
                }
                else
                {
                    // Clean invalid / unknown token, it will be removed outside the loop
                    (*it).clear();
                }
            }
        }

        if (!boost::filesystem::is_directory(*it))
        {
            if (create)
            {
                try
                {
                    boost::filesystem::create_directories (*it);
                }
                catch (...) {}

                if (boost::filesystem::is_directory(*it))
                    continue;
            }

            (*it).clear();
        }
    }

    dataDirs.erase(std::remove_if(dataDirs.begin(), dataDirs.end(),
        boost::bind(&boost::filesystem::path::empty, _1)), dataDirs.end());
}