Merge remote-tracking branch 'scrawl/master'

This commit is contained in:
Marc Zinnschlag 2013-03-06 18:59:02 +01:00
commit 69eb5aa99a
2 changed files with 16 additions and 5 deletions

View file

@ -94,9 +94,6 @@ namespace MWGui
mPtr = actor;
clearSpells();
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
MWMechanics::Spells& playerSpells = MWWorld::Class::get (player).getCreatureStats (player).getSpells();
MWMechanics::Spells& merchantSpells = MWWorld::Class::get (actor).getCreatureStats (actor).getSpells();
for (MWMechanics::Spells::TIterator iter = merchantSpells.begin(); iter!=merchantSpells.end(); ++iter)
@ -107,8 +104,8 @@ namespace MWGui
if (spell->mData.mType!=ESM::Spell::ST_Spell)
continue; // don't try to sell diseases, curses or powers
if (std::find (playerSpells.begin(), playerSpells.end(), *iter)!=playerSpells.end())
continue; // we have that spell already
if (playerHasSpell(iter->first))
continue;
addSpell (iter->first);
}
@ -118,6 +115,18 @@ namespace MWGui
mSpellsView->setCanvasSize (MyGUI::IntSize(mSpellsView->getWidth(), std::max(mSpellsView->getHeight(), mCurrentY)));
}
bool SpellBuyingWindow::playerHasSpell(const std::string &id)
{
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
MWMechanics::Spells& playerSpells = MWWorld::Class::get (player).getCreatureStats (player).getSpells();
for (MWMechanics::Spells::TIterator it = playerSpells.begin(); it != playerSpells.end(); ++it)
{
if (Misc::StringUtils::ciEqual(id, it->first))
return true;
}
return false;
}
void SpellBuyingWindow::onSpellButtonClick(MyGUI::Widget* _sender)
{
int price = *_sender->getUserData<int>();

View file

@ -47,6 +47,8 @@ namespace MWGui
void updateLabels();
virtual void onReferenceUnavailable();
bool playerHasSpell (const std::string& id);
};
}