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: egladil@8461: egladil@8461: egladil@8461: /** egladil@8461: * Get the major version of Mac OS we are running under. Useful for things like the cocoa driver. egladil@8461: * @return major version of the os. This would be 10 in the case of 10.4.11. egladil@8461: */ egladil@8461: long GetMacOSVersionMajor(); egladil@8461: egladil@8461: /** egladil@8461: * Get the minor version of Mac OS we are running under. Useful for things like the cocoa driver. egladil@8461: * @return minor version of the os. This would be 4 in the case of 10.4.11. egladil@8461: */ egladil@8461: long GetMacOSVersionMinor(); egladil@8461: egladil@8461: /** egladil@8461: * Get the bugfix version of Mac OS we are running under. Useful for things like the cocoa driver. egladil@8461: * @return bugfix version of the os. This would be 11 in the case of 10.4.11. egladil@8461: */ egladil@8461: long GetMacOSVersionBugfix(); egladil@8461: egladil@8461: /** egladil@8461: * Check if we are at least running on the specified version of Mac OS. egladil@8461: * @param major major version of the os. This would be 10 in the case of 10.4.11. egladil@8461: * @param minor minor version of the os. This would be 4 in the case of 10.4.11. egladil@8461: * @param bugfix bugfix version of the os. This would be 11 in the case of 10.4.11. egladil@8461: * @return true if the running os is at least what we asked, false otherwise. egladil@8461: */ egladil@8461: static inline bool MacOSVersionIsAtLeast(long major, long minor, long bugfix) egladil@8461: { egladil@8461: long maj = GetMacOSVersionMajor(); egladil@8461: long min = GetMacOSVersionMinor(); egladil@8461: long bf = GetMacOSVersionBugfix(); egladil@8461: egladil@8461: if (maj < major) return false; egladil@8461: if (maj == major && min < minor) return false; egladil@8461: if (maj == major && min == minor && bf < bugfix) return false; egladil@8461: egladil@8461: return true; egladil@8461: } egladil@8461: bjarni@2223: #endif /* MACOS_H */