use NSAlert for cocoa. Carbon support totally deprecated

This commit is contained in:
Bradley Bell 2014-11-23 19:53:02 -08:00
parent 1adb29da37
commit 7f10bb28bf
2 changed files with 44 additions and 2 deletions

View file

@ -1138,7 +1138,7 @@ class DXXCommon(LazyObjectConstructor):
def adjust_environment(self,program,env):
env.Append(CPPDEFINES = ['HAVE_STRUCT_TIMESPEC', 'HAVE_STRUCT_TIMEVAL', '__unix__'])
env.Append(CPPPATH = [os.path.join(os.getenv("HOME"), 'Library/Frameworks/SDL.framework/Headers'), '/Library/Frameworks/SDL.framework/Headers'])
env.Append(FRAMEWORKS = ['ApplicationServices', 'Carbon', 'Cocoa', 'SDL'])
env.Append(FRAMEWORKS = ['ApplicationServices', 'Cocoa', 'SDL'])
if (self.user_settings.opengl == 1) or (self.user_settings.opengles == 1):
env.Append(FRAMEWORKS = ['OpenGL'])
env.Append(FRAMEWORKPATH = [os.path.join(os.getenv("HOME"), 'Library/Frameworks'), '/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks'])
@ -1463,7 +1463,7 @@ class DXXArchive(DXXCommon):
pass
class DarwinPlatformSettings(LazyObjectConstructor, DXXCommon.DarwinPlatformSettings, _PlatformSettings):
platform_objects = LazyObjectConstructor.create_lazy_object_property([
'common/arch/carbon/messagebox.cpp',
'common/arch/cocoa/messagebox.mm',
'common/arch/cocoa/SDLMain.m'
])

View file

@ -0,0 +1,42 @@
/*
* 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_cocoa_alert(const char *message, int error)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSAlert *alert = [[NSAlert alloc] init];
alert.alertStyle = error == 1 ? NSCriticalAlertStyle : NSWarningAlertStyle;
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);
}