GFX2_MessageBox(): Doxygen + fix return code

This commit is contained in:
Thomas Bernard 2020-05-06 11:38:38 +02:00
parent 89d0a247fc
commit 6367ffa5a9
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
2 changed files with 16 additions and 1 deletions

View File

@ -114,6 +114,11 @@ int GFX2_GetScreenSize(int * width, int * height);
/**
* Display a modal message
*
* @param text body of the modal message
* @param caption title of the message
* @param type one of GFX2_MB_INFO, GFX2_MB_ERROR, GFX2_MB_WARNING
* @return 0 for error
*/
int GFX2_MessageBox(const char * text, const char * caption, unsigned int type);

View File

@ -803,7 +803,16 @@ void Set_mouse_position(void)
int GFX2_MessageBox(const char * text, const char * caption, unsigned int type)
{
#if defined(USE_SDL2)
return SDL_ShowSimpleMessageBox(type, caption, text, Window_SDL);
// SDL_ShowSimpleMessageBox() returns 0 on success
if (SDL_ShowSimpleMessageBox(type, caption, text, Window_SDL) == 0)
{
return 1;
}
else
{
GFX2_Log(GFX2_ERROR, "SDL_ShowSimpleMessageBox() failed : %s\n", SDL_GetError());
return 0;
}
#elif defined(WIN32)
return MessageBoxA(GFX2_Get_Window_Handle(), text, caption, type);
#elif defined(__macosx__)
@ -817,6 +826,7 @@ int GFX2_MessageBox(const char * text, const char * caption, unsigned int type)
NULL, NULL, NULL, &result);
CFRelease(text_ref);
CFRelease(caption_ref);
// CFUserNotificationDisplayAlert() returns 0 on success
return (r == 0);
#else
return 0;