|
|
|
@ -15,6 +15,7 @@
|
|
|
|
|
|
|
|
|
|
#include "tooltips.hpp"
|
|
|
|
|
#include "widgets.hpp"
|
|
|
|
|
#include "class.hpp"
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
@ -31,6 +32,7 @@ namespace MWGui
|
|
|
|
|
|
|
|
|
|
EditEffectDialog::EditEffectDialog(MWBase::WindowManager &parWindowManager)
|
|
|
|
|
: WindowModal("openmw_edit_effect.layout", parWindowManager)
|
|
|
|
|
, mEditing(false)
|
|
|
|
|
{
|
|
|
|
|
getWidget(mCancelButton, "CancelButton");
|
|
|
|
|
getWidget(mOkButton, "OkButton");
|
|
|
|
@ -64,7 +66,27 @@ namespace MWGui
|
|
|
|
|
onRangeButtonClicked(mRangeButton);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EditEffectDialog::setEffect (const ESM::MagicEffect *effect)
|
|
|
|
|
void EditEffectDialog::newEffect (const ESM::MagicEffect *effect)
|
|
|
|
|
{
|
|
|
|
|
setMagicEffect(effect);
|
|
|
|
|
mEditing = false;
|
|
|
|
|
|
|
|
|
|
mDeleteButton->setVisible (false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EditEffectDialog::editEffect (ESM::ENAMstruct effect)
|
|
|
|
|
{
|
|
|
|
|
const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(effect.mEffectID);
|
|
|
|
|
|
|
|
|
|
setMagicEffect(magicEffect);
|
|
|
|
|
|
|
|
|
|
mEffect = effect;
|
|
|
|
|
mEditing = true;
|
|
|
|
|
|
|
|
|
|
mDeleteButton->setVisible (true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EditEffectDialog::setMagicEffect (const ESM::MagicEffect *effect)
|
|
|
|
|
{
|
|
|
|
|
std::string icon = effect->mIcon;
|
|
|
|
|
icon[icon.size()-3] = 'd';
|
|
|
|
@ -75,6 +97,8 @@ namespace MWGui
|
|
|
|
|
mEffectImage->setImageTexture (icon);
|
|
|
|
|
|
|
|
|
|
mEffectName->setCaptionWithReplacing("#{"+ESM::MagicEffect::effectIdToString (effect->mIndex)+"}");
|
|
|
|
|
|
|
|
|
|
mEffect.mEffectID = effect->mIndex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EditEffectDialog::onRangeButtonClicked (MyGUI::Widget* sender)
|
|
|
|
@ -94,12 +118,19 @@ namespace MWGui
|
|
|
|
|
|
|
|
|
|
void EditEffectDialog::onDeleteButtonClicked (MyGUI::Widget* sender)
|
|
|
|
|
{
|
|
|
|
|
setVisible(false);
|
|
|
|
|
|
|
|
|
|
eventEffectRemoved(mEffect);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EditEffectDialog::onOkButtonClicked (MyGUI::Widget* sender)
|
|
|
|
|
{
|
|
|
|
|
setVisible(false);
|
|
|
|
|
|
|
|
|
|
if (mEditing)
|
|
|
|
|
eventEffectModified(mEffect);
|
|
|
|
|
else
|
|
|
|
|
eventEffectAdded(mEffect);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EditEffectDialog::onCancelButtonClicked (MyGUI::Widget* sender)
|
|
|
|
@ -107,6 +138,16 @@ namespace MWGui
|
|
|
|
|
setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EditEffectDialog::setSkill (int skill)
|
|
|
|
|
{
|
|
|
|
|
mEffect.mSkill = skill;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EditEffectDialog::setAttribute (int attribute)
|
|
|
|
|
{
|
|
|
|
|
mEffect.mAttribute = attribute;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
SpellCreationDialog::SpellCreationDialog(MWBase::WindowManager &parWindowManager)
|
|
|
|
@ -130,6 +171,10 @@ namespace MWGui
|
|
|
|
|
mBuyButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onBuyButtonClicked);
|
|
|
|
|
|
|
|
|
|
mAvailableEffectsList->eventWidgetSelected += MyGUI::newDelegate(this, &SpellCreationDialog::onAvailableEffectClicked);
|
|
|
|
|
|
|
|
|
|
mAddEffectDialog.eventEffectAdded += MyGUI::newDelegate(this, &SpellCreationDialog::onEffectAdded);
|
|
|
|
|
mAddEffectDialog.eventEffectModified += MyGUI::newDelegate(this, &SpellCreationDialog::onEffectModified);
|
|
|
|
|
mAddEffectDialog.eventEffectRemoved += MyGUI::newDelegate(this, &SpellCreationDialog::onEffectRemoved);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -205,15 +250,131 @@ namespace MWGui
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SpellCreationDialog::onSelectAttribute ()
|
|
|
|
|
{
|
|
|
|
|
mAddEffectDialog.setVisible(true);
|
|
|
|
|
mAddEffectDialog.setAttribute (mSelectAttributeDialog->getAttributeId());
|
|
|
|
|
mWindowManager.removeDialog (mSelectAttributeDialog);
|
|
|
|
|
mSelectAttributeDialog = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SpellCreationDialog::onSelectSkill ()
|
|
|
|
|
{
|
|
|
|
|
mAddEffectDialog.setVisible(true);
|
|
|
|
|
mAddEffectDialog.setSkill (mSelectSkillDialog->getSkillId ());
|
|
|
|
|
mWindowManager.removeDialog (mSelectSkillDialog);
|
|
|
|
|
mSelectSkillDialog = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SpellCreationDialog::onAttributeOrSkillCancel ()
|
|
|
|
|
{
|
|
|
|
|
if (mSelectSkillDialog)
|
|
|
|
|
mWindowManager.removeDialog (mSelectSkillDialog);
|
|
|
|
|
if (mSelectAttributeDialog)
|
|
|
|
|
mWindowManager.removeDialog (mSelectAttributeDialog);
|
|
|
|
|
|
|
|
|
|
mSelectSkillDialog = 0;
|
|
|
|
|
mSelectAttributeDialog = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SpellCreationDialog::onAvailableEffectClicked (MyGUI::Widget* sender)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
short effectId = *sender->getUserData<short>();
|
|
|
|
|
const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(effectId);
|
|
|
|
|
|
|
|
|
|
mAddEffectDialog.newEffect (effect);
|
|
|
|
|
|
|
|
|
|
mAddEffectDialog.setVisible(true);
|
|
|
|
|
mAddEffectDialog.setEffect (effect);
|
|
|
|
|
if (effect->mData.mFlags & ESM::MagicEffect::TargetSkill)
|
|
|
|
|
{
|
|
|
|
|
delete mSelectSkillDialog;
|
|
|
|
|
mSelectSkillDialog = new SelectSkillDialog(mWindowManager);
|
|
|
|
|
mSelectSkillDialog->eventCancel += MyGUI::newDelegate(this, &SpellCreationDialog::onAttributeOrSkillCancel);
|
|
|
|
|
mSelectSkillDialog->eventItemSelected += MyGUI::newDelegate(this, &SpellCreationDialog::onSelectSkill);
|
|
|
|
|
mSelectSkillDialog->setVisible (true);
|
|
|
|
|
}
|
|
|
|
|
else if (effect->mData.mFlags & ESM::MagicEffect::TargetAttribute)
|
|
|
|
|
{
|
|
|
|
|
delete mSelectAttributeDialog;
|
|
|
|
|
mSelectAttributeDialog = new SelectAttributeDialog(mWindowManager);
|
|
|
|
|
mSelectAttributeDialog->eventCancel += MyGUI::newDelegate(this, &SpellCreationDialog::onAttributeOrSkillCancel);
|
|
|
|
|
mSelectAttributeDialog->eventItemSelected += MyGUI::newDelegate(this, &SpellCreationDialog::onSelectAttribute);
|
|
|
|
|
mSelectAttributeDialog->setVisible (true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
mAddEffectDialog.setVisible(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SpellCreationDialog::onEffectModified (ESM::ENAMstruct effect)
|
|
|
|
|
{
|
|
|
|
|
mEffects[mSelectedEffect] = effect;
|
|
|
|
|
|
|
|
|
|
updateEffectsView();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SpellCreationDialog::onEffectRemoved (ESM::ENAMstruct effect)
|
|
|
|
|
{
|
|
|
|
|
mEffects.erase(mEffects.begin() + mSelectedEffect);
|
|
|
|
|
updateEffectsView();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SpellCreationDialog::updateEffectsView ()
|
|
|
|
|
{
|
|
|
|
|
MyGUI::EnumeratorWidgetPtr oldWidgets = mUsedEffectsView->getEnumerator ();
|
|
|
|
|
MyGUI::Gui::getInstance ().destroyWidgets (oldWidgets);
|
|
|
|
|
|
|
|
|
|
MyGUI::IntSize size(0,0);
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
for (std::vector<ESM::ENAMstruct>::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it)
|
|
|
|
|
{
|
|
|
|
|
Widgets::SpellEffectParams params;
|
|
|
|
|
params.mEffectID = it->mEffectID;
|
|
|
|
|
params.mSkill = it->mSkill;
|
|
|
|
|
params.mAttribute = it->mAttribute;
|
|
|
|
|
params.mDuration = it->mDuration;
|
|
|
|
|
params.mMagnMin = it->mMagnMin;
|
|
|
|
|
params.mMagnMax = it->mMagnMax;
|
|
|
|
|
params.mRange = it->mRange;
|
|
|
|
|
|
|
|
|
|
MyGUI::Button* button = mUsedEffectsView->createWidget<MyGUI::Button>("", MyGUI::IntCoord(0, size.height, 0, 24), MyGUI::Align::Default);
|
|
|
|
|
button->setUserData(i);
|
|
|
|
|
button->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onEditEffect);
|
|
|
|
|
button->setNeedMouseFocus (true);
|
|
|
|
|
|
|
|
|
|
Widgets::MWSpellEffectPtr effect = button->createWidget<Widgets::MWSpellEffect>("MW_EffectImage", MyGUI::IntCoord(0,0,0,24), MyGUI::Align::Default);
|
|
|
|
|
|
|
|
|
|
effect->setNeedMouseFocus (false);
|
|
|
|
|
effect->setWindowManager (&mWindowManager);
|
|
|
|
|
effect->setSpellEffect (params);
|
|
|
|
|
|
|
|
|
|
effect->setSize(effect->getRequestedWidth (), 24);
|
|
|
|
|
button->setSize(effect->getRequestedWidth (), 24);
|
|
|
|
|
|
|
|
|
|
size.width = std::max(size.width, effect->getRequestedWidth ());
|
|
|
|
|
size.height += 24;
|
|
|
|
|
++i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mUsedEffectsView->setCanvasSize(size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SpellCreationDialog::onEffectAdded (ESM::ENAMstruct effect)
|
|
|
|
|
{
|
|
|
|
|
mEffects.push_back(effect);
|
|
|
|
|
|
|
|
|
|
updateEffectsView();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SpellCreationDialog::onEditEffect (MyGUI::Widget *sender)
|
|
|
|
|
{
|
|
|
|
|
int id = *sender->getUserData<int>();
|
|
|
|
|
|
|
|
|
|
mSelectedEffect = id;
|
|
|
|
|
|
|
|
|
|
mAddEffectDialog.editEffect (mEffects[id]);
|
|
|
|
|
mAddEffectDialog.setVisible (true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|