Issue #107: removed redundant getStore function from window manager

This commit is contained in:
Marc Zinnschlag 2012-08-12 14:36:46 +02:00
parent f37d3cd3c9
commit 484cce12a8
13 changed files with 54 additions and 35 deletions

View file

@ -1,6 +1,8 @@
#include "journalimp.hpp" #include "journalimp.hpp"
#include <components/esm_store/store.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"

View file

@ -1,11 +1,16 @@
#include "birth.hpp" #include "birth.hpp"
#include "window_manager.hpp"
#include "widgets.hpp"
#include "components/esm_store/store.hpp"
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include "components/esm_store/store.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "window_manager.hpp"
#include "widgets.hpp"
using namespace MWGui; using namespace MWGui;
using namespace Widgets; using namespace Widgets;
@ -114,7 +119,7 @@ void BirthDialog::updateBirths()
{ {
mBirthList->removeAllItems(); mBirthList->removeAllItems();
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
ESMS::RecListT<ESM::BirthSign>::MapType::const_iterator it = store.birthSigns.list.begin(); ESMS::RecListT<ESM::BirthSign>::MapType::const_iterator it = store.birthSigns.list.begin();
ESMS::RecListT<ESM::BirthSign>::MapType::const_iterator end = store.birthSigns.list.end(); ESMS::RecListT<ESM::BirthSign>::MapType::const_iterator end = store.birthSigns.list.end();
@ -144,7 +149,7 @@ void BirthDialog::updateSpells()
const int lineHeight = 18; const int lineHeight = 18;
MyGUI::IntCoord coord(0, 0, mSpellArea->getWidth(), 18); MyGUI::IntCoord coord(0, 0, mSpellArea->getWidth(), 18);
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::BirthSign *birth = store.birthSigns.find(mCurrentBirthId); const ESM::BirthSign *birth = store.birthSigns.find(mCurrentBirthId);
std::string texturePath = std::string("textures\\") + birth->texture; std::string texturePath = std::string("textures\\") + birth->texture;

View file

@ -7,6 +7,9 @@
#include <components/esm_store/store.hpp> #include <components/esm_store/store.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "window_manager.hpp" #include "window_manager.hpp"
#include "tooltips.hpp" #include "tooltips.hpp"
@ -57,8 +60,7 @@ void GenerateClassResultDialog::setClassId(const std::string &classId)
{ {
mCurrentClassId = classId; mCurrentClassId = classId;
mClassImage->setImageTexture(std::string("textures\\levelup\\") + mCurrentClassId + ".dds"); mClassImage->setImageTexture(std::string("textures\\levelup\\") + mCurrentClassId + ".dds");
const ESMS::ESMStore &store = mWindowManager.getStore(); mClassName->setCaption(MWBase::Environment::get().getWorld()->getStore().classes.find(mCurrentClassId)->name);
mClassName->setCaption(store.classes.find(mCurrentClassId)->name);
} }
// widget controls // widget controls
@ -193,7 +195,7 @@ void PickClassDialog::updateClasses()
{ {
mClassList->removeAllItems(); mClassList->removeAllItems();
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
ESMS::RecListT<ESM::Class>::MapType::const_iterator it = store.classes.list.begin(); ESMS::RecListT<ESM::Class>::MapType::const_iterator it = store.classes.list.begin();
ESMS::RecListT<ESM::Class>::MapType::const_iterator end = store.classes.list.end(); ESMS::RecListT<ESM::Class>::MapType::const_iterator end = store.classes.list.end();
@ -217,7 +219,7 @@ void PickClassDialog::updateStats()
{ {
if (mCurrentClassId.empty()) if (mCurrentClassId.empty())
return; return;
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::Class *klass = store.classes.search(mCurrentClassId); const ESM::Class *klass = store.classes.search(mCurrentClassId);
if (!klass) if (!klass)
return; return;

View file

@ -8,6 +8,9 @@
#include <components/esm_store/store.hpp> #include <components/esm_store/store.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "window_manager.hpp" #include "window_manager.hpp"
#include "widgets.hpp" #include "widgets.hpp"
#include "tooltips.hpp" #include "tooltips.hpp"
@ -209,7 +212,7 @@ void RaceDialog::updateRaces()
{ {
mRaceList->removeAllItems(); mRaceList->removeAllItems();
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
ESMS::RecListT<ESM::Race>::MapType::const_iterator it = store.races.list.begin(); ESMS::RecListT<ESM::Race>::MapType::const_iterator it = store.races.list.begin();
ESMS::RecListT<ESM::Race>::MapType::const_iterator end = store.races.list.end(); ESMS::RecListT<ESM::Race>::MapType::const_iterator end = store.races.list.end();
@ -243,7 +246,7 @@ void RaceDialog::updateSkills()
const int lineHeight = 18; const int lineHeight = 18;
MyGUI::IntCoord coord1(0, 0, mSkillList->getWidth(), 18); MyGUI::IntCoord coord1(0, 0, mSkillList->getWidth(), 18);
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::Race *race = store.races.find(mCurrentRaceId); const ESM::Race *race = store.races.find(mCurrentRaceId);
int count = sizeof(race->data.bonus)/sizeof(race->data.bonus[0]); // TODO: Find a portable macro for this ARRAYSIZE? int count = sizeof(race->data.bonus)/sizeof(race->data.bonus[0]); // TODO: Find a portable macro for this ARRAYSIZE?
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)
@ -281,7 +284,7 @@ void RaceDialog::updateSpellPowers()
const int lineHeight = 18; const int lineHeight = 18;
MyGUI::IntCoord coord(0, 0, mSpellPowerList->getWidth(), 18); MyGUI::IntCoord coord(0, 0, mSpellPowerList->getWidth(), 18);
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::Race *race = store.races.find(mCurrentRaceId); const ESM::Race *race = store.races.find(mCurrentRaceId);
std::vector<std::string>::const_iterator it = race->powers.list.begin(); std::vector<std::string>::const_iterator it = race->powers.list.begin();

View file

@ -7,6 +7,9 @@
#include <components/esm_store/store.hpp> #include <components/esm_store/store.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "window_manager.hpp" #include "window_manager.hpp"
#include "widgets.hpp" #include "widgets.hpp"
#include "tooltips.hpp" #include "tooltips.hpp"
@ -138,7 +141,7 @@ void ReviewDialog::setPlayerName(const std::string &name)
void ReviewDialog::setRace(const std::string &raceId) void ReviewDialog::setRace(const std::string &raceId)
{ {
mRaceId = raceId; mRaceId = raceId;
const ESM::Race *race = mWindowManager.getStore().races.search(mRaceId); const ESM::Race *race = MWBase::Environment::get().getWorld()->getStore().races.search(mRaceId);
if (race) if (race)
{ {
ToolTips::createRaceToolTip(mRaceWidget, race); ToolTips::createRaceToolTip(mRaceWidget, race);
@ -156,7 +159,7 @@ void ReviewDialog::setClass(const ESM::Class& class_)
void ReviewDialog::setBirthSign(const std::string& signId) void ReviewDialog::setBirthSign(const std::string& signId)
{ {
mBirthSignId = signId; mBirthSignId = signId;
const ESM::BirthSign *sign = mWindowManager.getStore().birthSigns.search(mBirthSignId); const ESM::BirthSign *sign = MWBase::Environment::get().getWorld()->getStore().birthSigns.search(mBirthSignId);
if (sign) if (sign)
{ {
mBirthSignWidget->setCaption(sign->name); mBirthSignWidget->setCaption(sign->name);

View file

@ -57,7 +57,7 @@ StatsWindow::StatsWindow (WindowManager& parWindowManager)
{ 0, 0 } { 0, 0 }
}; };
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
for (int i=0; names[i][0]; ++i) for (int i=0; names[i][0]; ++i)
{ {
setText (names[i][0], store.gameSettings.find (names[i][1])->str); setText (names[i][0], store.gameSettings.find (names[i][1])->str);
@ -383,12 +383,12 @@ void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId,
float modified = stat.getModified(); float modified = stat.getModified();
int progressPercent = (modified - float(static_cast<int>(modified))) * 100; int progressPercent = (modified - float(static_cast<int>(modified))) * 100;
const ESM::Skill* skill = mWindowManager.getStore().skills.search(skillId); const ESM::Skill* skill = MWBase::Environment::get().getWorld()->getStore().skills.search(skillId);
assert(skill); assert(skill);
std::string icon = "icons\\k\\" + ESM::Skill::sIconNames[skillId]; std::string icon = "icons\\k\\" + ESM::Skill::sIconNames[skillId];
const ESM::Attribute* attr = mWindowManager.getStore().attributes.search(skill->data.attribute); const ESM::Attribute* attr = MWBase::Environment::get().getWorld()->getStore().attributes.search(skill->data.attribute);
assert(attr); assert(attr);
std::string state = "normal"; std::string state = "normal";
@ -443,7 +443,7 @@ void StatsWindow::updateSkillArea()
if (!mMiscSkills.empty()) if (!mMiscSkills.empty())
addSkills(mMiscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2); addSkills(mMiscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2);
const ESMS::ESMStore &store = mWindowManager.getStore(); const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
// race tooltip // race tooltip
const ESM::Race* playerRace = store.races.find (MWBase::Environment::get().getWorld()->getPlayer().getRace()); const ESM::Race* playerRace = store.races.find (MWBase::Environment::get().getWorld()->getPlayer().getRace());
@ -485,8 +485,8 @@ void StatsWindow::updateSkillArea()
text += std::string("\n\n#DDC79E#{sNextRank} ") + faction->ranks[it->second+1]; text += std::string("\n\n#DDC79E#{sNextRank} ") + faction->ranks[it->second+1];
ESM::RankData rankData = faction->data.rankData[it->second+1]; ESM::RankData rankData = faction->data.rankData[it->second+1];
const ESM::Attribute* attr1 = mWindowManager.getStore().attributes.search(faction->data.attribute1); const ESM::Attribute* attr1 = MWBase::Environment::get().getWorld()->getStore().attributes.search(faction->data.attribute1);
const ESM::Attribute* attr2 = mWindowManager.getStore().attributes.search(faction->data.attribute2); const ESM::Attribute* attr2 = MWBase::Environment::get().getWorld()->getStore().attributes.search(faction->data.attribute2);
assert(attr1 && attr2); assert(attr1 && attr2);
text += "\n#BF9959#{" + attr1->name + "}: " + boost::lexical_cast<std::string>(rankData.attribute1) text += "\n#BF9959#{" + attr1->name + "}: " + boost::lexical_cast<std::string>(rankData.attribute1)
@ -496,7 +496,7 @@ void StatsWindow::updateSkillArea()
text += "\n#BF9959"; text += "\n#BF9959";
for (int i=0; i<6; ++i) for (int i=0; i<6; ++i)
{ {
const ESM::Skill* skill = mWindowManager.getStore().skills.search(faction->data.skillID[i]); const ESM::Skill* skill = MWBase::Environment::get().getWorld()->getStore().skills.search(faction->data.skillID[i]);
assert(skill); assert(skill);
text += "#{"+ESM::Skill::sSkillNameIds[faction->data.skillID[i]]+"}"; text += "#{"+ESM::Skill::sSkillNameIds[faction->data.skillID[i]]+"}";
if (i<5) if (i<5)

View file

@ -1,9 +1,14 @@
#include "widgets.hpp" #include "widgets.hpp"
#include "window_manager.hpp"
#include "components/esm_store/store.hpp"
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include "components/esm_store/store.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "window_manager.hpp"
#undef min #undef min
#undef max #undef max
@ -190,7 +195,7 @@ void MWAttribute::initialiseOverride()
assignWidget(mAttributeNameWidget, "StatName"); assignWidget(mAttributeNameWidget, "StatName");
assignWidget(mAttributeValueWidget, "StatValue"); assignWidget(mAttributeValueWidget, "StatValue");
MyGUI::ButtonPtr button; MyGUI::ButtonPtr button;
assignWidget(button, "StatNameButton"); assignWidget(button, "StatNameButton");
if (button) if (button)
@ -224,7 +229,7 @@ void MWSpell::setSpellId(const std::string &spellId)
void MWSpell::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, int flags) void MWSpell::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, int flags)
{ {
const ESMS::ESMStore &store = mWindowManager->getStore(); const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::Spell *spell = store.spells.search(mId); const ESM::Spell *spell = store.spells.search(mId);
MYGUI_ASSERT(spell, "spell with id '" << mId << "' not found"); MYGUI_ASSERT(spell, "spell with id '" << mId << "' not found");
@ -255,7 +260,7 @@ void MWSpell::updateWidgets()
{ {
if (mSpellNameWidget && mWindowManager) if (mSpellNameWidget && mWindowManager)
{ {
const ESMS::ESMStore &store = mWindowManager->getStore(); const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::Spell *spell = store.spells.search(mId); const ESM::Spell *spell = store.spells.search(mId);
if (spell) if (spell)
static_cast<MyGUI::TextBox*>(mSpellNameWidget)->setCaption(spell->name); static_cast<MyGUI::TextBox*>(mSpellNameWidget)->setCaption(spell->name);
@ -384,7 +389,7 @@ void MWSpellEffect::updateWidgets()
if (!mWindowManager) if (!mWindowManager)
return; return;
const ESMS::ESMStore &store = mWindowManager->getStore(); const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::MagicEffect *magicEffect = store.magicEffects.search(mEffectParams.mEffectID); const ESM::MagicEffect *magicEffect = store.magicEffects.search(mEffectParams.mEffectID);
if (!magicEffect) if (!magicEffect)
return; return;

View file

@ -497,11 +497,6 @@ void WindowManager::onFrame (float frameDuration)
mConsole->checkReferenceAvailable(); mConsole->checkReferenceAvailable();
} }
const ESMS::ESMStore& WindowManager::getStore() const
{
return MWBase::Environment::get().getWorld()->getStore();
}
void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell) void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell)
{ {
if (!(cell->cell->data.flags & ESM::Cell::Interior)) if (!(cell->cell->data.flags & ESM::Cell::Interior))

View file

@ -13,8 +13,8 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <components/esm_store/store.hpp>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
#include <components/esm/loadclas.hpp>
#include "../mwmechanics/stat.hpp" #include "../mwmechanics/stat.hpp"
@ -201,8 +201,6 @@ namespace MWGui
*/ */
const std::string &getGameSettingString(const std::string &id, const std::string &default_); const std::string &getGameSettingString(const std::string &id, const std::string &default_);
const ESMS::ESMStore& getStore() const;
void processChangedSettings(const Settings::CategorySettingVector& changed); void processChangedSettings(const Settings::CategorySettingVector& changed);
void executeInConsole (const std::string& path); void executeInConsole (const std::string& path);

View file

@ -4,6 +4,8 @@
#include <OgreMaterialManager.h> #include <OgreMaterialManager.h>
#include <OgreHardwarePixelBuffer.h> #include <OgreHardwarePixelBuffer.h>
#include <components/esm_store/store.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"

View file

@ -18,6 +18,7 @@
#include <extern/shiny/Platforms/Ogre/OgrePlatform.hpp> #include <extern/shiny/Platforms/Ogre/OgrePlatform.hpp>
#include <components/esm/loadstat.hpp> #include <components/esm/loadstat.hpp>
#include <components/esm_store/store.hpp>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
#include "../mwbase/world.hpp" // these includes can be removed once the static-hack is gone #include "../mwbase/world.hpp" // these includes can be removed once the static-hack is gone

View file

@ -5,6 +5,7 @@
#include <stdexcept> #include <stdexcept>
#include <components/interpreter/types.hpp> #include <components/interpreter/types.hpp>
#include <components/esm_store/store.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"

View file

@ -1,5 +1,7 @@
#include "scene.hpp" #include "scene.hpp"
#include <components/esm_store/store.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" /// FIXME #include "../mwbase/world.hpp" /// FIXME
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"