peter1138@2847: /* $Id$ */ peter1138@2847: bjarni@2188: #ifndef MACOS_H bjarni@2188: #define MACOS_H bjarni@2188: bjarni@3127: /* bjarni@3127: * Functions to show the popup window bjarni@3127: * use ShowMacDialog when you want to control title, message and text on the button bjarni@3127: * ShowMacAssertDialog is used by assert bjarni@3127: * ShowMacErrorDialog should be used when an unrecoverable error shows up. It only contains the title, which will should tell what went wrong rubidium@4434: * the function then adds text that tells the user to update and then report the bug if it's present in the newest version rubidium@4434: * 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) bjarni@3127: */ bjarni@6192: void ShowMacDialog ( const char *title, const char *message, const char *buttonLabel ); bjarni@6192: void ShowMacAssertDialog ( const char *function, const char *file, const int line, const char *expression ); bjarni@6192: void ShowMacErrorDialog(const char *error); bjarni@2188: bjarni@2223: // Since MacOS X users will never see an assert unless they started the game from a terminal bjarni@2223: // we're using a custom assert(e) macro. bjarni@2223: #undef assert bjarni@2223: bjarni@2223: #ifdef NDEBUG bjarni@2223: #define assert(e) ((void)0) bjarni@2223: #else bjarni@2223: bjarni@2223: #define assert(e) \ bjarni@2223: (__builtin_expect(!(e), 0) ? ShowMacAssertDialog ( __func__, __FILE__, __LINE__, #e ): (void)0 ) bjarni@2223: #endif bjarni@2223: rubidium@6871: rubidium@6871: rubidium@6871: /** rubidium@6871: * Get the major version of Mac OS we are running under. Useful for things like the cocoa driver. rubidium@6871: * @return major version of the os. This would be 10 in the case of 10.4.11. rubidium@6871: */ rubidium@6871: long GetMacOSVersionMajor(); rubidium@6871: rubidium@6871: /** rubidium@6871: * Get the minor version of Mac OS we are running under. Useful for things like the cocoa driver. rubidium@6871: * @return minor version of the os. This would be 4 in the case of 10.4.11. rubidium@6871: */ rubidium@6871: long GetMacOSVersionMinor(); rubidium@6871: rubidium@6871: /** rubidium@6871: * Get the bugfix version of Mac OS we are running under. Useful for things like the cocoa driver. rubidium@6871: * @return bugfix version of the os. This would be 11 in the case of 10.4.11. rubidium@6871: */ rubidium@6871: long GetMacOSVersionBugfix(); rubidium@6871: rubidium@6871: /** rubidium@6871: * Check if we are at least running on the specified version of Mac OS. rubidium@6871: * @param major major version of the os. This would be 10 in the case of 10.4.11. rubidium@6871: * @param minor minor version of the os. This would be 4 in the case of 10.4.11. rubidium@6871: * @param bugfix bugfix version of the os. This would be 11 in the case of 10.4.11. rubidium@6871: * @return true if the running os is at least what we asked, false otherwise. rubidium@6871: */ rubidium@6871: static inline bool MacOSVersionIsAtLeast(long major, long minor, long bugfix) rubidium@6871: { rubidium@6871: long maj = GetMacOSVersionMajor(); rubidium@6871: long min = GetMacOSVersionMinor(); rubidium@6871: long bf = GetMacOSVersionBugfix(); rubidium@6871: rubidium@6871: if (maj < major) return false; rubidium@6871: if (maj == major && min < minor) return false; rubidium@6871: if (maj == major && min == minor && bf < bugfix) return false; rubidium@6871: rubidium@6871: return true; rubidium@6871: } rubidium@6871: bjarni@2223: #endif /* MACOS_H */