2010-11-28 12:02:38 +00:00
|
|
|
/*
|
|
|
|
* messagebox.c
|
|
|
|
* d1x-rebirth
|
|
|
|
*
|
|
|
|
* Display an error or warning messagebox using the OS's window server.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-30 12:46:10 +00:00
|
|
|
#include <windows.h>
|
2010-11-28 12:02:38 +00:00
|
|
|
#include "window.h"
|
|
|
|
#include "event.h"
|
|
|
|
#include "messagebox.h"
|
|
|
|
|
2013-06-08 22:24:17 +00:00
|
|
|
static void display_win32_alert(const char *message, int error)
|
2010-11-28 12:02:38 +00:00
|
|
|
{
|
2010-12-05 12:33:25 +00:00
|
|
|
d_event event;
|
2010-11-28 12:02:38 +00:00
|
|
|
window *wind;
|
|
|
|
|
|
|
|
// Handle Descent's windows properly
|
|
|
|
if ((wind = window_get_front()))
|
2010-12-05 12:33:25 +00:00
|
|
|
WINDOW_SEND_EVENT(wind, EVENT_WINDOW_DEACTIVATED);
|
2010-11-28 12:02:38 +00:00
|
|
|
|
2013-08-03 19:59:09 +00:00
|
|
|
int fullscreen = (grd_curscreen && gr_check_fullscreen());
|
|
|
|
if (fullscreen)
|
2010-11-30 12:46:10 +00:00
|
|
|
gr_toggle_fullscreen();
|
|
|
|
|
|
|
|
MessageBox(NULL, message, error?"Sorry, a critical error has occurred.":"Attention!", error?MB_OK|MB_ICONERROR:MB_OK|MB_ICONWARNING);
|
2010-11-28 12:02:38 +00:00
|
|
|
|
2010-12-05 12:33:25 +00:00
|
|
|
if ((wind = window_get_front()))
|
|
|
|
WINDOW_SEND_EVENT(wind, EVENT_WINDOW_ACTIVATED);
|
2013-01-12 11:07:57 +00:00
|
|
|
|
2013-08-03 19:59:09 +00:00
|
|
|
if (!error && fullscreen)
|
2013-01-12 11:07:57 +00:00
|
|
|
gr_toggle_fullscreen();
|
2010-11-28 12:02:38 +00:00
|
|
|
}
|
|
|
|
|
2013-06-08 22:24:17 +00:00
|
|
|
void msgbox_warning(const char *message)
|
2010-11-28 12:02:38 +00:00
|
|
|
{
|
|
|
|
display_win32_alert(message, 0);
|
|
|
|
}
|
|
|
|
|
2013-06-23 21:18:48 +00:00
|
|
|
void msgbox_error(const char *message)
|
2010-11-28 12:02:38 +00:00
|
|
|
{
|
|
|
|
display_win32_alert(message, 1);
|
|
|
|
}
|