Subversion Repositories Games.Descent

Rev

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.mm
9
 *  d1x-rebirth
10
 *
11
 *  Display an error or warning messagebox using the OS's window server.
12
 *
13
 */
14
 
15
#import <Cocoa/Cocoa.h>
16
 
17
#include "window.h"
18
#include "event.h"
19
#include "messagebox.h"
20
 
21
namespace dcx {
22
 
23
void display_cocoa_alert(const char *message, int error)
24
{
25
	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
26
	NSAlert *alert = [[NSAlert alloc] init];
27
	alert.alertStyle = error == 1 ? NSAlertStyleCritical : NSAlertStyleWarning;
28
	alert.messageText = error ? @"Sorry, a critical error has occurred." : @"Attention!";
29
	alert.informativeText = [NSString stringWithUTF8String:message];
30
 
31
	[alert runModal];
32
	[alert release];
33
	[pool drain];
34
}
35
 
36
void msgbox_warning(const char *message)
37
{
38
	display_cocoa_alert(message, 0);
39
}
40
 
41
void msgbox_error(const char *message)
42
{
43
	display_cocoa_alert(message, 1);
44
}
45
 
46
}