diff --git a/CMakeLists.txt b/CMakeLists.txt index 11278bb8b..951160a3b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -475,7 +475,8 @@ if(N3DS) list(APPEND devilutionx_SRCS Source/platform/ctr/system.cpp Source/platform/ctr/keyboard.cpp - Source/platform/ctr/display.cpp) + Source/platform/ctr/display.cpp + Source/platform/ctr/messagebox.cpp) set(BIN_TARGET ${BIN_TARGET}.elf) endif() diff --git a/Source/platform/ctr/messagebox.cpp b/Source/platform/ctr/messagebox.cpp new file mode 100644 index 000000000..7124f9cbb --- /dev/null +++ b/Source/platform/ctr/messagebox.cpp @@ -0,0 +1,29 @@ +#include <3ds.h> +#include +#include +#include "utils/sdl2_to_1_2_backports.h" + +int SDL_ShowSimpleMessageBox(Uint32 flags, + const char *title, + const char *message, + SDL_Surface *window) +{ + if (SDL_ShowCursor(SDL_DISABLE) <= -1) + SDL_Log("%s", SDL_GetError()); + + bool init = !gspHasGpuRight(); + auto text = fmt::format("{}\n\n{}", title, message); + + if (init) + gfxInitDefault(); + + errorConf error; + errorInit(&error, ERROR_TEXT, CFG_LANGUAGE_EN); + errorText(&error, text.c_str()); + errorDisp(&error); + + if (init) + gfxExit(); + + return 0; +} diff --git a/Source/utils/sdl2_to_1_2_backports.h b/Source/utils/sdl2_to_1_2_backports.h index dc3344247..38c999d21 100644 --- a/Source/utils/sdl2_to_1_2_backports.h +++ b/Source/utils/sdl2_to_1_2_backports.h @@ -123,6 +123,13 @@ enum { // clang-format on }; +#ifdef __3DS__ +/** Defined in Source/platform/ctr/messagebox.cpp */ +int SDL_ShowSimpleMessageBox(Uint32 flags, + const char *title, + const char *message, + SDL_Surface *window); +#else inline int SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, @@ -131,6 +138,7 @@ inline int SDL_ShowSimpleMessageBox(Uint32 flags, SDL_Log("MSGBOX: %s\n%s", title, message); return 0; } +#endif //= Window handling