summaryrefslogtreecommitdiff
path: root/os/macosx/macos.m
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-01-02 19:19:48 +0000
committerrubidium <rubidium@openttd.org>2007-01-02 19:19:48 +0000
commit013df98f79866a75f367853c9e436f3c5c79f645 (patch)
treead4a63860df2626b22f77e7dac712e958bea54cb /os/macosx/macos.m
parent3d32fd3f4bfaceb8a48530fbc2f4bd5db2752596 (diff)
downloadopenttd-013df98f79866a75f367853c9e436f3c5c79f645.tar.xz
(svn r7759) -Merge: makefile rewrite. This merge features:
- A proper ./configure, so everything needs to be configured only once, not for every make. - Usage of makedepend when available. This greatly reduces the time needed for generating the dependencies. - A generator for all project files. There is a single file with sources, which is used to generate Makefiles and the project files for MSVC. - Proper support for OSX universal binaries. - Object files for non-MSVC compiles are also placed in separate directories, making is faster to switch between debug and release compiles and it does not touch the directory with the source files. - Functionality to make a bundle of all needed files for for example a nightly or distribution of a binary with all needed GRFs and language files. Note: as this merge moves almost all files, it is recommended to make a backup of your working copy before updating your working copy.
Diffstat (limited to 'os/macosx/macos.m')
-rw-r--r--os/macosx/macos.m162
1 files changed, 0 insertions, 162 deletions
diff --git a/os/macosx/macos.m b/os/macosx/macos.m
deleted file mode 100644
index 59801fce0..000000000
--- a/os/macosx/macos.m
+++ /dev/null
@@ -1,162 +0,0 @@
-/* $Id$ */
-
-#include <AppKit/AppKit.h>
-
-#include <mach/mach.h>
-#include <mach/mach_host.h>
-#include <mach/host_info.h>
-#include <mach/machine.h>
-#include <stdio.h>
-#include "../../stdafx.h"
-#include "../../openttd.h"
-#include "../../newgrf.h"
-#include "../../gfx.h"
-#include "../../macros.h"
-#include "../../string.h"
-
-#ifndef CPU_SUBTYPE_POWERPC_970
-#define CPU_SUBTYPE_POWERPC_970 ((cpu_subtype_t) 100)
-#endif
-
-/*
- * This file contains objective C
- * Apple uses objective C instead of plain C to interact with OS specific/native functions
- *
- * Note: TrueLight's crosscompiler can handle this, but it likely needs a manual modification for each change in this file.
- * To insure that the crosscompiler still works, let him try any changes before they are committed
- */
-
-static char *GetOSString(void)
-{
- static char buffer[175];
- const char* CPU;
- char OS[20];
- char newgrf[125];
- long sysVersion;
- extern const char _openttd_revision[];
-
- // get the hardware info
- host_basic_info_data_t hostInfo;
- mach_msg_type_number_t infoCount;
-
- infoCount = HOST_BASIC_INFO_COUNT;
- host_info(
- mach_host_self(), HOST_BASIC_INFO, (host_info_t)&hostInfo, &infoCount
- );
-
- // replace the hardware info with strings, that tells a bit more than just an int
- switch (hostInfo.cpu_subtype) {
-#ifdef __POWERPC__
- case CPU_SUBTYPE_POWERPC_750: CPU = "G3"; break;
- case CPU_SUBTYPE_POWERPC_7400:
- case CPU_SUBTYPE_POWERPC_7450: CPU = "G4"; break;
- case CPU_SUBTYPE_POWERPC_970: CPU = "G5"; break;
- default: CPU = "Unknown PPC"; break;
-#else
- /* it looks odd to have a switch for two cases, but it leaves room for easy
- * expansion. Odds are that Apple will some day use newer CPUs than i686
- */
- case CPU_SUBTYPE_PENTPRO: CPU = "i686"; break;
- default: CPU = "Unknown Intel"; break;
-#endif
- }
-
- // get the version of OSX
- if (Gestalt(gestaltSystemVersion, &sysVersion) != noErr) {
- sprintf(OS, "Undetected");
- } else {
- int majorHiNib = GB(sysVersion, 12, 4);
- int majorLoNib = GB(sysVersion, 8, 4);
- int minorNib = GB(sysVersion, 4, 4);
- int bugNib = GB(sysVersion, 0, 4);
-
- sprintf(OS, "%d%d.%d.%d", majorHiNib, majorLoNib, minorNib, bugNib);
- }
-
- // make a list of used newgrf files
- if (_first_grffile != NULL) {
- char* n = newgrf;
- const GRFFile* file;
-
- for (file = _first_grffile; file != NULL; file = file->next) {
- n = strecpy(n, " ", lastof(newgrf));
- n = strecpy(n, file->filename, lastof(newgrf));
- }
- } else {
- sprintf(newgrf, "none");
- }
-
- snprintf(
- buffer, lengthof(buffer),
- "Please add this info: (tip: copy-paste works)\n"
- "CPU: %s, OSX: %s, OpenTTD version: %s\n"
- "NewGRF files:%s",
- CPU, OS, _openttd_revision, newgrf
- );
- return buffer;
-}
-
-
-#ifdef WITH_SDL
-
-void ShowMacDialog(const char* title, const char* message, const char* buttonLabel)
-{
- NSRunAlertPanel([NSString stringWithCString: title], [NSString stringWithCString: message], [NSString stringWithCString: buttonLabel], nil, nil);
-}
-
-#elif defined WITH_COCOA
-
-void CocoaDialog(const char* title, const char* message, const char* buttonLabel);
-
-void ShowMacDialog(const char* title, const char* message, const char* buttonLabel)
-{
- CocoaDialog(title, message, buttonLabel);
-}
-
-
-#else
-
-void ShowMacDialog(const char* title, const char* message, const char* buttonLabel)
-{
- fprintf(stderr, "%s: %s\n", title, message);
-}
-
-#endif
-
-void ShowMacAssertDialog(const char* function, const char* file, const int line, const char* expression)
-{
- const char* buffer =
- [[NSString stringWithFormat:@
- "An assertion has failed and OpenTTD must quit.\n"
- "%s in %s (line %d)\n"
- "\"%s\"\n"
- "\n"
- "You should report this error the OpenTTD developers if you think you found a bug.\n"
- "\n"
- "%s",
- function, file, line, expression, GetOSString()] cString
- ];
- NSLog(@"%s", buffer);
- ToggleFullScreen(0);
- ShowMacDialog("Assertion Failed", buffer, "Quit");
-
- // abort so that a debugger has a chance to notice
- abort();
-}
-
-
-void ShowMacErrorDialog(const char *error)
-{
- const char* buffer =
- [[NSString stringWithFormat:@
- "Please update to the newest version of OpenTTD\n"
- "If the problem presists, please report this to\n"
- "http://bugs.openttd.org\n"
- "\n"
- "%s",
- GetOSString()] cString
- ];
- ToggleFullScreen(0);
- ShowMacDialog(error, buffer, "Quit");
- abort();
-}