mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 11:23:51 +00:00
Quick keys menu: make sure selected spell still exists
This commit is contained in:
parent
805843d7ff
commit
c548dcee13
3 changed files with 12 additions and 2 deletions
|
@ -301,6 +301,12 @@ namespace MWGui
|
||||||
if (type == Type_Magic)
|
if (type == Type_Magic)
|
||||||
{
|
{
|
||||||
std::string spellId = button->getChildAt(0)->getUserString("Spell");
|
std::string spellId = button->getChildAt(0)->getUserString("Spell");
|
||||||
|
|
||||||
|
// Make sure the player still has this spell
|
||||||
|
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
|
||||||
|
MWMechanics::Spells& spells = stats.getSpells();
|
||||||
|
if (!spells.hasSpell(spellId))
|
||||||
|
return;
|
||||||
store.setSelectedEnchantItem(store.end());
|
store.setSelectedEnchantItem(store.end());
|
||||||
MWBase::Environment::get().getWindowManager()->setSelectedSpell(spellId, int(MWMechanics::getSpellSuccessChance(spellId, player)));
|
MWBase::Environment::get().getWindowManager()->setSelectedSpell(spellId, int(MWMechanics::getSpellSuccessChance(spellId, player)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -583,8 +583,10 @@ bool CharacterController::updateNpcState(bool onground, bool inwater, bool isrun
|
||||||
// This has to be done at the start of the casting animation,
|
// This has to be done at the start of the casting animation,
|
||||||
// *not* when selecting a spell in the GUI (otherwise you could change the spell mid-animation)
|
// *not* when selecting a spell in the GUI (otherwise you could change the spell mid-animation)
|
||||||
if (mPtr.getRefData().getHandle() == "player")
|
if (mPtr.getRefData().getHandle() == "player")
|
||||||
stats.getSpells().setSelectedSpell(MWBase::Environment::get().getWindowManager()->getSelectedSpell());
|
{
|
||||||
|
std::string selectedSpell = MWBase::Environment::get().getWindowManager()->getSelectedSpell();
|
||||||
|
stats.getSpells().setSelectedSpell(selectedSpell);
|
||||||
|
}
|
||||||
std::string spellid = stats.getSpells().getSelectedSpell();
|
std::string spellid = stats.getSpells().getSelectedSpell();
|
||||||
|
|
||||||
if(!spellid.empty() && MWBase::Environment::get().getWorld()->startSpellCast(mPtr))
|
if(!spellid.empty() && MWBase::Environment::get().getWorld()->startSpellCast(mPtr))
|
||||||
|
|
|
@ -44,6 +44,8 @@ namespace MWMechanics
|
||||||
|
|
||||||
TIterator end() const;
|
TIterator end() const;
|
||||||
|
|
||||||
|
bool hasSpell(const std::string& spell) { return mSpells.find(Misc::StringUtils::lowerCase(spell)) != mSpells.end(); }
|
||||||
|
|
||||||
void add (const std::string& spell);
|
void add (const std::string& spell);
|
||||||
///< Adding a spell that is already listed in *this is a no-op.
|
///< Adding a spell that is already listed in *this is a no-op.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue