puts up a message box with a title and message. define text for buttons, btn0_title, btn1_title, ..., until NULL. also define hotkey for button immediately after title is defined. DoMessageBoxAdvanced("Title", "Hi", "Abort", KEY_A, "Retry", KEY_R, "Cancel", KEY_ESC, NULL) if button with btn0_title pressed, returns 0, btn1_title, returns 1, etc. safe for up to three buttons.
| 671 | // if button with btn0_title pressed, returns 0, btn1_title, returns 1, etc. |
| 672 | // safe for up to three buttons. |
| 673 | int DoMessageBoxAdvanced(const char *title, const char *msg, const char *btn0_title, int key0, ...) { |
| 674 | newuiMessageBox mbox; |
| 675 | newuiSheet *sheet; |
| 676 | va_list args; |
| 677 | const char *curbtntitle; |
| 678 | int i; |
| 679 | |
| 680 | int old_screen_mode, res; |
| 681 | char msgbuf[256]; |
| 682 | |
| 683 | // force menu mode |
| 684 | old_screen_mode = GetScreenMode(); |
| 685 | |
| 686 | textaux_WordWrap(msg, msgbuf, NEWUI_MSGBOX_SHEET_W, MONITOR9_NEWUI_FONT); |
| 687 | |
| 688 | // make message box |
| 689 | mbox.Create(title, MSGBOX_NULL); |
| 690 | i = 0; |
| 691 | if (btn0_title) { |
| 692 | mbox.AddButton(btn0_title, i, key0); |
| 693 | i++; |
| 694 | } |
| 695 | |
| 696 | // go through all titles. |
| 697 | va_start(args, key0); |
| 698 | while ((curbtntitle = va_arg(args, char *)) != NULL) { |
| 699 | int key = va_arg(args, int); |
| 700 | |
| 701 | mbox.AddButton(curbtntitle, i, key); |
| 702 | i++; |
| 703 | if (i == NEWUI_MSGBOX_MAXBTNS) |
| 704 | break; |
| 705 | } |
| 706 | |
| 707 | va_end(args); |
| 708 | |
| 709 | sheet = mbox.GetSheet(); |
| 710 | sheet->NewGroup(NULL, 0, 0); |
| 711 | sheet->AddText(msgbuf); |
| 712 | |
| 713 | mbox.Open(); |
| 714 | res = mbox.DoUI(); |
| 715 | mbox.Close(); |
| 716 | |
| 717 | mbox.Destroy(); |
| 718 | |
| 719 | // restore screen |
| 720 | SetScreenMode(old_screen_mode); |
| 721 | |
| 722 | // return correct value. |
| 723 | return res; |
| 724 | } |
| 725 | |
| 726 | bool DoEditDialog(const char *title, char *buffer, int buflen, bool showcancel) { |
| 727 | newuiMessageBox mbox; |
no test coverage detected