X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fmain.cpp;h=cca8615e3dd46cd7f6274a470ff05011c58af03f;hb=47e305953079bdd3fb7079ee1bbce4edd2b6cb7b;hp=ade5d5d8df5990ac2eb7da955adbf1ede11ade89;hpb=9aa7909e583ee203065b37d75169cb1dcbfcdf12;p=supertux.git diff --git a/src/main.cpp b/src/main.cpp index ade5d5d8d..cca8615e3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,6 +34,12 @@ #include #include +#ifdef MACOSX +namespace supertux_apple { +#include +} +#endif + #include "gameconfig.hpp" #include "resources.hpp" #include "gettext.hpp" @@ -164,9 +170,22 @@ static void init_physfs(const char* argv0) } #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"); @@ -178,6 +197,7 @@ static void init_physfs(const char* argv0) sourcedir = true; } } +} #endif #ifdef _WIN32 @@ -381,11 +401,18 @@ void init_video() // 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(desktop_width) / static_cast(desktop_height); } else { +*/ aspect_ratio = 4.0 / 3.0; +/* } +*/ } // use aspect ratio to calculate logical resolution @@ -582,7 +609,6 @@ int main(int argc, char** argv) delete main_loop; main_loop = NULL; - free_options_menu(); unload_shared(); quit_audio();