src/video/cocoa_v.mm
branchgamebalance
changeset 9913 e79cd19772dd
parent 9895 7bd07f43b0e3
--- a/src/video/cocoa_v.mm	Wed Jun 13 12:05:56 2007 +0000
+++ b/src/video/cocoa_v.mm	Tue Jun 19 07:21:01 2007 +0000
@@ -71,6 +71,8 @@
 #include "../variables.h"
 #include "cocoa_v.h"
 #include "cocoa_keys.h"
+#include "../blitter/factory.hpp"
+#include "../fileio.h"
 
 #undef Point
 #undef Rect
@@ -950,6 +952,10 @@
 
 static void QZ_UpdateWindowPalette(uint start, uint count)
 {
+	/* We can only update the palette in 8bpp for now */
+	/* TODO -- We need support for other bpps too! */
+	if (BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth() != 8) return;
+
 	uint i;
 
 	switch (_cocoa_video_data.device_bpp) {
@@ -1726,6 +1732,8 @@
 
 static void QZ_VideoInit()
 {
+	if (BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth() == 0) error("Can't use a blitter that blits 0 bpp for normal visuals");
+
 	memset(&_cocoa_video_data, 0, sizeof(_cocoa_video_data));
 
 	/* Initialize the video settings; this data persists between mode switches */
@@ -2047,6 +2055,22 @@
 	_cocoa_video_dialog = false;
 }
 
+/* This is needed since OS X application bundles do not have a
+ * current directory and the data files are 'somewhere' in the bundle */
+void cocoaSetApplicationBundleDir()
+{
+	char tmp[MAXPATHLEN];
+	CFURLRef url = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle());
+	if (CFURLGetFileSystemRepresentation(url, true, (unsigned char*)tmp, MAXPATHLEN)) {
+		AppendPathSeparator(tmp, lengthof(tmp));
+		_searchpaths[SP_APPLICATION_BUNDLE_DIR] = strdup(tmp);
+	} else {
+		_searchpaths[SP_APPLICATION_BUNDLE_DIR] = NULL;
+	}
+
+	CFRelease(url);
+}
+
 /* These are called from main() to prevent a _NSAutoreleaseNoPool error when
  * exiting before the cocoa video driver has been loaded
  */