Removed unused code and files.

Making the mac platform easier to mantain
This commit is contained in:
Ricardo Quesada 2014-01-21 16:25:29 -08:00
parent 98d23d30a6
commit 06be466f29
5 changed files with 1 additions and 448 deletions

View File

@ -1 +1 @@
77bd50d1e878d40afd543d4d36cde040bfc21f54 98eebd5b205bbcad3d5c6b70ee9db766ab284e06

View File

@ -1,39 +0,0 @@
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
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.
****************************************************************************/
#ifndef __CC_WINDOW_H__
#define __CC_WINDOW_H__
#import <Cocoa/Cocoa.h>
@interface CCWindow : NSWindow
{
}
- (id) initWithFrame:(NSRect)frame fullscreen:(BOOL)fullscreen;
@end
#endif // __CC_WINDOW_H__

View File

@ -1,82 +0,0 @@
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
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 "CCWindow.h"
#import "EAGLView.h"
@implementation CCWindow
- (id) initWithFrame:(NSRect)frame fullscreen:(BOOL)fullscreen
{
int styleMask = fullscreen ? NSBackingStoreBuffered : ( NSTitledWindowMask | NSClosableWindowMask );
self = [self initWithContentRect:frame
styleMask:styleMask
backing:NSBackingStoreBuffered
defer:YES];
if (self != nil)
{
if(fullscreen)
{
[self setLevel:NSMainMenuWindowLevel+1];
[self setHidesOnDeactivate:YES];
[self setHasShadow:NO];
}
[self setAcceptsMouseMovedEvents:NO];
[self setOpaque:YES];
}
return self;
}
- (BOOL) canBecomeKeyWindow
{
return YES;
}
- (BOOL) canBecomeMainWindow
{
return YES;
}
- (void) keyDown:(NSEvent *)event
{
// exit fullscreen if user pressed esc
if([event keyCode] == 53)
{
CCEAGLView* eaglView = [CCEAGLView sharedEGLView];
// cancel full screen
if( [eaglView isFullScreen] )
[eaglView setFullScreen:NO];
// let another responder take it
else
[super keyDown:event];
}
}
@end

View File

@ -113,8 +113,6 @@ THE SOFTWARE.
-(int) getHeight; -(int) getHeight;
-(void) swapBuffers; -(void) swapBuffers;
-(void) setFullScreen:(BOOL)fullscreen;
@end @end
#endif // __EAGLVIEW_MAC_H__ #endif // __EAGLVIEW_MAC_H__

View File

@ -37,7 +37,6 @@ THE SOFTWARE.
#import "CCSet.h" #import "CCSet.h"
#import "CCTouch.h" #import "CCTouch.h"
#import "CCIMEDispatcher.h" #import "CCIMEDispatcher.h"
#import "CCWindow.h"
#import "CCEventDispatcherMac.h" #import "CCEventDispatcherMac.h"
#import "CCEGLView.h" #import "CCEGLView.h"
@ -54,60 +53,6 @@ static CCEAGLView *view;
return view; return view;
} }
- (id) initWithFrame:(NSRect)frameRect
{
self = [self initWithFrame:frameRect shareContext:nil];
return self;
}
- (id) initWithFrame:(NSRect)frameRect shareContext:(NSOpenGLContext*)context
{
NSOpenGLPixelFormatAttribute attribs[] =
{
// NSOpenGLPFAAccelerated,
// NSOpenGLPFANoRecovery,
NSOpenGLPFADoubleBuffer,
NSOpenGLPFADepthSize, 24,
0
};
NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
if (!pixelFormat)
NSLog(@"No OpenGL pixel format");
if( (self = [super initWithFrame:frameRect pixelFormat:[pixelFormat autorelease]]) ) {
if( context )
[self setOpenGLContext:context];
// event delegate
eventDelegate_ = [CCEventDispatcher sharedDispatcher];
}
cocos2d::EGLView::getInstance()->setFrameSize(frameRect.size.width, frameRect.size.height);
frameZoomFactor_ = 1.0f;
view = self;
return self;
}
- (id) initWithFrame:(NSRect)frameRect pixelFormat:(NSOpenGLPixelFormat *)format{
// event delegate
eventDelegate_ = [CCEventDispatcher sharedDispatcher];
cocos2d::EGLView::getInstance()->setFrameSize(frameRect.size.width, frameRect.size.height);
frameZoomFactor_ = 1.0f;
view = self;
[super initWithFrame:frameRect pixelFormat:format];
return self;
}
- (void) update - (void) update
{ {
@ -218,273 +163,4 @@ static CCEAGLView *view;
return bound.height; return bound.height;
} }
-(void) swapBuffers
{
}
//
// setFullScreen code taken from GLFullScreen example by Apple
//
- (void) setFullScreen:(BOOL)fullscreen
{
// Mac OS X 10.6 and later offer a simplified mechanism to create full-screen contexts
#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5
if (isFullScreen_ == fullscreen)
return;
CCEAGLView *openGLview = [[self class] sharedEGLView];
if( fullscreen ) {
originalWinRect_ = [openGLview frame];
// Cache normal window and superview of openGLView
if(!windowGLView_)
windowGLView_ = [[openGLview window] retain];
[superViewGLView_ release];
superViewGLView_ = [[openGLview superview] retain];
// Get screen size
NSRect displayRect = [[NSScreen mainScreen] frame];
// Create a screen-sized window on the display you want to take over
fullScreenWindow_ = [[CCWindow alloc] initWithFrame:displayRect fullscreen:YES];
// Remove glView from window
[openGLview removeFromSuperview];
// Set new frame
[openGLview setFrame:displayRect];
// Attach glView to fullscreen window
[fullScreenWindow_ setContentView:openGLview];
// Show the fullscreen window
[fullScreenWindow_ makeKeyAndOrderFront:self];
[fullScreenWindow_ makeMainWindow];
//[fullScreenWindow_ setNextResponder:superViewGLView_];
} else {
// Remove glView from fullscreen window
[openGLview removeFromSuperview];
// Release fullscreen window
[fullScreenWindow_ release];
fullScreenWindow_ = nil;
// Attach glView to superview
[superViewGLView_ addSubview:openGLview];
// Set new frame
[openGLview setFrame:originalWinRect_];
// Show the window
[windowGLView_ makeKeyAndOrderFront:self];
[windowGLView_ makeMainWindow];
}
// issue #1189
[windowGLView_ makeFirstResponder:openGLview];
isFullScreen_ = fullscreen;
//[openGLview retain]; // Retain +1
// is this necessary?
// re-configure glView
//cocos2d::Director *director = cocos2d::Director::getInstance();
//director->setOpenGLView(openGLview); //[self setView:openGLview];
//[openGLview release]; // Retain -1
[openGLview setNeedsDisplay:YES];
#else
#error Full screen is not supported for Mac OS 10.5 or older yet
#error If you don't want FullScreen support, you can safely remove these 2 lines
#endif
}
#if CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
#define DISPATCH_EVENT(__event__, __selector__) [eventDelegate_ queueEvent:__event__ selector:__selector__];
#else
#define DISPATCH_EVENT(__event__, __selector__) \
id obj = eventDelegate_; \
[obj performSelector:__selector__ \
onThread:[(cocos2d::Director*)[Director sharedDirector] runningThread] \
withObject:__event__ \
waitUntilDone:NO];
#endif
#pragma mark CCEAGLView - Mouse events
- (void)mouseDown:(NSEvent *)theEvent
{
NSPoint event_location = [theEvent locationInWindow];
NSPoint local_point = [self convertPoint:event_location fromView:nil];
float x = local_point.x;
float y = [self getHeight] - local_point.y;
NSInteger ids[1] = {0};
float xs[1] = {0.0f};
float ys[1] = {0.0f};
ids[0] = [theEvent eventNumber];
xs[0] = x / frameZoomFactor_;
ys[0] = y / frameZoomFactor_;
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesBegin(1, (int*)ids, xs, ys);
}
- (void)mouseMoved:(NSEvent *)theEvent
{
DISPATCH_EVENT(theEvent, _cmd);
}
- (void)mouseDragged:(NSEvent *)theEvent
{
NSPoint event_location = [theEvent locationInWindow];
NSPoint local_point = [self convertPoint:event_location fromView:nil];
float x = local_point.x;
float y = [self getHeight] - local_point.y;
NSInteger ids[1] = {0};
float xs[1] = {0.0f};
float ys[1] = {0.0f};
ids[0] = [theEvent eventNumber];
xs[0] = x / frameZoomFactor_;
ys[0] = y / frameZoomFactor_;
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesMove(1, (int*)ids, xs, ys);
}
- (void)mouseUp:(NSEvent *)theEvent
{
NSPoint event_location = [theEvent locationInWindow];
NSPoint local_point = [self convertPoint:event_location fromView:nil];
float x = local_point.x;
float y = [self getHeight] - local_point.y;
NSInteger ids[1] = {0};
float xs[1] = {0.0f};
float ys[1] = {0.0f};
ids[0] = [theEvent eventNumber];
xs[0] = x / frameZoomFactor_;
ys[0] = y / frameZoomFactor_;
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesEnd(1, (int*)ids, xs, ys);
}
- (void)rightMouseDown:(NSEvent *)theEvent {
DISPATCH_EVENT(theEvent, _cmd);
// pass the event along to the next responder (like your NSWindow subclass)
[super rightMouseDown:theEvent];
}
- (void)rightMouseDragged:(NSEvent *)theEvent {
DISPATCH_EVENT(theEvent, _cmd);
[super rightMouseDragged:theEvent];
}
- (void)rightMouseUp:(NSEvent *)theEvent {
DISPATCH_EVENT(theEvent, _cmd);
[super rightMouseUp:theEvent];
}
- (void)otherMouseDown:(NSEvent *)theEvent {
DISPATCH_EVENT(theEvent, _cmd);
[super otherMouseDown:theEvent];
}
- (void)otherMouseDragged:(NSEvent *)theEvent {
DISPATCH_EVENT(theEvent, _cmd);
[super otherMouseDragged:theEvent];
}
- (void)otherMouseUp:(NSEvent *)theEvent {
DISPATCH_EVENT(theEvent, _cmd);
[super otherMouseUp:theEvent];
}
- (void)mouseEntered:(NSEvent *)theEvent {
DISPATCH_EVENT(theEvent, _cmd);
[super mouseEntered:theEvent];
}
- (void)mouseExited:(NSEvent *)theEvent {
DISPATCH_EVENT(theEvent, _cmd);
[super mouseExited:theEvent];
}
-(void) scrollWheel:(NSEvent *)theEvent {
DISPATCH_EVENT(theEvent, _cmd);
[super scrollWheel:theEvent];
}
#pragma mark CCEAGLView - Key events
-(BOOL) becomeFirstResponder
{
return YES;
}
-(BOOL) acceptsFirstResponder
{
return YES;
}
-(BOOL) resignFirstResponder
{
return YES;
}
- (void)keyDown:(NSEvent *)theEvent
{
DISPATCH_EVENT(theEvent, _cmd);
// pass the event along to the next responder (like your NSWindow subclass)
[super keyDown:theEvent];
}
- (void)keyUp:(NSEvent *)theEvent
{
DISPATCH_EVENT(theEvent, _cmd);
// pass the event along to the next responder (like your NSWindow subclass)
[super keyUp:theEvent];
}
- (void)flagsChanged:(NSEvent *)theEvent
{
DISPATCH_EVENT(theEvent, _cmd);
}
#pragma mark CCEAGLView - Touch events
- (void)touchesBeganWithEvent:(NSEvent *)theEvent
{
DISPATCH_EVENT(theEvent, _cmd);
}
- (void)touchesMovedWithEvent:(NSEvent *)theEvent
{
DISPATCH_EVENT(theEvent, _cmd);
}
- (void)touchesEndedWithEvent:(NSEvent *)theEvent
{
DISPATCH_EVENT(theEvent, _cmd);
}
- (void)touchesCancelledWithEvent:(NSEvent *)theEvent
{
DISPATCH_EVENT(theEvent, _cmd);
}
@end @end