Esempio n. 1
0
void MwIniImporter::importGameFiles(multistrmap &cfg, const multistrmap &ini) const {
    std::vector<std::string> contentFiles;
    std::string baseGameFile("Game Files:GameFile");
    std::string gameFile("");

    multistrmap::const_iterator it = ini.begin();
    for(int i=0; it != ini.end(); i++) {
        gameFile = baseGameFile;
        gameFile.append(this->numberToString(i));

        it = ini.find(gameFile);
        if(it == ini.end()) {
            break;
        }

        for(std::vector<std::string>::const_iterator entry = it->second.begin(); entry!=it->second.end(); ++entry) {
            std::string filetype(entry->substr(entry->length()-3));
            Misc::StringUtils::toLower(filetype);

            if(filetype.compare("esm") == 0 || filetype.compare("esp") == 0) {
                contentFiles.push_back(*entry);
            }
        }

        gameFile = "";
    }

    cfg.erase("content");
    cfg.insert( std::make_pair("content", std::vector<std::string>() ) );

    for(std::vector<std::string>::const_iterator it=contentFiles.begin(); it!=contentFiles.end(); ++it) {
        cfg["content"].push_back(*it);
    }
}
Esempio n. 2
0
void MwIniImporter::importGameFiles(multistrmap &cfg, multistrmap &ini) {
    std::vector<std::string> esmFiles;
    std::vector<std::string> espFiles;
    std::string baseGameFile("Game Files:GameFile");
    std::string gameFile("");

    multistrmap::iterator it = ini.begin();
    for(int i=0; it != ini.end(); i++) {
        gameFile = baseGameFile;
        gameFile.append(this->numberToString(i));

        it = ini.find(gameFile);
        if(it == ini.end()) {
            break;
        }

        for(std::vector<std::string>::iterator entry = it->second.begin(); entry!=it->second.end(); ++entry) {
            std::string filetype(entry->substr(entry->length()-4, 3));
            std::transform(filetype.begin(), filetype.end(), filetype.begin(), ::tolower);

            if(filetype.compare("esm") == 0) {
                esmFiles.push_back(*entry);
            }
            else if(filetype.compare("esp") == 0) {
                espFiles.push_back(*entry);
            }
        }

        gameFile = "";
    }

    cfg.erase("master");
    cfg.insert( std::make_pair<std::string, std::vector<std::string> > ("master", std::vector<std::string>() ) );

    for(std::vector<std::string>::iterator it=esmFiles.begin(); it!=esmFiles.end(); ++it) {
        cfg["master"].push_back(*it);
    }

    cfg.erase("plugin");
    cfg.insert( std::make_pair<std::string, std::vector<std::string> > ("plugin", std::vector<std::string>() ) );

    for(std::vector<std::string>::iterator it=espFiles.begin(); it!=espFiles.end(); ++it) {
        cfg["plugin"].push_back(*it);
    }
}