OpenMW
|
00001 #ifndef MWGUI_MESSAGE_BOX_H 00002 #define MWGUI_MESSAGE_BOX_H 00003 00004 #include "windowbase.hpp" 00005 00006 #include "../mwbase/windowmanager.hpp" 00007 00008 #undef MessageBox 00009 00010 namespace MyGUI 00011 { 00012 class Widget; 00013 class Button; 00014 class EditBox; 00015 } 00016 00017 namespace MWGui 00018 { 00019 class InteractiveMessageBox; 00020 class MessageBoxManager; 00021 class MessageBox; 00022 class MessageBoxManager 00023 { 00024 public: 00025 MessageBoxManager (); 00026 ~MessageBoxManager (); 00027 void onFrame (float frameDuration); 00028 void createMessageBox (const std::string& message, bool stat = false); 00029 void removeStaticMessageBox (); 00030 bool createInteractiveMessageBox (const std::string& message, const std::vector<std::string>& buttons); 00031 bool isInteractiveMessageBox (); 00032 00033 bool removeMessageBox (MessageBox *msgbox); 00034 void setMessageBoxSpeed (int speed); 00035 00036 void okayPressed(); 00037 int readPressedButton (); 00038 00039 typedef MyGUI::delegates::CMultiDelegate1<int> EventHandle_Int; 00040 00041 // Note: this delegate unassigns itself after it was fired, i.e. works once. 00042 EventHandle_Int eventButtonPressed; 00043 00044 void onButtonPressed(int button) { eventButtonPressed(button); eventButtonPressed.clear(); } 00045 00046 private: 00047 std::vector<MessageBox*> mMessageBoxes; 00048 InteractiveMessageBox* mInterMessageBoxe; 00049 MessageBox* mStaticMessageBox; 00050 float mMessageBoxSpeed; 00051 int mLastButtonPressed; 00052 }; 00053 00054 class MessageBox : public OEngine::GUI::Layout 00055 { 00056 public: 00057 MessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message); 00058 void setMessage (const std::string& message); 00059 int getHeight (); 00060 void update (int height); 00061 00062 float mCurrentTime; 00063 float mMaxTime; 00064 00065 protected: 00066 MessageBoxManager& mMessageBoxManager; 00067 const std::string& mMessage; 00068 MyGUI::EditBox* mMessageWidget; 00069 int mBottomPadding; 00070 int mNextBoxPadding; 00071 }; 00072 00073 class InteractiveMessageBox : public WindowModal 00074 { 00075 public: 00076 InteractiveMessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector<std::string>& buttons); 00077 void okayPressed (); 00078 void mousePressed (MyGUI::Widget* _widget); 00079 int readPressedButton (); 00080 00081 bool mMarkedToDelete; 00082 00083 private: 00084 void buttonActivated (MyGUI::Widget* _widget); 00085 00086 MessageBoxManager& mMessageBoxManager; 00087 MyGUI::EditBox* mMessageWidget; 00088 MyGUI::Widget* mButtonsWidget; 00089 std::vector<MyGUI::Button*> mButtons; 00090 00091 int mTextButtonPadding; 00092 int mButtonPressed; 00093 }; 00094 00095 } 00096 00097 #endif