Hand-picked Mac OSX cursor and bundle path fixes from https://bitbucket.org/toabi...
authorPerttu Ahola <celeron55@gmail.com>
Sat, 18 Jun 2011 15:44:01 +0000 (18:44 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Sat, 18 Jun 2011 15:44:01 +0000 (18:44 +0300)
src/game.cpp
src/porting.cpp

index 1ab3d7962374f8ce80e3bef5aba4da48fbf3cfc9..f3fac0c84eb5bbdb6e80fbff49bf058ef32efabe 100644 (file)
@@ -1366,7 +1366,11 @@ void the_game(
                if((device->isWindowActive() && noMenuActive()) || random_input)
                {
                        if(!random_input)
-                               device->getCursorControl()->setVisible(false);
+                       {
+                               // Mac OSX gets upset if this is set every frame
+                               if(device->getCursorControl()->isVisible())
+                                       device->getCursorControl()->setVisible(false);
+                       }
 
                        if(first_loop_after_window_activation){
                                //std::cout<<"window active, first loop"<<std::endl;
@@ -1397,7 +1401,9 @@ void the_game(
                        input->setMousePos(displaycenter.X, displaycenter.Y);
                }
                else{
-                       device->getCursorControl()->setVisible(true);
+                       // Mac OSX gets upset if this is set every frame
+                       if(device->getCursorControl()->isVisible() == false)
+                               device->getCursorControl()->setVisible(true);
 
                        //std::cout<<"window inactive"<<std::endl;
                        first_loop_after_window_activation = true;
index 7c7ce48eae3a62265bab4856e867334daeff3f95..cce461be8a247a7de8156e856a606eafc71629c9 100644 (file)
@@ -214,10 +214,28 @@ void initializePaths()
        */
        #elif defined(__APPLE__)
                #include <unistd.h>
-
+               #include "CoreFoundation/CoreFoundation.h"
+
+    // Code based on
+    // http://stackoverflow.com/questions/516200/relative-paths-not-working-in-xcode-c
+    CFBundleRef main_bundle = CFBundleGetMainBundle();
+    CFURLRef resources_url = CFBundleCopyResourcesDirectoryURL(main_bundle);
+    char path[PATH_MAX];
+    if(CFURLGetFileSystemRepresentation(resources_url, TRUE, (UInt8 *)path, PATH_MAX))
+       {
+               dstream<<"Bundle resource path: "<<path<<std::endl;
+               //chdir(path);
+               path_data = std::string(path) + "/data";
+       }
+       else
+    {
+        // error!
+               dstream<<"WARNING: Could not determine bundle resource path"<<std::endl;
+    }
+    CFRelease(resources_url);
+       
        path_userdata = std::string(getenv("HOME")) + "/Library/Application Support/" + APPNAME;
-       path_data = std::string("minetest-mac.app/Contents/Resources/data/");
-
+    
        #endif
 
 #endif // RUN_IN_PLACE