|
|
|
@ -102,52 +102,53 @@ namespace MWGui
|
|
|
|
|
updateSpells();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SpellWindow::onModelIndexSelected(SpellModel::ModelIndex index)
|
|
|
|
|
void SpellWindow::askDeleteSpell(const std::string &spellId)
|
|
|
|
|
{
|
|
|
|
|
const Spell& spell = mSpellView->getModel()->getItem(index);
|
|
|
|
|
if (spell.mType == Spell::Type_EnchantedItem)
|
|
|
|
|
// delete spell, if allowed
|
|
|
|
|
const ESM::Spell* spell =
|
|
|
|
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
|
|
|
|
|
|
|
|
|
|
if (spell->mData.mFlags & ESM::Spell::F_Always
|
|
|
|
|
|| spell->mData.mType == ESM::Spell::ST_Power)
|
|
|
|
|
{
|
|
|
|
|
onEnchantedItemSelected(spell.mItem, spell.mActive);
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sDeleteSpellError}");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
onSpellSelected(spell.mId);
|
|
|
|
|
// ask for confirmation
|
|
|
|
|
mSpellToDelete = spellId;
|
|
|
|
|
ConfirmationDialog* dialog = MWBase::Environment::get().getWindowManager()->getConfirmationDialog();
|
|
|
|
|
std::string question = MWBase::Environment::get().getWindowManager()->getGameSettingString("sQuestionDeleteSpell", "Delete %s?");
|
|
|
|
|
question = boost::str(boost::format(question) % spell->mName);
|
|
|
|
|
dialog->open(question);
|
|
|
|
|
dialog->eventOkClicked.clear();
|
|
|
|
|
dialog->eventOkClicked += MyGUI::newDelegate(this, &SpellWindow::onDeleteSpellAccept);
|
|
|
|
|
dialog->eventCancelClicked.clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SpellWindow::onSpellSelected(const std::string& spellId)
|
|
|
|
|
void SpellWindow::onModelIndexSelected(SpellModel::ModelIndex index)
|
|
|
|
|
{
|
|
|
|
|
if (MyGUI::InputManager::getInstance().isShiftPressed())
|
|
|
|
|
const Spell& spell = mSpellView->getModel()->getItem(index);
|
|
|
|
|
if (spell.mType == Spell::Type_EnchantedItem)
|
|
|
|
|
{
|
|
|
|
|
// delete spell, if allowed
|
|
|
|
|
const ESM::Spell* spell =
|
|
|
|
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
|
|
|
|
|
|
|
|
|
|
if (spell->mData.mFlags & ESM::Spell::F_Always
|
|
|
|
|
|| spell->mData.mType == ESM::Spell::ST_Power)
|
|
|
|
|
{
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sDeleteSpellError}");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// ask for confirmation
|
|
|
|
|
mSpellToDelete = spellId;
|
|
|
|
|
ConfirmationDialog* dialog = MWBase::Environment::get().getWindowManager()->getConfirmationDialog();
|
|
|
|
|
std::string question = MWBase::Environment::get().getWindowManager()->getGameSettingString("sQuestionDeleteSpell", "Delete %s?");
|
|
|
|
|
question = boost::str(boost::format(question) % spell->mName);
|
|
|
|
|
dialog->open(question);
|
|
|
|
|
dialog->eventOkClicked.clear();
|
|
|
|
|
dialog->eventOkClicked += MyGUI::newDelegate(this, &SpellWindow::onDeleteSpellAccept);
|
|
|
|
|
dialog->eventCancelClicked.clear();
|
|
|
|
|
}
|
|
|
|
|
onEnchantedItemSelected(spell.mItem, spell.mActive);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
|
|
|
|
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
|
|
|
|
|
store.setSelectedEnchantItem(store.end());
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->setSelectedSpell(spellId, int(MWMechanics::getSpellSuccessChance(spellId, player)));
|
|
|
|
|
if (MyGUI::InputManager::getInstance().isShiftPressed())
|
|
|
|
|
askDeleteSpell(spell.mId);
|
|
|
|
|
else
|
|
|
|
|
onSpellSelected(spell.mId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SpellWindow::onSpellSelected(const std::string& spellId)
|
|
|
|
|
{
|
|
|
|
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
|
|
|
|
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
|
|
|
|
|
store.setSelectedEnchantItem(store.end());
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->setSelectedSpell(spellId, int(MWMechanics::getSpellSuccessChance(spellId, player)));
|
|
|
|
|
|
|
|
|
|
updateSpells();
|
|
|
|
|
}
|
|
|
|
@ -184,6 +185,10 @@ namespace MWGui
|
|
|
|
|
return;
|
|
|
|
|
selected = (selected + itemcount) % itemcount;
|
|
|
|
|
|
|
|
|
|
onModelIndexSelected(selected);
|
|
|
|
|
const Spell& spell = mSpellView->getModel()->getItem(selected);
|
|
|
|
|
if (spell.mType == Spell::Type_EnchantedItem)
|
|
|
|
|
onEnchantedItemSelected(spell.mItem, spell.mActive);
|
|
|
|
|
else
|
|
|
|
|
onSpellSelected(spell.mId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|