Added love.window.showMessageBox.

It has two variants: showMessageBox(type, title, message [, attachtowindow=true]), and showMessageBox(type, title, message, buttons [, attachtowindow=true]). The former shows a simple message box with a single OK button, and the latter displays several buttons. The buttons argument is an array of button names.

The second variant returns the index of the pressed button, or 0 if the message box was closed some other way. showMessageBox will block until the message box is closed (and it can't be called on a separate thread.)
This commit is contained in:
Alex Szpakowski
2014-07-21 21:28:21 -03:00
parent d52bab4221
commit 3ae336dd43
6 changed files with 176 additions and 0 deletions
+31
View File
@@ -69,12 +69,34 @@ public:
FULLSCREEN_TYPE_MAX_ENUM
};
enum MessageBoxType
{
MESSAGEBOX_ERROR,
MESSAGEBOX_WARNING,
MESSAGEBOX_INFO,
MESSAGEBOX_MAX_ENUM
};
struct WindowSize
{
int width;
int height;
};
struct MessageBoxData
{
MessageBoxType type;
std::string title;
std::string message;
std::vector<std::string> buttons;
int enterButtonIndex;
int escapeButtonIndex;
bool attachToWindow;
};
virtual ~Window();
// Implements Module.
@@ -127,6 +149,9 @@ public:
virtual const void *getHandle() const = 0;
virtual bool showMessageBox(MessageBoxType type, const std::string &title, const std::string &message, bool attachtowindow) = 0;
virtual int showMessageBox(const MessageBoxData &data) = 0;
//virtual static Window *createSingleton() = 0;
//virtual static Window *getSingleton() = 0;
// No virtual statics, of course, but you are supposed to implement these statics.
@@ -137,6 +162,9 @@ public:
static bool getConstant(const char *in, FullscreenType &out);
static bool getConstant(FullscreenType in, const char *&out);
static bool getConstant(const char *in, MessageBoxType &out);
static bool getConstant(MessageBoxType in, const char *&out);
protected:
static Window *singleton;
@@ -149,6 +177,9 @@ private:
static StringMap<FullscreenType, FULLSCREEN_TYPE_MAX_ENUM>::Entry fullscreenTypeEntries[];
static StringMap<FullscreenType, FULLSCREEN_TYPE_MAX_ENUM> fullscreenTypes;
static StringMap<MessageBoxType, MESSAGEBOX_MAX_ENUM>::Entry messageBoxTypeEntries[];
static StringMap<MessageBoxType, MESSAGEBOX_MAX_ENUM> messageBoxTypes;
}; // Window
struct WindowSettings