OpenMW
apps/openmw/mwgui/spellcreationdialog.hpp
Go to the documentation of this file.
00001 #ifndef MWGUI_SPELLCREATION_H
00002 #define MWGUI_SPELLCREATION_H
00003 
00004 #include "windowbase.hpp"
00005 #include "referenceinterface.hpp"
00006 #include "list.hpp"
00007 #include "widgets.hpp"
00008 
00009 namespace MWGui
00010 {
00011 
00012     class SelectSkillDialog;
00013     class SelectAttributeDialog;
00014 
00015     class EditEffectDialog : public WindowModal
00016     {
00017     public:
00018         EditEffectDialog();
00019 
00020         virtual void open();
00021 
00022         void setSkill(int skill);
00023         void setAttribute(int attribute);
00024 
00025         void newEffect (const ESM::MagicEffect* effect);
00026         void editEffect (ESM::ENAMstruct effect);
00027         bool constantEffect;
00028         typedef MyGUI::delegates::CMultiDelegate1<ESM::ENAMstruct> EventHandle_Effect;
00029 
00030         EventHandle_Effect eventEffectAdded;
00031         EventHandle_Effect eventEffectModified;
00032         EventHandle_Effect eventEffectRemoved;
00033 
00034     protected:
00035         MyGUI::Button* mCancelButton;
00036         MyGUI::Button* mOkButton;
00037         MyGUI::Button* mDeleteButton;
00038 
00039         MyGUI::Button* mRangeButton;
00040 
00041         MyGUI::Widget* mDurationBox;
00042         MyGUI::Widget* mMagnitudeBox;
00043         MyGUI::Widget* mAreaBox;
00044 
00045         MyGUI::TextBox* mMagnitudeMinValue;
00046         MyGUI::TextBox* mMagnitudeMaxValue;
00047         MyGUI::TextBox* mDurationValue;
00048         MyGUI::TextBox* mAreaValue;
00049 
00050         MyGUI::ScrollBar* mMagnitudeMinSlider;
00051         MyGUI::ScrollBar* mMagnitudeMaxSlider;
00052         MyGUI::ScrollBar* mDurationSlider;
00053         MyGUI::ScrollBar* mAreaSlider;
00054 
00055         MyGUI::TextBox* mAreaText;
00056 
00057         MyGUI::ImageBox* mEffectImage;
00058         MyGUI::TextBox* mEffectName;
00059 
00060         bool mEditing;
00061 
00062     protected:
00063         void onRangeButtonClicked (MyGUI::Widget* sender);
00064         void onDeleteButtonClicked (MyGUI::Widget* sender);
00065         void onOkButtonClicked (MyGUI::Widget* sender);
00066         void onCancelButtonClicked (MyGUI::Widget* sender);
00067 
00068         void onMagnitudeMinChanged (MyGUI::ScrollBar* sender, size_t pos);
00069         void onMagnitudeMaxChanged (MyGUI::ScrollBar* sender, size_t pos);
00070         void onDurationChanged (MyGUI::ScrollBar* sender, size_t pos);
00071         void onAreaChanged (MyGUI::ScrollBar* sender, size_t pos);
00072         void setMagicEffect(const ESM::MagicEffect* effect);
00073 
00074         void updateBoxes();
00075 
00076     protected:
00077         ESM::ENAMstruct mEffect;
00078         ESM::ENAMstruct mOldEffect;
00079 
00080         const ESM::MagicEffect* mMagicEffect;
00081     };
00082 
00083 
00084     class EffectEditorBase
00085     {
00086     public:
00087         EffectEditorBase();
00088         virtual ~EffectEditorBase();
00089 
00090     protected:
00091         std::map<int, short> mButtonMapping; // maps button ID to effect ID
00092 
00093         Widgets::MWList* mAvailableEffectsList;
00094         MyGUI::ScrollView* mUsedEffectsView;
00095 
00096         EditEffectDialog mAddEffectDialog;
00097         SelectAttributeDialog* mSelectAttributeDialog;
00098         SelectSkillDialog* mSelectSkillDialog;
00099 
00100         int mSelectedEffect;
00101 
00102         std::vector<ESM::ENAMstruct> mEffects;
00103 
00104         void onEffectAdded(ESM::ENAMstruct effect);
00105         void onEffectModified(ESM::ENAMstruct effect);
00106         void onEffectRemoved(ESM::ENAMstruct effect);
00107 
00108         void onAvailableEffectClicked (MyGUI::Widget* sender);
00109 
00110         void onAttributeOrSkillCancel();
00111         void onSelectAttribute();
00112         void onSelectSkill();
00113 
00114         void onEditEffect(MyGUI::Widget* sender);
00115 
00116         void updateEffectsView();
00117 
00118         void startEditing();
00119         void setWidgets (Widgets::MWList* availableEffectsList, MyGUI::ScrollView* usedEffectsView);
00120 
00121         virtual void notifyEffectsChanged () {}
00122     };
00123 
00124     class SpellCreationDialog : public WindowBase, public ReferenceInterface, public EffectEditorBase
00125     {
00126     public:
00127         SpellCreationDialog();
00128 
00129         virtual void open();
00130 
00131         void startSpellMaking(MWWorld::Ptr actor);
00132 
00133     protected:
00134         virtual void onReferenceUnavailable ();
00135 
00136         void onCancelButtonClicked (MyGUI::Widget* sender);
00137         void onBuyButtonClicked (MyGUI::Widget* sender);
00138 
00139         virtual void notifyEffectsChanged ();
00140 
00141         MyGUI::EditBox* mNameEdit;
00142         MyGUI::TextBox* mMagickaCost;
00143         MyGUI::TextBox* mSuccessChance;
00144         MyGUI::Button* mBuyButton;
00145         MyGUI::Button* mCancelButton;
00146         MyGUI::TextBox* mPriceLabel;
00147 
00148         Widgets::MWEffectList* mUsedEffectsList;
00149 
00150         ESM::Spell mSpell;
00151 
00152     };
00153 
00154 }
00155 
00156 #endif