2014-06-01 17:55:23 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the DXX-Rebirth project <http://www.dxx-rebirth.com/>.
|
|
|
|
* It is copyright by its individual contributors, as recorded in the
|
|
|
|
* project's Git history. See COPYING.txt at the top level for license
|
|
|
|
* terms and a link to the Git history.
|
|
|
|
*/
|
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"
|
|
|
|
|
2015-12-13 18:00:49 +00:00
|
|
|
namespace dcx {
|
2015-12-05 22:57:24 +00:00
|
|
|
|
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);
|
|
|
|
}
|
2015-12-05 22:57:24 +00:00
|
|
|
|
|
|
|
}
|