forked from mirror/openmw-tes3mp
Merge remote-tracking branch 'scrawl/spellcreation'
commit
e05e683da3
@ -0,0 +1,43 @@
|
||||
#include "enchantingdialog.hpp"
|
||||
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
|
||||
EnchantingDialog::EnchantingDialog(MWBase::WindowManager &parWindowManager)
|
||||
: WindowBase("openmw_enchanting_dialog.layout", parWindowManager)
|
||||
, EffectEditorBase(parWindowManager)
|
||||
{
|
||||
getWidget(mCancelButton, "CancelButton");
|
||||
getWidget(mAvailableEffectsList, "AvailableEffects");
|
||||
getWidget(mUsedEffectsView, "UsedEffects");
|
||||
|
||||
setWidgets(mAvailableEffectsList, mUsedEffectsView);
|
||||
|
||||
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EnchantingDialog::onCancelButtonClicked);
|
||||
}
|
||||
|
||||
void EnchantingDialog::open()
|
||||
{
|
||||
center();
|
||||
}
|
||||
|
||||
void EnchantingDialog::startEnchanting (MWWorld::Ptr actor)
|
||||
{
|
||||
mPtr = actor;
|
||||
|
||||
startEditing ();
|
||||
}
|
||||
|
||||
void EnchantingDialog::onReferenceUnavailable ()
|
||||
{
|
||||
mWindowManager.removeGuiMode (GM_Dialogue);
|
||||
mWindowManager.removeGuiMode (GM_Enchanting);
|
||||
}
|
||||
|
||||
void EnchantingDialog::onCancelButtonClicked(MyGUI::Widget* sender)
|
||||
{
|
||||
mWindowManager.removeGuiMode (GM_Enchanting);
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
#ifndef MWGUI_ENCHANTINGDIALOG_H
|
||||
#define MWGUI_ENCHANTINGDIALOG_H
|
||||
|
||||
#include "window_base.hpp"
|
||||
#include "referenceinterface.hpp"
|
||||
#include "spellcreationdialog.hpp"
|
||||
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
class EnchantingDialog : public WindowBase, public ReferenceInterface, public EffectEditorBase
|
||||
{
|
||||
public:
|
||||
EnchantingDialog(MWBase::WindowManager& parWindowManager);
|
||||
|
||||
virtual void open();
|
||||
void startEnchanting(MWWorld::Ptr actor);
|
||||
|
||||
protected:
|
||||
virtual void onReferenceUnavailable();
|
||||
|
||||
void onCancelButtonClicked(MyGUI::Widget* sender);
|
||||
|
||||
MyGUI::Button* mCancelButton;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,513 @@
|
||||
#include "spellcreationdialog.hpp"
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <components/esm_store/store.hpp>
|
||||
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/environment.hpp"
|
||||
|
||||
#include "../mwworld/player.hpp"
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
#include "../mwmechanics/spells.hpp"
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
#include "tooltips.hpp"
|
||||
#include "widgets.hpp"
|
||||
#include "class.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
bool sortMagicEffects (short id1, short id2)
|
||||
{
|
||||
return MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find(ESM::MagicEffect::effectIdToString (id1))->getString()
|
||||
< MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find(ESM::MagicEffect::effectIdToString (id2))->getString();
|
||||
}
|
||||
}
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
EditEffectDialog::EditEffectDialog(MWBase::WindowManager &parWindowManager)
|
||||
: WindowModal("openmw_edit_effect.layout", parWindowManager)
|
||||
, mEditing(false)
|
||||
{
|
||||
getWidget(mCancelButton, "CancelButton");
|
||||
getWidget(mOkButton, "OkButton");
|
||||
getWidget(mDeleteButton, "DeleteButton");
|
||||
getWidget(mRangeButton, "RangeButton");
|
||||
getWidget(mMagnitudeMinValue, "MagnitudeMinValue");
|
||||
getWidget(mMagnitudeMaxValue, "MagnitudeMaxValue");
|
||||
getWidget(mDurationValue, "DurationValue");
|
||||
getWidget(mAreaValue, "AreaValue");
|
||||
getWidget(mMagnitudeMinSlider, "MagnitudeMinSlider");
|
||||
getWidget(mMagnitudeMaxSlider, "MagnitudeMaxSlider");
|
||||
getWidget(mDurationSlider, "DurationSlider");
|
||||
getWidget(mAreaSlider, "AreaSlider");
|
||||
getWidget(mEffectImage, "EffectImage");
|
||||
getWidget(mEffectName, "EffectName");
|
||||
getWidget(mAreaText, "AreaText");
|
||||
getWidget(mDurationBox, "DurationBox");
|
||||
getWidget(mAreaBox, "AreaBox");
|
||||
getWidget(mMagnitudeBox, "MagnitudeBox");
|
||||
|
||||
mRangeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EditEffectDialog::onRangeButtonClicked);
|
||||
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EditEffectDialog::onOkButtonClicked);
|
||||
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EditEffectDialog::onCancelButtonClicked);
|
||||
mDeleteButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EditEffectDialog::onDeleteButtonClicked);
|
||||
|
||||
mMagnitudeMinSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &EditEffectDialog::onMagnitudeMinChanged);
|
||||
mMagnitudeMaxSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &EditEffectDialog::onMagnitudeMaxChanged);
|
||||
mDurationSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &EditEffectDialog::onDurationChanged);
|
||||
mAreaSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &EditEffectDialog::onAreaChanged);
|
||||
}
|
||||
|
||||
void EditEffectDialog::open()
|
||||
{
|
||||
WindowModal::open();
|
||||
center();
|
||||
}
|
||||
|
||||
void EditEffectDialog::newEffect (const ESM::MagicEffect *effect)
|
||||
{
|
||||
setMagicEffect(effect);
|
||||
mEditing = false;
|
||||
|
||||
mDeleteButton->setVisible (false);
|
||||
|
||||
mEffect.mRange = ESM::RT_Self;
|
||||
|
||||
onRangeButtonClicked(mRangeButton);
|
||||
|
||||
mMagnitudeMinSlider->setScrollPosition (0);
|
||||
mMagnitudeMaxSlider->setScrollPosition (0);
|
||||
mAreaSlider->setScrollPosition (0);
|
||||
mDurationSlider->setScrollPosition (0);
|
||||
|
||||
mDurationValue->setCaption("1");
|
||||
mMagnitudeMinValue->setCaption("1");
|
||||
mMagnitudeMaxValue->setCaption("- 1");
|
||||
mAreaValue->setCaption("0");
|
||||
|
||||
mEffect.mMagnMin = 1;
|
||||
mEffect.mMagnMax = 1;
|
||||
mEffect.mDuration = 1;
|
||||
mEffect.mArea = 0;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
mMagnitudeMinSlider->setScrollPosition (effect.mMagnMin-1);
|
||||
mMagnitudeMaxSlider->setScrollPosition (effect.mMagnMax-1);
|
||||
mAreaSlider->setScrollPosition (effect.mArea);
|
||||
mDurationSlider->setScrollPosition (effect.mDuration-1);
|
||||
|
||||
onMagnitudeMinChanged (mMagnitudeMinSlider, effect.mMagnMin-1);
|
||||
onMagnitudeMaxChanged (mMagnitudeMinSlider, effect.mMagnMax-1);
|
||||
onAreaChanged (mAreaSlider, effect.mArea);
|
||||
onDurationChanged (mDurationSlider, effect.mDuration-1);
|
||||
}
|
||||
|
||||
void EditEffectDialog::setMagicEffect (const ESM::MagicEffect *effect)
|
||||
{
|
||||
std::string icon = effect->mIcon;
|
||||
icon[icon.size()-3] = 'd';
|
||||
icon[icon.size()-2] = 'd';
|
||||
icon[icon.size()-1] = 's';
|
||||
icon = "icons\\" + icon;
|
||||
|
||||
mEffectImage->setImageTexture (icon);
|
||||
|
||||
mEffectName->setCaptionWithReplacing("#{"+ESM::MagicEffect::effectIdToString (effect->mIndex)+"}");
|
||||
|
||||
mEffect.mEffectID = effect->mIndex;
|
||||
|
||||
mMagicEffect = effect;
|
||||
|
||||
updateBoxes();
|
||||
}
|
||||
|
||||
void EditEffectDialog::updateBoxes()
|
||||
{
|
||||
static int startY = mMagnitudeBox->getPosition().top;
|
||||
int curY = startY;
|
||||
|
||||
mMagnitudeBox->setVisible (false);
|
||||
mDurationBox->setVisible (false);
|
||||
mAreaBox->setVisible (false);
|
||||
|
||||
if (!(mMagicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude))
|
||||
{
|
||||
mMagnitudeBox->setPosition(mMagnitudeBox->getPosition().left, curY);
|
||||
mMagnitudeBox->setVisible (true);
|
||||
curY += mMagnitudeBox->getSize().height;
|
||||
}
|
||||
if (!(mMagicEffect->mData.mFlags & ESM::MagicEffect::NoDuration))
|
||||
{
|
||||
mDurationBox->setPosition(mDurationBox->getPosition().left, curY);
|
||||
mDurationBox->setVisible (true);
|
||||
curY += mDurationBox->getSize().height;
|
||||
}
|
||||
if (mEffect.mRange == ESM::RT_Target)
|
||||
{
|
||||
mAreaBox->setPosition(mAreaBox->getPosition().left, curY);
|
||||
mAreaBox->setVisible (true);
|
||||
curY += mAreaBox->getSize().height;
|
||||
}
|
||||
}
|
||||
|
||||
void EditEffectDialog::onRangeButtonClicked (MyGUI::Widget* sender)
|
||||
{
|
||||
mEffect.mRange = (mEffect.mRange+1)%3;
|
||||
|
||||
if (mEffect.mRange == ESM::RT_Self)
|
||||
mRangeButton->setCaptionWithReplacing ("#{sRangeSelf}");
|
||||
else if (mEffect.mRange == ESM::RT_Target)
|
||||
mRangeButton->setCaptionWithReplacing ("#{sRangeTarget}");
|
||||
else if (mEffect.mRange == ESM::RT_Touch)
|
||||
mRangeButton->setCaptionWithReplacing ("#{sRangeTouch}");
|
||||
|
||||
mAreaSlider->setVisible (mEffect.mRange != ESM::RT_Self);
|
||||
mAreaText->setVisible (mEffect.mRange != ESM::RT_Self);
|
||||
|
||||
// cycle through range types until we find something that's allowed
|
||||
if (mEffect.mRange == ESM::RT_Target && !(mMagicEffect->mData.mFlags & ESM::MagicEffect::CastTarget))
|
||||
onRangeButtonClicked(sender);
|
||||
if (mEffect.mRange == ESM::RT_Self && !(mMagicEffect->mData.mFlags & ESM::MagicEffect::CastSelf))
|
||||
onRangeButtonClicked(sender);
|
||||
if (mEffect.mRange == ESM::RT_Touch && !(mMagicEffect->mData.mFlags & ESM::MagicEffect::CastTouch))
|
||||
onRangeButtonClicked(sender);
|
||||
|
||||
updateBoxes();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
void EditEffectDialog::setSkill (int skill)
|
||||
{
|
||||
mEffect.mSkill = skill;
|
||||
}
|
||||
|
||||
void EditEffectDialog::setAttribute (int attribute)
|
||||
{
|
||||
mEffect.mAttribute = attribute;
|
||||
}
|
||||
|
||||
void EditEffectDialog::onMagnitudeMinChanged (MyGUI::ScrollBar* sender, size_t pos)
|
||||
{
|
||||
mMagnitudeMinValue->setCaption(boost::lexical_cast<std::string>(pos+1));
|
||||
mEffect.mMagnMin = pos+1;
|
||||
|
||||
// trigger the check again (see below)
|
||||
onMagnitudeMaxChanged(mMagnitudeMaxSlider, mMagnitudeMaxSlider->getScrollPosition ());
|
||||
}
|
||||
|
||||
void EditEffectDialog::onMagnitudeMaxChanged (MyGUI::ScrollBar* sender, size_t pos)
|
||||
{
|
||||
// make sure the max value is actually larger or equal than the min value
|
||||
size_t magnMin = std::abs(mEffect.mMagnMin); // should never be < 0, this is just here to avoid the compiler warning
|
||||
if (pos+1 < magnMin)
|
||||
{
|
||||
pos = mEffect.mMagnMin-1;
|
||||
sender->setScrollPosition (pos);
|
||||
}
|
||||
|
||||
mEffect.mMagnMax = pos+1;
|
||||
|
||||
mMagnitudeMaxValue->setCaption("- " + boost::lexical_cast<std::string>(pos+1));
|
||||
}
|
||||
|
||||
void EditEffectDialog::onDurationChanged (MyGUI::ScrollBar* sender, size_t pos)
|
||||
{
|
||||
mDurationValue->setCaption(boost::lexical_cast<std::string>(pos+1));
|
||||
mEffect.mDuration = pos+1;
|
||||
}
|
||||
|
||||
void EditEffectDialog::onAreaChanged (MyGUI::ScrollBar* sender, size_t pos)
|
||||
{
|
||||
mAreaValue->setCaption(boost::lexical_cast<std::string>(pos));
|
||||
mEffect.mArea = pos;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
SpellCreationDialog::SpellCreationDialog(MWBase::WindowManager &parWindowManager)
|
||||
: WindowBase("openmw_spellcreation_dialog.layout", parWindowManager)
|
||||
, EffectEditorBase(parWindowManager)
|
||||
{
|
||||
getWidget(mNameEdit, "NameEdit");
|
||||
getWidget(mMagickaCost, "MagickaCost");
|
||||
getWidget(mSuccessChance, "SuccessChance");
|
||||
getWidget(mAvailableEffectsList, "AvailableEffects");
|
||||
getWidget(mUsedEffectsView, "UsedEffects");
|
||||
getWidget(mPriceLabel, "PriceLabel");
|
||||
getWidget(mBuyButton, "BuyButton");
|
||||
getWidget(mCancelButton, "CancelButton");
|
||||
|
||||
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onCancelButtonClicked);
|
||||
mBuyButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onBuyButtonClicked);
|
||||
|
||||
setWidgets(mAvailableEffectsList, mUsedEffectsView);
|
||||
}
|
||||
|
||||
void SpellCreationDialog::startSpellMaking (MWWorld::Ptr actor)
|
||||
{
|
||||
mPtr = actor;
|
||||
|
||||
startEditing();
|
||||
}
|
||||
|
||||
void SpellCreationDialog::onCancelButtonClicked (MyGUI::Widget* sender)
|
||||
{
|
||||
mWindowManager.removeGuiMode (MWGui::GM_SpellCreation);
|
||||
}
|
||||
|
||||
void SpellCreationDialog::onBuyButtonClicked (MyGUI::Widget* sender)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SpellCreationDialog::open()
|
||||
{
|
||||
center();
|
||||
}
|
||||
|
||||
void SpellCreationDialog::onReferenceUnavailable ()
|
||||
{
|
||||
mWindowManager.removeGuiMode (GM_Dialogue);
|
||||
mWindowManager.removeGuiMode (GM_SpellCreation);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
EffectEditorBase::EffectEditorBase(MWBase::WindowManager& parWindowManager)
|
||||
: mAddEffectDialog(parWindowManager)
|
||||
, mSelectAttributeDialog(NULL)
|
||||
, mSelectSkillDialog(NULL)
|
||||
{
|
||||
mAddEffectDialog.eventEffectAdded += MyGUI::newDelegate(this, &EffectEditorBase::onEffectAdded);
|
||||
mAddEffectDialog.eventEffectModified += MyGUI::newDelegate(this, &EffectEditorBase::onEffectModified);
|
||||
mAddEffectDialog.eventEffectRemoved += MyGUI::newDelegate(this, &EffectEditorBase::onEffectRemoved);
|
||||
|
||||
mAddEffectDialog.setVisible (false);
|
||||
}
|
||||
|
||||
void EffectEditorBase::startEditing ()
|
||||
{
|
||||
// get the list of magic effects that are known to the player
|
||||
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
||||
MWMechanics::Spells& spells = stats.getSpells();
|
||||
|
||||
std::vector<short> knownEffects;
|
||||
|
||||
for (MWMechanics::Spells::TIterator it = spells.begin(); it != spells.end(); ++it)
|
||||
{
|
||||
const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it);
|
||||
|
||||
// only normal spells count
|
||||
if (spell->mData.mType != ESM::Spell::ST_Spell)
|
||||
continue;
|
||||
|
||||
const std::vector<ESM::ENAMstruct>& list = spell->mEffects.mList;
|
||||
for (std::vector<ESM::ENAMstruct>::const_iterator it2 = list.begin(); it2 != list.end(); ++it2)
|
||||
{
|
||||
if (std::find(knownEffects.begin(), knownEffects.end(), it2->mEffectID) == knownEffects.end())
|
||||
knownEffects.push_back(it2->mEffectID);
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(knownEffects.begin(), knownEffects.end(), sortMagicEffects);
|
||||
|
||||
mAvailableEffectsList->clear ();
|
||||
|
||||
for (std::vector<short>::const_iterator it = knownEffects.begin(); it != knownEffects.end(); ++it)
|
||||
{
|
||||
mAvailableEffectsList->addItem(MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find(
|
||||
ESM::MagicEffect::effectIdToString (*it))->getString());
|
||||
}
|
||||
mAvailableEffectsList->adjustSize ();
|
||||
|
||||
for (std::vector<short>::const_iterator it = knownEffects.begin(); it != knownEffects.end(); ++it)
|
||||
{
|
||||
std::string name = MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find(
|
||||
ESM::MagicEffect::effectIdToString (*it))->getString();
|
||||
MyGUI::Widget* w = mAvailableEffectsList->getItemWidget(name);
|
||||
w->setUserData(*it);
|
||||
|
||||
ToolTips::createMagicEffectToolTip (w, *it);
|
||||
}
|
||||
}
|
||||
|
||||
void EffectEditorBase::setWidgets (Widgets::MWList *availableEffectsList, MyGUI::ScrollView *usedEffectsView)
|
||||
{
|
||||
mAvailableEffectsList = availableEffectsList;
|
||||
mUsedEffectsView = usedEffectsView;
|
||||
|
||||
mAvailableEffectsList->eventWidgetSelected += MyGUI::newDelegate(this, &EffectEditorBase::onAvailableEffectClicked);
|
||||
}
|
||||
|
||||
void EffectEditorBase::onSelectAttribute ()
|
||||
{
|
||||
mAddEffectDialog.setVisible(true);
|
||||
mAddEffectDialog.setAttribute (mSelectAttributeDialog->getAttributeId());
|
||||
MWBase::Environment::get().getWindowManager ()->removeDialog (mSelectAttributeDialog);
|
||||
mSelectAttributeDialog = 0;
|
||||
}
|
||||
|
||||
void EffectEditorBase::onSelectSkill ()
|
||||
{
|
||||
mAddEffectDialog.setVisible(true);
|
||||
mAddEffectDialog.setSkill (mSelectSkillDialog->getSkillId ());
|
||||
MWBase::Environment::get().getWindowManager ()->removeDialog (mSelectSkillDialog);
|
||||
mSelectSkillDialog = 0;
|
||||
}
|
||||
|
||||
void EffectEditorBase::onAttributeOrSkillCancel ()
|
||||
{
|
||||
if (mSelectSkillDialog)
|
||||
MWBase::Environment::get().getWindowManager ()->removeDialog (mSelectSkillDialog);
|
||||
if (mSelectAttributeDialog)
|
||||
MWBase::Environment::get().getWindowManager ()->removeDialog (mSelectAttributeDialog);
|
||||
|
||||
mSelectSkillDialog = 0;
|
||||
mSelectAttributeDialog = 0;
|
||||
}
|
||||
|
||||
void EffectEditorBase::onAvailableEffectClicked (MyGUI::Widget* sender)
|
||||
{
|
||||
|
||||
short effectId = *sender->getUserData<short>();
|
||||
const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(effectId);
|
||||
|
||||
mAddEffectDialog.newEffect (effect);
|
||||
|
||||
if (effect->mData.mFlags & ESM::MagicEffect::TargetSkill)
|
||||
{
|
||||
delete mSelectSkillDialog;
|
||||
mSelectSkillDialog = new SelectSkillDialog(*MWBase::Environment::get().getWindowManager ());
|
||||
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(*MWBase::Environment::get().getWindowManager ());
|
||||
mSelectAttributeDialog->eventCancel += MyGUI::newDelegate(this, &SpellCreationDialog::onAttributeOrSkillCancel);
|
||||
mSelectAttributeDialog->eventItemSelected += MyGUI::newDelegate(this, &SpellCreationDialog::onSelectAttribute);
|
||||
mSelectAttributeDialog->setVisible (true);
|
||||
}
|
||||
else
|
||||
{
|
||||
mAddEffectDialog.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
void EffectEditorBase::onEffectModified (ESM::ENAMstruct effect)
|
||||
{
|
||||
mEffects[mSelectedEffect] = effect;
|
||||
|
||||
updateEffectsView();
|
||||
}
|
||||
|
||||
void EffectEditorBase::onEffectRemoved (ESM::ENAMstruct effect)
|
||||
{
|
||||
mEffects.erase(mEffects.begin() + mSelectedEffect);
|
||||
updateEffectsView();
|
||||
}
|
||||
|
||||
void EffectEditorBase::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;
|
||||
params.mArea = it->mArea;
|
||||
|
||||
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 (MWBase::Environment::get().getWindowManager ());
|
||||
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 EffectEditorBase::onEffectAdded (ESM::ENAMstruct effect)
|
||||
{
|
||||
mEffects.push_back(effect);
|
||||
|
||||
updateEffectsView();
|
||||
}
|
||||
|
||||
void EffectEditorBase::onEditEffect (MyGUI::Widget *sender)
|
||||
{
|
||||
int id = *sender->getUserData<int>();
|
||||
|
||||
mSelectedEffect = id;
|
||||
|
||||
mAddEffectDialog.editEffect (mEffects[id]);
|
||||
mAddEffectDialog.setVisible (true);
|
||||
}
|
||||
}
|
@ -0,0 +1,150 @@
|
||||
#ifndef MWGUI_SPELLCREATION_H
|
||||
#define MWGUI_SPELLCREATION_H
|
||||
|
||||
#include "window_base.hpp"
|
||||
#include "referenceinterface.hpp"
|
||||
#include "list.hpp"
|
||||
#include "widgets.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
class SelectSkillDialog;
|
||||
class SelectAttributeDialog;
|
||||
|
||||
class EditEffectDialog : public WindowModal
|
||||
{
|
||||
public:
|
||||
EditEffectDialog(MWBase::WindowManager& parWindowManager);
|
||||
|
||||
virtual void open();
|
||||
|
||||
void setSkill(int skill);
|
||||
void setAttribute(int attribute);
|
||||
|
||||
void newEffect (const ESM::MagicEffect* effect);
|
||||
void editEffect (ESM::ENAMstruct effect);
|
||||
|
||||
typedef MyGUI::delegates::CMultiDelegate1<ESM::ENAMstruct> EventHandle_Effect;
|
||||
|
||||
EventHandle_Effect eventEffectAdded;
|
||||
EventHandle_Effect eventEffectModified;
|
||||
EventHandle_Effect eventEffectRemoved;
|
||||
|
||||
protected:
|
||||
MyGUI::Button* mCancelButton;
|
||||
MyGUI::Button* mOkButton;
|
||||
MyGUI::Button* mDeleteButton;
|
||||
|
||||
MyGUI::Button* mRangeButton;
|
||||
|
||||
MyGUI::Widget* mDurationBox;
|
||||
MyGUI::Widget* mMagnitudeBox;
|
||||
MyGUI::Widget* mAreaBox;
|
||||
|
||||
MyGUI::TextBox* mMagnitudeMinValue;
|
||||
MyGUI::TextBox* mMagnitudeMaxValue;
|
||||
MyGUI::TextBox* mDurationValue;
|
||||
MyGUI::TextBox* mAreaValue;
|
||||
|
||||
MyGUI::ScrollBar* mMagnitudeMinSlider;
|
||||
MyGUI::ScrollBar* mMagnitudeMaxSlider;
|
||||
MyGUI::ScrollBar* mDurationSlider;
|
||||
MyGUI::ScrollBar* mAreaSlider;
|
||||
|
||||
MyGUI::TextBox* mAreaText;
|
||||
|
||||
MyGUI::ImageBox* mEffectImage;
|
||||
MyGUI::TextBox* mEffectName;
|
||||
|
||||
bool mEditing;
|
||||
|
||||
protected:
|
||||
void onRangeButtonClicked (MyGUI::Widget* sender);
|
||||
void onDeleteButtonClicked (MyGUI::Widget* sender);
|
||||
void onOkButtonClicked (MyGUI::Widget* sender);
|
||||
void onCancelButtonClicked (MyGUI::Widget* sender);
|
||||
|
||||
void onMagnitudeMinChanged (MyGUI::ScrollBar* sender, size_t pos);
|
||||
void onMagnitudeMaxChanged (MyGUI::ScrollBar* sender, size_t pos);
|
||||
void onDurationChanged (MyGUI::ScrollBar* sender, size_t pos);
|
||||
void onAreaChanged (MyGUI::ScrollBar* sender, size_t pos);
|
||||
|
||||
void setMagicEffect(const ESM::MagicEffect* effect);
|
||||
|
||||
void updateBoxes();
|
||||
|
||||
protected:
|
||||
ESM::ENAMstruct mEffect;
|
||||
|
||||
const ESM::MagicEffect* mMagicEffect;
|
||||
};
|
||||
|
||||
|
||||
class EffectEditorBase
|
||||
{
|
||||
public:
|
||||
EffectEditorBase(MWBase::WindowManager& parWindowManager);
|
||||
|
||||
|
||||
protected:
|
||||
Widgets::MWList* mAvailableEffectsList;
|
||||
MyGUI::ScrollView* mUsedEffectsView;
|
||||
|
||||
EditEffectDialog mAddEffectDialog;
|
||||
SelectAttributeDialog* mSelectAttributeDialog;
|
||||
SelectSkillDialog* mSelectSkillDialog;
|
||||
|
||||
int mSelectedEffect;
|
||||
|
||||
std::vector<ESM::ENAMstruct> mEffects;
|
||||
|
||||
void onEffectAdded(ESM::ENAMstruct effect);
|
||||
void onEffectModified(ESM::ENAMstruct effect);
|
||||
void onEffectRemoved(ESM::ENAMstruct effect);
|
||||
|
||||
void onAvailableEffectClicked (MyGUI::Widget* sender);
|
||||
|
||||
void onAttributeOrSkillCancel();
|
||||
void onSelectAttribute();
|
||||
void onSelectSkill();
|
||||
|
||||
void onEditEffect(MyGUI::Widget* sender);
|
||||
|
||||
void updateEffectsView();
|
||||
|
||||
void startEditing();
|
||||
void setWidgets (Widgets::MWList* availableEffectsList, MyGUI::ScrollView* usedEffectsView);
|
||||
|
||||
};
|
||||
|
||||
class SpellCreationDialog : public WindowBase, public ReferenceInterface, public EffectEditorBase
|
||||
{
|
||||
public:
|
||||
SpellCreationDialog(MWBase::WindowManager& parWindowManager);
|
||||
|
||||
virtual void open();
|
||||
|
||||
void startSpellMaking(MWWorld::Ptr actor);
|
||||
|
||||
protected:
|
||||
virtual void onReferenceUnavailable ();
|
||||
|
||||
void onCancelButtonClicked (MyGUI::Widget* sender);
|
||||
void onBuyButtonClicked (MyGUI::Widget* sender);
|
||||
|
||||
|
||||
MyGUI::EditBox* mNameEdit;
|
||||
MyGUI::TextBox* mMagickaCost;
|
||||
MyGUI::TextBox* mSuccessChance;
|
||||
MyGUI::Button* mBuyButton;
|
||||
MyGUI::Button* mCancelButton;
|
||||
MyGUI::TextBox* mPriceLabel;
|
||||
|
||||
Widgets::MWEffectList* mUsedEffectsList;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<MyGUI type="Layout">
|
||||
<Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 362 310" name="_Main">
|
||||
|
||||
<Widget type="ImageBox" skin="ImageBox" position="8 12 16 16" name="EffectImage">
|
||||
</Widget>
|
||||
|
||||
<Widget type="TextBox" skin="NormalText" position="36 8 400 24" name="EffectName">
|
||||
<Property key="TextAlign" value="Left HCenter"/>
|
||||
</Widget>
|
||||
|
||||
|
||||
<!-- Range -->
|
||||
<Widget type="TextBox" skin="NormalText" position="8 36 400 24">
|
||||
<Property key="Caption" value="#{sRange}"/>
|
||||
<Property key="TextAlign" value="Left HCenter"/>
|
||||
</Widget>
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" position="130 36 0 24" name="RangeButton">
|
||||
<Property key="Caption" value="#{sRangeTouch}"/>
|
||||
</Widget>
|
||||
|
||||
<!-- Magnitude -->
|
||||
<Widget type="Widget" position="8 80 400 70" name="MagnitudeBox">
|
||||
<Widget type="TextBox" skin="NormalText" position="0 0 400 24">
|
||||
<Property key="Caption" value="#{sMagnitude}"/>
|
||||
<Property key="TextAlign" value="Left HCenter"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="TextBox" skin="SandText" position="122 0 210 20" name="MagnitudeMinValue">
|
||||
<Property key="TextAlign" value="Center"/>
|
||||
<Property key="Caption" value="0"/>
|
||||
</Widget>
|
||||
<Widget type="ScrollBar" skin="MW_HSlider" position="122 20 210 13" name="MagnitudeMinSlider">
|
||||
<Property key="Range" value="100"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="TextBox" skin="SandText" position="122 32 210 20" name="MagnitudeMaxValue">
|
||||
<Property key="TextAlign" value="Center"/>
|
||||
<Property key="Caption" value="0"/>
|
||||
</Widget>
|
||||
<Widget type="ScrollBar" skin="MW_HSlider" position="122 52 210 13" name="MagnitudeMaxSlider">
|
||||
<Property key="Range" value="100"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
|
||||
<!-- Duration -->
|
||||
<Widget type="Widget" position="8 153 400 40" name="DurationBox">
|
||||
<Widget type="TextBox" skin="NormalText" position="0 20 400 24">
|
||||
<Property key="Caption" value="#{sDuration}"/>
|
||||
<Property key="TextAlign" value="Left Top"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="TextBox" skin="SandText" position="122 0 210 20" name="DurationValue">
|
||||
<Property key="TextAlign" value="Center"/>
|
||||
<Property key="Caption" value="0"/>
|
||||
</Widget>
|
||||
<Widget type="ScrollBar" skin="MW_HSlider" position="122 20 210 13" name="DurationSlider">
|
||||
<Property key="Range" value="1440"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
<!-- Area -->
|
||||
<Widget type="Widget" position="8 197 400 40" name="AreaBox">
|
||||
<Widget type="TextBox" skin="NormalText" position="0 20 400 24" name="AreaText">
|
||||
<Property key="Caption" value="#{sArea}"/>
|
||||
<Property key="TextAlign" value="Left Top"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="TextBox" skin="SandText" position="122 0 210 20" name="AreaValue">
|
||||
<Property key="TextAlign" value="Center"/>
|
||||
<Property key="Caption" value="0"/>
|
||||
</Widget>
|
||||
<Widget type="ScrollBar" skin="MW_HSlider" position="122 20 210 13" name="AreaSlider">
|
||||
<Property key="Range" value="51"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
<Widget type="HBox" position="8 266 336 24">
|
||||
<Widget type="Widget">
|
||||
<UserString key="HStretch" value="true"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" name="DeleteButton">
|
||||
<Property key="Caption" value="#{sDelete}"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" name="OkButton">
|
||||
<Property key="Caption" value="#{sOk}"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" name="CancelButton">
|
||||
<Property key="Caption" value="#{sCancel}"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
</Widget>
|
||||
</MyGUI>
|
@ -0,0 +1,110 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<MyGUI type="Layout">
|
||||
<Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 560 400" name="_Main">
|
||||
|
||||
<Widget type="HBox" position="12 12 250 30">
|
||||
|
||||
<Widget type="AutoSizedTextBox" skin="NormalText">
|
||||
<Property key="Caption" value="#{sName}"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="EditBox" skin="MW_TextEdit" position="0 0 30 30" name="NameEdit">
|
||||
<UserString key="HStretch" value="true"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="Widget">
|
||||
</Widget>
|
||||
|
||||
</Widget>
|
||||
|
||||
<!-- Item -->
|
||||
|
||||
<Widget type="HBox" position="12 48 400 59">
|
||||
<Property key="Spacing" value="8"/>
|
||||
|
||||
<Widget type="AutoSizedTextBox" skin="NormalText">
|
||||
<Property key="Caption" value="#{sItem}"/>
|
||||
</Widget>
|
||||
<Widget type="Button" skin="MW_Box" position="0 0 60 59" name="ItemBox"/>
|
||||
|
||||
<Widget type="Widget" position="0 0 8 0"/>
|
||||
|
||||
<Widget type="AutoSizedTextBox" skin="NormalText">
|
||||
<Property key="Caption" value="#{sSoulGem}"/>
|
||||
</Widget>
|
||||
<Widget type="Button" skin="MW_Box" position="0 0 60 59" name="SoulBox"/>
|
||||
|
||||
</Widget>
|
||||
|
||||
|
||||
<Widget type="TextBox" skin="NormalText" position="320 0 300 24">
|
||||
<Property key="Caption" value="#{sEnchantmentMenu3}:"/>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="SandText" position="280 0 258 24" name="Enchantment">
|
||||
<Property key="Caption" value="1"/>
|
||||
<Property key="TextAlign" value="Right HCenter"/>
|
||||
</Widget>
|
||||
|
||||
|
||||
<Widget type="TextBox" skin="NormalText" position="320 24 300 24">
|
||||
<Property key="Caption" value="#{sCastCost}:"/>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="SandText" position="280 24 258 24" name="CastCost">
|
||||
<Property key="Caption" value="39"/>
|
||||
<Property key="TextAlign" value="Right HCenter"/>
|
||||
</Widget>
|
||||
|
||||
|
||||
<Widget type="TextBox" skin="NormalText" position="320 48 300 24">
|
||||
<Property key="Caption" value="#{sCharges}"/>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="SandText" position="280 48 258 24" name="Charge">
|
||||
<Property key="Caption" value="39"/>
|
||||
<Property key="TextAlign" value="Right HCenter"/>
|
||||
</Widget>
|
||||
|
||||
|
||||
<!-- Available effects -->
|
||||
<Widget type="TextBox" skin="NormalText" position="12 148 300 24">
|
||||
<Property key="Caption" value="#{sMagicEffects}"/>
|
||||
</Widget>
|
||||
<Widget type="MWList" skin="MW_SimpleList" position="12 176 202 169" name="AvailableEffects">
|
||||
</Widget>
|
||||
|
||||
<!-- Used effects -->
|
||||
<Widget type="TextBox" skin="NormalText" position="226 148 300 24">
|
||||
<Property key="Caption" value="#{sEffects}"/>
|
||||
</Widget>
|
||||
<Widget type="Widget" skin="MW_Box" position="226 176 316 169">
|
||||
<Widget type="ScrollView" skin="MW_ScrollViewH" position="4 4 308 161" name="UsedEffects">
|
||||
<Property key="CanvasAlign" value="Left Top"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
<Widget type="HBox" position="0 340 560 60">
|
||||
<Property key="Padding" value="16"/>
|
||||
|
||||
<Widget type="Widget" position="0 0 0 0">
|
||||
<UserString key="HStretch" value="true"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="AutoSizedTextBox" skin="NormalText">
|
||||
<Property key="Caption" value="#{sBarterDialog7}"/>
|
||||
</Widget>
|
||||
<Widget type="AutoSizedTextBox" skin="SandText" name="PriceLabel">
|
||||
<Property key="Caption" value="30"/>
|
||||
</Widget>
|
||||
|
||||
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" name="BuyButton">
|
||||
<Property key="Caption" value="#{sBuy}"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" name="CancelButton">
|
||||
<Property key="Caption" value="#{sCancel}"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
</Widget>
|
||||
</MyGUI>
|
@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<MyGUI type="Layout">
|
||||
<Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 560 400" name="_Main">
|
||||
|
||||
<Widget type="HBox" position="12 12 250 30">
|
||||
|
||||
<Widget type="AutoSizedTextBox" skin="NormalText">
|
||||
<Property key="Caption" value="#{sName}"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="EditBox" skin="MW_TextEdit" position="0 0 30 30" name="NameEdit">
|
||||
<UserString key="HStretch" value="true"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="Widget">
|
||||
</Widget>
|
||||
|
||||
</Widget>
|
||||
|
||||
<Widget type="TextBox" skin="NormalText" position="280 0 300 24">
|
||||
<Property key="Caption" value="#{sEnchantmentMenu4}"/>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="SandText" position="280 0 258 24" name="MagickaCost">
|
||||
<Property key="Caption" value="1"/>
|
||||
<Property key="TextAlign" value="Right HCenter"/>
|
||||
</Widget>
|
||||
|
||||
|
||||
<Widget type="TextBox" skin="NormalText" position="280 24 300 24">
|
||||
<Property key="Caption" value="#{sSpellmakingMenu1}"/>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="SandText" position="280 24 258 24" name="SuccessChance">
|
||||
<Property key="Caption" value="39"/>
|
||||
<Property key="TextAlign" value="Right HCenter"/>
|
||||
</Widget>
|
||||
|
||||
|
||||
<!-- Available effects -->
|
||||
<Widget type="TextBox" skin="NormalText" position="12 48 300 24">
|
||||
<Property key="Caption" value="#{sMagicEffects}"/>
|
||||
</Widget>
|
||||
<Widget type="MWList" skin="MW_SimpleList" position="12 76 202 269" name="AvailableEffects">
|
||||
</Widget>
|
||||
|
||||
<!-- Used effects -->
|
||||
<Widget type="TextBox" skin="NormalText" position="226 48 300 24">
|
||||
<Property key="Caption" value="#{sEffects}"/>
|
||||
</Widget>
|
||||
<Widget type="Widget" skin="MW_Box" position="226 76 316 269">
|
||||
<Widget type="ScrollView" skin="MW_ScrollViewH" position="4 4 308 261" name="UsedEffects">
|
||||
<Property key="CanvasAlign" value="Left Top"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
<Widget type="HBox" position="0 340 560 60">
|
||||
<Property key="Padding" value="16"/>
|
||||
|
||||
<Widget type="Widget" position="0 0 0 0">
|
||||
<UserString key="HStretch" value="true"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="AutoSizedTextBox" skin="NormalText">
|
||||
<Property key="Caption" value="#{sBarterDialog7}"/>
|
||||
</Widget>
|
||||
<Widget type="AutoSizedTextBox" skin="SandText" name="PriceLabel">
|
||||
<Property key="Caption" value="30"/>
|
||||
</Widget>
|
||||
|
||||
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" name="BuyButton">
|
||||
<Property key="Caption" value="#{sBuy}"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" name="CancelButton">
|
||||
<Property key="Caption" value="#{sCancel}"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
</Widget>
|
||||
</MyGUI>
|
Loading…
Reference in New Issue