OpenMW
apps/openmw/mwgui/race.hpp
Go to the documentation of this file.
00001 #ifndef MWGUI_RACE_H
00002 #define MWGUI_RACE_H
00003 
00004 #include "../mwrender/characterpreview.hpp"
00005 
00006 #include "windowbase.hpp"
00007 
00008 
00009 namespace MWGui
00010 {
00011     class WindowManager;
00012 }
00013 
00014 /*
00015   This file contains the dialog for choosing a race.
00016   Layout is defined by resources/mygui/openmw_chargen_race.layout.
00017  */
00018 
00019 namespace MWGui
00020 {
00021     class RaceDialog : public WindowModal
00022     {
00023     public:
00024         RaceDialog();
00025 
00026         enum Gender
00027         {
00028             GM_Male,
00029             GM_Female
00030         };
00031 
00032         const ESM::NPC &getResult() const { return mPreview->getPrototype(); }
00033         const std::string &getRaceId() const { return mCurrentRaceId; }
00034         Gender getGender() const { return mGenderIndex == 0 ? GM_Male : GM_Female; }
00035         // getFace()
00036         // getHair()
00037 
00038         void setRaceId(const std::string &raceId);
00039         void setGender(Gender gender) { mGenderIndex = gender == GM_Male ? 0 : 1; }
00040         // setFace()
00041         // setHair()
00042 
00043         void setNextButtonShow(bool shown);
00044         virtual void open();
00045         virtual void close();
00046 
00047         // Events
00048         typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
00049 
00053         EventHandle_Void eventBack;
00054 
00055         void doRenderUpdate();
00056 
00057     protected:
00058         void onHeadRotate(MyGUI::ScrollBar* _sender, size_t _position);
00059 
00060         void onSelectPreviousGender(MyGUI::Widget* _sender);
00061         void onSelectNextGender(MyGUI::Widget* _sender);
00062 
00063         void onSelectPreviousFace(MyGUI::Widget* _sender);
00064         void onSelectNextFace(MyGUI::Widget* _sender);
00065 
00066         void onSelectPreviousHair(MyGUI::Widget* _sender);
00067         void onSelectNextHair(MyGUI::Widget* _sender);
00068 
00069         void onSelectRace(MyGUI::ListBox* _sender, size_t _index);
00070 
00071         void onOkClicked(MyGUI::Widget* _sender);
00072         void onBackClicked(MyGUI::Widget* _sender);
00073 
00074     private:
00075         void updateRaces();
00076         void updateSkills();
00077         void updateSpellPowers();
00078         void updatePreview();
00079         void recountParts();
00080 
00081         void getBodyParts (int part, std::vector<std::string>& out);
00082 
00083         std::vector<std::string> mAvailableHeads;
00084         std::vector<std::string> mAvailableHairs;
00085 
00086         MyGUI::ImageBox*  mPreviewImage;
00087         MyGUI::ListBox*   mRaceList;
00088         MyGUI::ScrollBar* mHeadRotate;
00089 
00090         MyGUI::Widget* mSkillList;
00091         std::vector<MyGUI::Widget*> mSkillItems;
00092 
00093         MyGUI::Widget* mSpellPowerList;
00094         std::vector<MyGUI::Widget*> mSpellPowerItems;
00095 
00096         int mGenderIndex, mFaceIndex, mHairIndex;
00097 
00098         std::string mCurrentRaceId;
00099 
00100         float mCurrentAngle;
00101 
00102         MWRender::RaceSelectionPreview* mPreview;
00103 
00104         bool mPreviewDirty;
00105     };
00106 }
00107 #endif