Last active
August 29, 2015 14:10
-
-
Save MaddTheSane/ac69626aa417f302ca73 to your computer and use it in GitHub Desktop.
DXX-rebirth MessageBox, Cocoa version.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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. | |
*/ | |
/* | |
* 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" | |
void display_mac_alert(const char *message, int error) | |
{ | |
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | |
NSAlert *alert = [[NSAlert alloc] init]; | |
alert.alertStyle = error == 1 ? NSCriticalAlertStyle : NSWarningAlertStyle; | |
alert.informativeText = error ? @"Error!" : @"Warning"; | |
alert.messageText = [NSString stringWithUTF8String:message]; | |
[alert runModal]; | |
[alert release]; | |
NSLog(@"%@: %s", error ? @"ERROR" : @"WARNING", message); | |
[pool drain]; | |
} | |
void msgbox_warning(const char *message) | |
{ | |
display_mac_alert(message, 0); | |
} | |
void msgbox_error(const char *message) | |
{ | |
display_mac_alert(message, 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment