mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-20 22:16:49 +01:00
emscripten: special case to make SDL_ShowSimpleMessageBox() work.
Browsers don't have the functionality to fully support the generic SDL_ShowMessageBox(), but this handles the likely most-common case. Without this, you'd return immediately with a proper error result and no UI, but probably no one checks that for SDL_ShowSimpleMessageBox. And if they did: what would they do to handle this anyhow? We'd need to lobby for an HTML spec of some sort that allows customizable message boxes--that block!--to properly support SDL message boxes on Emscripten, but this is probably Good Enough for now.
This commit is contained in:
parent
45553ac4db
commit
da1e3d6938
@ -55,6 +55,10 @@
|
|||||||
#undef CreateWindow
|
#undef CreateWindow
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
#include <emscripten.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Available video drivers */
|
/* Available video drivers */
|
||||||
static VideoBootStrap *bootstrap[] = {
|
static VideoBootStrap *bootstrap[] = {
|
||||||
#if SDL_VIDEO_DRIVER_COCOA
|
#if SDL_VIDEO_DRIVER_COCOA
|
||||||
@ -3722,6 +3726,16 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
|||||||
int
|
int
|
||||||
SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window)
|
SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window)
|
||||||
{
|
{
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
/* !!! FIXME: propose a browser API for this, get this #ifdef out of here? */
|
||||||
|
/* Web browsers don't (currently) have an API for a custom message box
|
||||||
|
that can block, but for the most common case (SDL_ShowSimpleMessageBox),
|
||||||
|
we can use the standard Javascript alert() function. */
|
||||||
|
EM_ASM_({
|
||||||
|
alert(UTF8ToString($0) + "\n\n" + UTF8ToString($1));
|
||||||
|
}, title, message);
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
SDL_MessageBoxData data;
|
SDL_MessageBoxData data;
|
||||||
SDL_MessageBoxButtonData button;
|
SDL_MessageBoxButtonData button;
|
||||||
|
|
||||||
@ -3739,6 +3753,7 @@ SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, S
|
|||||||
button.text = "OK";
|
button.text = "OK";
|
||||||
|
|
||||||
return SDL_ShowMessageBox(&data, NULL);
|
return SDL_ShowMessageBox(&data, NULL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool
|
SDL_bool
|
||||||
|
Loading…
Reference in New Issue
Block a user