author | peter1138 |
Sun, 03 Aug 2008 17:35:08 +0000 | |
changeset 9834 | 7474149531c1 |
parent 9776 | 056e0e5c964a |
permissions | -rw-r--r-- |
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 |
|
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
7965
diff
changeset
|
3 |
/** @file macos.h Functions related to MacOS support. */ |
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
7965
diff
changeset
|
4 |
|
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
|
5 |
#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
|
6 |
#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
|
7 |
|
9776
056e0e5c964a
(svn r13913) -Fix (r13893): [OSX] fixed a warning about MAC_OS_X_VERSION_10_5 not being defined on all systems
bjarni
parents:
9111
diff
changeset
|
8 |
/* It would seem that to ensure backward compability we have to ensure that we have defined MAC_OS_X_VERSION_10_x everywhere */ |
056e0e5c964a
(svn r13913) -Fix (r13893): [OSX] fixed a warning about MAC_OS_X_VERSION_10_5 not being defined on all systems
bjarni
parents:
9111
diff
changeset
|
9 |
#ifndef MAC_OS_X_VERSION_10_3 |
056e0e5c964a
(svn r13913) -Fix (r13893): [OSX] fixed a warning about MAC_OS_X_VERSION_10_5 not being defined on all systems
bjarni
parents:
9111
diff
changeset
|
10 |
#define MAC_OS_X_VERSION_10_3 1030 |
056e0e5c964a
(svn r13913) -Fix (r13893): [OSX] fixed a warning about MAC_OS_X_VERSION_10_5 not being defined on all systems
bjarni
parents:
9111
diff
changeset
|
11 |
#endif |
056e0e5c964a
(svn r13913) -Fix (r13893): [OSX] fixed a warning about MAC_OS_X_VERSION_10_5 not being defined on all systems
bjarni
parents:
9111
diff
changeset
|
12 |
|
056e0e5c964a
(svn r13913) -Fix (r13893): [OSX] fixed a warning about MAC_OS_X_VERSION_10_5 not being defined on all systems
bjarni
parents:
9111
diff
changeset
|
13 |
#ifndef MAC_OS_X_VERSION_10_4 |
056e0e5c964a
(svn r13913) -Fix (r13893): [OSX] fixed a warning about MAC_OS_X_VERSION_10_5 not being defined on all systems
bjarni
parents:
9111
diff
changeset
|
14 |
#define MAC_OS_X_VERSION_10_4 1040 |
056e0e5c964a
(svn r13913) -Fix (r13893): [OSX] fixed a warning about MAC_OS_X_VERSION_10_5 not being defined on all systems
bjarni
parents:
9111
diff
changeset
|
15 |
#endif |
056e0e5c964a
(svn r13913) -Fix (r13893): [OSX] fixed a warning about MAC_OS_X_VERSION_10_5 not being defined on all systems
bjarni
parents:
9111
diff
changeset
|
16 |
|
056e0e5c964a
(svn r13913) -Fix (r13893): [OSX] fixed a warning about MAC_OS_X_VERSION_10_5 not being defined on all systems
bjarni
parents:
9111
diff
changeset
|
17 |
#ifndef MAC_OS_X_VERSION_10_5 |
056e0e5c964a
(svn r13913) -Fix (r13893): [OSX] fixed a warning about MAC_OS_X_VERSION_10_5 not being defined on all systems
bjarni
parents:
9111
diff
changeset
|
18 |
#define MAC_OS_X_VERSION_10_5 1050 |
056e0e5c964a
(svn r13913) -Fix (r13893): [OSX] fixed a warning about MAC_OS_X_VERSION_10_5 not being defined on all systems
bjarni
parents:
9111
diff
changeset
|
19 |
#endif |
056e0e5c964a
(svn r13913) -Fix (r13893): [OSX] fixed a warning about MAC_OS_X_VERSION_10_5 not being defined on all systems
bjarni
parents:
9111
diff
changeset
|
20 |
|
056e0e5c964a
(svn r13913) -Fix (r13893): [OSX] fixed a warning about MAC_OS_X_VERSION_10_5 not being defined on all systems
bjarni
parents:
9111
diff
changeset
|
21 |
|
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
|
22 |
/* |
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
|
23 |
* 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
|
24 |
* 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
|
25 |
* 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
|
26 |
* ShowMacErrorDialog should be used when an unrecoverable error shows up. It only contains the title, which will should tell what went wrong |
4434
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
3127
diff
changeset
|
27 |
* the function then adds text that tells the user to update and then report the bug if it's present in the newest version |
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
3127
diff
changeset
|
28 |
* 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) |
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
|
29 |
*/ |
5941
adaea39e84ab
(svn r8605) -Codechange: [OSX] changed all objective C to objective C++
bjarni
parents:
5587
diff
changeset
|
30 |
void ShowMacDialog ( const char *title, const char *message, const char *buttonLabel ); |
adaea39e84ab
(svn r8605) -Codechange: [OSX] changed all objective C to objective C++
bjarni
parents:
5587
diff
changeset
|
31 |
void ShowMacAssertDialog ( const char *function, const char *file, const int line, const char *expression ); |
adaea39e84ab
(svn r8605) -Codechange: [OSX] changed all objective C to objective C++
bjarni
parents:
5587
diff
changeset
|
32 |
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
|
33 |
|
2223
b9564d70ec3d
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
34 |
// 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
|
35 |
// 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
|
36 |
#undef assert |
b9564d70ec3d
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
37 |
|
b9564d70ec3d
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
38 |
#ifdef NDEBUG |
b9564d70ec3d
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
39 |
#define assert(e) ((void)0) |
b9564d70ec3d
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
40 |
#else |
b9564d70ec3d
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
41 |
|
b9564d70ec3d
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
42 |
#define assert(e) \ |
b9564d70ec3d
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
43 |
(__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
|
44 |
#endif |
b9564d70ec3d
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
45 |
|
7965
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
46 |
|
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
47 |
|
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
48 |
/** |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
49 |
* Get the major version of Mac OS we are running under. Useful for things like the cocoa driver. |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
50 |
* @return major version of the os. This would be 10 in the case of 10.4.11. |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
51 |
*/ |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
52 |
long GetMacOSVersionMajor(); |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
53 |
|
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
54 |
/** |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
55 |
* Get the minor version of Mac OS we are running under. Useful for things like the cocoa driver. |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
56 |
* @return minor version of the os. This would be 4 in the case of 10.4.11. |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
57 |
*/ |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
58 |
long GetMacOSVersionMinor(); |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
59 |
|
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
60 |
/** |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
61 |
* Get the bugfix version of Mac OS we are running under. Useful for things like the cocoa driver. |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
62 |
* @return bugfix version of the os. This would be 11 in the case of 10.4.11. |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
63 |
*/ |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
64 |
long GetMacOSVersionBugfix(); |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
65 |
|
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
66 |
/** |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
67 |
* Check if we are at least running on the specified version of Mac OS. |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
68 |
* @param major major version of the os. This would be 10 in the case of 10.4.11. |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
69 |
* @param minor minor version of the os. This would be 4 in the case of 10.4.11. |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
70 |
* @param bugfix bugfix version of the os. This would be 11 in the case of 10.4.11. |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
71 |
* @return true if the running os is at least what we asked, false otherwise. |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
72 |
*/ |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
73 |
static inline bool MacOSVersionIsAtLeast(long major, long minor, long bugfix) |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
74 |
{ |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
75 |
long maj = GetMacOSVersionMajor(); |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
76 |
long min = GetMacOSVersionMinor(); |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
77 |
long bf = GetMacOSVersionBugfix(); |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
78 |
|
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
79 |
if (maj < major) return false; |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
80 |
if (maj == major && min < minor) return false; |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
81 |
if (maj == major && min == minor && bf < bugfix) return false; |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
82 |
|
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
83 |
return true; |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
84 |
} |
e651c71175d6
(svn r11521) -Codechange: [OSX] Check what the running os version is in a cleaner way.
egladil
parents:
5941
diff
changeset
|
85 |
|
2223
b9564d70ec3d
(svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents:
2188
diff
changeset
|
86 |
#endif /* MACOS_H */ |