|
|
|
@ -86,61 +86,8 @@ namespace MWGui
|
|
|
|
|
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
|
|
|
|
MWMechanics::Spells& spells = stats.getSpells();
|
|
|
|
|
|
|
|
|
|
// the following code switches between selected enchanted item and selected spell (only one of these
|
|
|
|
|
// can be active at a time)
|
|
|
|
|
std::string selectedSpell = spells.getSelectedSpell();
|
|
|
|
|
MWWorld::Ptr selectedItem;
|
|
|
|
|
if (store.getSelectedEnchantItem() != store.end())
|
|
|
|
|
{
|
|
|
|
|
selectedSpell = "";
|
|
|
|
|
selectedItem = *store.getSelectedEnchantItem();
|
|
|
|
|
|
|
|
|
|
bool allowSelectedItem = true;
|
|
|
|
|
|
|
|
|
|
// make sure that the item is still in the player inventory, otherwise it can't be selected
|
|
|
|
|
bool found = false;
|
|
|
|
|
for (MWWorld::ContainerStoreIterator it(store.begin()); it != store.end(); ++it)
|
|
|
|
|
{
|
|
|
|
|
if (*it == selectedItem)
|
|
|
|
|
found = true;
|
|
|
|
|
}
|
|
|
|
|
if (!found)
|
|
|
|
|
allowSelectedItem = false;
|
|
|
|
|
|
|
|
|
|
// if the selected item can be equipped, make sure that it actually is equipped
|
|
|
|
|
std::pair<std::vector<int>, bool> slots_;
|
|
|
|
|
slots_ = MWWorld::Class::get(selectedItem).getEquipmentSlots(selectedItem);
|
|
|
|
|
if (!slots_.first.empty())
|
|
|
|
|
{
|
|
|
|
|
bool equipped = false;
|
|
|
|
|
for (int i=0; i < MWWorld::InventoryStore::Slots; ++i)
|
|
|
|
|
{
|
|
|
|
|
if (store.getSlot(i) != store.end() && *store.getSlot(i) == selectedItem)
|
|
|
|
|
{
|
|
|
|
|
equipped = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!equipped)
|
|
|
|
|
allowSelectedItem = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!allowSelectedItem)
|
|
|
|
|
{
|
|
|
|
|
store.setSelectedEnchantItem(store.end());
|
|
|
|
|
spells.setSelectedSpell("");
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->unsetSelectedSpell();
|
|
|
|
|
selectedItem = MWWorld::Ptr();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (MWMechanics::Spells::TIterator it = spells.begin(); it != spells.end(); ++it)
|
|
|
|
|
{
|
|
|
|
|
spellList.push_back (it->first);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const MWWorld::ESMStore &esmStore =
|
|
|
|
|
MWBase::Environment::get().getWorld()->getStore();
|
|
|
|
@ -210,7 +157,7 @@ namespace MWGui
|
|
|
|
|
t->eventMouseWheel += MyGUI::newDelegate(this, &SpellWindow::onMouseWheel);
|
|
|
|
|
t->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellWindow::onSpellSelected);
|
|
|
|
|
|
|
|
|
|
if (*it == selectedSpell)
|
|
|
|
|
if (*it == MWBase::Environment::get().getWindowManager()->getSelectedSpell())
|
|
|
|
|
t->setStateSelected(true);
|
|
|
|
|
|
|
|
|
|
mHeight += spellHeight;
|
|
|
|
@ -229,7 +176,7 @@ namespace MWGui
|
|
|
|
|
t->setUserString("Spell", *it);
|
|
|
|
|
t->eventMouseWheel += MyGUI::newDelegate(this, &SpellWindow::onMouseWheel);
|
|
|
|
|
t->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellWindow::onSpellSelected);
|
|
|
|
|
t->setStateSelected(*it == selectedSpell);
|
|
|
|
|
t->setStateSelected(*it == MWBase::Environment::get().getWindowManager()->getSelectedSpell());
|
|
|
|
|
|
|
|
|
|
// cost / success chance
|
|
|
|
|
MyGUI::Button* costChance = mSpellView->createWidget<MyGUI::Button>("SpellText",
|
|
|
|
@ -239,7 +186,7 @@ namespace MWGui
|
|
|
|
|
costChance->setCaption(cost + "/" + chance);
|
|
|
|
|
costChance->setTextAlign(MyGUI::Align::Right);
|
|
|
|
|
costChance->setNeedMouseFocus(false);
|
|
|
|
|
costChance->setStateSelected(*it == selectedSpell);
|
|
|
|
|
costChance->setStateSelected(*it == MWBase::Environment::get().getWindowManager()->getSelectedSpell());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mHeight += spellHeight;
|
|
|
|
@ -276,7 +223,9 @@ namespace MWGui
|
|
|
|
|
t->setUserString("Equipped", equipped ? "true" : "false");
|
|
|
|
|
t->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellWindow::onEnchantedItemSelected);
|
|
|
|
|
t->eventMouseWheel += MyGUI::newDelegate(this, &SpellWindow::onMouseWheel);
|
|
|
|
|
t->setStateSelected(item == selectedItem);
|
|
|
|
|
if (store.getSelectedEnchantItem() != store.end())
|
|
|
|
|
t->setStateSelected(item == *store.getSelectedEnchantItem());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// cost / charge
|
|
|
|
|
MyGUI::Button* costCharge = mSpellView->createWidget<MyGUI::Button>(equipped ? "SpellText" : "SpellTextUnequipped",
|
|
|
|
@ -302,7 +251,8 @@ namespace MWGui
|
|
|
|
|
costCharge->setCaption(cost + "/" + charge);
|
|
|
|
|
costCharge->setTextAlign(MyGUI::Align::Right);
|
|
|
|
|
costCharge->setNeedMouseFocus(false);
|
|
|
|
|
costCharge->setStateSelected(item == selectedItem);
|
|
|
|
|
if (store.getSelectedEnchantItem() != store.end())
|
|
|
|
|
costCharge->setStateSelected(item == *store.getSelectedEnchantItem());
|
|
|
|
|
|
|
|
|
|
mHeight += spellHeight;
|
|
|
|
|
}
|
|
|
|
@ -349,9 +299,7 @@ namespace MWGui
|
|
|
|
|
void SpellWindow::onEnchantedItemSelected(MyGUI::Widget* _sender)
|
|
|
|
|
{
|
|
|
|
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
|
|
|
|
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
|
|
|
|
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
|
|
|
|
|
MWMechanics::Spells& spells = stats.getSpells();
|
|
|
|
|
MWWorld::Ptr item = *_sender->getUserData<MWWorld::Ptr>();
|
|
|
|
|
|
|
|
|
|
// retrieve ContainerStoreIterator to the item
|
|
|
|
@ -379,7 +327,6 @@ namespace MWGui
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
store.setSelectedEnchantItem(it);
|
|
|
|
|
spells.setSelectedSpell("");
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->setSelectedEnchantItem(item);
|
|
|
|
|
|
|
|
|
|
updateSpells();
|
|
|
|
@ -389,9 +336,7 @@ namespace MWGui
|
|
|
|
|
{
|
|
|
|
|
std::string spellId = _sender->getUserString("Spell");
|
|
|
|
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
|
|
|
|
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
|
|
|
|
MWWorld::InventoryStore& store = MWWorld::Class::get(player).getInventoryStore(player);
|
|
|
|
|
MWMechanics::Spells& spells = stats.getSpells();
|
|
|
|
|
|
|
|
|
|
if (MyGUI::InputManager::getInstance().isShiftPressed())
|
|
|
|
|
{
|
|
|
|
@ -419,7 +364,6 @@ namespace MWGui
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
spells.setSelectedSpell(spellId);
|
|
|
|
|
store.setSelectedEnchantItem(store.end());
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->setSelectedSpell(spellId, int(MWMechanics::getSpellSuccessChance(spellId, player)));
|
|
|
|
|
}
|
|
|
|
@ -450,10 +394,7 @@ namespace MWGui
|
|
|
|
|
MWMechanics::Spells& spells = stats.getSpells();
|
|
|
|
|
|
|
|
|
|
if (spells.getSelectedSpell() == mSpellToDelete)
|
|
|
|
|
{
|
|
|
|
|
spells.setSelectedSpell("");
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->unsetSelectedSpell();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
spells.remove(mSpellToDelete);
|
|
|
|
|
|
|
|
|
|