OpenMW
|
00001 #ifndef MWGUI_CLASS_H 00002 #define MWGUI_CLASS_H 00003 00004 00005 #include "widgets.hpp" 00006 #include "windowbase.hpp" 00007 00008 /* 00009 This file contains the dialogs for choosing a class. 00010 Layout is defined by resources/mygui/openmw_chargen_class.layout. 00011 */ 00012 00013 namespace MWGui 00014 { 00015 class InfoBoxDialog : public WindowModal 00016 { 00017 public: 00018 InfoBoxDialog(); 00019 00020 typedef std::vector<std::string> ButtonList; 00021 00022 void setText(const std::string &str); 00023 std::string getText() const; 00024 void setButtons(ButtonList &buttons); 00025 00026 virtual void open(); 00027 int getChosenButton() const; 00028 00029 // Events 00030 typedef MyGUI::delegates::CMultiDelegate1<int> EventHandle_Int; 00031 00035 EventHandle_Int eventButtonSelected; 00036 00037 protected: 00038 void onButtonClicked(MyGUI::Widget* _sender); 00039 00040 private: 00041 00042 void fitToText(MyGUI::TextBox* widget); 00043 void layoutVertically(MyGUI::Widget* widget, int margin); 00044 int mCurrentButton; 00045 MyGUI::Widget* mTextBox; 00046 MyGUI::TextBox* mText; 00047 MyGUI::Widget* mButtonBar; 00048 std::vector<MyGUI::Button*> mButtons; 00049 }; 00050 00051 // Lets the player choose between 3 ways of creating a class 00052 class ClassChoiceDialog : public InfoBoxDialog 00053 { 00054 public: 00055 // Corresponds to the buttons that can be clicked 00056 enum ClassChoice 00057 { 00058 Class_Generate = 0, 00059 Class_Pick = 1, 00060 Class_Create = 2, 00061 Class_Back = 3 00062 }; 00063 ClassChoiceDialog(); 00064 }; 00065 00066 class GenerateClassResultDialog : public WindowModal 00067 { 00068 public: 00069 GenerateClassResultDialog(); 00070 00071 std::string getClassId() const; 00072 void setClassId(const std::string &classId); 00073 00074 // Events 00075 typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; 00076 00080 EventHandle_Void eventBack; 00081 00082 protected: 00083 void onOkClicked(MyGUI::Widget* _sender); 00084 void onBackClicked(MyGUI::Widget* _sender); 00085 00086 private: 00087 MyGUI::ImageBox* mClassImage; 00088 MyGUI::TextBox* mClassName; 00089 00090 std::string mCurrentClassId; 00091 }; 00092 00093 class PickClassDialog : public WindowModal 00094 { 00095 public: 00096 PickClassDialog(); 00097 00098 const std::string &getClassId() const { return mCurrentClassId; } 00099 void setClassId(const std::string &classId); 00100 00101 void setNextButtonShow(bool shown); 00102 virtual void open(); 00103 00104 // Events 00105 typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; 00106 00110 EventHandle_Void eventBack; 00111 00112 protected: 00113 void onSelectClass(MyGUI::ListBox* _sender, size_t _index); 00114 00115 void onOkClicked(MyGUI::Widget* _sender); 00116 void onBackClicked(MyGUI::Widget* _sender); 00117 00118 private: 00119 void updateClasses(); 00120 void updateStats(); 00121 00122 MyGUI::ImageBox* mClassImage; 00123 MyGUI::ListBox* mClassList; 00124 MyGUI::TextBox* mSpecializationName; 00125 Widgets::MWAttributePtr mFavoriteAttribute[2]; 00126 Widgets::MWSkillPtr mMajorSkill[5]; 00127 Widgets::MWSkillPtr mMinorSkill[5]; 00128 00129 std::string mCurrentClassId; 00130 }; 00131 00132 class SelectSpecializationDialog : public WindowModal 00133 { 00134 public: 00135 SelectSpecializationDialog(); 00136 ~SelectSpecializationDialog(); 00137 00138 ESM::Class::Specialization getSpecializationId() const { return mSpecializationId; } 00139 00140 // Events 00141 typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; 00142 00146 EventHandle_Void eventCancel; 00147 00151 EventHandle_Void eventItemSelected; 00152 00153 protected: 00154 void onSpecializationClicked(MyGUI::Widget* _sender); 00155 void onCancelClicked(MyGUI::Widget* _sender); 00156 00157 private: 00158 MyGUI::TextBox *mSpecialization0, *mSpecialization1, *mSpecialization2; 00159 00160 ESM::Class::Specialization mSpecializationId; 00161 }; 00162 00163 class SelectAttributeDialog : public WindowModal 00164 { 00165 public: 00166 SelectAttributeDialog(); 00167 ~SelectAttributeDialog(); 00168 00169 ESM::Attribute::AttributeID getAttributeId() const { return mAttributeId; } 00170 00171 // Events 00172 typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; 00173 00177 EventHandle_Void eventCancel; 00178 00182 EventHandle_Void eventItemSelected; 00183 00184 protected: 00185 void onAttributeClicked(Widgets::MWAttributePtr _sender); 00186 void onCancelClicked(MyGUI::Widget* _sender); 00187 00188 private: 00189 ESM::Attribute::AttributeID mAttributeId; 00190 }; 00191 00192 class SelectSkillDialog : public WindowModal 00193 { 00194 public: 00195 SelectSkillDialog(); 00196 ~SelectSkillDialog(); 00197 00198 ESM::Skill::SkillEnum getSkillId() const { return mSkillId; } 00199 00200 // Events 00201 typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; 00202 00206 EventHandle_Void eventCancel; 00207 00211 EventHandle_Void eventItemSelected; 00212 00213 protected: 00214 void onSkillClicked(Widgets::MWSkillPtr _sender); 00215 void onCancelClicked(MyGUI::Widget* _sender); 00216 00217 private: 00218 Widgets::MWSkillPtr mCombatSkill[9]; 00219 Widgets::MWSkillPtr mMagicSkill[9]; 00220 Widgets::MWSkillPtr mStealthSkill[9]; 00221 00222 ESM::Skill::SkillEnum mSkillId; 00223 }; 00224 00225 class DescriptionDialog : public WindowModal 00226 { 00227 public: 00228 DescriptionDialog(); 00229 ~DescriptionDialog(); 00230 00231 std::string getTextInput() const { return mTextEdit->getCaption(); } 00232 void setTextInput(const std::string &text) { mTextEdit->setCaption(text); } 00233 00234 protected: 00235 void onOkClicked(MyGUI::Widget* _sender); 00236 00237 private: 00238 MyGUI::EditBox* mTextEdit; 00239 }; 00240 00241 class CreateClassDialog : public WindowModal 00242 { 00243 public: 00244 CreateClassDialog(); 00245 virtual ~CreateClassDialog(); 00246 00247 std::string getName() const; 00248 std::string getDescription() const; 00249 ESM::Class::Specialization getSpecializationId() const; 00250 std::vector<int> getFavoriteAttributes() const; 00251 std::vector<ESM::Skill::SkillEnum> getMajorSkills() const; 00252 std::vector<ESM::Skill::SkillEnum> getMinorSkills() const; 00253 00254 void setNextButtonShow(bool shown); 00255 00256 // Events 00257 typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; 00258 00262 EventHandle_Void eventBack; 00263 00264 protected: 00265 void onOkClicked(MyGUI::Widget* _sender); 00266 void onBackClicked(MyGUI::Widget* _sender); 00267 00268 void onSpecializationClicked(MyGUI::Widget* _sender); 00269 void onSpecializationSelected(); 00270 void onAttributeClicked(Widgets::MWAttributePtr _sender); 00271 void onAttributeSelected(); 00272 void onSkillClicked(Widgets::MWSkillPtr _sender); 00273 void onSkillSelected(); 00274 void onDescriptionClicked(MyGUI::Widget* _sender); 00275 void onDescriptionEntered(WindowBase* parWindow); 00276 void onDialogCancel(); 00277 00278 void setSpecialization(int id); 00279 00280 void update(); 00281 00282 private: 00283 MyGUI::EditBox* mEditName; 00284 MyGUI::TextBox* mSpecializationName; 00285 Widgets::MWAttributePtr mFavoriteAttribute0, mFavoriteAttribute1; 00286 Widgets::MWSkillPtr mMajorSkill[5]; 00287 Widgets::MWSkillPtr mMinorSkill[5]; 00288 std::vector<Widgets::MWSkillPtr> mSkills; 00289 std::string mDescription; 00290 00291 SelectSpecializationDialog *mSpecDialog; 00292 SelectAttributeDialog *mAttribDialog; 00293 SelectSkillDialog *mSkillDialog; 00294 DescriptionDialog *mDescDialog; 00295 00296 ESM::Class::Specialization mSpecializationId; 00297 00298 Widgets::MWAttributePtr mAffectedAttribute; 00299 Widgets::MWSkillPtr mAffectedSkill; 00300 }; 00301 } 00302 #endif