From 2c1f055a4952b2f39263fe4bb2f491688195687b Mon Sep 17 00:00:00 2001 From: Kiritow <1362050620@qq.com> Date: Tue, 21 Mar 2017 13:58:48 +0800 Subject: [PATCH] SimpleMessageBox are supported. Use: SDL_ShowSimpleMessageBox --- MiniEngine.cpp | 18 ++++++++++++++++++ MiniEngine.h | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/MiniEngine.cpp b/MiniEngine.cpp index c2702e7..884dfa3 100644 --- a/MiniEngine.cpp +++ b/MiniEngine.cpp @@ -488,6 +488,24 @@ namespace MiniEngine winrnd.rnd.reset(SDL_CreateRenderer(wnd.get(), -1, flags), SDL_DestroyRenderer); } + int Window::showSimpleMessageBox(MessageBoxType type,std::string Title,std::string Message) + { + Uint32 flags=0; + switch(type) + { + case MessageBoxType::Error: + flags=SDL_MESSAGEBOX_ERROR; + break; + case MessageBoxType::Information: + flags=SDL_MESSAGEBOX_INFORMATION; + break; + case MessageBoxType::Warning: + flags=SDL_MESSAGEBOX_WARNING; + break; + } + return SDL_ShowSimpleMessageBox(flags,Title.c_str(),Message.c_str(),wnd.get()); + } + Font::Font(std::string FontFileName, int size) throw(ErrorViewer) { if (use(FontFileName, size) != 0) diff --git a/MiniEngine.h b/MiniEngine.h index a3d4497..1f69c7b 100644 --- a/MiniEngine.h +++ b/MiniEngine.h @@ -163,6 +163,8 @@ namespace MiniEngine friend class Window; }; + enum class MessageBoxType { Error,Warning,Information }; + class Window { public: @@ -186,6 +188,9 @@ namespace MiniEngine void setResizable(bool resizable); + /// Use UTF8 in Title and Message please. + int showSimpleMessageBox(MessageBoxType type,std::string Title,std::string Message); + void show(); void hide(); void raise();