Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | pmbaty | 1 | /* |
| 2 | * This file is part of the DXX-Rebirth project <https://www.dxx-rebirth.com/>. |
||
| 3 | * It is copyright by its individual contributors, as recorded in the |
||
| 4 | * project's Git history. See COPYING.txt at the top level for license |
||
| 5 | * terms and a link to the Git history. |
||
| 6 | */ |
||
| 7 | /* |
||
| 8 | * messagebox.c |
||
| 9 | * d1x-rebirth |
||
| 10 | * |
||
| 11 | * Display an error or warning messagebox using the OS's window server. |
||
| 12 | * |
||
| 13 | */ |
||
| 14 | |||
| 15 | #include <windows.h> |
||
| 16 | #include "window.h" |
||
| 17 | #include "event.h" |
||
| 18 | #include "messagebox.h" |
||
| 19 | |||
| 20 | namespace dcx { |
||
| 21 | |||
| 22 | static void display_win32_alert(const char *message, int error) |
||
| 23 | { |
||
| 24 | window *wind; |
||
| 25 | |||
| 26 | // Handle Descent's windows properly |
||
| 27 | if ((wind = window_get_front())) |
||
| 28 | { |
||
| 29 | const d_event event{EVENT_WINDOW_DEACTIVATED}; |
||
| 30 | WINDOW_SEND_EVENT(wind); |
||
| 31 | } |
||
| 32 | |||
| 33 | int fullscreen = (grd_curscreen && gr_check_fullscreen()); |
||
| 34 | if (fullscreen) |
||
| 35 | gr_toggle_fullscreen(); |
||
| 36 | |||
| 37 | MessageBox(NULL, message, error?"Sorry, a critical error has occurred.":"Attention!", error?MB_OK|MB_ICONERROR:MB_OK|MB_ICONWARNING); |
||
| 38 | |||
| 39 | if ((wind = window_get_front())) |
||
| 40 | { |
||
| 41 | const d_event event{EVENT_WINDOW_ACTIVATED}; |
||
| 42 | WINDOW_SEND_EVENT(wind); |
||
| 43 | } |
||
| 44 | |||
| 45 | if (!error && fullscreen) |
||
| 46 | gr_toggle_fullscreen(); |
||
| 47 | } |
||
| 48 | |||
| 49 | void msgbox_warning(const char *message) |
||
| 50 | { |
||
| 51 | display_win32_alert(message, 0); |
||
| 52 | } |
||
| 53 | |||
| 54 | void msgbox_error(const char *message) |
||
| 55 | { |
||
| 56 | display_win32_alert(message, 1); |
||
| 57 | } |
||
| 58 | |||
| 59 | } |