os/macosx/macos.h
author bjarni
Thu, 02 Mar 2006 21:43:09 +0000
changeset 3127 56a9c0db7c18
parent 2847 65c54f935db6
child 4434 a08cb4b5c179
permissions -rw-r--r--
(svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
It also adds a new error window, which can be used just like assert, but it is also active when asserts are turned off
This is useful for places where it's really important to check even if assert is turned off. It's not used in the code yet
2847
65c54f935db6 (svn r3395) Add Id tag (and svn property) to macosx files.
peter1138
parents: 2223
diff changeset
     1
/* $Id$ */
65c54f935db6 (svn r3395) Add Id tag (and svn property) to macosx files.
peter1138
parents: 2223
diff changeset
     2
2188
640a0a5f77ea (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
#ifndef MACOS_H
640a0a5f77ea (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
#define MACOS_H
640a0a5f77ea (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
3127
56a9c0db7c18 (svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents: 2847
diff changeset
     6
/*
56a9c0db7c18 (svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents: 2847
diff changeset
     7
 * Functions to show the popup window
56a9c0db7c18 (svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents: 2847
diff changeset
     8
 * use ShowMacDialog when you want to control title, message and text on the button
56a9c0db7c18 (svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents: 2847
diff changeset
     9
 * ShowMacAssertDialog is used by assert
56a9c0db7c18 (svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents: 2847
diff changeset
    10
 * ShowMacErrorDialog should be used when an unrecoverable error shows up. It only contains the title, which will should tell what went wrong
56a9c0db7c18 (svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents: 2847
diff changeset
    11
 *	the function then adds text that tells the user to update and then report the bug if it's present in the newest version
56a9c0db7c18 (svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents: 2847
diff changeset
    12
 *	It also quits in a nice way since we call it when we know something happened that will crash OpenTTD (like a needed pointer turns out to be NULL or similar)
56a9c0db7c18 (svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents: 2847
diff changeset
    13
 */
2188
640a0a5f77ea (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
    14
void ShowMacDialog ( const char *title, const char *message, const char *buttonLabel );
2223
b9564d70ec3d (svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents: 2188
diff changeset
    15
void ShowMacAssertDialog ( const char *function, const char *file, const int line, const char *expression );
3127
56a9c0db7c18 (svn r3740) -Feature: [OSX] added OS version, CPU type and newGRF settings to assert window and a message to tell people to add that to a bug report
bjarni
parents: 2847
diff changeset
    16
void ShowMacErrorDialog(const char *error);
2188
640a0a5f77ea (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
2223
b9564d70ec3d (svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents: 2188
diff changeset
    18
// Since MacOS X users will never see an assert unless they started the game from a terminal
b9564d70ec3d (svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents: 2188
diff changeset
    19
// we're using a custom assert(e) macro.
b9564d70ec3d (svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents: 2188
diff changeset
    20
#undef assert
b9564d70ec3d (svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents: 2188
diff changeset
    21
b9564d70ec3d (svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents: 2188
diff changeset
    22
#ifdef NDEBUG
b9564d70ec3d (svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents: 2188
diff changeset
    23
#define assert(e)       ((void)0)
b9564d70ec3d (svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents: 2188
diff changeset
    24
#else
b9564d70ec3d (svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents: 2188
diff changeset
    25
b9564d70ec3d (svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents: 2188
diff changeset
    26
#define assert(e) \
b9564d70ec3d (svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents: 2188
diff changeset
    27
		(__builtin_expect(!(e), 0) ? ShowMacAssertDialog ( __func__, __FILE__, __LINE__, #e ): (void)0 )
b9564d70ec3d (svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents: 2188
diff changeset
    28
#endif
b9564d70ec3d (svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents: 2188
diff changeset
    29
b9564d70ec3d (svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents: 2188
diff changeset
    30
#endif /* MACOS_H */