mirror of https://github.com/OpenTTD/OpenTTD
(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)
- As a bonus, we now have an objective C file (os/macosx/macos.m) to use the functions Apple made to interact with OS stuffrelease/0.4.5
parent
238e47cd42
commit
cb3c325e5f
17
Makefile
17
Makefile
|
@ -718,6 +718,8 @@ C_SOURCES += video/null_v.c
|
||||||
|
|
||||||
CXX_SOURCES =
|
CXX_SOURCES =
|
||||||
|
|
||||||
|
OBJC_SOURCES =
|
||||||
|
|
||||||
ifdef WITH_SDL
|
ifdef WITH_SDL
|
||||||
C_SOURCES += sdl.c
|
C_SOURCES += sdl.c
|
||||||
C_SOURCES += sound/sdl_s.c
|
C_SOURCES += sound/sdl_s.c
|
||||||
|
@ -734,7 +736,11 @@ C_SOURCES += unix.c
|
||||||
C_SOURCES += music/extmidi.c
|
C_SOURCES += music/extmidi.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
OBJS = $(C_SOURCES:%.c=%.o) $(CXX_SOURCES:%.cpp=%.o)
|
ifdef OSX
|
||||||
|
OBJC_SOURCES += os/macosx/macos.m
|
||||||
|
endif
|
||||||
|
|
||||||
|
OBJS = $(C_SOURCES:%.c=%.o) $(CXX_SOURCES:%.cpp=%.o) $(OBJC_SOURCES:%.m=%.o)
|
||||||
|
|
||||||
ifdef BEOS
|
ifdef BEOS
|
||||||
CXX_SOURCES += music/bemidi.cpp
|
CXX_SOURCES += music/bemidi.cpp
|
||||||
|
@ -795,6 +801,9 @@ quiet_cmd_c_compile = '===> Compiling $<'
|
||||||
quiet_cmd_cxx_compile = '===> Compiling $<'
|
quiet_cmd_cxx_compile = '===> Compiling $<'
|
||||||
cmd_cxx_compile = $(CXX) $(COMPILE_PARAMS)
|
cmd_cxx_compile = $(CXX) $(COMPILE_PARAMS)
|
||||||
|
|
||||||
|
quiet_cmd_objc_compile = '===> Compiling $<'
|
||||||
|
cmd_objc_compile = $(CC) $(COMPILE_PARAMS)
|
||||||
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
|
@ -1036,7 +1045,7 @@ upgradeconf: $(MAKE_CONFIG)
|
||||||
### Internal build rules
|
### Internal build rules
|
||||||
|
|
||||||
# This makes sure the .deps dir is always around.
|
# This makes sure the .deps dir is always around.
|
||||||
DEPS_MAGIC := $(shell mkdir -p .deps .deps/music .deps/sound .deps/video)
|
DEPS_MAGIC := $(shell mkdir -p .deps .deps/music .deps/sound .deps/video .deps/os .deps/os/macosx)
|
||||||
|
|
||||||
# Introduce the dependencies
|
# Introduce the dependencies
|
||||||
-include $(DEPS)
|
-include $(DEPS)
|
||||||
|
@ -1054,6 +1063,10 @@ DEPS_MAGIC := $(shell mkdir -p .deps .deps/music .deps/sound .deps/video)
|
||||||
$(call cmd,cxx_compile)
|
$(call cmd,cxx_compile)
|
||||||
@mv $(<:%.cpp=%.d) $(<:%.cpp=.deps/%.d)
|
@mv $(<:%.cpp=%.d) $(<:%.cpp=.deps/%.d)
|
||||||
|
|
||||||
|
%.o: %.m $(MAKE_CONFIG) endian_target.h table/strings.h
|
||||||
|
$(call cmd,objc_compile)
|
||||||
|
@mv $(<:%.m=%.d) $(<:%.m=.deps/%.d)
|
||||||
|
|
||||||
# Silence stale header dependencies
|
# Silence stale header dependencies
|
||||||
%.h:
|
%.h:
|
||||||
@true
|
@true
|
||||||
|
|
4
fileio.c
4
fileio.c
|
@ -165,6 +165,10 @@ void FioOpenFile(int slot, const char *filename)
|
||||||
*s = tolower(*s);
|
*s = tolower(*s);
|
||||||
f = fopen(buf, "rb");
|
f = fopen(buf, "rb");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (f == NULL)
|
||||||
|
sprintf(buf, "%s%s", _path.data_dir, filename); //makes it print the primary datadir path instead of the secundary one
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
#ifndef MACOS_H
|
||||||
|
#define MACOS_H
|
||||||
|
|
||||||
|
void ShowMacDialog ( const char *title, const char *message, const char *buttonLabel );
|
||||||
|
|
||||||
|
#endif /* MACOS_H */
|
|
@ -0,0 +1,15 @@
|
||||||
|
#include <AppKit/AppKit.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
void ShowMacDialog ( const char *title, const char *message, const char *buttonLabel )
|
||||||
|
{
|
||||||
|
NSRunAlertPanel([NSString stringWithCString: title], [NSString stringWithCString: message], [NSString stringWithCString: buttonLabel], nil, nil);
|
||||||
|
}
|
||||||
|
|
11
unix.c
11
unix.c
|
@ -53,6 +53,10 @@ ULONG __stack = (1024*1024)*2; // maybe not that much is needed actually ;)
|
||||||
// ULONG __stack =
|
// ULONG __stack =
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
#include "os/macosx/macos.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
static char *_fios_path;
|
static char *_fios_path;
|
||||||
static char *_fios_save_path;
|
static char *_fios_save_path;
|
||||||
static char *_fios_scn_path;
|
static char *_fios_scn_path;
|
||||||
|
@ -467,10 +471,9 @@ void ShowInfo(const char *str)
|
||||||
void ShowOSErrorBox(const char *buf)
|
void ShowOSErrorBox(const char *buf)
|
||||||
{
|
{
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
// this creates an error in the console and then opens the console.
|
// this creates an NSAlertPanel with the contents of 'buf'
|
||||||
// Colourcodes are not used in the console, so they are skipped here
|
// this is the native and nicest way to do this on OSX
|
||||||
fprintf(stderr, "Error: %s", buf);
|
ShowMacDialog( buf, "See readme for more info\nMost likely you are missing files from the original TTD", "Quit" );
|
||||||
system("/Applications/Utilities/Console.app/Contents/MacOS/Console &");
|
|
||||||
#else
|
#else
|
||||||
// all systems, but OSX
|
// all systems, but OSX
|
||||||
fprintf(stderr, "\033[1;31mError: %s\033[0;39m\n", buf);
|
fprintf(stderr, "\033[1;31mError: %s\033[0;39m\n", buf);
|
||||||
|
|
Loading…
Reference in New Issue