#include <SDL.h>
#include <SDL_image.h>
+#ifdef MACOSX
+namespace supertux_apple {
+#include <CoreFoundation/CoreFoundation.h>
+}
+#endif
+
#include "gameconfig.hpp"
#include "resources.hpp"
#include "gettext.hpp"
}
#ifdef MACOSX
+{
+ using namespace supertux_apple;
+
// when started from Application file on Mac OS X...
- dir = PHYSFS_getBaseDir();
- dir += "SuperTux.app/Contents/Resources/data";
+ char path[PATH_MAX];
+ CFBundleRef mainBundle = CFBundleGetMainBundle();
+ assert(mainBundle != 0);
+ CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
+ assert(mainBundleURL != 0);
+ CFStringRef pathStr = CFURLCopyFileSystemPath(mainBundleURL, kCFURLPOSIXPathStyle);
+ assert(pathStr != 0);
+ CFStringGetCString(pathStr, path, PATH_MAX, kCFStringEncodingUTF8);
+ CFRelease(mainBundleURL);
+ CFRelease(pathStr);
+
+ dir = std::string(path) + "/Contents/Resources/data";
testfname = dir + "/credits.txt";
sourcedir = false;
f = fopen(testfname.c_str(), "r");
sourcedir = true;
}
}
+}
#endif
#ifdef _WIN32
br_init (NULL);
dir = br_find_data_dir(APPDATADIR);
datadir = dir;
- datadir += "/" PACKAGE_NAME;
free(dir);
#else
// try to guess aspect ratio of monitor if needed
if (aspect_ratio <= 0) {
+// TODO: commented out because
+// 1) it tends to guess wrong if widescreen-monitors don't stretch 800x600 to fit, but just display black borders
+// 2) aspect ratios other than 4:3 are largely untested
+/*
if(config->use_fullscreen && desktop_width > 0) {
aspect_ratio = static_cast<double>(desktop_width) / static_cast<double>(desktop_height);
} else {
+*/
aspect_ratio = 4.0 / 3.0;
+/*
}
+*/
}
// use aspect ratio to calculate logical resolution
SDL_WM_SetCaption(PACKAGE_NAME " " PACKAGE_VERSION, 0);
// set icon
- SDL_Surface* icon = IMG_Load_RW(
- get_physfs_SDLRWops("images/engine/icons/supertux.xpm"), true);
+ #ifdef MACOSX
+ const char* icon_fname = "images/engine/icons/supertux-256x256.png";
+ #else
+ const char* icon_fname = "images/engine/icons/supertux.xpm";
+ #endif
+ SDL_Surface* icon = IMG_Load_RW(get_physfs_SDLRWops(icon_fname), true);
if(icon != 0) {
SDL_WM_SetIcon(icon, 0);
SDL_FreeSurface(icon);
}
#ifdef DEBUG
else {
- log_warning << "Couldn't find icon 'images/engine/icons/supertux.xpm'" << std::endl;
+ log_warning << "Couldn't find icon '" << icon_fname << "'" << std::endl;
}
#endif
delete main_loop;
main_loop = NULL;
- free_options_menu();
unload_shared();
quit_audio();