diff --git a/apps/openmw/mwgui/list.cpp b/apps/openmw/mwgui/list.cpp index ff23f8b31..0bafced97 100644 --- a/apps/openmw/mwgui/list.cpp +++ b/apps/openmw/mwgui/list.cpp @@ -128,6 +128,7 @@ void MWList::onItemSelected(MyGUI::Widget* _sender) std::string name = static_cast(_sender)->getCaption(); eventItemSelected(name); + eventWidgetSelected(_sender); } MyGUI::Widget* MWList::getItemWidget(const std::string& name) diff --git a/apps/openmw/mwgui/list.hpp b/apps/openmw/mwgui/list.hpp index c1f2d83b5..d07d49de6 100644 --- a/apps/openmw/mwgui/list.hpp +++ b/apps/openmw/mwgui/list.hpp @@ -18,6 +18,7 @@ namespace MWGui MWList(); typedef MyGUI::delegates::CMultiDelegate1 EventHandle_String; + typedef MyGUI::delegates::CMultiDelegate1 EventHandle_Widget; /** * Event: Item selected with the mouse. @@ -25,6 +26,13 @@ namespace MWGui */ EventHandle_String eventItemSelected; + /** + * Event: Item selected with the mouse. + * signature: void method(MyGUI::Widget* sender) + */ + EventHandle_Widget eventWidgetSelected; + + /** * Call after the size of the list changed, or items were inserted/removed */ diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index fd5e9594c..b1748edf8 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -29,8 +29,86 @@ namespace namespace MWGui { + EditEffectDialog::EditEffectDialog(MWBase::WindowManager &parWindowManager) + : WindowModal("openmw_edit_effect.layout", parWindowManager) + , mRange(ESM::RT_Touch) + { + 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"); + + 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); + } + + void EditEffectDialog::open() + { + WindowModal::open(); + center(); + } + + void EditEffectDialog::setEffect (const ESM::MagicEffect *effect) + { + std::string icon = effect->icon; + icon[icon.size()-3] = 'd'; + icon[icon.size()-2] = 'd'; + icon[icon.size()-1] = 's'; + icon = "icons\\" + icon; + + mEffectImage->setImageTexture (icon); + + mEffectName->setCaptionWithReplacing("#{"+Widgets::MWSpellEffect::effectIDToString (effect->index)+"}"); + } + + void EditEffectDialog::onRangeButtonClicked (MyGUI::Widget* sender) + { + mRange = (mRange+1)%3; + + if (mRange == ESM::RT_Self) + mRangeButton->setCaptionWithReplacing ("#{sRangeSelf}"); + else if (mRange == ESM::RT_Target) + mRangeButton->setCaptionWithReplacing ("#{sRangeTarget}"); + else if (mRange == ESM::RT_Touch) + mRangeButton->setCaptionWithReplacing ("#{sRangeTouch}"); + + mAreaSlider->setVisible (mRange != ESM::RT_Self); + mAreaText->setVisible (mRange != ESM::RT_Self); + } + + void EditEffectDialog::onDeleteButtonClicked (MyGUI::Widget* sender) + { + + } + + void EditEffectDialog::onOkButtonClicked (MyGUI::Widget* sender) + { + setVisible(false); + } + + void EditEffectDialog::onCancelButtonClicked (MyGUI::Widget* sender) + { + setVisible(false); + } + + // ------------------------------------------------------------------------------------------------ + SpellCreationDialog::SpellCreationDialog(MWBase::WindowManager &parWindowManager) : WindowBase("openmw_spellcreation_dialog.layout", parWindowManager) + , mAddEffectDialog(parWindowManager) { getWidget(mNameEdit, "NameEdit"); getWidget(mMagickaCost, "MagickaCost"); @@ -41,8 +119,12 @@ namespace MWGui getWidget(mBuyButton, "BuyButton"); getWidget(mCancelButton, "CancelButton"); + mAddEffectDialog.setVisible(false); + mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onCancelButtonClicked); mBuyButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onBuyButtonClicked); + + mAvailableEffectsList->eventWidgetSelected += MyGUI::newDelegate(this, &SpellCreationDialog::onAvailableEffectClicked); } @@ -101,6 +183,7 @@ namespace MWGui std::string name = MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find( MWGui::Widgets::MWSpellEffect::effectIDToString (*it))->getString(); MyGUI::Widget* w = mAvailableEffectsList->getItemWidget(name); + w->setUserData(*it); ToolTips::createMagicEffectToolTip (w, *it); } @@ -117,4 +200,13 @@ namespace MWGui } + void SpellCreationDialog::onAvailableEffectClicked (MyGUI::Widget* sender) + { + mAddEffectDialog.setVisible(true); + + short effectId = *sender->getUserData(); + const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(effectId); + mAddEffectDialog.setEffect (effect); + } + } diff --git a/apps/openmw/mwgui/spellcreationdialog.hpp b/apps/openmw/mwgui/spellcreationdialog.hpp index d0919ced0..8ea8ebb2d 100644 --- a/apps/openmw/mwgui/spellcreationdialog.hpp +++ b/apps/openmw/mwgui/spellcreationdialog.hpp @@ -8,6 +8,47 @@ namespace MWGui { + class EditEffectDialog : public WindowModal + { + public: + EditEffectDialog(MWBase::WindowManager& parWindowManager); + + virtual void open(); + + void setEffect (const ESM::MagicEffect* effect); + + protected: + MyGUI::Button* mCancelButton; + MyGUI::Button* mOkButton; + MyGUI::Button* mDeleteButton; + + MyGUI::Button* mRangeButton; + + 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::ScrollBar* mAreaText; + + MyGUI::ImageBox* mEffectImage; + MyGUI::TextBox* mEffectName; + + protected: + void onRangeButtonClicked (MyGUI::Widget* sender); + void onDeleteButtonClicked (MyGUI::Widget* sender); + void onOkButtonClicked (MyGUI::Widget* sender); + void onCancelButtonClicked (MyGUI::Widget* sender); + + protected: + int mRange; + }; + class SpellCreationDialog : public WindowBase, public ReferenceInterface { public: @@ -22,6 +63,7 @@ namespace MWGui void onCancelButtonClicked (MyGUI::Widget* sender); void onBuyButtonClicked (MyGUI::Widget* sender); + void onAvailableEffectClicked (MyGUI::Widget* sender); MyGUI::EditBox* mNameEdit; @@ -33,6 +75,8 @@ namespace MWGui MyGUI::Button* mCancelButton; MyGUI::TextBox* mPriceLabel; + EditEffectDialog mAddEffectDialog; + }; } diff --git a/files/mygui/CMakeLists.txt b/files/mygui/CMakeLists.txt index 2a1bf7510..d948a4cf7 100644 --- a/files/mygui/CMakeLists.txt +++ b/files/mygui/CMakeLists.txt @@ -76,6 +76,7 @@ set(MYGUI_FILES openmw_wait_dialog.layout openmw_wait_dialog_progressbar.layout openmw_spellcreation_dialog.layout + openmw_edit_effect.layout smallbars.png VeraMono.ttf markers.png diff --git a/files/mygui/openmw_edit_effect.layout b/files/mygui/openmw_edit_effect.layout new file mode 100644 index 000000000..884723feb --- /dev/null +++ b/files/mygui/openmw_edit_effect.layout @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +