peter1138@2847: /* $Id$ */ peter1138@2847: rubidium@9111: /** @file macos.h Functions related to MacOS support. */ rubidium@9111: 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@5941: void ShowMacDialog ( const char *title, const char *message, const char *buttonLabel ); bjarni@5941: void ShowMacAssertDialog ( const char *function, const char *file, const int line, const char *expression ); bjarni@5941: 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: egladil@7965: egladil@7965: egladil@7965: /** egladil@7965: * Get the major version of Mac OS we are running under. Useful for things like the cocoa driver. egladil@7965: * @return major version of the os. This would be 10 in the case of 10.4.11. egladil@7965: */ egladil@7965: long GetMacOSVersionMajor(); egladil@7965: egladil@7965: /** egladil@7965: * Get the minor version of Mac OS we are running under. Useful for things like the cocoa driver. egladil@7965: * @return minor version of the os. This would be 4 in the case of 10.4.11. egladil@7965: */ egladil@7965: long GetMacOSVersionMinor(); egladil@7965: egladil@7965: /** egladil@7965: * Get the bugfix version of Mac OS we are running under. Useful for things like the cocoa driver. egladil@7965: * @return bugfix version of the os. This would be 11 in the case of 10.4.11. egladil@7965: */ egladil@7965: long GetMacOSVersionBugfix(); egladil@7965: egladil@7965: /** egladil@7965: * Check if we are at least running on the specified version of Mac OS. egladil@7965: * @param major major version of the os. This would be 10 in the case of 10.4.11. egladil@7965: * @param minor minor version of the os. This would be 4 in the case of 10.4.11. egladil@7965: * @param bugfix bugfix version of the os. This would be 11 in the case of 10.4.11. egladil@7965: * @return true if the running os is at least what we asked, false otherwise. egladil@7965: */ egladil@7965: static inline bool MacOSVersionIsAtLeast(long major, long minor, long bugfix) egladil@7965: { egladil@7965: long maj = GetMacOSVersionMajor(); egladil@7965: long min = GetMacOSVersionMinor(); egladil@7965: long bf = GetMacOSVersionBugfix(); egladil@7965: egladil@7965: if (maj < major) return false; egladil@7965: if (maj == major && min < minor) return false; egladil@7965: if (maj == major && min == minor && bf < bugfix) return false; egladil@7965: egladil@7965: return true; egladil@7965: } egladil@7965: bjarni@2223: #endif /* MACOS_H */