enigma-dev/enigma-dev — pull request #813 by sorlok (2014-09-04 14:58:58+00:00)
Title: Final (possibly contentious) changes for OS-X

This pull request is a superset of https://github.com/enigma-dev/enigma-dev/pull/812; it contains additional changes that might be challenged from an OS-X point of view (as I am not a very good OS-X developer). It allows for full cross-compilation, and fixes some issues I found with building on OS-X itself.

First, a very brief overview of how OS-X apps work. Unlike Windows, which bundles everything into the same binary, and Linux, which has lots of files in all the right places, OS-X uses an application directory as the "executable". The actual binary is inside this folder, along with an "Info.plist" describing how to launch the app and find any resources (icons, etc.) the app might need.

So here's what this pull request changes (in addition to https://github.com/enigma-dev/enigma-dev/pull/812).

1. Removed the working_directory code from CocoaFunctions.cpp, and added it to main.cpp. The main problem here was that (a) every other platform sets the working directory in main and (b) the code in CocoaFunctions (which triggers on the first call to draw()) did not actually work (setting the working_directory to the empty string, if the app was launched by double-clicking on it). My code (also in main.m) works, although the question of where *in* the application bundle the working_directory should point is still open.

2. Adds an Info.plist to our skeleton bundle directory. This allows building OS-X games from LateralGM, which is essential for cross-compilation. If the app is built through X-Code, I assume that X-Code will create the Info.plist file. This file is necessary to run the app! I have also added a default Icon for the app based on the ENIGMA logo. We can overwrite this with the game's icon file, but we'll need to generate a Mac ".icns" format icon from the Windows ".ico" format. (We could also allow the user to specify a .icns and .ico file separately, which is what GM:S does.) For now, it's easy enough for the user to overwrite this icon after building their app (this is what Iji does).

3. Added MainMenu.nib; a file that is used for creating a MainMenu for the game (and is referenced in Info.plist). This is the only file I'm not 100% sure about; I think it's harmless to leave it in the repo, but perhaps there are other opinions on this (maybe we don't want menus in games? Other platforms don't have them).

Anyway, please let me know what you think. I'd especially like to hear from the OS-X developers, because the last thing I'd want to do is step on your toes.