2014-11-24 03:53:02 +00:00
|
|
|
/*
|
2018-09-02 00:57:29 +00:00
|
|
|
* This file is part of the DXX-Rebirth project <https://www.dxx-rebirth.com/>.
|
2014-11-24 03:53:02 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* messagebox.mm
|
|
|
|
* d1x-rebirth
|
|
|
|
*
|
|
|
|
* Display an error or warning messagebox using the OS's window server.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
|
|
|
|
#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
|
|
|
|
2014-11-24 03:53:02 +00:00
|
|
|
void display_cocoa_alert(const char *message, int error)
|
|
|
|
{
|
|
|
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
|
|
|
NSAlert *alert = [[NSAlert alloc] init];
|
2021-12-22 21:45:35 +00:00
|
|
|
alert.alertStyle = error == 1 ? NSAlertStyleCritical : NSAlertStyleWarning;
|
2014-11-24 03:53:02 +00:00
|
|
|
alert.messageText = error ? @"Sorry, a critical error has occurred." : @"Attention!";
|
|
|
|
alert.informativeText = [NSString stringWithUTF8String:message];
|
|
|
|
|
|
|
|
[alert runModal];
|
|
|
|
[alert release];
|
|
|
|
[pool drain];
|
|
|
|
}
|
|
|
|
|
|
|
|
void msgbox_warning(const char *message)
|
|
|
|
{
|
|
|
|
display_cocoa_alert(message, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void msgbox_error(const char *message)
|
|
|
|
{
|
|
|
|
display_cocoa_alert(message, 1);
|
|
|
|
}
|
2015-12-05 22:57:24 +00:00
|
|
|
|
|
|
|
}
|