1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 16:49:55 +00:00
openmw-tes3mp/apps/openmw/mwgui/messagebox.hpp

123 lines
3.6 KiB
C++
Raw Normal View History

#ifndef MWGUI_MESSAGE_BOX_H
#define MWGUI_MESSAGE_BOX_H
#include "windowbase.hpp"
#undef MessageBox
namespace MyGUI
{
class Widget;
class Button;
class EditBox;
}
namespace MWGui
{
2011-06-18 13:50:41 +00:00
class InteractiveMessageBox;
2011-06-14 16:29:55 +00:00
class MessageBoxManager;
class MessageBox;
class MessageBoxManager
{
public:
2014-01-10 21:27:31 +00:00
MessageBoxManager (float timePerChar);
~MessageBoxManager ();
void onFrame (float frameDuration);
2013-05-03 10:44:27 +00:00
void createMessageBox (const std::string& message, bool stat = false);
void removeStaticMessageBox ();
/*
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 ();
int getMessagesCount();
const InteractiveMessageBox* getInteractiveMessageBox() const { return mInterMessageBoxe; }
/// Remove all message boxes
void clear();
bool removeMessageBox (MessageBox *msgbox);
/// @param reset Reset the pressed button to -1 after reading it.
int readPressedButton (bool reset=true);
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;
float mMessageBoxSpeed;
int mLastButtonPressed;
};
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);
int getHeight ();
void update (int height);
float mCurrentTime;
float mMaxTime;
2011-06-14 16:29:55 +00:00
protected:
MessageBoxManager& mMessageBoxManager;
const std::string& mMessage;
MyGUI::EditBox* mMessageWidget;
2011-06-15 17:42:20 +00:00
int mBottomPadding;
int mNextBoxPadding;
2011-06-14 16:29:55 +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);
void mousePressed (MyGUI::Widget* _widget);
int readPressedButton ();
MyGUI::Widget* getDefaultKeyFocus() override;
bool exit() override { return false; }
bool mMarkedToDelete;
/*
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:
void buttonActivated (MyGUI::Widget* _widget);
2011-06-18 13:50:41 +00:00
MessageBoxManager& mMessageBoxManager;
MyGUI::EditBox* mMessageWidget;
MyGUI::Widget* mButtonsWidget;
std::vector<MyGUI::Button*> mButtons;
int mButtonPressed;
2011-06-18 13:50:41 +00:00
};
2011-06-14 16:29:55 +00:00
}
#endif