1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-30 12:32:36 +00:00
OpenMW/apps/openmw/mwgui/messagebox.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

121 lines
3.2 KiB
C++
Raw Normal View History

#ifndef MWGUI_MESSAGE_BOX_H
#define MWGUI_MESSAGE_BOX_H
#include <memory>
#include "windowbase.hpp"
namespace MyGUI
{
class Widget;
class Button;
class EditBox;
}
namespace MWGui
{
2011-06-18 15:50:41 +02:00
class InteractiveMessageBox;
2011-06-14 18:29:55 +02:00
class MessageBoxManager;
class MessageBox;
class MessageBoxManager
{
public:
2014-01-10 22:27:31 +01:00
MessageBoxManager(float timePerChar);
~MessageBoxManager();
void onFrame(float frameDuration);
void createMessageBox(std::string_view message, bool stat = false);
2013-05-03 12:44:27 +02:00
void removeStaticMessageBox();
bool createInteractiveMessageBox(
std::string_view message, const std::vector<std::string>& buttons, bool immediate = false);
2011-06-19 19:10:44 +02:00
bool isInteractiveMessageBox();
int getMessagesCount();
const InteractiveMessageBox* getInteractiveMessageBox() const { return mInterMessageBoxe.get(); }
/// 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);
void resetInteractiveMessageBox();
void setLastButtonPressed(int index);
typedef MyGUI::delegates::MultiDelegate<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();
}
2021-05-25 21:04:05 +02:00
void setVisible(bool value);
const std::vector<std::unique_ptr<MessageBox>>& getActiveMessageBoxes() const;
2021-11-26 05:20:58 +08:00
2011-06-14 22:11:36 +02:00
private:
std::vector<std::unique_ptr<MessageBox>> mMessageBoxes;
std::unique_ptr<InteractiveMessageBox> mInterMessageBoxe;
2013-05-03 12:44:27 +02:00
MessageBox* mStaticMessageBox;
float mMessageBoxSpeed;
int mLastButtonPressed;
2021-05-25 21:04:05 +02:00
bool mVisible = true;
};
2015-05-01 02:09:57 +02:00
class MessageBox : public Layout
2011-06-14 18:29:55 +02:00
{
public:
MessageBox(MessageBoxManager& parMessageBoxManager, std::string_view message);
2022-10-05 23:45:17 +02:00
const std::string& getMessage() { return mMessage; }
int getHeight();
void update(int height);
2021-05-25 21:04:05 +02:00
void setVisible(bool value);
2022-09-22 21:26:05 +03:00
float mCurrentTime;
float mMaxTime;
2022-09-22 21:26:05 +03:00
2011-06-14 18:29:55 +02:00
protected:
MessageBoxManager& mMessageBoxManager;
2021-12-14 22:40:05 +08:00
std::string mMessage;
MyGUI::EditBox* mMessageWidget;
2011-06-15 19:42:20 +02:00
int mBottomPadding;
int mNextBoxPadding;
2011-06-14 18:29:55 +02:00
};
class InteractiveMessageBox : public WindowModal
2011-06-18 15:50:41 +02:00
{
public:
2011-06-19 19:41:42 +02:00
InteractiveMessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message,
const std::vector<std::string>& buttons, bool immediate);
void mousePressed(MyGUI::Widget* _widget);
int readPressedButton();
MyGUI::Widget* getDefaultKeyFocus() override;
bool exit() override { return false; }
bool mMarkedToDelete;
2011-06-19 19:41:42 +02:00
private:
void buttonActivated(MyGUI::Widget* _widget);
2011-06-18 15:50:41 +02:00
MessageBoxManager& mMessageBoxManager;
MyGUI::EditBox* mMessageWidget;
MyGUI::Widget* mButtonsWidget;
std::vector<MyGUI::Button*> mButtons;
int mButtonPressed;
bool mImmediate;
2011-06-18 15:50:41 +02:00
};
2011-06-14 18:29:55 +02:00
}
#endif