#include "Dialogs.h" static SDL_MessageBoxButtonData buttonDataAbortRetryIgnore[] = { { .flags = 0, .buttonID = IDABORT, .text = "Abort" }, { .flags = 0, .buttonID = IDRETRY, .text = "Retry" }, { .flags = 0, .buttonID = IDIGNORE, .text = "Ignore" } }; static SDL_MessageBoxButtonData buttonDataCancelTryContinue[] = { { .flags = 0, .buttonID = IDCANCEL, .text = "Cancel" }, { .flags = 0, .buttonID = IDTRYAGAIN, .text = "Try Again" }, { .flags = 0, .buttonID = IDCONTINUE, .text = "Continue" } }; static SDL_MessageBoxButtonData buttonOk[] = { { .flags = 0, .buttonID = IDOK, .text = "OK" } }; static SDL_MessageBoxButtonData buttonOkCancel[] = { { .flags = 0, .buttonID = IDOK, .text = "OK" }, { .flags = 0, .buttonID = IDCANCEL, .text = "Cancel" } }; static SDL_MessageBoxButtonData buttonRetryCancel[] = { { .flags = 0, .buttonID = IDRETRY, .text = "Retry" }, { .flags = 0, .buttonID = IDCANCEL, .text = "Cancel" } }; static SDL_MessageBoxButtonData buttonDataYesNo[] = { { .flags = 0, .buttonID = IDYES, .text = "Yes" }, { .flags = 0, .buttonID = IDNO, .text = "No" } }; static SDL_MessageBoxButtonData buttonDataYesNoCancel[] = { { .flags = 0, .buttonID = IDYES, .text = "Yes" }, { .flags = 0, .buttonID = IDNO, .text = "No" }, { .flags = 0, .buttonID = IDCANCEL, .text = "Cancel" } }; int MessageBox(SDL_Window *parent, char const *msg, char const *caption, unsigned int type) { int numbuttons; SDL_MessageBoxButtonData *buttons; switch (type & MB_MASK_BUTTON) { case MB_ABORTRETRYIGNORE: buttons = buttonDataAbortRetryIgnore; numbuttons = sizeof(buttonDataAbortRetryIgnore) / sizeof(SDL_MessageBoxButtonData); break; case MB_CANCELTRYCONTINUE: buttons = buttonDataCancelTryContinue; numbuttons = sizeof(buttonDataCancelTryContinue) / sizeof(SDL_MessageBoxButtonData); break; case MB_OK: buttons = buttonOk; numbuttons = sizeof(buttonOk) / sizeof(SDL_MessageBoxButtonData); break; case MB_OKCANCEL: buttons = buttonOkCancel; numbuttons = sizeof(buttonOkCancel) / sizeof(SDL_MessageBoxButtonData); break; case MB_RETRYCANCEL: buttons = buttonRetryCancel; numbuttons = sizeof(buttonRetryCancel) / sizeof(SDL_MessageBoxButtonData); break; case MB_YESNO: buttons = buttonDataYesNo; numbuttons = sizeof(buttonDataYesNo) / sizeof(SDL_MessageBoxButtonData); break; case MB_YESNOCANCEL: buttons = buttonDataYesNoCancel; numbuttons = sizeof(buttonDataYesNoCancel) / sizeof(SDL_MessageBoxButtonData); break; } SDL_MessageBoxData data = { .flags = type & MB_MASK_ICON, .window = parent, .title = caption, .message = msg, .numbuttons = numbuttons, .buttons = buttons, .colorScheme = NULL }; int result; SDL_ShowMessageBox(&data, &result); return result; }