edit effect dialog

actorid
scrawl 12 years ago
parent 9d7c35ae48
commit d393f551ed

@ -128,6 +128,7 @@ void MWList::onItemSelected(MyGUI::Widget* _sender)
std::string name = static_cast<MyGUI::Button*>(_sender)->getCaption(); std::string name = static_cast<MyGUI::Button*>(_sender)->getCaption();
eventItemSelected(name); eventItemSelected(name);
eventWidgetSelected(_sender);
} }
MyGUI::Widget* MWList::getItemWidget(const std::string& name) MyGUI::Widget* MWList::getItemWidget(const std::string& name)

@ -18,6 +18,7 @@ namespace MWGui
MWList(); MWList();
typedef MyGUI::delegates::CMultiDelegate1<std::string> EventHandle_String; typedef MyGUI::delegates::CMultiDelegate1<std::string> EventHandle_String;
typedef MyGUI::delegates::CMultiDelegate1<MyGUI::Widget*> EventHandle_Widget;
/** /**
* Event: Item selected with the mouse. * Event: Item selected with the mouse.
@ -25,6 +26,13 @@ namespace MWGui
*/ */
EventHandle_String eventItemSelected; 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 * Call after the size of the list changed, or items were inserted/removed
*/ */

@ -29,8 +29,86 @@ namespace
namespace MWGui 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) SpellCreationDialog::SpellCreationDialog(MWBase::WindowManager &parWindowManager)
: WindowBase("openmw_spellcreation_dialog.layout", parWindowManager) : WindowBase("openmw_spellcreation_dialog.layout", parWindowManager)
, mAddEffectDialog(parWindowManager)
{ {
getWidget(mNameEdit, "NameEdit"); getWidget(mNameEdit, "NameEdit");
getWidget(mMagickaCost, "MagickaCost"); getWidget(mMagickaCost, "MagickaCost");
@ -41,8 +119,12 @@ namespace MWGui
getWidget(mBuyButton, "BuyButton"); getWidget(mBuyButton, "BuyButton");
getWidget(mCancelButton, "CancelButton"); getWidget(mCancelButton, "CancelButton");
mAddEffectDialog.setVisible(false);
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onCancelButtonClicked); mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onCancelButtonClicked);
mBuyButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onBuyButtonClicked); 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( std::string name = MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find(
MWGui::Widgets::MWSpellEffect::effectIDToString (*it))->getString(); MWGui::Widgets::MWSpellEffect::effectIDToString (*it))->getString();
MyGUI::Widget* w = mAvailableEffectsList->getItemWidget(name); MyGUI::Widget* w = mAvailableEffectsList->getItemWidget(name);
w->setUserData(*it);
ToolTips::createMagicEffectToolTip (w, *it); ToolTips::createMagicEffectToolTip (w, *it);
} }
@ -117,4 +200,13 @@ namespace MWGui
} }
void SpellCreationDialog::onAvailableEffectClicked (MyGUI::Widget* sender)
{
mAddEffectDialog.setVisible(true);
short effectId = *sender->getUserData<short>();
const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(effectId);
mAddEffectDialog.setEffect (effect);
}
} }

@ -8,6 +8,47 @@
namespace MWGui 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 class SpellCreationDialog : public WindowBase, public ReferenceInterface
{ {
public: public:
@ -22,6 +63,7 @@ namespace MWGui
void onCancelButtonClicked (MyGUI::Widget* sender); void onCancelButtonClicked (MyGUI::Widget* sender);
void onBuyButtonClicked (MyGUI::Widget* sender); void onBuyButtonClicked (MyGUI::Widget* sender);
void onAvailableEffectClicked (MyGUI::Widget* sender);
MyGUI::EditBox* mNameEdit; MyGUI::EditBox* mNameEdit;
@ -33,6 +75,8 @@ namespace MWGui
MyGUI::Button* mCancelButton; MyGUI::Button* mCancelButton;
MyGUI::TextBox* mPriceLabel; MyGUI::TextBox* mPriceLabel;
EditEffectDialog mAddEffectDialog;
}; };
} }

@ -76,6 +76,7 @@ set(MYGUI_FILES
openmw_wait_dialog.layout openmw_wait_dialog.layout
openmw_wait_dialog_progressbar.layout openmw_wait_dialog_progressbar.layout
openmw_spellcreation_dialog.layout openmw_spellcreation_dialog.layout
openmw_edit_effect.layout
smallbars.png smallbars.png
VeraMono.ttf VeraMono.ttf
markers.png markers.png

@ -0,0 +1,88 @@
<?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="TextBox" skin="NormalText" position="8 80 400 24">
<Property key="Caption" value="#{sMagnitude}"/>
<Property key="TextAlign" value="Left HCenter"/>
</Widget>
<Widget type="TextBox" skin="SandText" position="130 80 210 20" name="MagnitudeMinValue">
<Property key="TextAlign" value="Center"/>
<Property key="Caption" value="0"/>
</Widget>
<Widget type="ScrollBar" skin="MW_HSlider" position="130 100 210 13" name="MagnitudeMinSlider">
</Widget>
<Widget type="TextBox" skin="SandText" position="130 112 210 20" name="MagnitudeMaxValue">
<Property key="TextAlign" value="Center"/>
<Property key="Caption" value="0"/>
</Widget>
<Widget type="ScrollBar" skin="MW_HSlider" position="130 132 210 13" name="MagnitudeMaxSlider">
</Widget>
<!-- Duration -->
<Widget type="TextBox" skin="NormalText" position="8 173 400 24">
<Property key="Caption" value="#{sDuration}"/>
<Property key="TextAlign" value="Left Top"/>
</Widget>
<Widget type="TextBox" skin="SandText" position="130 153 210 20" name="DurationValue">
<Property key="TextAlign" value="Center"/>
<Property key="Caption" value="0"/>
</Widget>
<Widget type="ScrollBar" skin="MW_HSlider" position="130 173 210 13" name="DurationSlider">
</Widget>
<!-- Area -->
<Widget type="TextBox" skin="NormalText" position="8 217 400 24" name="AreaText">
<Property key="Caption" value="#{sArea}"/>
<Property key="TextAlign" value="Left Top"/>
</Widget>
<Widget type="TextBox" skin="SandText" position="130 197 210 20" name="AreaValue">
<Property key="TextAlign" value="Center"/>
<Property key="Caption" value="0"/>
</Widget>
<Widget type="ScrollBar" skin="MW_HSlider" position="130 217 210 13" name="AreaSlider">
</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>
Loading…
Cancel
Save