| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- #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;
- }
|