2011-06-14 14:41:30 +00:00
|
|
|
#ifndef MWGUI_MESSAGE_BOX_H
|
|
|
|
#define MWGUI_MESSAGE_BOX_H
|
|
|
|
|
2013-04-10 04:32:05 +00:00
|
|
|
#include "windowbase.hpp"
|
2012-08-12 16:11:09 +00:00
|
|
|
|
2012-03-26 22:36:53 +00:00
|
|
|
#undef MessageBox
|
2011-06-15 20:53:05 +00:00
|
|
|
|
2013-03-03 12:11:02 +00:00
|
|
|
namespace MyGUI
|
|
|
|
{
|
|
|
|
class Widget;
|
|
|
|
class Button;
|
|
|
|
class EditBox;
|
|
|
|
}
|
|
|
|
|
2011-06-14 14:41:30 +00:00
|
|
|
namespace MWGui
|
|
|
|
{
|
2011-06-18 13:50:41 +00:00
|
|
|
class InteractiveMessageBox;
|
2011-06-14 16:29:55 +00:00
|
|
|
class MessageBoxManager;
|
|
|
|
class MessageBox;
|
2011-06-14 14:41:30 +00:00
|
|
|
class MessageBoxManager
|
|
|
|
{
|
|
|
|
public:
|
2014-01-10 21:27:31 +00:00
|
|
|
MessageBoxManager (float timePerChar);
|
2013-12-30 22:08:53 +00:00
|
|
|
~MessageBoxManager ();
|
2011-06-15 20:53:05 +00:00
|
|
|
void onFrame (float frameDuration);
|
2013-05-03 10:44:27 +00:00
|
|
|
void createMessageBox (const std::string& message, bool stat = false);
|
|
|
|
void removeStaticMessageBox ();
|
2020-07-17 23:36:13 +00:00
|
|
|
/*
|
|
|
|
Start of tes3mp change (major)
|
|
|
|
|
|
|
|
Add a hasServerOrigin boolean to the list of arguments so those messageboxes
|
|
|
|
can be differentiated from client-only ones
|
|
|
|
*/
|
|
|
|
bool createInteractiveMessageBox (const std::string& message, const std::vector<std::string>& buttons, bool hasServerOrigin = false);
|
|
|
|
/*
|
|
|
|
End of tes3mp change (major)
|
|
|
|
*/
|
2011-06-19 17:10:44 +00:00
|
|
|
bool isInteractiveMessageBox ();
|
2012-08-12 16:11:09 +00:00
|
|
|
|
2018-10-28 07:44:14 +00:00
|
|
|
int getMessagesCount();
|
|
|
|
|
2018-01-14 00:27:53 +00:00
|
|
|
const InteractiveMessageBox* getInteractiveMessageBox() const { return mInterMessageBoxe; }
|
|
|
|
|
2014-06-14 19:52:54 +00:00
|
|
|
/// Remove all message boxes
|
|
|
|
void clear();
|
|
|
|
|
2011-06-16 11:02:49 +00:00
|
|
|
bool removeMessageBox (MessageBox *msgbox);
|
2013-04-10 04:32:05 +00:00
|
|
|
|
2015-01-10 22:58:55 +00:00
|
|
|
/// @param reset Reset the pressed button to -1 after reading it.
|
|
|
|
int readPressedButton (bool reset=true);
|
2012-08-12 16:11:09 +00:00
|
|
|
|
2013-03-30 14:51:07 +00:00
|
|
|
typedef MyGUI::delegates::CMultiDelegate1<int> EventHandle_Int;
|
|
|
|
|
|
|
|
// Note: this delegate unassigns itself after it was fired, i.e. works once.
|
|
|
|
EventHandle_Int eventButtonPressed;
|
|
|
|
|
|
|
|
void onButtonPressed(int button) { eventButtonPressed(button); eventButtonPressed.clear(); }
|
|
|
|
|
2011-06-14 20:11:36 +00:00
|
|
|
private:
|
|
|
|
std::vector<MessageBox*> mMessageBoxes;
|
2011-06-19 17:10:44 +00:00
|
|
|
InteractiveMessageBox* mInterMessageBoxe;
|
2013-05-03 10:44:27 +00:00
|
|
|
MessageBox* mStaticMessageBox;
|
2011-06-15 20:53:05 +00:00
|
|
|
float mMessageBoxSpeed;
|
2013-10-14 09:15:23 +00:00
|
|
|
int mLastButtonPressed;
|
2011-06-14 14:41:30 +00:00
|
|
|
};
|
2012-08-12 16:11:09 +00:00
|
|
|
|
2015-05-01 00:09:57 +00:00
|
|
|
class MessageBox : public Layout
|
2011-06-14 16:29:55 +00:00
|
|
|
{
|
|
|
|
public:
|
2011-06-14 20:11:36 +00:00
|
|
|
MessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message);
|
|
|
|
void setMessage (const std::string& message);
|
2011-06-15 11:58:57 +00:00
|
|
|
int getHeight ();
|
|
|
|
void update (int height);
|
2012-08-12 16:11:09 +00:00
|
|
|
|
2013-11-20 04:49:05 +00:00
|
|
|
float mCurrentTime;
|
|
|
|
float mMaxTime;
|
2012-08-12 16:11:09 +00:00
|
|
|
|
2011-06-14 16:29:55 +00:00
|
|
|
protected:
|
|
|
|
MessageBoxManager& mMessageBoxManager;
|
2012-07-13 10:51:58 +00:00
|
|
|
const std::string& mMessage;
|
2013-03-03 12:11:02 +00:00
|
|
|
MyGUI::EditBox* mMessageWidget;
|
2011-06-15 17:42:20 +00:00
|
|
|
int mBottomPadding;
|
2011-06-15 17:53:32 +00:00
|
|
|
int mNextBoxPadding;
|
2011-06-14 16:29:55 +00:00
|
|
|
};
|
2012-08-12 16:11:09 +00:00
|
|
|
|
2013-03-30 14:51:07 +00:00
|
|
|
class InteractiveMessageBox : public WindowModal
|
2011-06-18 13:50:41 +00:00
|
|
|
{
|
|
|
|
public:
|
2011-06-19 17:41:42 +00:00
|
|
|
InteractiveMessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector<std::string>& buttons);
|
2011-07-12 18:05:04 +00:00
|
|
|
void mousePressed (MyGUI::Widget* _widget);
|
|
|
|
int readPressedButton ();
|
2012-08-12 16:11:09 +00:00
|
|
|
|
2018-01-14 00:27:53 +00:00
|
|
|
MyGUI::Widget* getDefaultKeyFocus() override;
|
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
bool exit() override { return false; }
|
2017-09-27 20:00:20 +00:00
|
|
|
|
2011-07-12 18:05:04 +00:00
|
|
|
bool mMarkedToDelete;
|
2012-08-12 16:11:09 +00:00
|
|
|
|
2020-07-17 23:36:13 +00:00
|
|
|
/*
|
|
|
|
Start of tes3mp addition
|
|
|
|
|
|
|
|
Track whether the message box has a server origin
|
|
|
|
*/
|
|
|
|
bool mHasServerOrigin = false;
|
|
|
|
/*
|
|
|
|
End of tes3mp addition
|
|
|
|
*/
|
|
|
|
|
2011-06-19 17:41:42 +00:00
|
|
|
private:
|
2013-02-10 14:58:46 +00:00
|
|
|
void buttonActivated (MyGUI::Widget* _widget);
|
2013-04-10 04:32:05 +00:00
|
|
|
|
2011-06-18 13:50:41 +00:00
|
|
|
MessageBoxManager& mMessageBoxManager;
|
2013-03-03 12:11:02 +00:00
|
|
|
MyGUI::EditBox* mMessageWidget;
|
|
|
|
MyGUI::Widget* mButtonsWidget;
|
|
|
|
std::vector<MyGUI::Button*> mButtons;
|
2011-07-12 15:57:16 +00:00
|
|
|
|
2011-07-12 18:05:04 +00:00
|
|
|
int mButtonPressed;
|
2011-06-18 13:50:41 +00:00
|
|
|
};
|
2011-06-14 16:29:55 +00:00
|
|
|
|
2011-06-14 14:41:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|