|
|
|
@ -1,7 +1,9 @@
|
|
|
|
|
#include "spellwindow.hpp"
|
|
|
|
|
|
|
|
|
|
#include <MyGUI_Button.h>
|
|
|
|
|
#include <MyGUI_EditBox.h>
|
|
|
|
|
#include <MyGUI_InputManager.h>
|
|
|
|
|
#include <MyGUI_Window.h>
|
|
|
|
|
|
|
|
|
|
#include <components/misc/stringops.hpp>
|
|
|
|
|
#include <components/settings/settings.hpp>
|
|
|
|
@ -36,6 +38,9 @@ namespace MWGui
|
|
|
|
|
{
|
|
|
|
|
mSpellIcons = new SpellIcons();
|
|
|
|
|
|
|
|
|
|
MyGUI::Widget* deleteButton;
|
|
|
|
|
getWidget(deleteButton, "DeleteSpellButton");
|
|
|
|
|
|
|
|
|
|
getWidget(mSpellView, "SpellView");
|
|
|
|
|
getWidget(mEffectBox, "EffectsBox");
|
|
|
|
|
getWidget(mFilterEdit, "FilterEdit");
|
|
|
|
@ -44,8 +49,13 @@ namespace MWGui
|
|
|
|
|
|
|
|
|
|
mSpellView->eventSpellClicked += MyGUI::newDelegate(this, &SpellWindow::onModelIndexSelected);
|
|
|
|
|
mFilterEdit->eventEditTextChange += MyGUI::newDelegate(this, &SpellWindow::onFilterChanged);
|
|
|
|
|
deleteButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellWindow::onDeleteClicked);
|
|
|
|
|
|
|
|
|
|
setCoord(498, 300, 302, 300);
|
|
|
|
|
|
|
|
|
|
// Adjust the spell filtering widget size because of MyGUI limitations.
|
|
|
|
|
int filterWidth = mSpellView->getSize().width - deleteButton->getSize().width - 3;
|
|
|
|
|
mFilterEdit->setSize(filterWidth, mFilterEdit->getSize().height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SpellWindow::~SpellWindow()
|
|
|
|
@ -187,6 +197,17 @@ namespace MWGui
|
|
|
|
|
mSpellView->setModel(new SpellModel(MWMechanics::getPlayer(), sender->getCaption()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SpellWindow::onDeleteClicked(MyGUI::Widget *widget)
|
|
|
|
|
{
|
|
|
|
|
SpellModel::ModelIndex selected = mSpellView->getModel()->getSelectedIndex();
|
|
|
|
|
if (selected < 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const Spell& spell = mSpellView->getModel()->getItem(selected);
|
|
|
|
|
if (spell.mType != Spell::Type_EnchantedItem)
|
|
|
|
|
askDeleteSpell(spell.mId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SpellWindow::onSpellSelected(const std::string& spellId)
|
|
|
|
|
{
|
|
|
|
|
MWWorld::Ptr player = MWMechanics::getPlayer();
|
|
|
|
@ -224,12 +245,9 @@ namespace MWGui
|
|
|
|
|
|
|
|
|
|
mSpellView->setModel(new SpellModel(MWMechanics::getPlayer(), ""));
|
|
|
|
|
|
|
|
|
|
SpellModel::ModelIndex selected = 0;
|
|
|
|
|
for (SpellModel::ModelIndex i = 0; i<int(mSpellView->getModel()->getItemCount()); ++i)
|
|
|
|
|
{
|
|
|
|
|
if (mSpellView->getModel()->getItem(i).mSelected)
|
|
|
|
|
selected = i;
|
|
|
|
|
}
|
|
|
|
|
SpellModel::ModelIndex selected = mSpellView->getModel()->getSelectedIndex();
|
|
|
|
|
if (selected < 0)
|
|
|
|
|
selected = 0;
|
|
|
|
|
|
|
|
|
|
selected += next ? 1 : -1;
|
|
|
|
|
int itemcount = mSpellView->getModel()->getItemCount();
|
|
|
|
|