Line data Source code
1 0 : /* 2 : 3 : OoliteApp.m 4 : 5 : Oolite 6 : Copyright (C) 2004-2013 Giles C Williams and contributors 7 : 8 : This program is free software; you can redistribute it and/or 9 : modify it under the terms of the GNU General Public License 10 : as published by the Free Software Foundation; either version 2 11 : of the License, or (at your option) any later version. 12 : 13 : This program is distributed in the hope that it will be useful, 14 : but WITHOUT ANY WARRANTY; without even the implied warranty of 15 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 : GNU General Public License for more details. 17 : 18 : You should have received a copy of the GNU General Public License 19 : along with this program; if not, write to the Free Software 20 : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 21 : MA 02110-1301, USA. 22 : 23 : */ 24 : 25 : #import "OoliteApp.h" 26 : #import "GameController.h" 27 : #import "MyOpenGLView.h" 28 : 29 : 30 : @implementation OoliteApp 31 : 32 0 : - (void)sendEvent:(NSEvent *)theEvent 33 : { 34 : NSEventType etype = [theEvent type]; 35 : MyOpenGLView* gameView = [_gameController gameView]; 36 : 37 : if ([NSApp keyWindow] == _gameWindow) 38 : { 39 : // Ensure key events are handled at least once when game window is key 40 : switch (etype) 41 : { 42 : case NSKeyDown: 43 : [gameView keyDown:theEvent]; 44 : break; 45 : 46 : case NSKeyUp: 47 : [gameView keyUp:theEvent]; 48 : break; 49 : 50 : default: 51 : break; 52 : } 53 : } 54 : [super sendEvent:theEvent]; // perform the default event behaviour 55 : } 56 : 57 : 58 : - (void) setExitContext:(NSString *)exitContext 59 : { 60 : [_exitContext release]; 61 : _exitContext = [exitContext copy]; 62 : } 63 : 64 : 65 0 : - (void) terminate:(id)sender 66 : { 67 : if (_exitContext == nil) [self setExitContext:@"Cocoa terminate event"]; 68 : OOLog(@"exit.context", @"Exiting: %@.", _exitContext); 69 : [super terminate:sender]; 70 : } 71 : 72 : @end