Browse Source

Custom message box for 3DS (#1932)

pull/1944/head
Stephen C. Wills 5 years ago committed by GitHub
parent
commit
081a077f6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      CMakeLists.txt
  2. 29
      Source/platform/ctr/messagebox.cpp
  3. 8
      Source/utils/sdl2_to_1_2_backports.h

3
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()

29
Source/platform/ctr/messagebox.cpp

@ -0,0 +1,29 @@
#include <3ds.h>
#include <SDL.h>
#include <fmt/core.h>
#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;
}

8
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

Loading…
Cancel
Save