author | peter1138 |
Thu, 12 Jan 2006 11:20:41 +0000 | |
changeset 2847 | 5c667829bc67 |
parent 2827 | 61e2ac8b0801 |
child 3127 | c734d50ad134 |
permissions | -rw-r--r-- |
2847
5c667829bc67
(svn r3395) Add Id tag (and svn property) to macosx files.
peter1138
parents:
2827
diff
changeset
|
1 |
/* $Id$ */ |
5c667829bc67
(svn r3395) Add Id tag (and svn property) to macosx files.
peter1138
parents:
2827
diff
changeset
|
2 |
|
2188
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
3 |
#include <AppKit/AppKit.h> |
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
4 |
|
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
5 |
/* |
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
6 |
* This file contains objective C |
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
7 |
* Apple uses objective C instead of plain C to interact with OS specific/native functions |
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
8 |
* |
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
9 |
* Note: TrueLight's crosscompiler can handle this, but it likely needs a manual modification for each change in this file. |
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
10 |
* To insure that the crosscompiler still works, let him try any changes before they are committed |
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
11 |
*/ |
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
12 |
|
2827
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
13 |
|
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
14 |
#ifdef WITH_SDL |
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
15 |
|
2188
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
16 |
void ShowMacDialog ( const char *title, const char *message, const char *buttonLabel ) |
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
17 |
{ |
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
18 |
NSRunAlertPanel([NSString stringWithCString: title], [NSString stringWithCString: message], [NSString stringWithCString: buttonLabel], nil, nil); |
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
19 |
} |
9acde6fcc645
(svn r2703) - Feature: [OSX] Added a native alert window to show whatever error() needs to print (Tobin made this, while I fixed some issued in it)
bjarni
parents:
diff
changeset
|
20 |
|
2827
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
21 |
#elif defined WITH_COCOA |
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
22 |
|
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
23 |
void CocoaDialog ( const char *title, const char *message, const char *buttonLabel ); |
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
24 |
|
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
25 |
void ShowMacDialog ( const char *title, const char *message, const char *buttonLabel ) |
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
26 |
{ |
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
27 |
CocoaDialog(title, message, buttonLabel); |
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
28 |
} |
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
29 |
|
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
30 |
|
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
31 |
#else |
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
32 |
|
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
33 |
void ShowMacDialog ( const char *title, const char *message, const char *buttonLabel ) |
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
34 |
{ |
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
35 |
fprintf(stderr, "%s: %s\n", title, message); |
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
36 |
} |
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
37 |
|
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
38 |
#endif |
61e2ac8b0801
(svn r3375) -Add: [ FS#29 ] show an error dialog for OSX cocoa driver (egladil)
truelight
parents:
2741
diff
changeset
|
39 |
|
2223
29d61b962cb0
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
40 |
void ShowMacAssertDialog ( const char *function, const char *file, const int line, const char *expression ) |
29d61b962cb0
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
41 |
{ |
2736
1ea068235989
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2223
diff
changeset
|
42 |
const char *buffer = |
2223
29d61b962cb0
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
43 |
[[NSString stringWithFormat:@"An assertion has failed and OpenTTD must quit.\n%s in %s (line %d)\n\"%s\"\n\nYou should report this error the OpenTTD developers if you think you found a bug.", |
2741
011462ebb67b
(svn r3286) -Fix: [OSX] 10.2 works again and universal binaries got 10.2 as target by default
bjarni
parents:
2736
diff
changeset
|
44 |
function, file, line, expression] cString]; |
2223
29d61b962cb0
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
45 |
NSLog(@"%s", buffer); |
29d61b962cb0
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
46 |
ShowMacDialog( "Assertion Failed", buffer, "Quit" ); |
2736
1ea068235989
(svn r3281) -Feature: [OSX] added native cocoa sound and video drivers (egladil)
bjarni
parents:
2223
diff
changeset
|
47 |
|
2223
29d61b962cb0
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
48 |
// abort so that a debugger has a chance to notice |
29d61b962cb0
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
49 |
abort(); |
29d61b962cb0
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
50 |
} |