Browse Source

3DS: Support simple message boxes

Cameron Cawley 6 months ago
parent
commit
23d456e146
2 changed files with 24 additions and 1 deletions
  1. 3 1
      src/SDL_assert.c
  2. 21 0
      src/video/SDL_video.c

+ 3 - 1
src/SDL_assert.c

@@ -292,7 +292,7 @@ static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data,
                 break;
             }
         }
-#elif defined(HAVE_STDIO_H)
+#elif defined(HAVE_STDIO_H) && !defined(__3DS__)
         /* this is a little hacky. */
         for (;;) {
             char buf[32];
@@ -319,6 +319,8 @@ static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data,
                 break;
             }
         }
+#else
+        SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING, "Assertion Failed", message, window);
 #endif /* HAVE_STDIO_H */
     }
 

+ 21 - 0
src/video/SDL_video.c

@@ -59,6 +59,10 @@
 #include <emscripten.h>
 #endif
 
+#ifdef __3DS__
+#include <3ds.h>
+#endif
+
 #ifdef __LINUX__
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -4556,6 +4560,23 @@ int SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *messag
     },
             title, message);
     return 0;
+#elif defined(__3DS__)
+    errorConf errCnf;
+    bool hasGpuRight;
+
+    /* If the video subsystem has not been initialised, set up graphics temporarily */
+    hasGpuRight = gspHasGpuRight();
+    if (!hasGpuRight)
+        gfxInitDefault();
+
+    errorInit(&errCnf, ERROR_TEXT_WORD_WRAP, CFG_LANGUAGE_EN);
+    errorText(&errCnf, message);
+    errorDisp(&errCnf);
+
+    if (!hasGpuRight)
+        gfxExit();
+
+    return 0;
 #else
     SDL_MessageBoxData data;
     SDL_MessageBoxButtonData button;