diff --git a/apps/openmw/mwgui/quickkeysmenu.cpp b/apps/openmw/mwgui/quickkeysmenu.cpp index e927af95d..02512425d 100644 --- a/apps/openmw/mwgui/quickkeysmenu.cpp +++ b/apps/openmw/mwgui/quickkeysmenu.cpp @@ -29,8 +29,11 @@ namespace bool sortSpells(const std::string& left, const std::string& right) { - const ESM::Spell* a = MWBase::Environment::get().getWorld()->getStore().spells.find(left); - const ESM::Spell* b = MWBase::Environment::get().getWorld()->getStore().spells.find(right); + const MWWorld::Store &spells = + MWBase::Environment::get().getWorld()->getStore().get(); + + const ESM::Spell* a = spells.find(left); + const ESM::Spell* b = spells.find(right); int cmp = a->mName.compare(b->mName); return cmp < 0; @@ -234,9 +237,15 @@ namespace MWGui MyGUI::ImageBox* image = frame->createWidget("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default); + const MWWorld::ESMStore &esmStore = + MWBase::Environment::get().getWorld()->getStore(); + // use the icon of the first effect - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); - const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(spell->mEffects.mList.front().mEffectID); + const ESM::Spell* spell = esmStore.get().find(spellId); + + const ESM::MagicEffect* effect = + esmStore.get().find(spell->mEffects.mList.front().mEffectID); + std::string path = effect->mIcon; int slashPos = path.find("\\"); path.insert(slashPos+1, "b_"); @@ -434,11 +443,14 @@ namespace MWGui spellList.push_back(*it); } + const MWWorld::ESMStore &esmStore = + MWBase::Environment::get().getWorld()->getStore(); + std::vector powers; std::vector::iterator it = spellList.begin(); while (it != spellList.end()) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); + const ESM::Spell* spell = esmStore.get().find(*it); if (spell->mData.mType == ESM::Spell::ST_Power) { powers.push_back(*it); @@ -465,7 +477,9 @@ namespace MWGui if (enchantId != "") { // only add items with "Cast once" or "Cast on use" - const ESM::Enchantment* enchant = MWBase::Environment::get().getWorld()->getStore().enchants.find(enchantId); + const ESM::Enchantment* enchant = + esmStore.get().find(enchantId); + int type = enchant->mData.mType; if (type != ESM::Enchantment::CastOnce && type != ESM::Enchantment::WhenUsed) @@ -487,7 +501,7 @@ namespace MWGui for (std::vector::const_iterator it = powers.begin(); it != powers.end(); ++it) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); + const ESM::Spell* spell = esmStore.get().find(*it); MyGUI::Button* t = mMagicList->createWidget("SpellText", MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top); t->setCaption(spell->mName); @@ -504,7 +518,7 @@ namespace MWGui addGroup("#{sSpells}", ""); for (std::vector::const_iterator it = spellList.begin(); it != spellList.end(); ++it) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); + const ESM::Spell* spell = esmStore.get().find(*it); MyGUI::Button* t = mMagicList->createWidget("SpellText", MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top); t->setCaption(spell->mName); diff --git a/apps/openmw/mwgui/spellwindow.cpp b/apps/openmw/mwgui/spellwindow.cpp index c7f61a935..d62b23de4 100644 --- a/apps/openmw/mwgui/spellwindow.cpp +++ b/apps/openmw/mwgui/spellwindow.cpp @@ -26,8 +26,11 @@ namespace { bool sortSpells(const std::string& left, const std::string& right) { - const ESM::Spell* a = MWBase::Environment::get().getWorld()->getStore().spells.find(left); - const ESM::Spell* b = MWBase::Environment::get().getWorld()->getStore().spells.find(right); + const MWWorld::Store &spells = + MWBase::Environment::get().getWorld()->getStore().get(); + + const ESM::Spell* a = spells.find(left); + const ESM::Spell* b = spells.find(right); int cmp = a->mName.compare(b->mName); return cmp < 0; @@ -139,11 +142,15 @@ namespace MWGui spellList.push_back(*it); } + const MWWorld::ESMStore &esmStore = + MWBase::Environment::get().getWorld()->getStore(); + std::vector powers; std::vector::iterator it = spellList.begin(); while (it != spellList.end()) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); + const ESM::Spell* spell = esmStore.get().find(*it); + if (spell->mData.mType == ESM::Spell::ST_Power) { powers.push_back(*it); @@ -170,7 +177,9 @@ namespace MWGui if (enchantId != "") { // only add items with "Cast once" or "Cast on use" - const ESM::Enchantment* enchant = MWBase::Environment::get().getWorld()->getStore().enchants.find(enchantId); + const ESM::Enchantment* enchant = + esmStore.get().find(enchantId); + int type = enchant->mData.mType; if (type != ESM::Enchantment::CastOnce && type != ESM::Enchantment::WhenUsed) @@ -191,7 +200,7 @@ namespace MWGui for (std::vector::const_iterator it = powers.begin(); it != powers.end(); ++it) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); + const ESM::Spell* spell = esmStore.get().find(*it); MyGUI::Button* t = mSpellView->createWidget("SpellText", MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top); t->setCaption(spell->mName); @@ -211,7 +220,7 @@ namespace MWGui addGroup("#{sSpells}", "#{sCostChance}"); for (std::vector::const_iterator it = spellList.begin(); it != spellList.end(); ++it) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); + const ESM::Spell* spell = esmStore.get().find(*it); MyGUI::Button* t = mSpellView->createWidget("SpellText", MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top); t->setCaption(spell->mName); @@ -244,7 +253,8 @@ namespace MWGui { MWWorld::Ptr item = *it; - const ESM::Enchantment* enchant = MWBase::Environment::get().getWorld()->getStore().enchants.find(MWWorld::Class::get(item).getEnchantment(item)); + const ESM::Enchantment* enchant = + esmStore.get().find(MWWorld::Class::get(item).getEnchantment(item)); // check if the item is currently equipped (will display in a different color) bool equipped = false; @@ -378,7 +388,9 @@ namespace MWGui if (MyGUI::InputManager::getInstance().isShiftPressed()) { // delete spell, if allowed - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); + const ESM::Spell* spell = + MWBase::Environment::get().getWorld()->getStore().get().find(spellId); + if (spell->mData.mFlags & ESM::Spell::F_Always || spell->mData.mType == ESM::Spell::ST_Power) { diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index ccba9cf74..5d30b142a 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -57,7 +57,7 @@ StatsWindow::StatsWindow (MWBase::WindowManager& parWindowManager) const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); for (int i=0; names[i][0]; ++i) { - setText (names[i][0], store.gameSettings.find (names[i][1])->getString()); + setText (names[i][0], store.get().find (names[i][1])->getString()); } getWidget(mSkillView, "SkillView"); @@ -363,12 +363,16 @@ void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId, float modified = stat.getModified(); int progressPercent = (modified - float(static_cast(modified))) * 100; - const ESM::Skill* skill = MWBase::Environment::get().getWorld()->getStore().skills.search(skillId); + const MWWorld::ESMStore &esmStore = + MWBase::Environment::get().getWorld()->getStore(); + + const ESM::Skill* skill = esmStore.get().find(skillId); assert(skill); std::string icon = "icons\\k\\" + ESM::Skill::sIconNames[skillId]; - const ESM::Attribute* attr = MWBase::Environment::get().getWorld()->getStore().attributes.search(skill->mData.mAttribute); + const ESM::Attribute* attr = + esmStore.get().find(skill->mData.mAttribute); assert(attr); std::string state = "normal"; @@ -425,7 +429,9 @@ void StatsWindow::updateSkillArea() const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); // race tooltip - const ESM::Race* playerRace = store.races.find (MWBase::Environment::get().getWorld()->getPlayer().getRace()); + const ESM::Race* playerRace = + store.get().find (MWBase::Environment::get().getWorld()->getPlayer().getRace()); + MyGUI::Widget* raceWidget; getWidget(raceWidget, "RaceText"); ToolTips::createRaceToolTip(raceWidget, playerRace); @@ -464,8 +470,8 @@ void StatsWindow::updateSkillArea() text += std::string("\n\n#DDC79E#{sNextRank} ") + faction->mRanks[it->second+1]; ESM::RankData rankData = faction->mData.mRankData[it->second+1]; - const ESM::Attribute* attr1 = MWBase::Environment::get().getWorld()->getStore().attributes.search(faction->mData.mAttribute1); - const ESM::Attribute* attr2 = MWBase::Environment::get().getWorld()->getStore().attributes.search(faction->mData.mAttribute2); + const ESM::Attribute* attr1 = store.get().find(faction->mData.mAttribute1); + const ESM::Attribute* attr2 = store.get().find(faction->mData.mAttribute2); assert(attr1 && attr2); text += "\n#BF9959#{" + attr1->mName + "}: " + boost::lexical_cast(rankData.mAttribute1) diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index d47a0f547..93118fa11 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -179,7 +179,9 @@ void ToolTips::onFrame(float frameDuration) else if (type == "Spell") { ToolTipInfo info; - const ESM::Spell *spell = MWBase::Environment::get().getWorld()->getStore().spells.find(focus->getUserString("Spell")); + + const ESM::Spell *spell = + MWBase::Environment::get().getWorld()->getStore().get().find(focus->getUserString("Spell")); info.caption = spell->mName; Widgets::SpellEffectList effects; std::vector::const_iterator end = spell->mEffects.mList.end(); @@ -368,7 +370,7 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info) const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); if (info.enchant != "") { - enchant = store.enchants.search(info.enchant); + enchant = store.get().find(info.enchant); if (enchant->mData.mType == ESM::Enchantment::CastOnce) text += "\n#{sItemCastOnce}"; else if (enchant->mData.mType == ESM::Enchantment::WhenStrikes) @@ -571,10 +573,15 @@ void ToolTips::createSkillToolTip(MyGUI::Widget* widget, int skillId) if (skillId == -1) return; + const MWWorld::ESMStore &store = + MWBase::Environment::get().getWorld()->getStore(); + const std::string &skillNameId = ESM::Skill::sSkillNameIds[skillId]; - const ESM::Skill* skill = MWBase::Environment::get().getWorld()->getStore().skills.search(skillId); + const ESM::Skill* skill = store.get().find(skillId); assert(skill); - const ESM::Attribute* attr = MWBase::Environment::get().getWorld()->getStore().attributes.search(skill->mData.mAttribute); + + const ESM::Attribute* attr = + store.get().find(skill->mData.mAttribute); assert(attr); std::string icon = "icons\\k\\" + ESM::Skill::sIconNames[skillId]; @@ -607,12 +614,14 @@ void ToolTips::createSpecializationToolTip(MyGUI::Widget* widget, const std::str widget->setUserString("Caption_CenteredCaption", name); std::string specText; // get all skills of this specialisation - std::map skills = MWBase::Environment::get().getWorld()->getStore().skills.list; - for (std::map::const_iterator it = skills.begin(); - it != skills.end(); ++it) + const MWWorld::Store &skills = + MWBase::Environment::get().getWorld()->getStore().get(); + + MWWorld::Store::iterator it = skills.begin(); + for (; it != skills.end(); ++it) { - if (it->second.mData.mSpecialization == specId) - specText += std::string("\n#{") + ESM::Skill::sSkillNameIds[it->second.mIndex] + "}"; + if (it->mData.mSpecialization == specId) + specText += std::string("\n#{") + ESM::Skill::sSkillNameIds[it->mIndex] + "}"; } widget->setUserString("Caption_CenteredCaptionText", specText); widget->setUserString("ToolTipLayout", "TextWithCenteredCaptionToolTip"); @@ -621,7 +630,10 @@ void ToolTips::createSpecializationToolTip(MyGUI::Widget* widget, const std::str void ToolTips::createBirthsignToolTip(MyGUI::Widget* widget, const std::string& birthsignId) { - const ESM::BirthSign *sign = MWBase::Environment::get().getWorld()->getStore().birthSigns.find(birthsignId); + const MWWorld::ESMStore &store = + MWBase::Environment::get().getWorld()->getStore(); + + const ESM::BirthSign *sign = store.get().find(birthsignId); widget->setUserString("ToolTipType", "Layout"); widget->setUserString("ToolTipLayout", "BirthSignToolTip"); @@ -640,7 +652,7 @@ void ToolTips::createBirthsignToolTip(MyGUI::Widget* widget, const std::string& for (; it != end; ++it) { const std::string &spellId = *it; - const ESM::Spell *spell = MWBase::Environment::get().getWorld()->getStore().spells.search(spellId); + const ESM::Spell *spell = store.get().search(spellId); if (!spell) continue; // Skip spells which cannot be found ESM::Spell::SpellType type = static_cast(spell->mData.mType); @@ -655,7 +667,11 @@ void ToolTips::createBirthsignToolTip(MyGUI::Widget* widget, const std::string& spells.push_back(spellId); } - struct{ const std::vector &spells; std::string label; } categories[3] = { + struct { + const std::vector &spells; + std::string label; + } + categories[3] = { {abilities, "sBirthsignmenu1"}, {powers, "sPowers"}, {spells, "sBirthsignmenu2"} @@ -672,7 +688,7 @@ void ToolTips::createBirthsignToolTip(MyGUI::Widget* widget, const std::string& const std::string &spellId = *it; - const ESM::Spell *spell = MWBase::Environment::get().getWorld()->getStore().spells.search(spellId); + const ESM::Spell *spell = store.get().find(spellId); text += "\n#BF9959" + spell->mName; } } @@ -711,7 +727,8 @@ void ToolTips::createClassToolTip(MyGUI::Widget* widget, const ESM::Class& playe void ToolTips::createMagicEffectToolTip(MyGUI::Widget* widget, short id) { - const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld ()->getStore ().magicEffects.find(id); + const ESM::MagicEffect* effect = + MWBase::Environment::get().getWorld ()->getStore ().get().find(id); const std::string &name = ESM::MagicEffect::effectIdToString (id); std::string icon = effect->mIcon; diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index 0e755f49d..6498cd712 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -107,10 +107,14 @@ namespace MWGui bool goldFound = false; MWWorld::Ptr gold; MWWorld::ContainerStore& playerStore = mWindowManager.getInventoryWindow()->getContainerStore(); + + const MWWorld::Store &gmst = + MWBase::Environment::get().getWorld()->getStore().get(); + for (MWWorld::ContainerStoreIterator it = playerStore.begin(); it != playerStore.end(); ++it) { - if (MWWorld::Class::get(*it).getName(*it) == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString()) + if (MWWorld::Class::get(*it).getName(*it) == gmst.find("sGold")->getString()) { goldFound = true; gold = *it; diff --git a/apps/openmw/mwgui/trainingwindow.cpp b/apps/openmw/mwgui/trainingwindow.cpp index 226167ba3..08e64eba8 100644 --- a/apps/openmw/mwgui/trainingwindow.cpp +++ b/apps/openmw/mwgui/trainingwindow.cpp @@ -113,8 +113,11 @@ namespace MWGui MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer (); MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player); + const MWWorld::ESMStore &store = + MWBase::Environment::get().getWorld()->getStore(); + /// \todo mercantile skill - int price = pcStats.getSkill (skillId).getBase() * MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find("iTrainingMod")->getInt (); + int price = pcStats.getSkill (skillId).getBase() * store.get().find("iTrainingMod")->getInt (); if (mWindowManager.getInventoryWindow()->getPlayerGold() *playerRef = player.get(); - const ESM::Class *class_ = MWBase::Environment::get().getWorld()->getStore().classes.find ( - playerRef->mBase->mClass); + + const ESM::Class *class_ = + store.get().find(playerRef->mBase->mClass); pcStats.increaseSkill (skillId, *class_, true); // remove gold diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index 6431aa76e..0e7ebaaa3 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -54,16 +54,19 @@ namespace MWGui { int price = 0; + const MWWorld::Store &gmst = + MWBase::Environment::get().getWorld()->getStore().get(); + if(interior) { - price = MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fMagesGuildTravel")->getFloat(); + price = gmst.find("fMagesGuildTravel")->getFloat(); } else { MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); ESM::Position PlayerPos = player.getRefData().getPosition(); float d = sqrt( pow(pos.pos[0] - PlayerPos.pos[0],2) + pow(pos.pos[1] - PlayerPos.pos[1],2) + pow(pos.pos[2] - PlayerPos.pos[2],2) ); - price = d/MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fTravelMult")->getFloat(); + price = d/gmst.find("fTravelMult")->getFloat(); } MyGUI::Button* toAdd = mDestinationsView->createWidget((price>mWindowManager.getInventoryWindow()->getPlayerGold()) ? "SandTextGreyedOut" : "SandTextButton", 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default); @@ -142,7 +145,7 @@ namespace MWGui cell = MWBase::Environment::get().getWorld()->getExterior(x,y); ESM::Position PlayerPos = player.getRefData().getPosition(); float d = sqrt( pow(pos.pos[0] - PlayerPos.pos[0],2) + pow(pos.pos[1] - PlayerPos.pos[1],2) + pow(pos.pos[2] - PlayerPos.pos[2],2) ); - int time = int(d /MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fTravelTimeMult")->getFloat()); + int time = int(d /MWBase::Environment::get().getWorld()->getStore().get().find("fTravelTimeMult")->getFloat()); for(int i = 0;i < time;i++) { MWBase::Environment::get().getMechanicsManager ()->restoreDynamicStats (); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index d5d88960a..8e4187f7f 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -554,7 +554,9 @@ int WindowManager::readPressedButton () std::string WindowManager::getGameSettingString(const std::string &id, const std::string &default_) { - const ESM::GameSetting *setting = MWBase::Environment::get().getWorld()->getStore().gameSettings.search(id); + const ESM::GameSetting *setting = + MWBase::Environment::get().getWorld()->getStore().get().search(id); + if (setting && setting->mType == ESM::VT_String) return setting->getString(); return default_; @@ -614,7 +616,8 @@ void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell) } else { - const ESM::Region* region = MWBase::Environment::get().getWorld()->getStore().regions.search(cell->mCell->mRegion); + const ESM::Region* region = + MWBase::Environment::get().getWorld()->getStore().get().search(cell->mCell->mRegion); if (region) name = region->mName; else @@ -717,7 +720,9 @@ void WindowManager::setDragDrop(bool dragDrop) void WindowManager::onRetrieveTag(const MyGUI::UString& _tag, MyGUI::UString& _result) { - const ESM::GameSetting *setting = MWBase::Environment::get().getWorld()->getStore().gameSettings.find(_tag); + const ESM::GameSetting *setting = + MWBase::Environment::get().getWorld()->getStore().get().find(_tag); + if (setting && setting->mType == ESM::VT_String) _result = setting->getString(); else @@ -808,7 +813,10 @@ void WindowManager::removeGuiMode(GuiMode mode) void WindowManager::setSelectedSpell(const std::string& spellId, int successChancePercent) { mHud->setSelectedSpell(spellId, successChancePercent); - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); + + const ESM::Spell* spell = + MWBase::Environment::get().getWorld()->getStore().get().find(spellId); + mSpellWindow->setTitle(spell->mName); }