mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 12:35:46 +00:00
Don't prompt for spell deletion when using cycling keys (Fixes #2382)
This commit is contained in:
parent
4c5bba2947
commit
6d62aa7544
@ -102,6 +102,31 @@ namespace MWGui
|
|||||||
updateSpells();
|
updateSpells();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SpellWindow::askDeleteSpell(const std::string &spellId)
|
||||||
|
{
|
||||||
|
// 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SpellWindow::onModelIndexSelected(SpellModel::ModelIndex index)
|
void SpellWindow::onModelIndexSelected(SpellModel::ModelIndex index)
|
||||||
{
|
{
|
||||||
const Spell& spell = mSpellView->getModel()->getItem(index);
|
const Spell& spell = mSpellView->getModel()->getItem(index);
|
||||||
@ -111,43 +136,19 @@ namespace MWGui
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
onSpellSelected(spell.mId);
|
if (MyGUI::InputManager::getInstance().isShiftPressed())
|
||||||
|
askDeleteSpell(spell.mId);
|
||||||
|
else
|
||||||
|
onSpellSelected(spell.mId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpellWindow::onSpellSelected(const std::string& spellId)
|
void SpellWindow::onSpellSelected(const std::string& spellId)
|
||||||
{
|
{
|
||||||
if (MyGUI::InputManager::getInstance().isShiftPressed())
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
{
|
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
|
||||||
// delete spell, if allowed
|
store.setSelectedEnchantItem(store.end());
|
||||||
const ESM::Spell* spell =
|
MWBase::Environment::get().getWindowManager()->setSelectedSpell(spellId, int(MWMechanics::getSpellSuccessChance(spellId, player)));
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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)));
|
|
||||||
}
|
|
||||||
|
|
||||||
updateSpells();
|
updateSpells();
|
||||||
}
|
}
|
||||||
@ -184,6 +185,10 @@ namespace MWGui
|
|||||||
return;
|
return;
|
||||||
selected = (selected + itemcount) % itemcount;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ namespace MWGui
|
|||||||
void onSpellSelected(const std::string& spellId);
|
void onSpellSelected(const std::string& spellId);
|
||||||
void onModelIndexSelected(SpellModel::ModelIndex index);
|
void onModelIndexSelected(SpellModel::ModelIndex index);
|
||||||
void onDeleteSpellAccept();
|
void onDeleteSpellAccept();
|
||||||
|
void askDeleteSpell(const std::string& spellId);
|
||||||
|
|
||||||
virtual void onPinToggled();
|
virtual void onPinToggled();
|
||||||
virtual void onTitleDoubleClicked();
|
virtual void onTitleDoubleClicked();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user