diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index 2ccf96bc4..1891bf550 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -130,19 +130,18 @@ void BirthDialog::updateBirths() { mBirthList->removeAllItems(); - const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::Store &signs = + MWBase::Environment::get().getWorld()->getStore().get(); - MWWorld::RecListT::MapType::const_iterator it = store.birthSigns.list.begin(); - MWWorld::RecListT::MapType::const_iterator end = store.birthSigns.list.end(); int index = 0; // sort by name std::vector < std::pair > birthSigns; - for (; it!=end; ++it) + + MWWorld::Store::iterator it = signs.begin(); + for (; it != signs.end(); ++it) { - std::string id = it->first; - const ESM::BirthSign* sign = &it->second; - birthSigns.push_back(std::make_pair(id, sign)); + birthSigns.push_back(std::make_pair(it->mId, &(*it))); } std::sort(birthSigns.begin(), birthSigns.end(), sortBirthSigns); @@ -170,8 +169,11 @@ void BirthDialog::updateSpells() const int lineHeight = 18; MyGUI::IntCoord coord(0, 0, mSpellArea->getWidth(), 18); - const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - const ESM::BirthSign *birth = store.birthSigns.find(mCurrentBirthId); + const MWWorld::ESMStore &store = + MWBase::Environment::get().getWorld()->getStore(); + + const ESM::BirthSign *birth = + store.get().find(mCurrentBirthId); std::string texturePath = std::string("textures\\") + birth->mTexture; fixTexturePath(texturePath); @@ -200,11 +202,17 @@ void BirthDialog::updateSpells() } int i = 0; - struct{ const std::vector &spells; const char *label; } categories[3] = { + + struct { + const std::vector &spells; + const char *label; + } + categories[3] = { {abilities, "sBirthsignmenu1"}, {powers, "sPowers"}, {spells, "sBirthsignmenu2"} }; + for (int category = 0; category < 3; ++category) { if (!categories[category].spells.empty()) diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index e4b77287c..253e0779c 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -357,7 +357,9 @@ void CharacterCreation::onPickClassDialogDone(WindowBase* parWindow) const std::string &classId = mPickClassDialog->getClassId(); if (!classId.empty()) MWBase::Environment::get().getMechanicsManager()->setPlayerClass(classId); - const ESM::Class *klass = MWBase::Environment::get().getWorld()->getStore().classes.find(classId); + + const ESM::Class *klass = + MWBase::Environment::get().getWorld()->getStore().get().find(classId); if (klass) { mPlayerClass = *klass; @@ -729,7 +731,10 @@ void CharacterCreation::onGenerateClassDone(WindowBase* parWindow) mGenerateClassResultDialog = 0; MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass); - const ESM::Class *klass = MWBase::Environment::get().getWorld()->getStore().classes.find(mGenerateClass); + + const ESM::Class *klass = + MWBase::Environment::get().getWorld()->getStore().get().find(mGenerateClass); + mPlayerClass = *klass; mWM->setPlayerClass(mPlayerClass); diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index 589a7abac..9595f3284 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -92,10 +92,10 @@ namespace MWGui scanner.listKeywords (mNames); // identifier - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = + MWBase::Environment::get().getWorld()->getStore(); - for (MWWorld::RecListList::const_iterator iter (store.recLists.begin()); - iter!=store.recLists.end(); ++iter) + for (MWWorld::ESMStore::iterator it = store.begin(); it != store.end(); ++it) { iter->second->listIdentifier (mNames); } diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 66444e18c..49804be2e 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -127,33 +127,36 @@ void DialogueWindow::onSelectTopic(std::string topic) { if (!mEnabled) return; - if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sBarter")->getString()) + const MWWorld::Store &gmst = + MWBase::Environment::get().getWorld()->getStore().get(); + + if (topic == gmst.find("sBarter")->getString()) { /// \todo check if the player is allowed to trade with this actor (e.g. faction rank high enough)? mWindowManager.pushGuiMode(GM_Barter); mWindowManager.getTradeWindow()->startTrade(mPtr); } - else if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sSpells")->getString()) + else if (topic == gmst.find("sSpells")->getString()) { mWindowManager.pushGuiMode(GM_SpellBuying); mWindowManager.getSpellBuyingWindow()->startSpellBuying(mPtr); } - else if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sTravel")->getString()) + else if (topic == gmst.find("sTravel")->getString()) { mWindowManager.pushGuiMode(GM_Travel); mWindowManager.getTravelWindow()->startTravel(mPtr); } - else if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sSpellMakingMenuTitle")->getString()) + else if (topic == gmst.find("sSpellMakingMenuTitle")->getString()) { mWindowManager.pushGuiMode(GM_SpellCreation); mWindowManager.startSpellMaking (mPtr); } - else if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sEnchanting")->getString()) + else if (topic == gmst.find("sEnchanting")->getString()) { mWindowManager.pushGuiMode(GM_Enchanting); mWindowManager.startEnchanting (mPtr); } - else if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sServiceTrainingTitle")->getString()) + else if (topic == gmst.find("sServiceTrainingTitle")->getString()) { mWindowManager.pushGuiMode(GM_Training); mWindowManager.startTraining (mPtr); @@ -180,23 +183,26 @@ void DialogueWindow::setKeywords(std::list keyWords) bool anyService = mServices > 0; + const MWWorld::Store &gmst = + MWBase::Environment::get().getWorld()->getStore().get(); + if (mServices & Service_Trade) - mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sBarter")->getString()); + mTopicsList->addItem(gmst.find("sBarter")->getString()); if (mServices & Service_BuySpells) - mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sSpells")->getString()); + mTopicsList->addItem(gmst.find("sSpells")->getString()); if (mServices & Service_Travel) - mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sTravel")->getString()); + mTopicsList->addItem(gmst.find("sTravel")->getString()); if (mServices & Service_CreateSpells) - mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sSpellmakingMenuTitle")->getString()); + mTopicsList->addItem(gmst.find("sSpellmakingMenuTitle")->getString()); // if (mServices & Service_Enchant) -// mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sEnchanting")->getString()); +// mTopicsList->addItem(gmst.find("sEnchanting")->getString()); if (mServices & Service_Training) - mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sServiceTrainingTitle")->getString()); + mTopicsList->addItem(gmst.find("sServiceTrainingTitle")->getString()); if (anyService) mTopicsList->addSeparator(); @@ -301,7 +307,7 @@ void DialogueWindow::updateOptions() void DialogueWindow::goodbye() { - mHistory->addDialogText("\n#572D21" + MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGoodbye")->getString()); + mHistory->addDialogText("\n#572D21" + MWBase::Environment::get().getWorld()->getStore().get().find("sGoodbye")->getString()); mTopicsList->setEnabled(false); mEnabled = false; } diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 72feb84a4..cb8efe5cc 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -224,20 +224,20 @@ void RaceDialog::updateRaces() { mRaceList->removeAllItems(); - const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::Store &races = + MWBase::Environment::get().getWorld()->getStore().get(); - MWWorld::RecListT::MapType::const_iterator it = store.races.list.begin(); - MWWorld::RecListT::MapType::const_iterator end = store.races.list.end(); + int index = 0; - for (; it != end; ++it) + MWWorld::Store::iterator it = races.begin() + for (; it != races.end(); ++it) { - const ESM::Race &race = it->second; - bool playable = race.mData.mFlags & ESM::Race::Playable; + bool playable = it->mData.mFlags & ESM::Race::Playable; if (!playable) // Only display playable races continue; - mRaceList->addItem(race.mName, it->first); - if (boost::iequals(it->first, mCurrentRaceId)) + mRaceList->addItem(it->mName, it->mId); + if (boost::iequals(it->mId, mCurrentRaceId)) mRaceList->setIndexSelected(index); ++index; } @@ -259,7 +259,7 @@ void RaceDialog::updateSkills() MyGUI::IntCoord coord1(0, 0, mSkillList->getWidth(), 18); const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - const ESM::Race *race = store.races.find(mCurrentRaceId); + const ESM::Race *race = store.get().find(mCurrentRaceId); int count = sizeof(race->mData.mBonus)/sizeof(race->mData.mBonus[0]); // TODO: Find a portable macro for this ARRAYSIZE? for (int i = 0; i < count; ++i) { @@ -297,7 +297,7 @@ void RaceDialog::updateSpellPowers() MyGUI::IntCoord coord(0, 0, mSpellPowerList->getWidth(), 18); const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - const ESM::Race *race = store.races.find(mCurrentRaceId); + const ESM::Race *race = store.get().find(mCurrentRaceId); std::vector::const_iterator it = race->mPowers.mList.begin(); std::vector::const_iterator end = race->mPowers.mList.end(); diff --git a/apps/openmw/mwgui/review.cpp b/apps/openmw/mwgui/review.cpp index 961856b7c..45adb5383 100644 --- a/apps/openmw/mwgui/review.cpp +++ b/apps/openmw/mwgui/review.cpp @@ -108,7 +108,9 @@ void ReviewDialog::setPlayerName(const std::string &name) void ReviewDialog::setRace(const std::string &raceId) { mRaceId = raceId; - const ESM::Race *race = MWBase::Environment::get().getWorld()->getStore().races.search(mRaceId); + + const ESM::Race *race = + MWBase::Environment::get().getWorld()->getStore().get().search(mRaceId); if (race) { ToolTips::createRaceToolTip(mRaceWidget, race); @@ -126,7 +128,9 @@ void ReviewDialog::setClass(const ESM::Class& class_) void ReviewDialog::setBirthSign(const std::string& signId) { mBirthSignId = signId; - const ESM::BirthSign *sign = MWBase::Environment::get().getWorld()->getStore().birthSigns.search(mBirthSignId); + + const ESM::BirthSign *sign = + MWBase::Environment::get().getWorld()->getStore().get().search(mBirthSignId); if (sign) { mBirthSignWidget->setCaption(sign->mName); diff --git a/apps/openmw/mwgui/spellbuyingwindow.cpp b/apps/openmw/mwgui/spellbuyingwindow.cpp index ece19cdc3..813a21b12 100644 --- a/apps/openmw/mwgui/spellbuyingwindow.cpp +++ b/apps/openmw/mwgui/spellbuyingwindow.cpp @@ -49,8 +49,12 @@ namespace MWGui void SpellBuyingWindow::addSpell(const std::string& spellId) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); - int price = spell->mData.mCost*MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fSpellValueMult")->getFloat(); + const MWWorld::ESMStore &store = + MWBase::Environment::get().getWorld()->getStore(); + + const ESM::Spell* spell = store.get().find(spellId); + + int price = spell->mData.mCost*store.get().find("fSpellValueMult")->getFloat(); MyGUI::Button* toAdd = mSpellsView->createWidget( @@ -97,7 +101,8 @@ namespace MWGui for (MWMechanics::Spells::TIterator iter = merchantSpells.begin(); iter!=merchantSpells.end(); ++iter) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find (*iter); + const ESM::Spell* spell = + MWBase::Environment::get().getWorld()->getStore().get().find (*iter); if (spell->mData.mType!=ESM::Spell::ST_Spell) continue; // don't try to sell diseases, curses or powers diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index 5050ba88a..82e112826 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -228,8 +228,10 @@ void MWSpell::setSpellId(const std::string &spellId) void MWSpell::createEffectWidgets(std::vector &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, int flags) { - const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - const ESM::Spell *spell = store.spells.search(mId); + const MWWorld::ESMStore &store = + MWBase::Environment::get().getWorld()->getStore(); + + const ESM::Spell *spell = store.get().search(mId); MYGUI_ASSERT(spell, "spell with id '" << mId << "' not found"); MWSpellEffectPtr effect = nullptr; @@ -259,8 +261,10 @@ void MWSpell::updateWidgets() { if (mSpellNameWidget && mWindowManager) { - const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - const ESM::Spell *spell = store.spells.search(mId); + const MWWorld::ESMStore &store = + MWBase::Environment::get().getWorld()->getStore(); + + const ESM::Spell *spell = store.get().search(mId); if (spell) static_cast(mSpellNameWidget)->setCaption(spell->mName); else @@ -389,8 +393,11 @@ void MWSpellEffect::updateWidgets() if (!mWindowManager) return; - const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - const ESM::MagicEffect *magicEffect = store.magicEffects.search(mEffectParams.mEffectID); + const MWWorld::ESMStore &store = + MWBase::Environment::get().getWorld()->getStore(); + + const ESM::MagicEffect *magicEffect = + store.get().search(mEffectParams.mEffectID); assert(magicEffect); assert(mWindowManager); diff --git a/apps/openmw/mwworld/esmstore.hpp b/apps/openmw/mwworld/esmstore.hpp index 525341a30..6073bc6d9 100644 --- a/apps/openmw/mwworld/esmstore.hpp +++ b/apps/openmw/mwworld/esmstore.hpp @@ -68,6 +68,17 @@ namespace MWWorld std::map mStores; public: + /// \todo replace with SharedIterator + typedef std::map::const_iterator iterator; + + iterator begin() const { + return mStores.begin(); + } + + iterator end() const { + return mStores.end(); + } + // Look up the given ID in 'all'. Returns 0 if not found. int find(const std::string &id) const {