diff --git a/Doc/Version-bump.txt b/Doc/Version-bump.txt index fb5a64f34..5a1e8d6d4 100644 --- a/Doc/Version-bump.txt +++ b/Doc/Version-bump.txt @@ -1,16 +1,13 @@ Prior to release: - Minor & Major versions: -installers/autopackage/default.x86.apspec -installers/autopackage/default.x86_64.apspec -src/Cocoa/Info-Oolite.plist -src/Cocoa/oolite-version.xcconfig +Resources/Info-gnustep.plist Resources/InfoPlist.strings (twice. note: UTF-16) DebugOXP/Debug.oxp/manifest.plist +README.md +installers/flatpak/space.oolite.Oolite.yaml - Major versions: -Doc/OoliteReadMe.doc -Doc/OoliteReadMe.pdf http://wiki.alioth.net/index.php/Oolite_Instruction_Manual#Playing_the_game http://wiki.alioth.net/index.php/Pilot%27s_Reference_Manual DebugOXP/Resources/oolite-debug-console.js diff --git a/src/Cocoa/Info-Oolite.plist b/Resources/Info-gnustep.plist similarity index 100% rename from src/Cocoa/Info-Oolite.plist rename to Resources/Info-gnustep.plist diff --git a/ShellScripts/common/post_build.sh b/ShellScripts/common/post_build.sh index cc6871a1d..8f2676a29 100755 --- a/ShellScripts/common/post_build.sh +++ b/ShellScripts/common/post_build.sh @@ -38,7 +38,6 @@ run_script() { return 1 fi generate_manifest "$resourcesdir/manifest.plist" "$deployment_release" "$ver_full" "$ver_quad" "$ver_githash" "$buildtime" - cp -fu src/Cocoa/Info-Oolite.plist "$resourcesdir/Info-gnustep.plist" if [[ "$deployment_release" == "no" ]]; then local addonsdir="$progdir/AddOns" mkdir -p "$addonsdir" diff --git a/src/Cocoa/Comparison.h b/src/Cocoa/Comparison.h deleted file mode 100644 index b3d494efe..000000000 --- a/src/Cocoa/Comparison.h +++ /dev/null @@ -1 +0,0 @@ -// Empty for OS X, compatibility stuff for GNUstep. diff --git a/src/Cocoa/JAPersistentFileReference.h b/src/Cocoa/JAPersistentFileReference.h deleted file mode 100644 index e5a15ac0d..000000000 --- a/src/Cocoa/JAPersistentFileReference.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - -JAPersistentFileReference.h - -Store file references in a property list format. For file URLs, uses bookmark -data (when available) and aliases to track files even if they're moved or -renamed. - - -Copyright (C) 2010-2013 Jens Ayton - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -*/ - -#import - - -enum -{ - kJAPersistentFileReferenceWithoutUI = 0x00000001UL, // Avoid user interaction. - kJAPersistentFileReferenceWithoutMounting = 0x00000002UL, // Avoid mounting volumes. - kJAPersistentFileReferenceReturnReferenceURL = 0x00000004UL // Return a file reference URL if possible. -}; - -typedef uint32_t JAPersistentFileReferenceResolveFlags; - - -NSDictionary *JAPersistentFileReferenceFromURL(NSURL *url); -NSURL *JAURLFromPersistentFileReference(NSDictionary *fileRef, JAPersistentFileReferenceResolveFlags flags, BOOL *isStale); - -NSDictionary *JAPersistentFileReferenceFromPath(NSString *path); -NSString *JAPathFromPersistentFileReference(NSDictionary *fileRef, JAPersistentFileReferenceResolveFlags flags, BOOL *isStale); diff --git a/src/Cocoa/JAPersistentFileReference.m b/src/Cocoa/JAPersistentFileReference.m deleted file mode 100644 index e45303cfa..000000000 --- a/src/Cocoa/JAPersistentFileReference.m +++ /dev/null @@ -1,244 +0,0 @@ -/* - -JAPersistentFileReference.m - - -Copyright (C) 2010-2013 Jens Ayton - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -*/ - -#import "JAPersistentFileReference.h" -#import - - -#define kURLKey @"url" -#define kAliasKey @"alias" -#define kBookmarkKey @"bookmark" - - -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 -#define BookmarkDataSupported() (YES) -#else -#if __ppc__ || __ppc64__ -// Bookmark data is only available in Snow Leopard and later, which excludes PPC systems. -#define BookmarkDataSupported() (NO) -#else -#define BookmarkDataSupported() ([NSURL instancesRespondToSelector:@selector(bookmarkDataWithOptions:includingResourceValuesForKeys:relativeToURL:error:)]) -#endif - - -#if MAC_OS_X_VERSION_10_6 > MAC_OS_X_VERSION_MAX_ALLOWED - -@interface NSURL (SnowLeopardMethods) - -- (NSData *)bookmarkDataWithOptions:(unsigned long)options includingResourceValuesForKeys:(NSArray *)keys relativeToURL:(NSURL *)relativeURL error:(NSError **)error; -- (NSURL *)fileReferenceURL; -- (NSURL *)filePathURL; -- (BOOL)isFileReferenceURL; -+ (id)URLByResolvingBookmarkData:(NSData *)bookmarkData options:(unsigned long)options relativeToURL:(NSURL *)relativeURL bookmarkDataIsStale:(BOOL *)isStale error:(NSError **)error; - -@end - - -enum -{ - NSURLBookmarkResolutionWithoutUI = ( 1UL << 8 ), - NSURLBookmarkResolutionWithoutMounting = ( 1UL << 9 ), -}; - -#endif -#endif - - -NSDictionary *JAPersistentFileReferenceFromURL(NSURL *url) -{ - if (url == nil) return nil; - - NSMutableDictionary *result = [NSMutableDictionary dictionaryWithCapacity:3]; - [result setObject:[url absoluteString] forKey:kURLKey]; - - if ([url isFileURL]) - { - FSRef fsRef; - if (CFURLGetFSRef((CFURLRef)[url absoluteURL], &fsRef)) - { - AliasHandle alias = NULL; - if (FSNewAlias(NULL, &fsRef, &alias) == noErr) - { - NSData *aliasData = [NSData dataWithBytes:*alias length:GetAliasSize(alias)]; - if (aliasData != NULL) - { - [result setObject:aliasData forKey:kAliasKey]; - } - DisposeHandle((Handle)alias); - } - } - } - - if (BookmarkDataSupported()) - { - NSURL *refURL = [url fileReferenceURL]; - if (refURL != nil) - { - NSData *bookmarkData = [refURL bookmarkDataWithOptions:0 - includingResourceValuesForKeys:nil - relativeToURL:nil - error:NULL]; - if (bookmarkData != nil) - { - [result setObject:bookmarkData forKey:kBookmarkKey]; - } - } - } - - return result; -} - - -static inline unsigned long BookmarkOptionsFromFlags(JAPersistentFileReferenceResolveFlags flags) -{ - unsigned long result = 0; - if (flags & kJAPersistentFileReferenceWithoutUI) result |= NSURLBookmarkResolutionWithoutUI; - if (flags & NSURLBookmarkResolutionWithoutMounting) result |= NSURLBookmarkResolutionWithoutMounting; - return result; -} - - -static inline unsigned long AliasMountFlagsFromFlags(JAPersistentFileReferenceResolveFlags flags) -{ - unsigned long result = 0; - if (flags & kJAPersistentFileReferenceWithoutUI) result |= kResolveAliasFileNoUI; - return result; -} - - -NSURL *JAURLFromPersistentFileReference(NSDictionary *fileRef, JAPersistentFileReferenceResolveFlags flags, BOOL *isStale) -{ - NSURL *result = nil; - BOOL stale = NO, staleIfFile = NO; - - // Try bookmark. - if (BookmarkDataSupported()) - { - NSData *bookmarkData = [fileRef objectForKey:kBookmarkKey]; - if ([bookmarkData isKindOfClass:[NSData class]]) - { - result = [NSURL URLByResolvingBookmarkData:bookmarkData - options:BookmarkOptionsFromFlags(flags) - relativeToURL:nil - bookmarkDataIsStale:&stale - error:NULL]; - } - else staleIfFile = YES; - } - - // Try alias. - if (result == nil) - { - NSData *aliasData = [fileRef objectForKey:kAliasKey]; - if ([aliasData isKindOfClass:[NSData class]]) - { - size_t size = [aliasData length]; - AliasHandle alias = (AliasHandle)NewHandle(size); - if (alias != NULL) - { - memcpy(*alias, [aliasData bytes], size); - FSRef fsRef; - - Boolean carbonStale; - if (FSResolveAliasWithMountFlags(NULL, alias, &fsRef, &carbonStale, AliasMountFlagsFromFlags(flags)) == noErr) - { - stale = carbonStale; - result = (NSURL *)CFURLCreateFromFSRef(kCFAllocatorDefault, &fsRef); -#if 1050 <= MAC_OS_X_VERSION_MAX_ALLOWED - CFMakeCollectable((CFURLRef)result); -#endif - [result autorelease]; - } - DisposeHandle((Handle)alias); - } - } - else staleIfFile = YES; - } - - // Try URL. - if (result == nil) - { - NSString *urlString = [fileRef objectForKey:kURLKey]; - if ([urlString isKindOfClass:[NSString class]]) - { - result = [NSURL URLWithString:urlString relativeToURL:nil]; - if ([result isFileURL] && ![[NSFileManager defaultManager] fileExistsAtPath:[result path]]) - { - result = nil; - } - } - } - - // If we got nothing, it's definitely stale. - if (result == nil) - { - stale = YES; - } - else - { - if ([result isFileURL] && staleIfFile) stale = YES; - - // Convert to/from file reference URL as appropriate. - if (BookmarkDataSupported()) - { - if (flags & kJAPersistentFileReferenceReturnReferenceURL) - { - if (![result isFileReferenceURL] && [result isFileURL]) - { - NSURL *refURL = [result fileReferenceURL]; - if (refURL != nil) result = refURL; - } - } - else - { - if ([result isFileReferenceURL]) - { - NSURL *pathURL = [result filePathURL]; - if (pathURL != nil) result = pathURL; - } - } - } - } - - - if (isStale != NULL) *isStale = stale; - return result; -} - - -NSDictionary *JAPersistentFileReferenceFromPath(NSString *path) -{ - return JAPersistentFileReferenceFromURL([NSURL fileURLWithPath:path]); -} - - -NSString *JAPathFromPersistentFileReference(NSDictionary *fileRef, JAPersistentFileReferenceResolveFlags flags, BOOL *isStale) -{ - NSURL *url = JAURLFromPersistentFileReference(fileRef, flags & ~kJAPersistentFileReferenceReturnReferenceURL, isStale); - if ([url isFileURL]) return [url path]; - return nil; -} diff --git a/src/Cocoa/MyOpenGLView.h b/src/Cocoa/MyOpenGLView.h deleted file mode 100644 index 1b032c93f..000000000 --- a/src/Cocoa/MyOpenGLView.h +++ /dev/null @@ -1,277 +0,0 @@ -/* - -MyOpenGLView.h - -Oolite -Copyright (C) 2004-2013 Giles C Williams and contributors - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -MA 02110-1301, USA. - -*/ - -#import "OOCocoa.h" -#import "OOOpenGL.h" -#import "OOMouseInteractionMode.h" -#import "OOOpenGLMatrixManager.h" - - -#define MAX_CLEAR_DEPTH 10000000000.0 -// 10 000 000 km. -#define INTERMEDIATE_CLEAR_DEPTH 50000.0 -// 100 m. - -#define MIN_FOV_DEG 30.0f -#define MAX_FOV_DEG 80.0f -#define MIN_FOV (tan((MIN_FOV_DEG / 2) * M_PI / 180.0f)) -#define MAX_FOV (tan((MAX_FOV_DEG / 2) * M_PI / 180.0f)) - -#define NUM_KEYS 327 -#define MOUSE_DOUBLE_CLICK_INTERVAL 0.40 -#define OOMOUSEWHEEL_EVENTS_DELAY_INTERVAL 0.05 -#define OOMOUSEWHEEL_DELTA 1.0 - -@class Entity, GameController; - -enum GameViewKeys -{ - - gvFunctionKey1 = 256, - gvFunctionKey2, - gvFunctionKey3, - gvFunctionKey4, - gvFunctionKey5, // 260 - gvFunctionKey6, - gvFunctionKey7, - gvFunctionKey8, - gvFunctionKey9, - gvFunctionKey10, - gvFunctionKey11, - gvArrowKeyRight, - gvArrowKeyLeft, - gvArrowKeyDown, - gvArrowKeyUp, // 270 - gvPauseKey, - gvPrintScreenKey, // 272 - gvMouseLeftButton = 301, - gvMouseDoubleClick, - gvHomeKey, - gvEndKey, - gvInsertKey, - gvDeleteKey, - gvPageUpKey, - gvPageDownKey, - gvBackspaceKey, // 309 - gvNumberKey0 = 48, - gvNumberKey1, - gvNumberKey2, - gvNumberKey3, - gvNumberKey4, - gvNumberKey5, - gvNumberKey6, - gvNumberKey7, - gvNumberKey8, - gvNumberKey9, // 57 - gvNumberPadKey0 = 310, - gvNumberPadKey1, - gvNumberPadKey2, - gvNumberPadKey3, - gvNumberPadKey4, - gvNumberPadKey5, - gvNumberPadKey6, - gvNumberPadKey7, - gvNumberPadKey8, - gvNumberPadKey9, - gvNumberPadKeyDivide, // 320 - gvNumberPadKeyMultiply, - gvNumberPadKeyMinus, - gvNumberPadKeyPlus, - gvNumberPadKeyPeriod, - gvNumberPadKeyEquals, - gvNumberPadKeyEnter // 326 -}; - -enum MouseWheelStatus -{ - gvMouseWheelDown = -1, - gvMouseWheelNeutral, - gvMouseWheelUp -}; - -enum StringInput -{ - gvStringInputNo = 0, - gvStringInputAlpha = 1, - gvStringInputLoadSave = 2, - gvStringInputAll = 3 -}; - -extern int debug; - -@interface MyOpenGLView: NSOpenGLView -{ -@private - GameController *gameController; - - BOOL keys[NUM_KEYS]; - int scancode2Unicode[NUM_KEYS]; - NSDictionary *keyMappings_normal; - NSDictionary *keyMappings_shifted; - - BOOL suppressKeys; // DJS - - BOOL opt, ctrl, command, shift, capsLockOn, lastKeyShifted; - BOOL allowingStringInput; - BOOL isAlphabetKeyDown; - BOOL commandQ; - BOOL commandF; - BOOL f12; - - int keycodetrans[255]; - - BOOL m_glContextInitialized; - - NSTimeInterval timeIntervalAtLastClick; - NSTimeInterval timeIntervalAtLastMouseWheel; - BOOL doubleClick; - - NSMutableString *typedString; - - NSPoint virtualJoystickPosition; - float _mouseWheelDelta; - - NSSize viewSize; - NSSize backingViewSize; - GLfloat display_z; - GLfloat x_offset, y_offset; - - float _fov; - - int _virtualScreen; - NSData *_pixelFormatAttributes; - - OOOpenGLMatrixManager *matrixManager; - -} - - -- (void) initKeyMappingData; -- (void) setStringInput: (enum StringInput) value; -- (void) allowStringInput: (BOOL) value; -- (enum StringInput) allowingStringInput; -- (NSString *) typedString; -- (void) resetTypedString; -- (void) setTypedString:(NSString*) value; - -- (NSSize) viewSize; -- (NSSize) backingViewSize; -- (GLfloat) display_z; -- (GLfloat) x_offset; -- (GLfloat) y_offset; - -- (GameController *) gameController; -- (void) setGameController:(GameController *) controller; - -- (void) noteMouseInteractionModeChangedFrom:(OOMouseInteractionMode)oldMode to:(OOMouseInteractionMode)newMode; - -- (void) initialiseGLWithSize:(NSSize) v_size; - -- (NSData *)pixelFormatAttributes; - -- (void) drawRect:(NSRect)rect; -- (void) updateScreen; -- (void) pollControls; - -- (void) stringToClipboard:(NSString *)stringToCopy; - -- (BOOL) snapShot:(NSString *)filename; - -- (void)mouseDown:(NSEvent *)theEvent; -- (void)mouseUp:(NSEvent *)theEvent; -- (void)resetMouse; - -- (void) setVirtualJoystick:(double) vmx :(double) vmy; -- (NSPoint) virtualJoystickPosition; - -- (void) clearKeys; -- (void) clearMouse; -- (void) clearKey: (int)theKey; -- (BOOL) isAlphabetKeyDown; -- (void) suppressKeysUntilKeyUp; // DJS -- (BOOL) isDown: (int) key; -- (BOOL) isOptDown; -- (BOOL) isCtrlDown; -- (BOOL) isCommandDown; -- (BOOL) isShiftDown; -- (BOOL) isCapsLockOn; -- (BOOL) lastKeyWasShifted; -- (int) numKeys; -- (int) mouseWheelState; -- (float) mouseWheelDelta; -- (void) setMouseWheelDelta: (float) newWheelDelta; - -// Command-key combinations need special handling. -- (BOOL) isCommandQDown; -- (BOOL) isCommandFDown; -- (void) clearCommandF; - -// Check current state of shift key rather than relying on last event. -+ (BOOL)pollShiftKey; - -- (OOOpenGLMatrixManager *) getOpenGLMatrixManager; - -#ifndef NDEBUG -// General image-dumping methods. -- (void) dumpRGBAToFileNamed:(NSString *)name - bytes:(uint8_t *)bytes - width:(NSUInteger)width - height:(NSUInteger)height - rowBytes:(NSUInteger)rowBytes; - -- (void) dumpRGBToFileNamed:(NSString *)name - bytes:(uint8_t *)bytes - width:(NSUInteger)width - height:(NSUInteger)height - rowBytes:(NSUInteger)rowBytes; - -- (void) dumpGrayToFileNamed:(NSString *)name - bytes:(uint8_t *)bytes - width:(NSUInteger)width - height:(NSUInteger)height - rowBytes:(NSUInteger)rowBytes; - -- (void) dumpGrayAlphaToFileNamed:(NSString *)name - bytes:(uint8_t *)bytes - width:(NSUInteger)width - height:(NSUInteger)height - rowBytes:(NSUInteger)rowBytes; - -// Split alpha into separate file. -- (void) dumpRGBAToRGBFileNamed:(NSString *)rgbName - andGrayFileNamed:(NSString *)grayName - bytes:(uint8_t *)bytes - width:(NSUInteger)width - height:(NSUInteger)height - rowBytes:(NSUInteger)rowBytes; -#endif - -// no-ops to allow gamma value to be easily saved/restored -- (void) setGammaValue: (float) value; -- (float) gammaValue; - -- (void) setFov:(float)value fromFraction:(BOOL)fromFraction; -- (float) fov:(BOOL)inFraction; - -@end diff --git a/src/Cocoa/MyOpenGLView.m b/src/Cocoa/MyOpenGLView.m deleted file mode 100644 index fee2c6ae8..000000000 --- a/src/Cocoa/MyOpenGLView.m +++ /dev/null @@ -1,1381 +0,0 @@ -/* - -MyOpenGLView.m - -Oolite -Copyright (C) 2004-2013 Giles C Williams and contributors - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -MA 02110-1301, USA. - -*/ - -#import "MyOpenGLView.h" - -#import "GameController.h" -#import "Universe.h" -#import "Entity.h" -#import "OOPlanetEntity.h" -#import "ResourceManager.h" -#import "GuiDisplayGen.h" -#import -#import "NSFileManagerOOExtensions.h" -#import "OOGraphicsResetManager.h" -#import "PlayerEntity.h" - -#ifndef NDEBUG -#import -#endif - - -static NSString * kOOLogKeyCodeOutOfRange = @"input.keyMapping.codeOutOfRange"; -static NSString * kOOLogKeyUp = @"input.keyMapping.keyPress.keyUp"; -static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown"; - - -static void GetDesiredCursorState(OOMouseInteractionMode mode, BOOL *outHidden, BOOL *outObscured); -static void ApplyCursorState(OOMouseInteractionMode mode); -static void UnapplyCursorState(OOMouseInteractionMode mode); - - -@interface MyOpenGLView(Internal) - -- (int) translateKeyCode:(int)input; - -- (void) recenterVirtualJoystick; - -@end - - -#if !OOLITE_MAC_OS_X_10_7 -@interface NSView (Lion) - -- (BOOL) wantsBestResolutionOpenGLSurface; -- (void) setWantsBestResolutionOpenGLSurface:(BOOL)flag; - -- (NSPoint) convertPointToBacking:(NSPoint)aPoint; -- (NSPoint) convertPointFromBacking:(NSPoint)aPoint; -- (NSSize) convertSizeToBacking:(NSSize)aSize; -- (NSSize) convertSizeFromBacking:(NSSize)aSize; -- (NSRect) convertRectToBacking:(NSRect)aRect; -- (NSRect) convertRectFromBacking:(NSRect)aRect; - -@end -#endif - - -@implementation MyOpenGLView - -- (id) initWithFrame:(NSRect)frameRect -{ -#ifndef NDEBUG - if (NSZombieEnabled) - { - OOLog(@"debug.zombieEnabled", @"*** ZOMBIES WILL EAT YOUR BRAIN ***"); - } -#endif - - // Pixel Format Attributes for the View-based (non-FullScreen) NSOpenGLContext - NSOpenGLPixelFormatAttribute attrs[] = - { - // Specify that we want a windowed OpenGL context. - // Must be first or we'll hit an assert in the legacy fullscreen controller. - NSOpenGLPFAWindow, - - // We may be on a multi-display system (and each screen may be driven by a different renderer), so we need to specify which screen we want to take over. - // For this demo, we'll specify the main screen. - NSOpenGLPFAScreenMask, CGDisplayIDToOpenGLDisplayMask(kCGDirectMainDisplay), - - // Specifying "NoRecovery" gives us a context that cannot fall back to the software renderer. - // This makes the View-based context a compatible with the fullscreen context, enabling us to use the "shareContext" - // feature to share textures, display lists, and other OpenGL objects between the two. - NSOpenGLPFANoRecovery, - - // Attributes Common to FullScreen and non-FullScreen - NSOpenGLPFACompliant, - - NSOpenGLPFAColorSize, 32, - NSOpenGLPFADepthSize, 32, - NSOpenGLPFADoubleBuffer, - NSOpenGLPFAAccelerated, -#if FSAA - // Need a preference or other sane way to activate this - NSOpenGLPFAMultisample, - NSOpenGLPFASampleBuffers, 1, - NSOpenGLPFASamples,4, -#endif - 0 - }; - - // Create our non-FullScreen pixel format. - NSOpenGLPixelFormat *pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attrs] autorelease]; - - if ((self = [super initWithFrame:frameRect pixelFormat:pixelFormat])) - { - if ([self respondsToSelector:@selector(setAcceptsTouchEvents:)]) - { - [self setAcceptsTouchEvents:YES]; - } - - if ([self respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)]) - { - // Enable high resolution on Retina displays. - [self setWantsBestResolutionOpenGLSurface:YES]; - } - - matrixManager = [[OOOpenGLMatrixManager alloc] init]; - _pixelFormatAttributes = [[NSData alloc] initWithBytes:attrs length:sizeof attrs]; - virtualJoystickPosition = NSMakePoint(0.0,0.0); - - typedString = [[NSMutableString alloc] initWithString:@""]; - allowingStringInput = gvStringInputNo; - isAlphabetKeyDown = NO; - - timeIntervalAtLastClick = [NSDate timeIntervalSinceReferenceDate]; - - _virtualScreen = [[self openGLContext] currentVirtualScreen]; - } - - // preload the printscreen key into our translation array because SDLK_PRINTSCREEN isn't available - scancode2Unicode[55] = gvPrintScreenKey; - [self initKeyMappingData]; - - return self; -} - -- (void) initKeyMappingData -{ - NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; - NSDictionary *kmap = [NSDictionary dictionaryWithDictionary:[ResourceManager dictionaryFromFilesNamed:@"keymappings_mac.plist" inFolder:@"Config" mergeMode:MERGE_BASIC cache:NO]]; - // get the stored keyboard code from preferences - NSString *kbd = [prefs oo_stringForKey:@"keyboard-code" defaultValue:@"default"]; - NSDictionary *subset = [kmap objectForKey:kbd]; - - [keyMappings_normal release]; - keyMappings_normal = [[subset objectForKey:@"mapping_normal"] copy]; - [keyMappings_shifted release]; - keyMappings_shifted = [[subset objectForKey:@"mapping_shifted"] copy]; -} - - -- (void) dealloc -{ - DESTROY(typedString); - DESTROY(_pixelFormatAttributes); - DESTROY(matrixManager); - - if (keyMappings_normal) - [keyMappings_normal release]; - if (keyMappings_shifted) - [keyMappings_shifted release]; - - [super dealloc]; -} - - -- (void) setStringInput:(enum StringInput)value -{ - allowingStringInput = value; -} - - -- (void) allowStringInput:(BOOL)value -{ - if (value) - { - allowingStringInput = gvStringInputAlpha; - } - else - { - allowingStringInput = gvStringInputNo; - } -} - -- (enum StringInput) allowingStringInput -{ - return allowingStringInput; -} - - -- (NSString *) typedString -{ - return typedString; -} - - -- (void) resetTypedString -{ - [typedString setString:@""]; -} - - -- (void) setTypedString:(NSString *)value -{ - [typedString setString:value]; -} - - -- (NSSize) viewSize -{ - return viewSize; -} - - -- (NSSize) backingViewSize -{ - return backingViewSize; -} - - -- (GLfloat) display_z -{ - return display_z; -} - - -- (GLfloat) x_offset -{ - return x_offset; -} - - -- (GLfloat) y_offset -{ - return y_offset; -} - - -- (GameController *) gameController -{ - return gameController; -} - - -- (void) setGameController:(GameController *) controller -{ - gameController = controller; -} - - -- (void) noteMouseInteractionModeChangedFrom:(OOMouseInteractionMode)oldMode to:(OOMouseInteractionMode)newMode -{ - UnapplyCursorState(oldMode); - ApplyCursorState(newMode); -} - - -- (void) updateScreen -{ - if ([[self window] isVisible]) - { - [self drawRect:NSMakeRect(0, 0, viewSize.width, viewSize.height)]; - } -} - -- (void) pollControls -{ - if ([NSDate timeIntervalSinceReferenceDate] > timeIntervalAtLastMouseWheel + OOMOUSEWHEEL_EVENTS_DELAY_INTERVAL) - _mouseWheelDelta = 0.0f; -} - -- (void) drawRect:(NSRect)rect -{ - if ((viewSize.width != [self frame].size.width)||(viewSize.height != [self frame].size.height)) // resized - { - m_glContextInitialized = NO; - viewSize = [self frame].size; - } - - if (!m_glContextInitialized) [self initialiseGLWithSize:viewSize]; - - // do all the drawing! - if (UNIVERSE != nil) [UNIVERSE drawUniverse]; - else - { - // not set up yet, draw a black screen - OOGL(glClearColor(0.0, 0.0, 0.0, 0.0)); - OOGL(glClear(GL_COLOR_BUFFER_BIT)); - } - - [[self openGLContext] flushBuffer]; -} - - -- (void) noteMovedToBadDisplay -{ - NSRunInformationalAlertPanel(DESC(@"oolite-mac-bad-display"), @"%@", nil, nil, nil, DESC(@"oolite-mac-bad-display-2")); -} - - -- (void) update -{ - NSOpenGLContext *context = [self openGLContext]; - - [context update]; - int virtualScreen = [context currentVirtualScreen]; - if (virtualScreen != _virtualScreen) - { - @try - { - [[OOGraphicsResetManager sharedManager] resetGraphicsState]; - _virtualScreen = virtualScreen; - } - @catch (NSException *exception) - { - /* Graphics reset failed, most likely because of OpenGL context - incompatibility. Reset to previous "virtual screen" (i.e., - renderer). OS X's OpenGL implementation will take care of - copying - */ - [context setCurrentVirtualScreen:_virtualScreen]; - [[OOGraphicsResetManager sharedManager] resetGraphicsState]; // If this throws, we're screwed. - - if ([[self gameController] inFullScreenMode]) - { - [[self gameController] pauseFullScreenModeToPerform:@selector(noteMovedToBadDisplay) onTarget:self]; - } - else - { - [self noteMovedToBadDisplay]; - } - } - } -} - - -- (void) initialiseGLWithSize:(NSSize)v_size -{ - viewSize = v_size; - if (viewSize.width/viewSize.height > 4.0/3.0) { - display_z = 480.0 * viewSize.width/viewSize.height; - x_offset = 240.0 * viewSize.width/viewSize.height; - y_offset = 240.0; - } else { - display_z = 640.0; - x_offset = 320.0; - y_offset = 320.0 * viewSize.height/viewSize.width; - } - - if ([self respondsToSelector:@selector(convertSizeToBacking:)]) - { - // High resolution mode support. - backingViewSize = [self convertSizeToBacking:viewSize]; - } - else - { - backingViewSize = viewSize; - } - - [self openGLContext]; // Force lazy setup if needed. - [[self gameController] setUpBasicOpenGLStateWithSize:v_size]; - [[self openGLContext] flushBuffer]; - - m_glContextInitialized = YES; -} - - -- (NSData *)pixelFormatAttributes -{ - return _pixelFormatAttributes; -} - - -#ifdef MAC_OS_X_VERSION_10_7 // If building against 10.7 SDK, where relevant symbols are defined... -- (void) viewDidMoveToWindow -{ - /* Subscribe to NSWindowDidChangeBackingPropertiesNotification on systems - which support it (10.7 and later). This notification fires when the - scale factor or colour space of the window's backing store changes. - We use it to track scale factor changes. - */ - if (&NSWindowDidChangeBackingPropertiesNotification != NULL && [self.window respondsToSelector:@selector(backingScaleFactor)]) - { - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(backingPropertiesChanged:) - name:NSWindowDidChangeBackingPropertiesNotification - object:self.window]; - - // Also, ensure the initial state makes sense. - [self backingPropertiesChanged:nil]; - } -} - - -- (void) backingPropertiesChanged:(NSNotification *)notification -{ - GLSetDisplayScaleFactor(self.window.backingScaleFactor); -} -#endif - - -- (BOOL) snapShot:(NSString *)filename -{ - BOOL snapShotOK = YES; - NSSize v_size = backingViewSize; - - int w = v_size.width; - int h = v_size.height; - - if (w & 3) - w = w + 4 - (w & 3); - - long nPixels = w * h + 1; - - unsigned char *red = (unsigned char *)malloc(nPixels); - unsigned char *green = (unsigned char *)malloc(nPixels); - unsigned char *blue = (unsigned char *)malloc(nPixels); - - // backup the previous directory - NSString *originalDirectory = [[NSFileManager defaultManager] currentDirectoryPath]; - // use the snapshots directory - NSString *snapshotsDirectory = [[[GameController sharedController] snapshotsURLCreatingIfNeeded:YES] path]; - if (![[NSFileManager defaultManager] changeCurrentDirectoryPath:snapshotsDirectory]) - { - NSBeep(); - OOLog(@"savedSnapshot.defaultPath.chdir.failed", @"Could not navigate to %@", snapshotsDirectory); - snapShotOK = NO; - goto FAIL; - } - - BOOL withFilename = (filename != nil); - static unsigned imageNo = 0; - unsigned tmpImageNo = 0; - NSString *pathToPic = nil; - NSString *baseName = @"oolite"; - - if (withFilename) - { - baseName = filename; - pathToPic = [filename stringByAppendingString:@".png"]; - } - else - { - tmpImageNo = imageNo; - } - - if (withFilename && [[NSFileManager defaultManager] fileExistsAtPath:pathToPic]) - { - OOLog(@"screenshot.filenameExists", @"Snapshot \"%@.png\" already exists - adding numerical sequence.", pathToPic); - pathToPic = nil; - } - - if (pathToPic == nil) - { - do - { - tmpImageNo++; - pathToPic = [NSString stringWithFormat:@"%@-%03d.png", baseName, tmpImageNo]; - } while ([[NSFileManager defaultManager] fileExistsAtPath:pathToPic]); - } - - if (!withFilename) - { - imageNo = tmpImageNo; - } - - OOLog(@"screenshot", @"Saved screen shot \"%@\" (%u x %u pixels).", pathToPic, w, h); - - NSBitmapImageRep* bitmapRep = - [[NSBitmapImageRep alloc] - initWithBitmapDataPlanes:NULL // --> let the class allocate it - pixelsWide: w - pixelsHigh: h - bitsPerSample: 8 // each component is 8 bits (1 byte) - samplesPerPixel: 3 // number of components (R, G, B) - hasAlpha: NO // no transparency - isPlanar: NO // data integrated into single plane - colorSpaceName: NSDeviceRGBColorSpace - bytesPerRow: 3*w // can no longer let the class figure it out - bitsPerPixel: 24 // can no longer let the class figure it out - ]; - - unsigned char *pixels = [bitmapRep bitmapData]; - - OOGL(glReadPixels(0,0, w,h, GL_RED, GL_UNSIGNED_BYTE, red)); - OOGL(glReadPixels(0,0, w,h, GL_GREEN, GL_UNSIGNED_BYTE, green)); - OOGL(glReadPixels(0,0, w,h, GL_BLUE, GL_UNSIGNED_BYTE, blue)); - - int x,y; - for (y = 0; y < h; y++) - { - long index = (h - y - 1)*w; - for (x = 0; x < w; x++) // set bitmap pixels - { - *pixels++ = red[index]; - *pixels++ = green[index]; - *pixels++ = blue[index++]; - } - } - - [[bitmapRep representationUsingType:NSPNGFileType properties:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], NSImageInterlaced, NULL]] - writeToFile:pathToPic atomically:YES]; // save PNG representation of image - - // free allocated objects and memory - [bitmapRep release]; - -FAIL: - free(red); - free(green); - free(blue); - - // return to the previous directory - [[NSFileManager defaultManager] changeCurrentDirectoryPath:originalDirectory]; - return snapShotOK; -} - - -- (void) stringToClipboard:(NSString *)stringToCopy -{ - NSPasteboard *clipBoard = [NSPasteboard generalPasteboard]; - [clipBoard declareTypes:[NSArray arrayWithObject:NSPasteboardTypeString] owner:nil]; - [clipBoard setString:stringToCopy forType:NSPasteboardTypeString]; -} - - -- (BOOL) acceptsFirstResponder -{ - return YES; -} - - -- (void) keyUp:(NSEvent *)theEvent -{ - NSString *stringValue = nil; - int key; - int keycode; - - stringValue = [theEvent charactersIgnoringModifiers]; - - /* Bug: exception when releasing accent key. - Analysis: Dead keys (accents and similar) return an empty string. - Fix: reject zero-length strings. This is the Wrong Thing - we should - really be using KeyTranslate()/UCKeyTranslate() to find out what the - string would be if you pressed the key and then space. - -- Ahruman 20070714 - */ - if ([stringValue length] < 1) return; - - suppressKeys = NO; - - keycode = [theEvent keyCode] & 255; - key = keycodetrans[keycode]; // retrieve the character we got for pressing the hardware at key location 'keycode' - - OOLog(kOOLogKeyUp, @"Key up: stringValue = \"%@\", keyCode = %d, key = %u", stringValue, keycode, key); - - // Special handling of command keys used in full-screen mode. - if ([theEvent modifierFlags] & NSCommandKeyMask) - { - switch (key) - { - case 'q': - commandQ = NO; - break; - - case 'f': - commandF = NO; - break; - } - // Pass through to allow clearing of normal key as well. - } - - /* HACK: treat f12 as alias to cmd-F for compatibility with helpful forum - advice etc. - */ - if (key == NSF12FunctionKey) - { - commandF = NO; - f12 = NO; - return; - }; - - isAlphabetKeyDown = NO; - if ((key >= 0)&&(key < [self numKeys])&&(keys[key])) - { - keys[key] = NO; - } - else - { - if (key > [self numKeys]) - OOLog(kOOLogKeyCodeOutOfRange, @"Translated key: %d out of range", key); - } -} - - -- (void) keyDown:(NSEvent *)theEvent -{ - NSString *stringValue = nil; - int key; - int keycode; - - stringValue = [theEvent charactersIgnoringModifiers]; - - /* Bug: exception when pressing accent key. - Analysis: Dead keys (accents and similar) return an empty string. - Fix: reject zero-length strings. This is the Wrong Thing - we should - really be using KeyTranslate()/UCKeyTranslate() to find out what the - string would be if you pressed the key and then space. - -- Ahruman 20070714 - */ - //if ([stringValue length] < 1) return; - - keycode = [theEvent keyCode] & 255; - - if ([stringValue length] < 1) - { - if (!shift) - { - NSString *keyNormal = [keyMappings_normal objectForKey:[NSString stringWithFormat:@"%d", keycode]]; - if (keyNormal) stringValue = [NSString stringWithFormat:@"%c", [keyNormal integerValue]]; - } - else - { - NSString *keyShifted = [keyMappings_shifted objectForKey:[NSString stringWithFormat:@"%d", keycode]]; - if (keyShifted) stringValue = [NSString stringWithFormat:@"%c", [keyShifted integerValue]]; - } - // if we still have a zero-length string, return at this point - if ([stringValue length] < 1) return; - } - - key = [stringValue characterAtIndex:0]; - key = [self translateKeyCode:key]; - - OOLog(kOOLogKeyDown, @"Key down: stringValue = \"%@\", keyCode = %d, key = %u", stringValue, keycode, key); - - // Special handling of command keys used in full-screen mode. - if ([theEvent modifierFlags] & NSCommandKeyMask) - { - switch (key) - { - case 'q': - commandQ = YES; - break; - - case 'f': - commandF = YES; - break; - } - - return; - } - - keycodetrans[keycode] = key; // record the character we got for pressing the hardware at key location 'keycode' - - /* HACK: treat f12 as alias to cmd-F for compatibility with helpful forum - advice etc. - */ - if (key == NSF12FunctionKey) - { - if (!f12) - { - f12 = YES; - [gameController performSelector:@selector(toggleFullScreenAction:) withObject:nil afterDelay:0.0]; - } - - return; - }; - - if ((key >= 0)&&(key < [self numKeys])&&(!keys[key])) - { - keys[key] = YES; - - if (allowingStringInput) - { - if ((key == gvDeleteKey || key == gvBackspaceKey) && [typedString length] > 0) - { - // delete - [typedString deleteCharactersInRange:NSMakeRange([typedString length] - 1, 1)]; - } - - isAlphabetKeyDown = NO; - lastKeyShifted = shift; - - // limited input for planet find screen - if (allowingStringInput == gvStringInputAlpha) - { - if (isalpha(key)) - { - isAlphabetKeyDown = YES; - // convert to lower case - [typedString appendFormat:@"%c", tolower(key)]; - } - } - - // full input for load-save screen or 'all' input - if (allowingStringInput >= gvStringInputLoadSave) - { - // except '/' for loadsave - if (isprint(key) && key != '/') - { - isAlphabetKeyDown = YES; - [typedString appendFormat:@"%c", key]; - } - else if (key == '/' && allowingStringInput == gvStringInputAll) - { - isAlphabetKeyDown = YES; - [typedString appendFormat:@"%c", key]; - } - } - - } - } - else - { - if (key > [self numKeys]) - { - OOLog(kOOLogKeyCodeOutOfRange, @"Translated key: %d out of range", key); - } - } -} - -/* Capture shift, ctrl, opt and command press & release */ -- (void)flagsChanged:(NSEvent *)theEvent -{ - NSUInteger flags = [theEvent modifierFlags]; - opt = (flags & NSAlternateKeyMask) ? YES : NO; - ctrl = (flags & NSControlKeyMask) ? YES : NO; - command = (flags & NSCommandKeyMask) ? YES : NO; - shift = ( flags & NSShiftKeyMask ) ? YES : NO; - if ([theEvent keyCode] == 0x39) // 57 = key code for caps lock - { - capsLockOn = (flags & NSAlphaShiftKeyMask) ? YES : NO; - } -} - - -- (void)mouseDown:(NSEvent *)theEvent -{ - if (doubleClick) - { - doubleClick = NO; - keys[gvMouseDoubleClick] = NO; - } - keys[gvMouseLeftButton] = YES; // 'a' down -} - - -- (void)mouseUp:(NSEvent *)theEvent -{ - NSTimeInterval timeBetweenClicks = [NSDate timeIntervalSinceReferenceDate] - timeIntervalAtLastClick; - timeIntervalAtLastClick += timeBetweenClicks; - - if (!doubleClick) - { - doubleClick = (timeBetweenClicks < MOUSE_DOUBLE_CLICK_INTERVAL); // One fifth of a second - keys[gvMouseDoubleClick] = doubleClick; - } - - keys[gvMouseLeftButton] = NO; // 'a' up -} - - -- (void)resetMouse -{ - CGPoint centerPoint = CGPointMake(viewSize.width / 2.0, viewSize.height / 2.0); - CGWarpMouseCursorPosition(centerPoint); - [self setVirtualJoystick:0.0 :0.0]; -} - - -- (void)mouseMoved:(NSEvent *)theEvent -{ - double mx = [theEvent locationInWindow].x - viewSize.width/2.0; - double my = [theEvent locationInWindow].y - viewSize.height/2.0; - - if (display_z > 640.0) - { - mx /= viewSize.width * MAIN_GUI_PIXEL_WIDTH / display_z; - my /= viewSize.height; - } - else - { - mx /= MAIN_GUI_PIXEL_WIDTH * viewSize.width / 640.0; - my /= MAIN_GUI_PIXEL_HEIGHT * viewSize.width / 640.0; - } - - [self setVirtualJoystick:mx :-my]; -} - - -- (void) mouseDragged:(NSEvent *)theEvent -{ - [self mouseMoved:theEvent]; -} - -- (void)scrollWheel:(NSEvent *)theEvent -{ - float dy = [theEvent scrollingDeltaY]; - - if (dy == 0) - return; - - if (dy > 0) - { - if (_mouseWheelDelta >= 0) - _mouseWheelDelta += dy; - else - _mouseWheelDelta = 0; - } - else - { - if (_mouseWheelDelta <= 0) - _mouseWheelDelta += dy; - else - _mouseWheelDelta = 0; - } - timeIntervalAtLastMouseWheel = [NSDate timeIntervalSinceReferenceDate]; -} - -- (void) otherMouseDragged:(NSEvent *)theEvent -{ - [self mouseMoved:theEvent]; -} - - -- (void) rightMouseDown:(NSEvent *)theEvent -{ - [self resetMouse]; -} - - -- (void) rightMouseUp:(NSEvent *)theEvent -{ - [self recenterVirtualJoystick]; -} - - -- (void) touchesEndedWithEvent:(NSEvent *)theEvent -{ - [self recenterVirtualJoystick]; -} - - -- (void) recenterVirtualJoystick -{ - if ([PLAYER guiScreen] == GUI_SCREEN_MAIN) - { - [[GameController sharedController] recenterVirtualJoystick]; - } -} - - -///////////////////////////////////////////////////////////// -/* Turn the Cocoa ArrowKeys into our arrow key constants. */ -- (int) translateKeyCode: (int) input -{ - int key = input; - switch ( input ) - { - case NSUpArrowFunctionKey: - key = gvArrowKeyUp; - break; - - case NSDownArrowFunctionKey: - key = gvArrowKeyDown; - break; - - case NSLeftArrowFunctionKey: - key = gvArrowKeyLeft; - break; - - case NSRightArrowFunctionKey: - key = gvArrowKeyRight; - break; - - case NSF1FunctionKey: - key = gvFunctionKey1; - break; - - case NSF2FunctionKey: - key = gvFunctionKey2; - break; - - case NSF3FunctionKey: - key = gvFunctionKey3; - break; - - case NSF4FunctionKey: - key = gvFunctionKey4; - break; - - case NSF5FunctionKey: - key = gvFunctionKey5; - break; - - case NSF6FunctionKey: - key = gvFunctionKey6; - break; - - case NSF7FunctionKey: - key = gvFunctionKey7; - break; - - case NSF8FunctionKey: - key = gvFunctionKey8; - break; - - case NSF9FunctionKey: - key = gvFunctionKey9; - break; - - case NSF10FunctionKey: - key = gvFunctionKey10; - break; - - case NSF11FunctionKey: - key = gvFunctionKey11; - break; - - case NSHomeFunctionKey: - key = gvHomeKey; - break; - - case NSBackspaceCharacter: - key = gvBackspaceKey; - break; - - case NSDeleteCharacter: - key = gvDeleteKey; - break; - - case NSInsertFunctionKey: - key = gvInsertKey; - break; - - case NSEndFunctionKey: - key = gvEndKey; - break; - - case NSPageUpFunctionKey: - key = gvPageUpKey; - break; - - case NSPageDownFunctionKey: - key = gvPageDownKey; - break; - - case NSPrintScreenFunctionKey: - key = gvPrintScreenKey; - break; - - case NSPauseFunctionKey: - key = gvPauseKey; - break; - - default: - break; - } - return key; -} - - -- (void) setVirtualJoystick:(double) vmx :(double) vmy -{ - virtualJoystickPosition.x = vmx; - virtualJoystickPosition.y = vmy; -} - - -- (NSPoint) virtualJoystickPosition -{ - return virtualJoystickPosition; -} - - -///////////////////////////////////////////////////////////// - -- (void) clearKeys -{ - int i; - lastKeyShifted = NO; - for (i = 0; i < [self numKeys]; i++) - keys[i] = NO; -} - - -- (void) clearMouse -{ - keys[gvMouseDoubleClick] = NO; - keys[gvMouseLeftButton] = NO; - doubleClick = NO; -} - - -- (void) clearKey: (int)theKey -{ - if (theKey >= 0 && theKey < [self numKeys]) - { - keys[theKey] = NO; - } -} - - -- (BOOL) isAlphabetKeyDown -{ - return isAlphabetKeyDown = NO; -} - -// DJS: When entering submenus in the gui, it is not helpful if the -// key down that brought you into the submenu is still registered -// as down when we're in. This makes isDown return NO until a key up -// event has been received from SDL. -- (void) suppressKeysUntilKeyUp -{ - if (keys[gvMouseDoubleClick] == NO) - { - suppressKeys = YES; - [self clearKeys]; - } - else - { - [self clearMouse]; - } -} - - -- (BOOL) isDown: (int) key -{ - if( suppressKeys ) - return NO; - if ( key < 0 ) - return NO; - if ( key >= [self numKeys] ) - return NO; - return keys[key]; -} - - -- (BOOL) isOptDown -{ - return opt; -} - - -- (BOOL) isCtrlDown -{ - return ctrl; -} - - -- (BOOL) isCommandDown -{ - return command; -} - - -- (BOOL) isShiftDown -{ - return shift; -} - - -- (BOOL) isCapsLockOn -{ - return capsLockOn; -} - - -- (BOOL) lastKeyWasShifted -{ - return lastKeyShifted; -} - - -- (int) numKeys -{ - return NUM_KEYS; -} - - -- (int) mouseWheelState -{ - if (_mouseWheelDelta > 0.0f) - return gvMouseWheelUp; - else if (_mouseWheelDelta < 0.0f) - return gvMouseWheelDown; - else - return gvMouseWheelNeutral; -} - - -- (float) mouseWheelDelta -{ - return _mouseWheelDelta / OOMOUSEWHEEL_DELTA; -} - - -- (void) setMouseWheelDelta: (float) newWheelDelta -{ - _mouseWheelDelta = newWheelDelta * OOMOUSEWHEEL_DELTA; -} - - -- (BOOL) isCommandQDown -{ - return commandQ; -} - - -- (BOOL) isCommandFDown -{ - return commandF; -} - - -- (void) clearCommandF -{ - commandF = NO; -} - - -+ (BOOL)pollShiftKey -{ - #define KEYMAP_GET(m, index) ((((uint8_t*)(m))[(index) >> 3] & (1L << ((index) & 7))) ? 1 : 0) - - KeyMap map; - - GetKeys(map); - return KEYMAP_GET(map, 56) || KEYMAP_GET(map, 60); // Left shift or right shift -- although 60 shouldn't occur. -} - -- (OOOpenGLMatrixManager *) getOpenGLMatrixManager -{ - return matrixManager; -} - -#ifndef NDEBUG -// General image-dumping method. -- (void) dumpRGBAToFileNamed:(NSString *)name - bytes:(uint8_t *)bytes - width:(NSUInteger)width - height:(NSUInteger)height - rowBytes:(NSUInteger)rowBytes -{ - if (name == nil || bytes == NULL || width == 0 || height == 0 || rowBytes < width * 4) return; - - NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:&bytes - pixelsWide:width - pixelsHigh:height - bitsPerSample:8 - samplesPerPixel:4 - hasAlpha:YES - isPlanar:NO - colorSpaceName:NSCalibratedRGBColorSpace - bytesPerRow:rowBytes - bitsPerPixel:32]; - - if (bitmap != nil) - { - [bitmap autorelease]; - - NSString *filepath = [[[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:name] stringByAppendingPathExtension:@"png"]; - [[bitmap representationUsingType:NSPNGFileType properties:[NSDictionary dictionary]] writeToFile:filepath atomically:YES]; - } -} - -- (void) dumpRGBToFileNamed:(NSString *)name - bytes:(uint8_t *)bytes - width:(NSUInteger)width - height:(NSUInteger)height - rowBytes:(NSUInteger)rowBytes -{ - if (name == nil || bytes == NULL || width == 0 || height == 0 || rowBytes < width * 3) return; - - NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:&bytes - pixelsWide:width - pixelsHigh:height - bitsPerSample:8 - samplesPerPixel:3 - hasAlpha:NO - isPlanar:NO - colorSpaceName:NSCalibratedRGBColorSpace - bytesPerRow:rowBytes - bitsPerPixel:24]; - - if (bitmap != nil) - { - [bitmap autorelease]; - - NSString *filepath = [[[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:name] stringByAppendingPathExtension:@"png"]; - [[bitmap representationUsingType:NSPNGFileType properties:[NSDictionary dictionary]] writeToFile:filepath atomically:YES]; - } -} - - -- (void) dumpGrayToFileNamed:(NSString *)name - bytes:(uint8_t *)bytes - width:(NSUInteger)width - height:(NSUInteger)height - rowBytes:(NSUInteger)rowBytes -{ - if (name == nil || bytes == NULL || width == 0 || height == 0 || rowBytes < width) return; - - NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:&bytes - pixelsWide:width - pixelsHigh:height - bitsPerSample:8 - samplesPerPixel:1 - hasAlpha:NO - isPlanar:NO - colorSpaceName:NSCalibratedWhiteColorSpace - bytesPerRow:rowBytes - bitsPerPixel:8]; - - if (bitmap != nil) - { - [bitmap autorelease]; - - NSString *filepath = [[[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:name] stringByAppendingPathExtension:@"png"]; - [[bitmap representationUsingType:NSPNGFileType properties:[NSDictionary dictionary]] writeToFile:filepath atomically:YES]; - } -} - - -- (void) dumpGrayAlphaToFileNamed:(NSString *)name - bytes:(uint8_t *)bytes - width:(NSUInteger)width - height:(NSUInteger)height - rowBytes:(NSUInteger)rowBytes -{ - if (name == nil || bytes == NULL || width == 0 || height == 0 || rowBytes < width * 2) return; - - NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:&bytes - pixelsWide:width - pixelsHigh:height - bitsPerSample:8 - samplesPerPixel:2 - hasAlpha:YES - isPlanar:NO - colorSpaceName:NSCalibratedWhiteColorSpace - bytesPerRow:rowBytes - bitsPerPixel:16]; - - if (bitmap != nil) - { - [bitmap autorelease]; - - NSString *filepath = [[[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:name] stringByAppendingPathExtension:@"png"]; - [[bitmap representationUsingType:NSPNGFileType properties:[NSDictionary dictionary]] writeToFile:filepath atomically:YES]; - } -} - - -- (void) dumpRGBAToRGBFileNamed:(NSString *)rgbName - andGrayFileNamed:(NSString *)grayName - bytes:(uint8_t *)bytes - width:(NSUInteger)width - height:(NSUInteger)height - rowBytes:(NSUInteger)rowBytes -{ - if ((rgbName == nil && grayName == nil) || bytes == NULL || width == 0 || height == 0 || rowBytes < width * 4) return; - - uint8_t *rgbBytes, *rgbPx, *grayBytes, *grayPx, *srcPx; - NSUInteger x, y; - BOOL trivalAlpha = YES; - - rgbPx = rgbBytes = malloc(width * height * 3); - if (rgbBytes == NULL) return; - - grayPx = grayBytes = malloc(width * height); - if (grayBytes == NULL) - { - free(rgbBytes); - return; - } - - for (y = 0; y < height; y++) - { - srcPx = bytes + rowBytes * y; - - for (x = 0; x < width; x++) - { - *rgbPx++ = *srcPx++; - *rgbPx++ = *srcPx++; - *rgbPx++ = *srcPx++; - trivalAlpha = trivalAlpha && ((*srcPx == 0xFF) || (*srcPx == 0x00)); // Look for any "interesting" pixels in alpha. - *grayPx++ = *srcPx++; - } - } - - [self dumpRGBToFileNamed:rgbName - bytes:rgbBytes - width:width - height:height - rowBytes:width * 3]; - free(rgbBytes); - - if (!trivalAlpha) - { - [self dumpGrayToFileNamed:grayName - bytes:grayBytes - width:width - height:height - rowBytes:width]; - } - free(grayBytes); -} - -#endif - - -static void GetDesiredCursorState(OOMouseInteractionMode mode, BOOL *outHidden, BOOL *outObscured) -{ - NSCParameterAssert(outHidden != NULL && outObscured != NULL); - - *outHidden = (mode == MOUSE_MODE_FLIGHT_WITH_MOUSE_CONTROL); - *outObscured = (mode == MOUSE_MODE_FLIGHT_NO_MOUSE_CONTROL); -} - - -static void ApplyCursorState(OOMouseInteractionMode mode) -{ - BOOL hidden, obscured; - GetDesiredCursorState(mode, &hidden, &obscured); - if (hidden) [NSCursor hide]; - if (obscured) [NSCursor setHiddenUntilMouseMoves:YES]; -} - - -static void UnapplyCursorState(OOMouseInteractionMode mode) -{ - BOOL hidden, obscured; - GetDesiredCursorState(mode, &hidden, &obscured); - if (hidden) [NSCursor unhide]; - if (obscured) [NSCursor setHiddenUntilMouseMoves:NO]; -} - - -- (void) setGammaValue: (float) value -{ - // no-op -} - -- (float) gammaValue -{ - return 1.0; -} - - -- (void) setFov:(float)value fromFraction:(BOOL)fromFraction -{ - _fov = fromFraction ? value : tanf((value / 2.0f) * M_PI / 180.0f); -} - - -- (float) fov:(BOOL)inFraction -{ - return inFraction ? _fov : 2 * atanf(_fov) * 180.0f / M_PI; -} - -@end diff --git a/src/Cocoa/OOFullScreenWindow.h b/src/Cocoa/OOFullScreenWindow.h deleted file mode 100644 index c1163bb08..000000000 --- a/src/Cocoa/OOFullScreenWindow.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - -OOFullScreenWindow.h - -Trivial NSWindow subclass which allows canBecomeKeyWindow and -canBecomeMainWindow to be set. - - -Copyright (C) 2012-2013 Jens Ayton - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -*/ - -#import "OOCocoa.h" - -#if OOLITE_64_BIT // Not used in 32-bit builds. - -@interface OOFullScreenWindow: NSWindow - -@property (readwrite) BOOL canBecomeKeyWindow; -@property (readwrite) BOOL canBecomeMainWindow; - -@end - -#endif diff --git a/src/Cocoa/OOFullScreenWindow.m b/src/Cocoa/OOFullScreenWindow.m deleted file mode 100644 index 4d92acb52..000000000 --- a/src/Cocoa/OOFullScreenWindow.m +++ /dev/null @@ -1,51 +0,0 @@ -/* - -OOFullScreenWindow.m - -Copyright (C) 2012-2013 Jens Ayton - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -*/ - -#import "OOFullScreenWindow.h" - -#if OOLITE_64_BIT - -@implementation OOFullScreenWindow - -@synthesize canBecomeKeyWindow = _canBecomeKeyWindow; -@synthesize canBecomeMainWindow = _canBecomeMainWindow; - - -- (id) initWithContentRect:(NSRect)contentRect styleMask:(NSWindowStyleMask)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag -{ - self = [super initWithContentRect:contentRect styleMask:aStyle backing:bufferingType defer:flag]; - if (self != nil) - { - _canBecomeKeyWindow = [super canBecomeKeyWindow]; - _canBecomeMainWindow = [super canBecomeMainWindow]; - } - - return self; -} - -@end - -#endif diff --git a/src/Cocoa/OOMacJoystickManager.h b/src/Cocoa/OOMacJoystickManager.h deleted file mode 100644 index 8bef7e25e..000000000 --- a/src/Cocoa/OOMacJoystickManager.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - -OOMacJoystickManager.h -By Alex Smith and Jens Ayton - -Oolite -Copyright (C) 2004-2013 Giles C Williams and contributors - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -MA 02110-1301, USA. - -*/ - - -#import -#import "OOJoystickManager.h" - - -#define STICK_GAMMA 2.0 - - -enum -{ - kJoystickGammaTableSize = 256 -}; - - -@interface OOMacJoystickManager: OOJoystickManager -{ -@private - IOHIDManagerRef hidManager; - CFMutableArrayRef devices; - int gammaTable[kJoystickGammaTableSize]; -} - -@end diff --git a/src/Cocoa/OOMacJoystickManager.m b/src/Cocoa/OOMacJoystickManager.m deleted file mode 100644 index 7bb8fa1e9..000000000 --- a/src/Cocoa/OOMacJoystickManager.m +++ /dev/null @@ -1,368 +0,0 @@ -/* - -OOMacJoystickManager.m -By Alex Smith and Jens Ayton - -Oolite -Copyright (C) 2004-2013 Giles C Williams and contributors - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -MA 02110-1301, USA. - -*/ - -#import "OOMacJoystickManager.h" -#import "OOLogging.h" -#import "OOCollectionExtractors.h" - - -@interface OOMacJoystickManager () - -- (void) handleInputEvent:(IOHIDValueRef)value; -- (void) handleJoystickAttach:(IOHIDDeviceRef)device; -- (void) handleDeviceRemoval:(IOHIDDeviceRef)device; - -@end - - -static void HandleDeviceMatchingCallback(void * inContext, IOReturn inResult, void* inSender, IOHIDDeviceRef inIOHIDDeviceRef); -static void HandleInputValueCallback(void * inContext, IOReturn inResult, void* inSender, IOHIDValueRef inIOHIDValueRef); -static void HandleDeviceRemovalCallback(void * inContext, IOReturn inResult, void* inSender, IOHIDDeviceRef inIOHIDDeviceRef); - - -@implementation OOMacJoystickManager - -- (id) init -{ - if ((self = [super init])) - { - // Initialise gamma table - int i; - for (i = 0; i< kJoystickGammaTableSize; i++) - { - double x = ((double) i - 128.0) / 128.0; - double sign = x>=0 ? 1.0 : -1.0; - double y = sign * floor(32767.0 * pow (fabs(x), STICK_GAMMA)); - gammaTable[i] = (int) y; - } - - /* - SLOW_CODE - The call to IOHIDManagerSetDeviceMatching() has a significiant - presence in warm startup profiles; sometimes it's even makes - -[OOMacJoystickManager init] the single heaviest Oolite symbol - within -[GameController applicationDidFinishLaunching]. Setup - should be made asynchronous. - -- Ahruman 2012-09-14 - */ - hidManager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); - IOHIDManagerSetDeviceMatching(hidManager, NULL); - - IOHIDManagerRegisterDeviceMatchingCallback(hidManager, HandleDeviceMatchingCallback, self); - IOHIDManagerRegisterDeviceRemovalCallback(hidManager, HandleDeviceRemovalCallback, self); - - IOHIDManagerScheduleWithRunLoop(hidManager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); - IOReturn iores = IOHIDManagerOpen(hidManager, kIOHIDOptionsTypeNone); - if (iores != kIOReturnSuccess) - { - OOLog(@"joystick.error.init", @"Cannot open HID manager; joystick support will not function."); - } - - devices = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); - } - return self; -} - - -- (void) dealloc -{ - if (hidManager != NULL) CFRelease(hidManager); - if (devices != NULL) CFRelease(devices); - - [super dealloc]; -} - - -- (NSUInteger) joystickCount -{ - return CFArrayGetCount(devices); -} - - -- (void) handleDeviceAttach:(IOHIDDeviceRef)device -{ - NSArray *usagePairs = (NSArray *)IOHIDDeviceGetProperty(device, CFSTR(kIOHIDDeviceUsagePairsKey)); - - for (NSDictionary *pair in usagePairs) - { - if ([pair oo_unsignedIntForKey:@kIOHIDDeviceUsagePageKey] == kHIDPage_GenericDesktop) - { - unsigned usage = [pair oo_unsignedIntForKey:@kIOHIDDeviceUsageKey]; - if (usage == kHIDUsage_GD_Joystick || usage == kHIDUsage_GD_GamePad) - { - [self handleJoystickAttach:device]; - return; - } - } - } - - if (OOLogWillDisplayMessagesInClass(@"joystick.reject")) - { - NSString *product = (NSString *)IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductKey)); - unsigned usagePage = [(NSNumber *)IOHIDDeviceGetProperty(device, CFSTR(kIOHIDPrimaryUsagePageKey)) unsignedIntValue]; - unsigned usage = [(NSNumber *)IOHIDDeviceGetProperty(device, CFSTR(kIOHIDPrimaryUsageKey)) unsignedIntValue]; - OOLog(@"joystick.reject", @"Ignoring HID device: %@ (primary usage %u:%u)", product, usagePage, usage); - } -} - - -- (void) handleJoystickAttach:(IOHIDDeviceRef)device -{ - OOLog(@"joystick.connect", @"Joystick connected: %@", IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductKey))); - - CFArrayAppendValue(devices, device); - IOHIDDeviceRegisterInputValueCallback(device, HandleInputValueCallback, self); - - if (OOLogWillDisplayMessagesInClass(@"joystick.connect.element")) - { - // Print out elements of new device - CFArrayRef elementList = IOHIDDeviceCopyMatchingElements(device, NULL, 0L); - if (elementList != NULL) - { - OOLogIndent(); - - CFIndex idx, count = CFArrayGetCount(elementList); - - for (idx = 0; idx < count; idx++) - { - IOHIDElementRef element = (IOHIDElementRef)CFArrayGetValueAtIndex(elementList, idx); - IOHIDElementType elementType = IOHIDElementGetType(element); - if (elementType > kIOHIDElementTypeInput_ScanCodes) - { - continue; - } - IOHIDElementCookie elementCookie = IOHIDElementGetCookie(element); - uint32_t usagePage = IOHIDElementGetUsagePage(element); - uint32_t usage = IOHIDElementGetUsage(element); - uint32_t min = (uint32_t)IOHIDElementGetPhysicalMin(element); - uint32_t max = (uint32_t)IOHIDElementGetPhysicalMax(element); - NSString *name = (NSString *)IOHIDElementGetProperty(element, CFSTR(kIOHIDElementNameKey)) ?: @"unnamed"; - OOLog(@"joystick.connect.element", @"%@ - usage %d:%d, cookie %d, range %d-%d", name, usagePage, usage, (int) elementCookie, min, max); - } - - OOLogOutdent(); - CFRelease(elementList); - } - } -} - - -- (void) handleDeviceRemoval:(IOHIDDeviceRef)device -{ - OOLog(@"joystick.remove", @"Joystick removed: %@", IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductKey))); - - CFIndex index = CFArrayGetFirstIndexOfValue(devices, CFRangeMake(0, CFArrayGetCount(devices)), device); - if (index != kCFNotFound) CFArrayRemoveValueAtIndex(devices, index); -} - - -static int AxisIndex(uint32_t page, uint32_t usage) -{ - /* - Map axis-like HID usages to SDL-like axis indices. These are all the - commonly used joystick axes according to Microsoft's DirectInput - documentation (hey, you've got to get your info somewhere). - - GD_Slider, GD_Dial, DG_Wheel and Sim_Throttle are actually distinct; - unlike the others, they're uncentered. (By implication, - IOHIDElementHasPreferredState() should be false.) This should, in - particular, be considered when mapping to the throttle: centered axes - should provide relative input (for gamepads), while uncentered ones - should provide absolute input. Since that festering pool of pus, SDL, - can't make this distinction, OOJoystickManager can't either (yet). - -- Ahruman 2011-01-04 - */ - - switch (page) - { - case kHIDPage_GenericDesktop: - switch (usage) - { - case kHIDUsage_GD_X: return 0; - case kHIDUsage_GD_Y: return 1; - case kHIDUsage_GD_Z: return 2; - case kHIDUsage_GD_Rx: return 3; - case kHIDUsage_GD_Ry: return 4; - case kHIDUsage_GD_Rz: return 5; - case kHIDUsage_GD_Slider: return 6; - case kHIDUsage_GD_Dial: return 7; - case kHIDUsage_GD_Wheel: return 8; - } - break; - - case kHIDPage_Simulation: - switch (usage) - { - case kHIDUsage_Sim_Throttle: - return 9; - } - } - - // Negative numbers indicate non-axis. - return -1; -} - - -static uint8_t MapHatValue(CFIndex value, CFIndex max) -{ - /* - A hat switch has four or eight values, indicating directions. 0 - is straight up/forwards, and subsequent values increase clockwise. - Out-of-range values are nulls, indicating no direction is pressed. - */ - - if (0 <= value && value <= max) - { - if (max == 3) - { - const uint8_t valueMap4[4] = { JOYHAT_UP, JOYHAT_RIGHT, JOYHAT_DOWN, JOYHAT_LEFT }; - return valueMap4[value]; - } - else if (max == 7) - { - const uint8_t valueMap8[8] = { JOYHAT_UP, JOYHAT_RIGHTUP, JOYHAT_RIGHT, JOYHAT_RIGHTDOWN, JOYHAT_DOWN, JOYHAT_LEFTDOWN, JOYHAT_LEFT, JOYHAT_LEFTUP }; - return valueMap8[value]; - } - } - return JOYHAT_CENTERED; -} - - -- (void) handleInputEvent:(IOHIDValueRef)value -{ - IOHIDElementRef element = IOHIDValueGetElement(value); - uint32_t usagePage = IOHIDElementGetUsagePage(element); - uint32_t usage = IOHIDElementGetUsage(element); - int buttonNum = 0; - int axisNum = 0; - - axisNum = AxisIndex(usagePage, usage); - if (axisNum >= 0) - { - JoyAxisEvent evt; - evt.type = JOYAXISMOTION; - evt.which = 0; - evt.axis = axisNum; - - CFIndex intValue = IOHIDValueGetIntegerValue(value); - CFIndex min = IOHIDElementGetLogicalMin(element); - CFIndex max = IOHIDElementGetLogicalMax(element); - float axisValue = (float)(intValue - min) / (float)(max + 1 - min); - - // Note: this is designed so gammaIndex == intValue if min == 0 and max == kJoystickGammaTableSize - 1 (the common case). - unsigned gammaIndex = floor(axisValue * kJoystickGammaTableSize); - - /* - CRASH: r4435, Mac OS X 10.6.6, x86_64 -[OOMacJoystickManager handleInputEvent:] + 260 - http://aegidian.org/bb/viewtopic.php?f=3&t=9382 - The instruction is: - movl (%r15,%rbx,4), %r12d - which corresponds to the load gammaTable[gammaIndex]. - Check added to find out-of-range values. - -- Ahruman 2011-03-07 - */ - if (EXPECT_NOT(gammaIndex > kJoystickGammaTableSize)) - { - OOLogERR(@"joystick.gamma.overflow", @"Joystick gamma table overflow - gammaIndex is %u of %u. Raw value: %i in [%i..%i]; axisValue: %g; unrounded gammaIndex: %g. Ignoring event. This is an internal error, please report it.", - gammaIndex, kJoystickGammaTableSize, - (int)intValue, (int)min, (int)max, - axisValue, - axisValue * kJoystickGammaTableSize - ); - - return; - } - // End bug check - - evt.value = gammaTable[gammaIndex]; - [self decodeAxisEvent:&evt]; - } - else if (usagePage == kHIDPage_GenericDesktop && usage == kHIDUsage_GD_Hatswitch) - { - CFIndex max = IOHIDElementGetLogicalMax(element); - CFIndex min = IOHIDElementGetLogicalMin(element); - - JoyHatEvent evt = - { - .type = JOYHAT_MOTION, - .which = 0, - .hat = 0, // The abuse of usage values for identifying elements means we can't distinguish between hats. - .value = MapHatValue(IOHIDValueGetIntegerValue(value) - min, max - min) - }; - - [self decodeHatEvent:&evt]; - } - else if (usagePage == kHIDPage_Button) - { - // Button Event - buttonNum = usage; - JoyButtonEvent evt; - BOOL buttonState = (IOHIDValueGetIntegerValue(value) != 0); - evt.type = buttonState ? JOYBUTTONDOWN : JOYBUTTONUP; - evt.which = 0; - evt.button = buttonNum; - evt.state = buttonState ? 1 : 0; - [self decodeButtonEvent:&evt]; - } -} - - -- (NSString *) nameOfJoystick:(NSUInteger)stickNumber -{ - IOHIDDeviceRef device = (IOHIDDeviceRef)CFArrayGetValueAtIndex(devices, stickNumber); - return (NSString *)IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductKey)); -} - - - -- (int16_t) getAxisWithStick:(NSUInteger) stickNum axis:(NSUInteger) axisNum -{ - return 0; -} - - - -@end - - -//Thunking to Objective-C -static void HandleDeviceMatchingCallback(void * inContext, IOReturn inResult, void* inSender, IOHIDDeviceRef inIOHIDDeviceRef) -{ - [(OOMacJoystickManager *)inContext handleDeviceAttach:inIOHIDDeviceRef]; -} - - - -static void HandleInputValueCallback(void * inContext, IOReturn inResult, void* inSender, IOHIDValueRef inIOHIDValueRef) -{ - [(OOMacJoystickManager *)inContext handleInputEvent:inIOHIDValueRef]; -} - - - -static void HandleDeviceRemovalCallback(void * inContext, IOReturn inResult, void* inSender, IOHIDDeviceRef inIOHIDDeviceRef) -{ - [(OOMacJoystickManager *)inContext handleDeviceRemoval:inIOHIDDeviceRef]; -} diff --git a/src/Cocoa/OOMacSnowLeopardFullScreenController.h b/src/Cocoa/OOMacSnowLeopardFullScreenController.h deleted file mode 100644 index c79054e3e..000000000 --- a/src/Cocoa/OOMacSnowLeopardFullScreenController.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - -OOMacSnowLeopardFullScreenController.h - -Full-screen controller used in 64-bit Mac builds under Mac OS X 10.6. - - -Oolite -Copyright (C) 2004-2013 Giles C Williams and contributors - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -MA 02110-1301, USA. - -*/ - -#import "OOFullScreenController.h" - -#if OOLITE_MAC_OS_X && OOLITE_64_BIT - - -@interface OOMacSnowLeopardFullScreenController: OOFullScreenController - -@end - -#endif diff --git a/src/Cocoa/OOMacSnowLeopardFullScreenController.m b/src/Cocoa/OOMacSnowLeopardFullScreenController.m deleted file mode 100644 index 7ed431a18..000000000 --- a/src/Cocoa/OOMacSnowLeopardFullScreenController.m +++ /dev/null @@ -1,298 +0,0 @@ -/* - -OOMacSnowLeopardFullScreenController.m - - -Oolite -Copyright (C) 2004-2013 Giles C Williams and contributors - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -MA 02110-1301, USA. - -*/ - -#import "OOMacSnowLeopardFullScreenController.h" - -#if OOLITE_MAC_OS_X && OOLITE_64_BIT - - -#import // For SetSystemUIMode() -#import "MyOpenGLView.h" -#import "OOLogging.h" -#import "OOFullScreenWindow.h" -#import "OOCollectionExtractors.h" - - -#define SUPPRESS_BLANKING_WINDOWS ( 1 && OO_DEBUG) - - -@interface OOMacSnowLeopardFullScreenController () - -@property (nonatomic, retain) NSWindow *fullScreenWindow; // Window on main gameplay screen which contains our OpenGL view in full screen mode. -@property (nonatomic, retain) NSArray *blankingWindows; // Plain black windows covering other screens if relevant. -@property (nonatomic, retain) NSWindow *standardWindow; // The main game window, stashed away for use when existing full screen mode. - -@property (nonatomic, retain) NSScreen *gameScreen; - -- (void) beginFullScreenMode; -- (void) endFullScreenMode; - -- (void) screenParametersChanged:(NSNotification *)notification; - -- (void) setUpBlankingWindowsForScreensOtherThan:(NSScreen *)gameScreen; -- (void) removeBlankingWindows; - -@end - - -@implementation OOMacSnowLeopardFullScreenController - -@synthesize fullScreenMode = _fullScreenMode; // Future note: needs to be explicit because property declaration is inherited. -@synthesize fullScreenWindow = _fullScreenWindow; -@synthesize blankingWindows = _blankingWindows; -@synthesize standardWindow = _standardWindow; -@synthesize gameScreen = _gameScreen; - - -- (void) dealloc -{ - self.fullScreenMode = NO; - - DESTROY(_fullScreenWindow); - DESTROY(_blankingWindows); - DESTROY(_standardWindow); - DESTROY(_gameScreen); - - [super dealloc]; -} - - -- (void) setFullScreenMode:(BOOL)value -{ - if (!value && self.fullScreenMode) - { - [self endFullScreenMode]; - } - else if (value && !self.fullScreenMode) - { - [self beginFullScreenMode]; - } -} - - -- (NSArray *) displayModes -{ - NSSize size = self.fullScreenWindow.frame.size; - NSDictionary *fakeMode = [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithUnsignedInt:size.width], kOODisplayWidth, - [NSNumber numberWithUnsignedInt:size.height], kOODisplayHeight, - nil]; - return [NSArray arrayWithObject:fakeMode]; -} - - -- (NSUInteger) indexOfCurrentDisplayMode -{ - return 0; -} - - -- (BOOL) setDisplayWidth:(NSUInteger)width height:(NSUInteger)height refreshRate:(NSUInteger)refresh -{ - return NO; -} - - -- (NSDictionary *) findDisplayModeForWidth:(NSUInteger)width height:(NSUInteger)height refreshRate:(NSUInteger)refresh -{ - NSDictionary *fakeMode = [self.displayModes objectAtIndex:0]; - if (width == [fakeMode oo_unsignedIntegerForKey:kOODisplayWidth] && - height == [fakeMode oo_unsignedIntegerForKey:kOODisplayHeight]) - { - return fakeMode; - } - return nil; -} - - -- (void) noteMouseInteractionModeChangedFrom:(OOMouseInteractionMode)oldMode to:(OOMouseInteractionMode)newMode -{ - NSAssert(self.fullScreenMode, @"%s called in wrong state.", __FUNCTION__); - - [self.gameView noteMouseInteractionModeChangedFrom:oldMode to:newMode]; -} - - -#pragma mark - Actual full screen mode handling - -- (void) beginFullScreenMode -{ - NSAssert(!self.fullScreenMode, @"%s called in wrong state.", __FUNCTION__); - - // Stash the windowed-mode window so we can restore to it later. - self.standardWindow = self.gameView.window; - - /* - Set up a full-screen window. Based on OpenGL Programming Guide for Mac - [developer.apple.com], dated 2012-07-23, "Drawing to the Full Screen". - */ - self.gameScreen = self.gameView.window.screen; - NSRect frame = self.gameScreen.frame; - OOFullScreenWindow *window = [[OOFullScreenWindow alloc] initWithContentRect:frame - styleMask:NSBorderlessWindowMask - backing:NSBackingStoreBuffered - defer:NO]; - if (window == nil) return; - - self.fullScreenWindow = [window autorelease]; - - [window setOpaque:YES]; - [window setMovable:YES]; - window.canBecomeKeyWindow = YES; - window.canBecomeMainWindow = YES; - window.acceptsMouseMovedEvents = YES; -#if !OO_DEBUG - /* - Leaving a full-screen window visible in the background is anti-social, - but convenient in debug builds. - */ - window.hidesOnDeactivate = YES; -#endif - - // TODO: handle screen reconfiguration. - - [self.standardWindow orderOut:nil]; - window.contentView = self.gameView; - - SetSystemUIMode(kUIModeAllSuppressed, kUIOptionDisableMenuBarTransparency); - [self setUpBlankingWindowsForScreensOtherThan:self.gameScreen]; - - [window makeKeyAndOrderFront:self]; - - _fullScreenMode = YES; - - // Subscribe to reconfiguration notifications. - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(screenParametersChanged:) - name:NSApplicationDidChangeScreenParametersNotification - object:NSApp]; -} - - -- (void) endFullScreenMode -{ - NSAssert(self.fullScreenMode, @"%s called in wrong state.", __FUNCTION__); - - [self.fullScreenWindow orderOut:nil]; - - [self removeBlankingWindows]; - SetSystemUIMode(kUIModeNormal, 0); - - self.standardWindow.contentView = self.gameView; - [self.standardWindow makeKeyAndOrderFront:nil]; - - self.standardWindow = nil; - self.fullScreenWindow = nil; - self.gameScreen = nil; - - _fullScreenMode = NO; - - // Unsubscribe from notifications. - [[NSNotificationCenter defaultCenter] removeObserver:self - name:NSApplicationDidChangeScreenParametersNotification - object:NSApp]; -} - - -- (void) screenParametersChanged:(NSNotification *)notification -{ - NSAssert(self.fullScreenMode, @"%s called in wrong state.", __FUNCTION__); - - [self.fullScreenWindow setFrame:self.gameScreen.frame display:YES]; - [self setUpBlankingWindowsForScreensOtherThan:self.gameScreen]; -} - - -- (void) setUpBlankingWindowsForScreensOtherThan:(NSScreen *)gameScreen -{ -#if SUPPRESS_BLANKING_WINDOWS - // Skip blanking windows while debugging. - return; -#endif - - /* - On muliple-screen systems, fill all screens except the game screen - with an all-black window. This behaviour has its critics, but it is - consistent with both traditional Oolite behaviour and Mac OS X 10.7 - and later standard behaviour. - */ - - // Remove any existing blanking windows. - [self removeBlankingWindows]; - - NSArray *screens = [NSScreen screens]; - if (screens.count <= 1) - { - // No blanking windows needed on single-screen systems. - return; - } - - NSMutableArray *windows = [NSMutableArray arrayWithCapacity:screens.count - 1]; - for (NSScreen *screen in screens) - { - if ([screen isEqual:gameScreen]) continue; - - NSRect frame = screen.frame; - OOFullScreenWindow *window = [[OOFullScreenWindow alloc] initWithContentRect:frame - styleMask:NSBorderlessWindowMask - backing:NSBackingStoreBuffered - defer:NO]; - - [window setOpaque:YES]; - [window setMovable:YES]; - window.collectionBehavior = NSWindowCollectionBehaviorTransient | NSWindowCollectionBehaviorIgnoresCycle; - window.canBecomeKeyWindow = NO; - window.canBecomeMainWindow = NO; - window.hidesOnDeactivate = YES; - window.backgroundColor = [NSColor blackColor]; - - [windows addObject:window]; - [window orderFront:nil]; - [window release]; - } - - self.blankingWindows = windows; -} - - -- (void) removeBlankingWindows -{ - for (NSWindow *window in self.blankingWindows) - { - [window orderOut:nil]; - } - self.blankingWindows = nil; -} - - -- (void) checkWindowVisible:(NSTimer *)timer -{ - NSWindow *window = timer.userInfo; - OOLog(@"temp.fullScreen", @"Window %@ is %@ on screen %@", window, window.isVisible ? @"visible" : @"INVISIBLE", window.screen); -} - -@end - -#endif diff --git a/src/Cocoa/OOMacSystemStandardFullScreenController.h b/src/Cocoa/OOMacSystemStandardFullScreenController.h deleted file mode 100644 index b882ea740..000000000 --- a/src/Cocoa/OOMacSystemStandardFullScreenController.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - -OOMacSystemStandardFullScreenController.h - -Full-screen controller used in 64-bit Mac builds under Mac OS X 10.7 (on systems -with a single display, as determined at application startup) and always under -Mac OS X 10.8 or later. - - -Oolite -Copyright (C) 2004-2013 Giles C Williams and contributors - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -MA 02110-1301, USA. - -*/ - -#import "OOFullScreenController.h" - -/* - OOMacSystemStandardFullScreenController requires the Mac OS X 10.7 SDK. -*/ -#if OOLITE_MAC_OS_X -#if OOLITE_64_BIT && defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 -#define OO_MAC_SUPPORT_SYSTEM_STANDARD_FULL_SCREEN 1 -#endif -#endif - -#ifndef OO_MAC_SUPPORT_SYSTEM_STANDARD_FULL_SCREEN -#define OO_MAC_SUPPORT_SYSTEM_STANDARD_FULL_SCREEN 0 -#endif - - -#if OO_MAC_SUPPORT_SYSTEM_STANDARD_FULL_SCREEN - - -@interface OOMacSystemStandardFullScreenController: OOFullScreenController - -+ (BOOL) shouldUseSystemStandardFullScreenController; - -@end - -#endif diff --git a/src/Cocoa/OOMacSystemStandardFullScreenController.m b/src/Cocoa/OOMacSystemStandardFullScreenController.m deleted file mode 100644 index 9453abefe..000000000 --- a/src/Cocoa/OOMacSystemStandardFullScreenController.m +++ /dev/null @@ -1,131 +0,0 @@ -/* - -OOMacSystemStandardFullScreenController.m - - -Oolite -Copyright (C) 2004-2013 Giles C Williams and contributors - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -MA 02110-1301, USA. - -*/ - -#import "OOMacSystemStandardFullScreenController.h" - -#if OO_MAC_SUPPORT_SYSTEM_STANDARD_FULL_SCREEN - - -#import "MyOpenGLView.h" -#import "OOLogging.h" -#import "OOPrimaryWindow.h" -#import "OOCollectionExtractors.h" - - -#ifndef NSAppKitVersionNumber10_7 -#define NSAppKitVersionNumber10_7 1138 -#endif - - -@implementation OOMacSystemStandardFullScreenController - -+ (BOOL) shouldUseSystemStandardFullScreenController -{ - if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_6) - { - // Never on 10.6 or earlier; the necessary API doesn't exist. - return NO; - } - - // If safe to use, allow override for debugging. - NSString *override = [[NSUserDefaults standardUserDefaults] stringForKey:@"full-screen-mode-override"]; - if (override != nil) - { - if ([override isEqualToString:@"lion"]) return YES; - if ([override isEqualToString:@"snow-leopard"]) return NO; - } - - if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_7) - { - // Always use on 10.8 or later. - return YES; - } - - return NSScreen.screens.count == 1; // Use if there's a single screen on 10.7. -} - - -- (BOOL) inFullScreenMode -{ - return ([NSApp presentationOptions] & NSApplicationPresentationFullScreen) != 0; -} - - -- (void) setFullScreenMode:(BOOL)value -{ - if (value != self.fullScreenMode) - { - OOPrimaryWindow *window = (OOPrimaryWindow *)self.gameView.window; - NSAssert([window isKindOfClass:OOPrimaryWindow.class], @"Incorrect UI setup; main game window should be OOPrimaryWindow."); - - [window makeKeyAndOrderFront:nil]; - [window standardToggleFullScreen:nil]; - } -} - - -- (NSArray *) displayModes -{ - NSSize size = self.gameView.window.frame.size; - NSDictionary *fakeMode = [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithUnsignedInt:size.width], kOODisplayWidth, - [NSNumber numberWithUnsignedInt:size.height], kOODisplayHeight, - nil]; - return [NSArray arrayWithObject:fakeMode]; -} - - -- (NSUInteger) indexOfCurrentDisplayMode -{ - return 0; -} - - -- (BOOL) setDisplayWidth:(NSUInteger)width height:(NSUInteger)height refreshRate:(NSUInteger)refresh -{ - return NO; -} - - -- (NSDictionary *) findDisplayModeForWidth:(NSUInteger)width height:(NSUInteger)height refreshRate:(NSUInteger)refresh -{ - NSDictionary *fakeMode = [self.displayModes objectAtIndex:0]; - if (width == [fakeMode oo_unsignedIntegerForKey:kOODisplayWidth] && - height == [fakeMode oo_unsignedIntegerForKey:kOODisplayHeight]) - { - return fakeMode; - } - return nil; -} - - -- (void) noteMouseInteractionModeChangedFrom:(OOMouseInteractionMode)oldMode to:(OOMouseInteractionMode)newMode -{ - [self.gameView noteMouseInteractionModeChangedFrom:oldMode to:newMode]; -} - -@end - -#endif diff --git a/src/Cocoa/OOPDFView.h b/src/Cocoa/OOPDFView.h deleted file mode 100644 index 287c68a30..000000000 --- a/src/Cocoa/OOPDFView.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - -OOPDFView.h - -PDFView subclass which renders images using high-quality interpolation. - - -Copyright (C) 2011-2013 Jens Ayton - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -*/ - -#import - - -@interface OOPDFView: PDFView -@end diff --git a/src/Cocoa/OOPDFView.m b/src/Cocoa/OOPDFView.m deleted file mode 100644 index da48c2b9d..000000000 --- a/src/Cocoa/OOPDFView.m +++ /dev/null @@ -1,45 +0,0 @@ -/* - -OOPDFView.m - - -Copyright (C) 2011-2013 Jens Ayton - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -*/ - -#import "OOPDFView.h" - - -@implementation OOPDFView - -- (void) drawPage:(PDFPage *)page -{ - // Force PDF view to render scaled images nicely (just like Preview). - - [NSGraphicsContext saveGraphicsState]; - [[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationHigh]; - - [super drawPage:page]; - - [NSGraphicsContext restoreGraphicsState]; -} - -@end diff --git a/src/Cocoa/OOPrimaryWindow.h b/src/Cocoa/OOPrimaryWindow.h deleted file mode 100644 index dc2f3b695..000000000 --- a/src/Cocoa/OOPrimaryWindow.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - -OOPrimaryWindow.h - -Trivial NSWindow subclass which lets us intercept toggleFullScreen: in order -to interpose our custom full screen handling when needed. - - -Copyright (C) 2012-2013 Jens Ayton - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -*/ - -#import "OOCocoa.h" - -@protocol OOPrimaryWindowDelegate; - - -@interface OOPrimaryWindow: NSWindow -#if !__OBJC2__ -{ -@private - id _fullScreenDelegate; -} -#endif - -@property (nonatomic, assign) IBOutlet id fullScreenDelegate; - -// Call through to standard toggleFullScreen: implementation. -- (void) standardToggleFullScreen:(id)sender; - -@end - - -@protocol OOPrimaryWindowDelegate -@optional - -// Sent in response to toggleFullScreen:. -- (void) toggleFullScreenCalledForWindow:(OOPrimaryWindow *)window withSender:(id)sender; - -@end diff --git a/src/Cocoa/OOPrimaryWindow.m b/src/Cocoa/OOPrimaryWindow.m deleted file mode 100644 index 959a6f831..000000000 --- a/src/Cocoa/OOPrimaryWindow.m +++ /dev/null @@ -1,61 +0,0 @@ -/* - -OOPrimaryWindow.m - - -Copyright (C) 2012-2013 Jens Ayton - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -*/ - -#import "OOPrimaryWindow.h" - - -#if !OOLITE_MAC_OS_X_10_7 -@interface NSWindow (Lion) - -- (void) toggleFullScreen:(id)sender; - -@end -#endif - - -@implementation OOPrimaryWindow - -@synthesize fullScreenDelegate = _fullScreenDelegate; - - -- (void) standardToggleFullScreen:(id)sender -{ - [super toggleFullScreen:sender]; -} - - -- (void) toggleFullScreen:(id)sender -{ - id delegate = self.fullScreenDelegate; - - if ([delegate respondsToSelector:@selector(toggleFullScreenCalledForWindow:withSender:)]) - { - [delegate toggleFullScreenCalledForWindow:self withSender:sender]; - } -} - -@end diff --git a/src/Cocoa/Oolite.xib b/src/Cocoa/Oolite.xib deleted file mode 100644 index 7f79d8985..000000000 --- a/src/Cocoa/Oolite.xib +++ /dev/null @@ -1,1722 +0,0 @@ - - - - 1060 - 12E55 - 3084 - 1187.39 - 626.00 - - 3084 - 2053 - - - NSBox - NSCustomObject - NSCustomView - NSImageCell - NSImageView - NSMenu - NSMenuItem - NSTextField - NSTextFieldCell - NSUserDefaultsController - NSView - NSWindowTemplate - PDFView - - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.pdfkit.ibplugin - - - PluginDependencyRecalculationVersion - - - - - OoliteApp - - - FirstResponder - - - NSApplication - - - MainMenu - - - - Oolite - - 1048576 - 2147483647 - - NSImage - NSMenuCheckmark - - - NSImage - NSMenuMixedState - - submenuAction: - - Oolite - - - - About Oolite - - 2147483647 - - - - - - Check for Updates… - - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Oolite Screen Shots - - 1048576 - 2147483647 - - - - - - Expansion Packs - - 1048576 - 2147483647 - - - - - - Show Previous Log - - 1048576 - 2147483647 - - - - - - YES - Logs Folder - - 524288 - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Hide Oolite - h - 1048576 - 2147483647 - - - - - - Hide Others - H - 1048576 - 2147483647 - - - - - - Show All - - 1048576 - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Quit Oolite - q - 1048576 - 2147483647 - - - - - _NSAppleMenu - - - - - Edit - - 1048576 - 2147483647 - - - submenuAction: - - - Edit - - - - - Undo - z - 1048576 - 2147483647 - - - - - - Redo - Z - 1048576 - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Cut - x - 1048576 - 2147483647 - - - - - - Copy - c - 1048576 - 2147483647 - - - - - - Paste - v - 1048576 - 2147483647 - - - - - - Paste and Match Style - V - 1572864 - 2147483647 - - - - - - Delete - - 1048576 - 2147483647 - - - - - - Select All - a - 1048576 - 2147483647 - - - - - - - - - Window - - 1048576 - 2147483647 - - - submenuAction: - - - Window - - - - - Minimize - m - 1048576 - 2147483647 - - - - - - Zoom - - 1048576 - 2147483647 - - - - - - Close - w - 1048576 - 2147483647 - - - - - - Enter Full Screen - f - 1310720 - 2147483647 - - - - - - YES - YES - - - 1048576 - 2147483647 - - - - - - Bring All to Front - - 1048576 - 2147483647 - - - - - _NSWindowsMenu - - - - - Help - - 1048576 - 2147483647 - - - submenuAction: - - - Help - - - - - Oolite Help - ? - 1048576 - 2147483647 - - - - - - - - _NSMainMenu - - - 9 - 2 - {{44, 222}, {640, 480}} - 1886912512 - Oolite - OOPrimaryWindow - - View - - - {640, 480} - - - 256 - - - - 18 - - - - 274 - - - - 298 - - - - 301 - - Apple PDF pasteboard type - Apple PICT pasteboard type - Apple PNG pasteboard type - NSFilenamesPboardType - NeXT Encapsulated PostScript v1.2 pasteboard type - NeXT TIFF v4.0 pasteboard type - - {{128, 41}, {384, 384}} - - - YES - - 134217728 - 33554432 - - NSImage - splash - - 0 - 1 - 0 - NO - - NO - YES - - - - 298 - {{17, 8}, {606, 17}} - - YES - - 67108864 - 138412032 - loading… - - LucidaGrande - 13 - 1044 - - - YES - - 6 - System - controlColor - - 3 - MC42NjY2NjY2NjY3AA - - - - 1 - MC44MTU2MDgzMjI2IDAuODIwMTg5MTc4IDEAA - - - NO - - - {{0, 30}, {640, 424}} - - - NSView - - - {640, 480} - - - - - {640, 480} - - - {0, 0} - - 67108864 - 0 - - - LucidaGrande - 11 - 3100 - - - 6 - System - textBackgroundColor - - 3 - MQA - - - - 3 - MCAwLjgwMDAwMDAxMTkAA - - - - 0 - 4 - 0 - NO - - 1 - MCAwIDAAA - - - - {640, 480} - - - {{0, 0}, {1366, 746}} - {640, 502} - {10000000000000, 10000000000000} - oolite-main-window - 128 - YES - - - GameController - - - 15 - 2 - {{26, 348}, {640, 480}} - 1886912512 - Help - NSWindow - - View - - - {640, 400} - - - 256 - - - - 18 - - - NSFilenamesPboardType - - {640, 480} - - YES - 1 - NO - 1.0212417840957642 - YES - - - {640, 480} - - {{0, 0}, {1366, 746}} - {640, 422} - {10000000000000, 10000000000000} - oolitehelp - 256 - YES - - - 3 - 2 - {{50, 220}, {640, 480}} - 1886912512 - - Panel - - NSWindow - - View - - - {213, 107} - - - 256 - - - - 274 - {640, 480} - - MyOpenGLView - NSOpenGLView - - - {640, 480} - - {{0, 0}, {1366, 746}} - {213, 129} - {10000000000000, 10000000000000} - YES - - - YES - - - - - - - Show - - 2147483647 - - - submenuAction: - - Show - - - - Screen Shots - - 2147483647 - - - - - - Expansion Packs - - 2147483647 - - - - - - Previous Log - - 2147483647 - - - - - - YES - Logs Folder - - 524288 - 2147483647 - - - - - - - - - - SUUpdater - - - - - - - terminate: - - - - 139 - - - - hideOtherApplications: - - - - 146 - - - - hide: - - - - 152 - - - - unhideAllApplications: - - - - 153 - - - - delegate - - - - 207 - - - - orderFrontStandardAboutPanel: - - - - 273 - - - - _gameController - - - - 361 - - - - _gameWindow - - - - 362 - - - - pasteAsPlainText: - - - - 328 - - - - paste: - - - - 329 - - - - delete: - - - - 332 - - - - cut: - - - - 338 - - - - redo: - - - - 339 - - - - selectAll: - - - - 341 - - - - undo: - - - - 342 - - - - copy: - - - - 343 - - - - performZoom: - - - - 351 - - - - performMiniaturize: - - - - 352 - - - - arrangeInFront: - - - - 353 - - - - performClose: - - - - 358 - - - - delegate - - - - 241 - - - - initialFirstResponder - - - - 296 - - - - fullScreenDelegate - - - - 439 - - - - gameWindow - - - - 213 - - - - gameView - - - - 262 - - - - splashView - - - - 264 - - - - splashProgressTextField - - - - 271 - - - - showLogAction: - - - - 399 - - - - showAddOnsAction: - - - - 400 - - - - showSnapshotsAction: - - - - 409 - - - - dockMenu - - - - 423 - - - - showSnapshotsAction: - - - - 424 - - - - showAddOnsAction: - - - - 425 - - - - showLogAction: - - - - 426 - - - - showLogFolderAction: - - - - 427 - - - - showLogFolderAction: - - - - 429 - - - - helpView - - - - 437 - - - - toggleFullScreenAction: - - - - 438 - - - - makeKeyAndOrderFront: - - - - 228 - - - - gameController - - - - 265 - - - - checkForUpdates: - - - - 433 - - - - - - 0 - - - - - - -2 - - - File's Owner - - - -1 - - - First Responder - - - -3 - - - Application - - - 29 - - - - - - - - - MainMenu - - - 56 - - - - - - - - 57 - - - - - - - - - - - - - - - - - - - - 58 - - - - - 134 - - - - - 136 - - - - - 144 - - - - - 145 - - - - - 149 - - - - - 150 - - - - - 381 - - - - - 382 - - - - - 383 - - - - - 384 - - - - - 103 - - - - - - - - 106 - - - - - - - - 111 - - - - - 299 - - - - - - - - 300 - - - - - - - - - - - - - - - - 301 - - - - - 302 - - - - - 303 - - - - - 305 - - - - - 313 - - - - - 319 - - - - - 320 - - - - - 325 - - - - - 326 - - - - - 345 - - - - - - - - 346 - - - - - - - - - - - - - 347 - - - - - 348 - - - - - 349 - - - - - 350 - - - - - 354 - - - - - 356 - - - - - 198 - - - - - - Main Window - - - 199 - - - - - - - - 205 - - - GameController - - - 225 - - - - - - Help Window - - - 224 - - - - - - - - 256 - - - - - - non-displayed Window - - - 257 - - - - - - - - 260 - - - - - 385 - - - Shared User Defaults Controller - - - 416 - - - - - - Dock menu - - - 417 - - - - - - - - 418 - - - - - - - - - - - 419 - - - - - 420 - - - - - 421 - - - - - 422 - - - - - 428 - - - - - 431 - - - - - 432 - - - - - 435 - - - - - - - - 360 - - - - - - - - - 261 - - - - - - - - 412 - - - - - 270 - - - - - - - - 413 - - - - - 436 - - - - - - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - - - com.apple.InterfaceBuilder.CocoaPlugin - {{274, 644}, {640, 480}} - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - - - com.apple.InterfaceBuilder.CocoaPlugin - {{358, 638}, {640, 480}} - - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - OOPDFView - com.apple.pdfkit.ibplugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - - - - - - 439 - - - - - GameController - NSObject - - id - id - id - id - id - - - - showAddOnsAction: - id - - - showLogAction: - id - - - showLogFolderAction: - id - - - showSnapshotsAction: - id - - - toggleFullScreenAction: - id - - - - NSMenu - MyOpenGLView - NSWindow - PDFView - NSTextField - NSView - - - - dockMenu - NSMenu - - - gameView - MyOpenGLView - - - gameWindow - NSWindow - - - helpView - PDFView - - - splashProgressTextField - NSTextField - - - splashView - NSView - - - - IBProjectSource - ./Classes/GameController.h - - - - MyOpenGLView - NSOpenGLView - - IBProjectSource - ./Classes/MyOpenGLView.h - - - - OOPDFView - PDFView - - IBProjectSource - ./Classes/OOPDFView.h - - - - OOPrimaryWindow - NSWindow - - fullScreenDelegate - id - - - fullScreenDelegate - - fullScreenDelegate - id - - - - IBProjectSource - ./Classes/OOPrimaryWindow.h - - - - OoliteApp - NSApplication - - GameController - NSWindow - - - - _gameController - GameController - - - _gameWindow - NSWindow - - - - IBProjectSource - ./Classes/OoliteApp.h - - - - SUUpdater - NSObject - - checkForUpdates: - id - - - checkForUpdates: - - checkForUpdates: - id - - - - delegate - id - - - delegate - - delegate - id - - - - IBProjectSource - ./Classes/SUUpdater.h - - - - - 0 - IBCocoaFramework - - com.apple.InterfaceBuilder.CocoaPlugin.macosx - - - - com.apple.InterfaceBuilder.CocoaPlugin.macosx - - - YES - 3 - - {11, 11} - {10, 3} - {384, 384} - - - diff --git a/src/Cocoa/OoliteApp.h b/src/Cocoa/OoliteApp.h deleted file mode 100644 index f459c8a32..000000000 --- a/src/Cocoa/OoliteApp.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - -OoliteApp.h - -This is a subclass of NSApplication for Oolite. - -It gets around problems with the system intercepting certain events (NSKeyDown -and NSKeyUp) before MyOpenGLView gets to see them, it does this by sending -those events to MyOpenGLView regardless of any other processing NSApplication -will do with them. - -Oolite -Copyright (C) 2004-2013 Giles C Williams and contributors - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -MA 02110-1301, USA. - -*/ - -#import "OOCocoa.h" - -@class GameController; - - -@interface OoliteApp: NSApplication -{ -@private - IBOutlet NSWindow *_gameWindow; - IBOutlet GameController *_gameController; - NSString *_exitContext; -} - -- (void) setExitContext:(NSString *)exitContext; - -@end diff --git a/src/Cocoa/OoliteApp.m b/src/Cocoa/OoliteApp.m deleted file mode 100644 index 34db4c6f7..000000000 --- a/src/Cocoa/OoliteApp.m +++ /dev/null @@ -1,72 +0,0 @@ -/* - -OoliteApp.m - -Oolite -Copyright (C) 2004-2013 Giles C Williams and contributors - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -MA 02110-1301, USA. - -*/ - -#import "OoliteApp.h" -#import "GameController.h" -#import "MyOpenGLView.h" - - -@implementation OoliteApp - -- (void)sendEvent:(NSEvent *)theEvent -{ - NSEventType etype = [theEvent type]; - MyOpenGLView* gameView = [_gameController gameView]; - - if ([NSApp keyWindow] == _gameWindow) - { - // Ensure key events are handled at least once when game window is key - switch (etype) - { - case NSKeyDown: - [gameView keyDown:theEvent]; - break; - - case NSKeyUp: - [gameView keyUp:theEvent]; - break; - - default: - break; - } - } - [super sendEvent:theEvent]; // perform the default event behaviour -} - - -- (void) setExitContext:(NSString *)exitContext -{ - [_exitContext release]; - _exitContext = [exitContext copy]; -} - - -- (void) terminate:(id)sender -{ - if (_exitContext == nil) [self setExitContext:@"Cocoa terminate event"]; - OOLog(@"exit.context", @"Exiting: %@.", _exitContext); - [super terminate:sender]; -} - -@end diff --git a/src/Cocoa/exports-debug-64.exp b/src/Cocoa/exports-debug-64.exp deleted file mode 100644 index 30ab64de2..000000000 --- a/src/Cocoa/exports-debug-64.exp +++ /dev/null @@ -1,79 +0,0 @@ -# Symbols used by Debug.OXP -.objc_class_name_PlayerEntity -.objc_class_name_OOCacheManager -.objc_class_name_OOGraphicsResetManager -.objc_class_name_OOTexture -.objc_class_name_ResourceManager -.objc_class_name_OOJavaScriptEngine -.objc_class_name_OOColor -.objc_class_name_OOWeakRefObject -.objc_class_name_OOScript -.objc_class_name_OOJSScript -.objc_class_name_OODebugMonitor -.objc_class_name_ShipEntity -.objc_class_name_OOEntityWithDrawable -.objc_class_name_OOOpenGLExtensionManager - -_OBJC_CLASS_$_ShipEntity -_OBJC_CLASS_$_Entity -_OBJC_CLASS_$_AI -_OBJC_CLASS_$_OOShipGroup - -_OOLogWithFunctionFileAndLine -_OOLogWithPrefix -_OOLogInsertMarker -_OOLogSetDisplayMessagesInClass -_OOLogSetShowFileAndLine -_OOLogSetShowFunction -_OOLogSetShowTime -_OOLogSetShowMessageClass -_OOLogShowFileAndLine -_OOLogShowFunction -_OOLogShowTime -_OOLogShowMessageClass -_OOLogWillDisplayMessagesInClass -_OOLogHandlerGetLogPath -_OOLogIndent -_OOLogOutdent -_gDebugFlags -_gSharedUniverse -_OOJSBasicPrivateObjectConverter -_OOJSNativeObjectFromJSObject -_OOJSRegisterObjectConverter -_JS_ConvertStub -_JS_EnumerateStub -_JS_GetPrivate -_JS_SetPrivate -_JS_InitClass -_JS_NewObject -_JS_PropertyStub -_JS_ResolveStub -_OOJSReportBadPropertySelector -_OOJSReportError -_JS_InternString -_OOJSNativeObjectFromJSValue -_JS_ValueToNumber -_JS_SetProperty -_OOJSReportWarning -_OOBooleanFromObject -_OOStringFromScanClass -_OOStringFromEntityStatus -_QuaternionDescription -_VectorDescription -_OOStringFromBehaviour -_OOStringFromShaderSetting -# _OOSoundRegisterDebugMonitor # Not implemented in OpenAL builds -_OOJSProfileEnter -_OOJSProfileExit -_OOJSUnreachable -_OOStringFromGraphicsDetail - -# Debug value formatter support -_JSValueToStrDbg -_JSObjectToStrDbg -_JSStringToStrDbg -_JSValueTypeDbg -_JSValueToStrSafeDbg -_JSObjectToStrSafeDbg -_JSStringToStrSafeDbg -_JSIDToStrSafeDbg diff --git a/src/Cocoa/exports-release.exp b/src/Cocoa/exports-release.exp deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/Cocoa/main.m b/src/Cocoa/main.m deleted file mode 100644 index 37f51dcf9..000000000 --- a/src/Cocoa/main.m +++ /dev/null @@ -1,23 +0,0 @@ -#import "OOCocoa.h" -#import "OOLoggingExtended.h" -#import "OODebugFlags.h" - - -#ifndef NDEBUG -NSUInteger gDebugFlags = 0; -#endif - -/** - * \ingroup cli - * Entry point for MacOS. Initializes logging and runs NSApplicationMain. - * - * @param argc the number of command line arguments - * @param argv the string array values of the command line arguments - * @return whatever NSApplicationMain returns - */ -int main(int argc, const char *argv[]) -{ - OOLoggingInit(); - return NSApplicationMain(argc, argv); -} - diff --git a/src/Cocoa/oolite-nonshared.xcconfig b/src/Cocoa/oolite-nonshared.xcconfig deleted file mode 100644 index 60a5bd36e..000000000 --- a/src/Cocoa/oolite-nonshared.xcconfig +++ /dev/null @@ -1,6 +0,0 @@ -#include "oolite-options.xcconfig" - -EXPORTED_SYMBOLS_FILE = src/Cocoa/exports-debug-32.exp -EXPORTED_SYMBOLS_FILE[arch=x86_64] = src/Cocoa/exports-debug-64.exp - -OO_MATHS_OPTS = -O3 diff --git a/src/Cocoa/oolite-options.xcconfig b/src/Cocoa/oolite-options.xcconfig deleted file mode 100644 index 63183e966..000000000 --- a/src/Cocoa/oolite-options.xcconfig +++ /dev/null @@ -1,10 +0,0 @@ -#include "oolite-version.xcconfig" -#include "oolite-targets.xcconfig" -#include "oolite-snapshot.xcconfig" - - -// OOLITE_MAC_OS_X is used within Oolite to detect the platform it's being built for. -// OBJC_OLD_DISPATCH_PROTOTYPES causes the Objective-C runtime headers (in the 10.8 -// SDK or later) to declare objc_msgSend(), etc. and IMP as void(*)(void), so they -// need to be cast to the appropriate function pointer type. -OOLITE_OPTION_MACROS = OOLITE_MAC_OS_X=1 OBJC_OLD_DISPATCH_PROTOTYPES=0 diff --git a/src/Cocoa/oolite-snapshot.xcconfig b/src/Cocoa/oolite-snapshot.xcconfig deleted file mode 100644 index 16e7743b4..000000000 --- a/src/Cocoa/oolite-snapshot.xcconfig +++ /dev/null @@ -1,7 +0,0 @@ -// Hacktackular: Universe.m and OOLogHeader.m have $SNAPSHOT_MACROS in their -// "Additional Compiler Flags" setting. The Mac nightly script overrides this -// file to set up the SNAPSHOT_BUILD and OOLITE_SNAPSHOT_VERSION macros. -// OO_UNUSED_MACRO is, as the name suggests, unused; putting an empty string -// here leads to build problems. - -SNAPSHOT_MACROS = "-DOO_UNUSED_MACRO" diff --git a/src/Cocoa/oolite-targets.xcconfig b/src/Cocoa/oolite-targets.xcconfig deleted file mode 100644 index 39a54c80d..000000000 --- a/src/Cocoa/oolite-targets.xcconfig +++ /dev/null @@ -1,10 +0,0 @@ -#include "oolite-warnings.xcconfig" - -ARCHS = x86_64 -SDKROOT = macosx - -MACOSX_DEPLOYMENT_TARGET = 10.6 - -GCC_VERSION = com.apple.compilers.llvm.clang.1_0 - -CLANG_ENABLE_MODULES = YES diff --git a/src/Cocoa/oolite-version.xcconfig b/src/Cocoa/oolite-version.xcconfig deleted file mode 100644 index bafb1836c..000000000 --- a/src/Cocoa/oolite-version.xcconfig +++ /dev/null @@ -1 +0,0 @@ -OOLITE_VERSION=1.93 diff --git a/src/Cocoa/oolite-warnings.xcconfig b/src/Cocoa/oolite-warnings.xcconfig deleted file mode 100644 index be03f5b8b..000000000 --- a/src/Cocoa/oolite-warnings.xcconfig +++ /dev/null @@ -1,56 +0,0 @@ -// The vast majority of format warnings in 32-bit will be using %l{diux} for -// NS[U]Integer, which is perfectly safe. It's possible suppressing this will -// miss some real bugs, but not too likely, and casting everywhere is too ugly. -OO_ARCH_WARNING_FLAGS = -OO_ARCH_WARNING_FLAGS[arch=i386] = -Wno-format - - -// Start off with all possible warnings. -OO_LOTS_OF_WARNINGS = -Weverything - -// Trim off stylistic warnings from -Wall or -Wextra that we don't want. -OO_WARNING_EXCEPTIONS = -Wno-unused-parameter -Wno-missing-field-initializers - -// Disable stuff from -Weverything that we don't want. -// -Wpedantic: Even I can't be bothered to conform to -Wpedantic. Yet. -// -Wgnu: We use GNU extensions freely. -// -Wundef: Warns about legal and normal use of the preprocessor. -// -Wobjc-interface-ivars, Wdirect-ivar-access, -Wno-receiver-forward-class: -// Newfangled Objective-C style stuff we can't adopt while being -// compatible with old versions of GNUstep and GCC. -// -Wpadded: Points out normal and exepected compiler behaviour. -// -Wfloat-equal: Would be a good warning if it ignored comparison to 0. -// -Wswitch-enum: Extra-pedantic version of -Wswitch which complains about -// missed enum cases even if there's a default case. -// -Wcast-align: rarely a real problem. -// -Wunused-exception-parameter: Who cares? -// -Wmissing-noreturn: Bad analysis for a micro-optimization. -// -Wunreachable-code: Lies. -// -Wused-but-marked-unused: This is compatible with the semantics of unused. -// -Wformat-nonliteral: Good warning, but we currently use DESC for format -// strings rather a lot. -// -Wconditional-uninitialized: Too many false positives, use static analyizer -// instead. -// -Wbad-function-cast: Warns about explicit casts of integers to other integer -// types. That's what explict casts are for. -// -Wassign-enum: Correctly warns about Cocoa's abuse of enum types for bit -// masks, which we can't do anything sensible about. -// -Wvla: We use variable-length arrays with reckless abandon. -// -Rmodule-build: Very chatty remarks about the Clang module system that we -// don't care about -// -Wcstring-format-directive Warning when using %s in NSString formatting, -// unfortunately this is triggered by NSParameterAssert -// -Wreserved-id-macro: use of initial underscores in macros, invalid but used -// in libaries -// -Wnullable-to-nonnull-conversion: ill-considered Swift compatibilit feature -// we don't care about -// -Wcast-qual: strict checking of const/volatile qualifier cast rules, which -// are incompatible with most real code. Including the C standard library. -// -Wdouble-promotion: warns about implicit casts from float to double. We -// have loads. Someone should fix them. -OO_EXTRA_WARNING_EXCEPTIONS = -Wno-pedantic -Wno-gnu -Wno-undef -Wno-objc-interface-ivars -Wno-direct-ivar-access -Wno-receiver-forward-class -Wno-padded -Wno-float-equal -Wno-switch-enum -Wno-cast-align -Wno-unused-exception-parameter -Wno-missing-noreturn -Wno-unreachable-code -Wno-used-but-marked-unused -Wno-format-nonliteral -Wno-conditional-uninitialized -Wno-bad-function-cast -Wno-assign-enum -Wno-vla -Wno-auto-import -Rno-module-build -Wno-cstring-format-directive -Wno-reserved-id-macro -Wno-nullable-to-nonnull-conversion -Wno-cast-qual -Wno-double-promotion $(OO_VERSION_SPECIFIC_WARNING_EXCEPTIONS_$(XCODE_VERSION_MINOR)) - -// Things we don't want to break the build when they're introduced by devs on other platforms. -OO_WARNING_NO_ERROR = -Wno-error=deprecated-declarations -Wno-error=semicolon-before-method-body - -OO_WARNING_FLAGS = $OO_LOTS_OF_WARNINGS $OO_WARNING_EXCEPTIONS $OO_EXTRA_WARNING_EXCEPTIONS $OO_WARNING_NO_ERROR $OO_ARCH_WARNING_FLAGS diff --git a/src/Cocoa/release-exports-64.exp b/src/Cocoa/release-exports-64.exp deleted file mode 100644 index 3d6a2b2e6..000000000 --- a/src/Cocoa/release-exports-64.exp +++ /dev/null @@ -1,9 +0,0 @@ -# Symbols used by Oolite Leopard support.bundle -_OOLogWithFunctionFileAndLine -_OOLogWillDisplayMessagesInClass -_OOLogIndent -_OOLogOutdent - -.objc_class_name_OOJoystickManager -_OBJC_CLASS_$_OOJoystickManager -_OBJC_METACLASS_$_OOJoystickManager