fallback in apps/openmw; fix for apps/mwiniimporter

actorid
Sebastian Wick 13 years ago
parent 6e19076dc5
commit ab9c430632

@ -141,8 +141,8 @@ void MwIniImporter::mergeFallback(multistrmap &cfg, multistrmap &ini) {
for(strmap::iterator it=mMergeFallback.begin(); it!=mMergeFallback.end(); it++) {
if((iniIt = ini.find(it->second)) != ini.end()) {
for(std::vector<std::string>::iterator vc = iniIt->second.begin(); vc != iniIt->second.end(); vc++) {
std::string value("\"");
value.append(it->first).append("=").append(vc->substr(0,vc->length()-1)).append("\"");
std::string value(it->first);
value.append("=").append(vc->substr(0,vc->length()-1));
insertMultistrmap(cfg, "fallback", value);
}
}

@ -28,6 +28,8 @@ int main(int argc, char *argv[]) {
return 0;
}
bpo::notify(vm);
std::string iniFile = vm["ini"].as<std::string>();
std::string cfgFile = vm["cfg"].as<std::string>();

@ -341,7 +341,7 @@ void OMW::Engine::go()
// Create the world
mEnvironment.mWorld = new MWWorld::World (*mOgre, mFileCollections, mMaster,
mResDir, mNewGame, mEnvironment, mEncoding);
mResDir, mNewGame, mEnvironment, mEncoding, mFallbackPairs);
// Create window manager - this manages all the MW-specific GUI windows
MWScript::registerExtensions (mExtensions);
@ -508,3 +508,8 @@ void OMW::Engine::setEncoding(const std::string& encoding)
{
mEncoding = encoding;
}
void OMW::Engine::setFallbackValues(std::vector<std::string> pairs)
{
mFallbackPairs = pairs;
}

@ -76,6 +76,7 @@ namespace OMW
bool mReportFocus;
float mFocusTDiff;
std::string mFocusName;
std::vector<std::string> mFallbackPairs;
MWWorld::Environment mEnvironment;
Compiler::Extensions mExtensions;
@ -163,6 +164,8 @@ namespace OMW
void setAnimationVerbose(bool animverbose);
void setFallbackValues(std::vector<std::string> pairs);
private:
Files::ConfigurationManager& mCfgMgr;
};

@ -92,39 +92,43 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
("plugin", bpo::value<StringsVector>()->default_value(StringsVector(), "")
->multitoken(), "plugin file(s)")
("fps", boost::program_options::value<int>()->implicit_value(1)
("fps", bpo::value<int>()->implicit_value(1)
->default_value(0), "fps counter detail (0 = off, 1 = fps counter, 2 = full detail)")
("anim-verbose", boost::program_options::value<bool>()->implicit_value(true)
("anim-verbose", bpo::value<bool>()->implicit_value(true)
->default_value(false), "output animation indices files")
("debug", boost::program_options::value<bool>()->implicit_value(true)
("debug", bpo::value<bool>()->implicit_value(true)
->default_value(false), "debug mode")
("nosound", boost::program_options::value<bool>()->implicit_value(true)
("nosound", bpo::value<bool>()->implicit_value(true)
->default_value(false), "disable all sounds")
("script-verbose", boost::program_options::value<bool>()->implicit_value(true)
("script-verbose", bpo::value<bool>()->implicit_value(true)
->default_value(false), "verbose script output")
("new-game", boost::program_options::value<bool>()->implicit_value(true)
("new-game", bpo::value<bool>()->implicit_value(true)
->default_value(false), "activate char gen/new game mechanics")
("script-all", boost::program_options::value<bool>()->implicit_value(true)
("script-all", bpo::value<bool>()->implicit_value(true)
->default_value(false), "compile all scripts (excluding dialogue scripts) at startup")
("fs-strict", boost::program_options::value<bool>()->implicit_value(true)
("fs-strict", bpo::value<bool>()->implicit_value(true)
->default_value(false), "strict file system handling (no case folding)")
( "encoding", boost::program_options::value<std::string>()->
( "encoding", bpo::value<std::string>()->
default_value("win1252"),
"Character encoding used in OpenMW game messages:\n"
"\n\twin1250 - Central and Eastern European such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian, Serbian (Latin script), Romanian and Albanian languages\n"
"\n\twin1251 - Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic and other languages\n"
"\n\twin1252 - Western European (Latin) alphabet, used by default")
("report-focus", boost::program_options::value<bool>()->implicit_value(true)
("report-focus", bpo::value<bool>()->implicit_value(true)
->default_value(false), "write name of focussed object to cout")
("fallback", bpo::value<StringsVector>()->default_value(StringsVector(), "")
->multitoken()->composing(), "fallback values")
;
bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv)
@ -232,6 +236,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
engine.setCompileAll(variables["script-all"].as<bool>());
engine.setReportFocus(variables["report-focus"].as<bool>());
engine.setAnimationVerbose(variables["anim-verbose"].as<bool>());
engine.setFallbackValues(variables["fallback"].as<std::vector<std::string> >());
return true;
}

@ -152,10 +152,40 @@ namespace MWWorld
mRendering->skyDisable();
}
void World::setFallbackValues(std::vector<std::string> pairs)
{
for(std::vector<std::string>::iterator it = pairs.begin(); it != pairs.end(); it++)
{
std::string kv = *it;
int seperator = kv.find("=");
if(seperator < 1 || seperator == (kv.length()-1))
{
continue;
}
std::string key = it->substr(0,seperator);
std::string value = it->substr(seperator+1);
if(mFallback.find(key) == mFallback.end()) {
std::cout << "insert " << key << ":" << value << std::endl;
mFallback.insert(std::make_pair<std::string,std::string>(key,value));
}
}
}
std::string World::getFallback(std::string key)
{
std::map<std::string,std::string>::iterator it;
if((it = mFallback.find(key)) == mFallback.end())
{
return std::string("");
}
return it->second;
}
World::World (OEngine::Render::OgreRenderer& renderer,
const Files::Collections& fileCollections,
const std::string& master, const boost::filesystem::path& resDir,
bool newGame, Environment& environment, const std::string& encoding)
bool newGame, Environment& environment, const std::string& encoding, std::vector<std::string> fallbackPairs)
: mPlayer (0), mLocalScripts (mStore), mGlobalVariables (0),
mSky (true), mEnvironment (environment), mNextDynamicRecord (0), mCells (mStore, mEsm, *this),
mNumFacing(0)
@ -190,6 +220,8 @@ namespace MWWorld
}
mWorldScene = new Scene(environment, this, *mRendering, mPhysics);
setFallbackValues(fallbackPairs);
}

@ -100,6 +100,7 @@ namespace MWWorld
std::string mFaced1Name;
std::string mFaced2Name;
int mNumFacing;
std::map<std::string,std::string> mFallback;
int getDaysPerMonth (int month) const;
@ -110,7 +111,7 @@ namespace MWWorld
World (OEngine::Render::OgreRenderer& renderer,
const Files::Collections& fileCollections,
const std::string& master, const boost::filesystem::path& resDir, bool newGame,
Environment& environment, const std::string& encoding);
Environment& environment, const std::string& encoding, std::vector<std::string> fallbackPairs);
~World();
@ -125,6 +126,10 @@ namespace MWWorld
void adjustSky();
void setFallbackValues(std::vector<std::string> pairs);
std::string getFallback(std::string key);
MWWorld::Player& getPlayer();
const ESMS::ESMStore& getStore() const;

Loading…
Cancel
Save