mirror of
https://github.com/OpenMW/openmw.git
synced 2025-07-13 05:11:43 +00:00
master/plugin support; needs multimap instead of map
This commit is contained in:
parent
ceedae4a1a
commit
653fbdd10c
3 changed files with 64 additions and 0 deletions
|
@ -2,6 +2,9 @@
|
||||||
#include <boost/iostreams/device/file.hpp>
|
#include <boost/iostreams/device/file.hpp>
|
||||||
#include <boost/iostreams/stream.hpp>
|
#include <boost/iostreams/stream.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
MwIniImporter::MwIniImporter() {
|
MwIniImporter::MwIniImporter() {
|
||||||
const char *map[][2] =
|
const char *map[][2] =
|
||||||
|
@ -99,6 +102,61 @@ void MwIniImporter::merge(strmap &cfg, strmap &ini) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MwIniImporter::importGameFiles(strmap &cfg, strmap &ini) {
|
||||||
|
std::vector<std::string> esmFiles;
|
||||||
|
std::string baseEsm("Game Files:GameFile");
|
||||||
|
std::string esmFile("");
|
||||||
|
|
||||||
|
strmap::iterator it = ini.begin();
|
||||||
|
for(int i=0; it != ini.end(); i++) {
|
||||||
|
esmFile = baseEsm;
|
||||||
|
esmFile.append(1,i+'0');
|
||||||
|
|
||||||
|
it = ini.find(esmFile);
|
||||||
|
if(it == ini.end()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "found EMS file: " << it->second << std::endl;
|
||||||
|
esmFiles.push_back(it->second);
|
||||||
|
esmFile = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<std::string> bsaFiles;
|
||||||
|
std::string baseBsa("Archives:Archive ");
|
||||||
|
std::string bsaFile("");
|
||||||
|
|
||||||
|
it = ini.begin();
|
||||||
|
for(int i=0; it != ini.end(); i++) {
|
||||||
|
bsaFile = baseBsa;
|
||||||
|
bsaFile.append(1,i+'0');
|
||||||
|
|
||||||
|
it = ini.find(bsaFile);
|
||||||
|
if(it == ini.end()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "found BSA file: " << it->second << std::endl;
|
||||||
|
bsaFiles.push_back(it->second);
|
||||||
|
bsaFile = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!esmFiles.empty()) {
|
||||||
|
cfg.erase("master");
|
||||||
|
for(std::vector<std::string>::iterator it = esmFiles.begin(); it != esmFiles.end(); it++) {
|
||||||
|
cfg.insert(std::make_pair<std::string, std::string>("master", *it));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!bsaFile.empty()) {
|
||||||
|
cfg.erase("plugin");
|
||||||
|
for(std::vector<std::string>::iterator it = bsaFiles.begin(); it != bsaFiles.end(); it++) {
|
||||||
|
cfg.insert(std::make_pair<std::string, std::string>("plugin", *it));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool MwIniImporter::specialMerge(std::string cfgKey, std::string iniKey, strmap &cfg, strmap &ini) {
|
bool MwIniImporter::specialMerge(std::string cfgKey, std::string iniKey, strmap &cfg, strmap &ini) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ class MwIniImporter {
|
||||||
strmap loadIniFile(std::string filename);
|
strmap loadIniFile(std::string filename);
|
||||||
strmap loadCfgFile(std::string filename);
|
strmap loadCfgFile(std::string filename);
|
||||||
void merge(strmap &cfg, strmap &ini);
|
void merge(strmap &cfg, strmap &ini);
|
||||||
|
void importGameFiles(strmap &cfg, strmap &ini);
|
||||||
void writeToFile(std::string file, strmap &cfg);
|
void writeToFile(std::string file, strmap &cfg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -16,6 +16,7 @@ int main(int argc, char *argv[]) {
|
||||||
("ini,i", bpo::value<std::string>(), "morrowind.ini file")
|
("ini,i", bpo::value<std::string>(), "morrowind.ini file")
|
||||||
("cfg,c", bpo::value<std::string>(), "openmw.cfg file")
|
("cfg,c", bpo::value<std::string>(), "openmw.cfg file")
|
||||||
("output,o", bpo::value<std::string>()->default_value(""), "openmw.cfg file")
|
("output,o", bpo::value<std::string>()->default_value(""), "openmw.cfg file")
|
||||||
|
("game-files,g", "import esm and esp files")
|
||||||
;
|
;
|
||||||
|
|
||||||
bpo::variables_map vm;
|
bpo::variables_map vm;
|
||||||
|
@ -65,6 +66,10 @@ int main(int argc, char *argv[]) {
|
||||||
std::map<std::string, std::string>cfg = importer.loadCfgFile(cfgFile);
|
std::map<std::string, std::string>cfg = importer.loadCfgFile(cfgFile);
|
||||||
|
|
||||||
importer.merge(cfg, ini);
|
importer.merge(cfg, ini);
|
||||||
|
|
||||||
|
if(vm.count("game-files")) {
|
||||||
|
importer.importGameFiles(cfg, ini);
|
||||||
|
}
|
||||||
|
|
||||||
std::cout << "write to: " << outputFile << std::endl;
|
std::cout << "write to: " << outputFile << std::endl;
|
||||||
importer.writeToFile(outputFile, cfg);
|
importer.writeToFile(outputFile, cfg);
|
||||||
|
|
Loading…
Reference in a new issue