mirror of https://github.com/axmolengine/axmol.git
Merge pull request #2956 from ricardoquesada/cc_namespace_obj
issue #2129: Re-adds 'CC' prefix to objective-c classes.
This commit is contained in:
commit
2a715ec3cf
|
@ -29,7 +29,7 @@
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
#import <functional>
|
#import <functional>
|
||||||
|
|
||||||
@interface AccelerometerDispatcher : NSObject<UIAccelerometerDelegate>
|
@interface CCAccelerometerDispatcher : NSObject<UIAccelerometerDelegate>
|
||||||
{
|
{
|
||||||
std::function<void(cocos2d::Acceleration*)> _function;
|
std::function<void(cocos2d::Acceleration*)> _function;
|
||||||
cocos2d::Acceleration *_acceleration;
|
cocos2d::Acceleration *_acceleration;
|
||||||
|
@ -42,9 +42,9 @@
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation AccelerometerDispatcher
|
@implementation CCAccelerometerDispatcher
|
||||||
|
|
||||||
static AccelerometerDispatcher* s_pAccelerometerDispatcher;
|
static CCAccelerometerDispatcher* s_pAccelerometerDispatcher;
|
||||||
|
|
||||||
+ (id) sharedAccelerometerDispather
|
+ (id) sharedAccelerometerDispather
|
||||||
{
|
{
|
||||||
|
@ -140,12 +140,12 @@ Accelerometer::~Accelerometer() {}
|
||||||
|
|
||||||
void Accelerometer::setDelegate(std::function<void (Acceleration *)> function)
|
void Accelerometer::setDelegate(std::function<void (Acceleration *)> function)
|
||||||
{
|
{
|
||||||
[[AccelerometerDispatcher sharedAccelerometerDispather] addDelegate:function];
|
[[CCAccelerometerDispatcher sharedAccelerometerDispather] addDelegate:function];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Accelerometer::setAccelerometerInterval(float interval)
|
void Accelerometer::setAccelerometerInterval(float interval)
|
||||||
{
|
{
|
||||||
[[AccelerometerDispatcher sharedAccelerometerDispather] setAccelerometerInterval:interval];
|
[[CCAccelerometerDispatcher sharedAccelerometerDispather] setAccelerometerInterval:interval];
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -49,14 +49,14 @@ int Application::run()
|
||||||
{
|
{
|
||||||
if (applicationDidFinishLaunching())
|
if (applicationDidFinishLaunching())
|
||||||
{
|
{
|
||||||
[[DirectorCaller sharedDirectorCaller] startMainLoop];
|
[[CCDirectorCaller sharedDirectorCaller] startMainLoop];
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::setAnimationInterval(double interval)
|
void Application::setAnimationInterval(double interval)
|
||||||
{
|
{
|
||||||
[[DirectorCaller sharedDirectorCaller] setAnimationInterval: interval ];
|
[[CCDirectorCaller sharedDirectorCaller] setAnimationInterval: interval ];
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
@interface DirectorCaller : NSObject {
|
@interface CCDirectorCaller : NSObject {
|
||||||
id displayLink;
|
id displayLink;
|
||||||
int interval;
|
int interval;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ static id s_sharedDirectorCaller;
|
||||||
-(void) invalidate;
|
-(void) invalidate;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation DirectorCaller
|
@implementation CCDirectorCaller
|
||||||
|
|
||||||
@synthesize interval;
|
@synthesize interval;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ static id s_sharedDirectorCaller;
|
||||||
{
|
{
|
||||||
if (s_sharedDirectorCaller == nil)
|
if (s_sharedDirectorCaller == nil)
|
||||||
{
|
{
|
||||||
s_sharedDirectorCaller = [DirectorCaller new];
|
s_sharedDirectorCaller = [CCDirectorCaller new];
|
||||||
}
|
}
|
||||||
|
|
||||||
return s_sharedDirectorCaller;
|
return s_sharedDirectorCaller;
|
||||||
|
|
|
@ -32,8 +32,8 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
EGLView::EGLView()
|
EGLView::EGLView()
|
||||||
{
|
{
|
||||||
_screenSize.width = _designResolutionSize.width = [[EAGLView sharedEGLView] getWidth];
|
_screenSize.width = _designResolutionSize.width = [[CCEAGLView sharedEGLView] getWidth];
|
||||||
_screenSize.height = _designResolutionSize.height = [[EAGLView sharedEGLView] getHeight];
|
_screenSize.height = _designResolutionSize.height = [[CCEAGLView sharedEGLView] getHeight];
|
||||||
}
|
}
|
||||||
|
|
||||||
EGLView::~EGLView()
|
EGLView::~EGLView()
|
||||||
|
@ -43,7 +43,7 @@ EGLView::~EGLView()
|
||||||
|
|
||||||
bool EGLView::isOpenGLReady()
|
bool EGLView::isOpenGLReady()
|
||||||
{
|
{
|
||||||
return [EAGLView sharedEGLView] != NULL;
|
return [CCEAGLView sharedEGLView] != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EGLView::setContentScaleFactor(float contentScaleFactor)
|
bool EGLView::setContentScaleFactor(float contentScaleFactor)
|
||||||
|
@ -51,34 +51,34 @@ bool EGLView::setContentScaleFactor(float contentScaleFactor)
|
||||||
assert(_resolutionPolicy == kResolutionUnKnown); // cannot enable retina mode
|
assert(_resolutionPolicy == kResolutionUnKnown); // cannot enable retina mode
|
||||||
|
|
||||||
_scaleX = _scaleY = contentScaleFactor;
|
_scaleX = _scaleY = contentScaleFactor;
|
||||||
[[EAGLView sharedEGLView] setNeedsLayout];
|
[[CCEAGLView sharedEGLView] setNeedsLayout];
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EGLView::end()
|
void EGLView::end()
|
||||||
{
|
{
|
||||||
[DirectorCaller destroy];
|
[CCDirectorCaller destroy];
|
||||||
|
|
||||||
// destroy EAGLView
|
// destroy EAGLView
|
||||||
[[EAGLView sharedEGLView] removeFromSuperview];
|
[[CCEAGLView sharedEGLView] removeFromSuperview];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EGLView::swapBuffers()
|
void EGLView::swapBuffers()
|
||||||
{
|
{
|
||||||
[[EAGLView sharedEGLView] swapBuffers];
|
[[CCEAGLView sharedEGLView] swapBuffers];
|
||||||
}
|
}
|
||||||
|
|
||||||
void EGLView::setIMEKeyboardState(bool bOpen)
|
void EGLView::setIMEKeyboardState(bool bOpen)
|
||||||
{
|
{
|
||||||
if (bOpen)
|
if (bOpen)
|
||||||
{
|
{
|
||||||
[[EAGLView sharedEGLView] becomeFirstResponder];
|
[[CCEAGLView sharedEGLView] becomeFirstResponder];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[[EAGLView sharedEGLView] resignFirstResponder];
|
[[CCEAGLView sharedEGLView] resignFirstResponder];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
|
||||||
* The view content is basically an EAGL surface you render your OpenGL scene into.
|
* The view content is basically an EAGL surface you render your OpenGL scene into.
|
||||||
* Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.
|
* Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.
|
||||||
*/
|
*/
|
||||||
@interface EAGLView : UIView <UIKeyInput, UITextInput>
|
@interface CCEAGLView : UIView <UIKeyInput, UITextInput>
|
||||||
{
|
{
|
||||||
id <CCESRenderer> renderer_;
|
id <CCESRenderer> renderer_;
|
||||||
EAGLContext *context_; // weak ref
|
EAGLContext *context_; // weak ref
|
||||||
|
|
|
@ -75,14 +75,14 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
|
||||||
|
|
||||||
#define IOS_MAX_TOUCHES_COUNT 10
|
#define IOS_MAX_TOUCHES_COUNT 10
|
||||||
|
|
||||||
static EAGLView *view = 0;
|
static CCEAGLView *view = 0;
|
||||||
|
|
||||||
@interface EAGLView (Private)
|
@interface CCEAGLView (Private)
|
||||||
- (BOOL) setupSurfaceWithSharegroup:(EAGLSharegroup*)sharegroup;
|
- (BOOL) setupSurfaceWithSharegroup:(EAGLSharegroup*)sharegroup;
|
||||||
- (unsigned int) convertPixelFormat:(NSString*) pixelFormat;
|
- (unsigned int) convertPixelFormat:(NSString*) pixelFormat;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation EAGLView
|
@implementation CCEAGLView
|
||||||
|
|
||||||
@synthesize surfaceSize=size_;
|
@synthesize surfaceSize=size_;
|
||||||
@synthesize pixelFormat=pixelformat_, depthFormat=depthFormat_;
|
@synthesize pixelFormat=pixelformat_, depthFormat=depthFormat_;
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// our own version of the Accelerometer
|
// our own version of the Accelerometer
|
||||||
@interface AccelerometerSimulation : UIAccelerometer <NSMachPortDelegate>
|
@interface CCAccelerometerSimulation : UIAccelerometer <NSMachPortDelegate>
|
||||||
{
|
{
|
||||||
|
|
||||||
//CFSocketRef udpSocket;
|
//CFSocketRef udpSocket;
|
||||||
|
@ -51,8 +51,8 @@
|
||||||
- (void) setUpThreadingSupport;
|
- (void) setUpThreadingSupport;
|
||||||
- (void) handleMachMessage:(void *) msg;
|
- (void) handleMachMessage:(void *) msg;
|
||||||
- (void) processNotification:(NSNotification *) notification;
|
- (void) processNotification:(NSNotification *) notification;
|
||||||
+ (AccelerometerSimulation *)getAccelerometer;
|
+ (CCAccelerometerSimulation *)getAccelerometer;
|
||||||
- (AccelerometerSimulation *)initialize;
|
- (CCAccelerometerSimulation *)initialize;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
// override the static method and return our simulated version instead
|
// override the static method and return our simulated version instead
|
||||||
+ (UIAccelerometer *)sharedAccelerometer
|
+ (UIAccelerometer *)sharedAccelerometer
|
||||||
{
|
{
|
||||||
return [AccelerometerSimulation getAccelerometer];
|
return [CCAccelerometerSimulation getAccelerometer];
|
||||||
}
|
}
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
@end
|
@end
|
||||||
|
@ -63,9 +63,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// singleton
|
// singleton
|
||||||
static AccelerometerSimulation *sharedAccelerometer = NULL;
|
static CCAccelerometerSimulation *sharedAccelerometer = NULL;
|
||||||
|
|
||||||
@implementation AccelerometerSimulation
|
@implementation CCAccelerometerSimulation
|
||||||
|
|
||||||
- (void) dealloc {
|
- (void) dealloc {
|
||||||
if (sharedAccelerometer) {
|
if (sharedAccelerometer) {
|
||||||
|
@ -135,10 +135,10 @@ static AccelerometerSimulation *sharedAccelerometer = NULL;
|
||||||
[notificationLock unlock];
|
[notificationLock unlock];
|
||||||
}
|
}
|
||||||
#ifndef __clang_analyzer__
|
#ifndef __clang_analyzer__
|
||||||
+ (AccelerometerSimulation *)getAccelerometer
|
+ (CCAccelerometerSimulation *)getAccelerometer
|
||||||
{
|
{
|
||||||
if( sharedAccelerometer == NULL )
|
if( sharedAccelerometer == NULL )
|
||||||
sharedAccelerometer = [[AccelerometerSimulation alloc] initialize];
|
sharedAccelerometer = [[CCAccelerometerSimulation alloc] initialize];
|
||||||
|
|
||||||
return sharedAccelerometer;
|
return sharedAccelerometer;
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ static AccelerometerSimulation *sharedAccelerometer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize our version of the accelerometer
|
// initialize our version of the accelerometer
|
||||||
- (AccelerometerSimulation *)initialize
|
- (CCAccelerometerSimulation *)initialize
|
||||||
{
|
{
|
||||||
accObject = [UIAccelerationSimulation alloc];
|
accObject = [UIAccelerationSimulation alloc];
|
||||||
isExiting = false;
|
isExiting = false;
|
||||||
|
|
|
@ -50,14 +50,14 @@ int Application::run()
|
||||||
{
|
{
|
||||||
if (/*initInstance() &&*/ applicationDidFinishLaunching())
|
if (/*initInstance() &&*/ applicationDidFinishLaunching())
|
||||||
{
|
{
|
||||||
[[DirectorCaller sharedDirectorCaller] startMainLoop];
|
[[CCDirectorCaller sharedDirectorCaller] startMainLoop];
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::setAnimationInterval(double interval)
|
void Application::setAnimationInterval(double interval)
|
||||||
{
|
{
|
||||||
[[DirectorCaller sharedDirectorCaller] setAnimationInterval: interval ];
|
[[CCDirectorCaller sharedDirectorCaller] setAnimationInterval: interval ];
|
||||||
}
|
}
|
||||||
|
|
||||||
TargetPlatform Application::getTargetPlatform()
|
TargetPlatform Application::getTargetPlatform()
|
||||||
|
|
|
@ -63,7 +63,7 @@ void MessageBox(const char * pszMsg, const char * pszTitle)
|
||||||
[alert setInformativeText:title];
|
[alert setInformativeText:title];
|
||||||
[alert setAlertStyle:NSWarningAlertStyle];
|
[alert setAlertStyle:NSWarningAlertStyle];
|
||||||
|
|
||||||
NSWindow *window = [[EAGLView sharedEGLView] window];
|
NSWindow *window = [[CCEAGLView sharedEGLView] window];
|
||||||
[alert beginSheetModalForWindow:window
|
[alert beginSheetModalForWindow:window
|
||||||
modalDelegate:[window delegate]
|
modalDelegate:[window delegate]
|
||||||
didEndSelector:nil
|
didEndSelector:nil
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import <QuartzCore/CVDisplayLink.h>
|
#import <QuartzCore/CVDisplayLink.h>
|
||||||
|
|
||||||
@interface DirectorCaller : NSObject {
|
@interface CCDirectorCaller : NSObject {
|
||||||
CVDisplayLinkRef displayLink;
|
CVDisplayLinkRef displayLink;
|
||||||
NSTimer *renderTimer;
|
NSTimer *renderTimer;
|
||||||
int interval;
|
int interval;
|
||||||
|
|
|
@ -37,7 +37,7 @@ static id s_sharedDirectorCaller;
|
||||||
-(void) invalidate;
|
-(void) invalidate;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation DirectorCaller
|
@implementation CCDirectorCaller
|
||||||
|
|
||||||
@synthesize interval;
|
@synthesize interval;
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ static id s_sharedDirectorCaller;
|
||||||
{
|
{
|
||||||
if (s_sharedDirectorCaller == nil)
|
if (s_sharedDirectorCaller == nil)
|
||||||
{
|
{
|
||||||
s_sharedDirectorCaller = [[DirectorCaller alloc] init];
|
s_sharedDirectorCaller = [[CCDirectorCaller alloc] init];
|
||||||
}
|
}
|
||||||
|
|
||||||
return s_sharedDirectorCaller;
|
return s_sharedDirectorCaller;
|
||||||
|
@ -81,7 +81,7 @@ static id s_sharedDirectorCaller;
|
||||||
|
|
||||||
cocos2d::Director::sharedDirector()->drawScene();
|
cocos2d::Director::sharedDirector()->drawScene();
|
||||||
cocos2d::PoolManager::sharedPoolManager()->pop();
|
cocos2d::PoolManager::sharedPoolManager()->pop();
|
||||||
[[EventDispatcher sharedDispatcher] dispatchQueuedEvents];
|
[[CCEventDispatcher sharedDispatcher] dispatchQueuedEvents];
|
||||||
|
|
||||||
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:nil];
|
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:nil];
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
// get the opengl view
|
// get the opengl view
|
||||||
EAGLView *openGLView = [EAGLView sharedEGLView];
|
CCEAGLView *openGLView = [CCEAGLView sharedEGLView];
|
||||||
[openGLView lockOpenGLContext];
|
[openGLView lockOpenGLContext];
|
||||||
|
|
||||||
// run the main cocos2d loop
|
// run the main cocos2d loop
|
||||||
|
@ -127,7 +127,7 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime
|
||||||
[openGLView unlockOpenGLContext];
|
[openGLView unlockOpenGLContext];
|
||||||
|
|
||||||
// send any queued events
|
// send any queued events
|
||||||
[[EventDispatcher sharedDispatcher] dispatchQueuedEvents];
|
[[CCEventDispatcher sharedDispatcher] dispatchQueuedEvents];
|
||||||
|
|
||||||
[pool release];
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ EGLView::~EGLView(void)
|
||||||
|
|
||||||
bool EGLView::isOpenGLReady(void)
|
bool EGLView::isOpenGLReady(void)
|
||||||
{
|
{
|
||||||
return [EAGLView sharedEGLView] != NULL;
|
return [CCEAGLView sharedEGLView] != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EGLView::setContentScaleFactor(float contentScaleFactor)
|
bool EGLView::setContentScaleFactor(float contentScaleFactor)
|
||||||
|
@ -63,34 +63,34 @@ bool EGLView::setContentScaleFactor(float contentScaleFactor)
|
||||||
|
|
||||||
void EGLView::end(void)
|
void EGLView::end(void)
|
||||||
{
|
{
|
||||||
[[DirectorCaller sharedDirectorCaller] end];
|
[[CCDirectorCaller sharedDirectorCaller] end];
|
||||||
|
|
||||||
// destroy EAGLView
|
// destroy EAGLView
|
||||||
[[EAGLView sharedEGLView] removeFromSuperview];
|
[[CCEAGLView sharedEGLView] removeFromSuperview];
|
||||||
|
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EGLView::swapBuffers()
|
void EGLView::swapBuffers()
|
||||||
{
|
{
|
||||||
[[EAGLView sharedEGLView] swapBuffers];
|
[[CCEAGLView sharedEGLView] swapBuffers];
|
||||||
}
|
}
|
||||||
|
|
||||||
void EGLView::setIMEKeyboardState(bool bOpen)
|
void EGLView::setIMEKeyboardState(bool bOpen)
|
||||||
{
|
{
|
||||||
if (bOpen)
|
if (bOpen)
|
||||||
{
|
{
|
||||||
[[EAGLView sharedEGLView] becomeFirstResponder];
|
[[CCEAGLView sharedEGLView] becomeFirstResponder];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[[EAGLView sharedEGLView] resignFirstResponder];
|
[[CCEAGLView sharedEGLView] resignFirstResponder];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EGLView::setViewPortInPoints(float x , float y , float w , float h)
|
void EGLView::setViewPortInPoints(float x , float y , float w , float h)
|
||||||
{
|
{
|
||||||
float frameZoomFactor = [[EAGLView sharedEGLView] frameZoomFactor];
|
float frameZoomFactor = [[CCEAGLView sharedEGLView] frameZoomFactor];
|
||||||
|
|
||||||
glViewport((GLint)(x * _scaleX * frameZoomFactor + _viewPortRect.origin.x * frameZoomFactor),
|
glViewport((GLint)(x * _scaleX * frameZoomFactor + _viewPortRect.origin.x * frameZoomFactor),
|
||||||
(GLint)(y * _scaleY * frameZoomFactor + _viewPortRect.origin.y * frameZoomFactor),
|
(GLint)(y * _scaleY * frameZoomFactor + _viewPortRect.origin.y * frameZoomFactor),
|
||||||
|
@ -100,7 +100,7 @@ void EGLView::setViewPortInPoints(float x , float y , float w , float h)
|
||||||
|
|
||||||
void EGLView::setScissorInPoints(float x , float y , float w , float h)
|
void EGLView::setScissorInPoints(float x , float y , float w , float h)
|
||||||
{
|
{
|
||||||
float frameZoomFactor = [[EAGLView sharedEGLView] frameZoomFactor];
|
float frameZoomFactor = [[CCEAGLView sharedEGLView] frameZoomFactor];
|
||||||
|
|
||||||
glScissor((GLint)(x * _scaleX * frameZoomFactor + _viewPortRect.origin.x * frameZoomFactor),
|
glScissor((GLint)(x * _scaleX * frameZoomFactor + _viewPortRect.origin.x * frameZoomFactor),
|
||||||
(GLint)(y * _scaleY * frameZoomFactor + _viewPortRect.origin.y * frameZoomFactor),
|
(GLint)(y * _scaleY * frameZoomFactor + _viewPortRect.origin.y * frameZoomFactor),
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
/** MouseEventDelegate protocol.
|
/** MouseEventDelegate protocol.
|
||||||
Implement it in your node to receive any of mouse events
|
Implement it in your node to receive any of mouse events
|
||||||
*/
|
*/
|
||||||
@protocol MouseEventDelegate <NSObject>
|
@protocol CCMouseEventDelegate <NSObject>
|
||||||
@optional
|
@optional
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -141,7 +141,7 @@
|
||||||
/** KeyboardEventDelegate protocol.
|
/** KeyboardEventDelegate protocol.
|
||||||
Implement it in your node to receive any of keyboard events
|
Implement it in your node to receive any of keyboard events
|
||||||
*/
|
*/
|
||||||
@protocol KeyboardEventDelegate <NSObject>
|
@protocol CCKeyboardEventDelegate <NSObject>
|
||||||
@optional
|
@optional
|
||||||
/** called when the "keyUp" event is received.
|
/** called when the "keyUp" event is received.
|
||||||
Return YES to avoid propagating the event to other delegates.
|
Return YES to avoid propagating the event to other delegates.
|
||||||
|
@ -164,7 +164,7 @@
|
||||||
/** TouchEventDelegate protocol.
|
/** TouchEventDelegate protocol.
|
||||||
Implement it in your node to receive any of touch events
|
Implement it in your node to receive any of touch events
|
||||||
*/
|
*/
|
||||||
@protocol TouchEventDelegate <NSObject>
|
@protocol CCTouchEventDelegate <NSObject>
|
||||||
@optional
|
@optional
|
||||||
/** called when the "touchesBegan" event is received.
|
/** called when the "touchesBegan" event is received.
|
||||||
Return YES to avoid propagating the event to other delegates.
|
Return YES to avoid propagating the event to other delegates.
|
||||||
|
@ -203,7 +203,7 @@ struct _listEntry;
|
||||||
|
|
||||||
Only available on Mac
|
Only available on Mac
|
||||||
*/
|
*/
|
||||||
@interface EventDispatcher : NSObject <MacEventDelegate> {
|
@interface CCEventDispatcher : NSObject <CCMacEventDelegate> {
|
||||||
|
|
||||||
BOOL dispatchEvents_;
|
BOOL dispatchEvents_;
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ struct _listEntry;
|
||||||
|
|
||||||
|
|
||||||
/** EventDispatcher singleton */
|
/** EventDispatcher singleton */
|
||||||
+(EventDispatcher*) sharedDispatcher;
|
+(CCEventDispatcher*) sharedDispatcher;
|
||||||
|
|
||||||
#pragma mark EventDispatcher - Mouse
|
#pragma mark EventDispatcher - Mouse
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ struct _listEntry;
|
||||||
|
|
||||||
IMPORTANT: The delegate will be retained.
|
IMPORTANT: The delegate will be retained.
|
||||||
*/
|
*/
|
||||||
-(void) addMouseDelegate:(id<MouseEventDelegate>) delegate priority:(NSInteger)priority;
|
-(void) addMouseDelegate:(id<CCMouseEventDelegate>) delegate priority:(NSInteger)priority;
|
||||||
|
|
||||||
/** removes a mouse delegate */
|
/** removes a mouse delegate */
|
||||||
-(void) removeMouseDelegate:(id) delegate;
|
-(void) removeMouseDelegate:(id) delegate;
|
||||||
|
@ -242,7 +242,7 @@ struct _listEntry;
|
||||||
|
|
||||||
IMPORTANT: The delegate will be retained.
|
IMPORTANT: The delegate will be retained.
|
||||||
*/
|
*/
|
||||||
-(void) addKeyboardDelegate:(id<KeyboardEventDelegate>) delegate priority:(NSInteger)priority;
|
-(void) addKeyboardDelegate:(id<CCKeyboardEventDelegate>) delegate priority:(NSInteger)priority;
|
||||||
|
|
||||||
/** removes a mouse delegate */
|
/** removes a mouse delegate */
|
||||||
-(void) removeKeyboardDelegate:(id) delegate;
|
-(void) removeKeyboardDelegate:(id) delegate;
|
||||||
|
@ -258,7 +258,7 @@ struct _listEntry;
|
||||||
|
|
||||||
IMPORTANT: The delegate will be retained.
|
IMPORTANT: The delegate will be retained.
|
||||||
*/
|
*/
|
||||||
- (void)addTouchDelegate:(id<TouchEventDelegate>)delegate priority:(NSInteger)priority;
|
- (void)addTouchDelegate:(id<CCTouchEventDelegate>)delegate priority:(NSInteger)priority;
|
||||||
|
|
||||||
/** Removes a touch delegate */
|
/** Removes a touch delegate */
|
||||||
- (void)removeTouchDelegate:(id) delegate;
|
- (void)removeTouchDelegate:(id) delegate;
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
#include "keyboard_dispatcher/CCKeyboardDispatcher.h"
|
#include "keyboard_dispatcher/CCKeyboardDispatcher.h"
|
||||||
|
|
||||||
//NS_CC_BEGIN;
|
//NS_CC_BEGIN;
|
||||||
static EventDispatcher *sharedDispatcher = nil;
|
static CCEventDispatcher *sharedDispatcher = nil;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
// mouse
|
// mouse
|
||||||
|
@ -88,12 +88,12 @@ static int eventQueueCount;
|
||||||
#endif // CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
|
#endif // CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
|
||||||
|
|
||||||
|
|
||||||
@implementation EventDispatcher
|
@implementation CCEventDispatcher
|
||||||
|
|
||||||
@synthesize dispatchEvents=dispatchEvents_;
|
@synthesize dispatchEvents=dispatchEvents_;
|
||||||
|
|
||||||
|
|
||||||
+(EventDispatcher*) sharedDispatcher
|
+(CCEventDispatcher*) sharedDispatcher
|
||||||
{
|
{
|
||||||
@synchronized(self) {
|
@synchronized(self) {
|
||||||
if (sharedDispatcher == nil)
|
if (sharedDispatcher == nil)
|
||||||
|
@ -204,7 +204,7 @@ static int eventQueueCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
-(void) addMouseDelegate:(id<MouseEventDelegate>) delegate priority:(NSInteger)priority
|
-(void) addMouseDelegate:(id<CCMouseEventDelegate>) delegate priority:(NSInteger)priority
|
||||||
{
|
{
|
||||||
NSUInteger flags = 0;
|
NSUInteger flags = 0;
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ static int eventQueueCount;
|
||||||
[self removeAllDelegatesFromList:&mouseDelegates_];
|
[self removeAllDelegatesFromList:&mouseDelegates_];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) addKeyboardDelegate:(id<KeyboardEventDelegate>) delegate priority:(NSInteger)priority
|
-(void) addKeyboardDelegate:(id<CCKeyboardEventDelegate>) delegate priority:(NSInteger)priority
|
||||||
{
|
{
|
||||||
NSUInteger flags = 0;
|
NSUInteger flags = 0;
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ static int eventQueueCount;
|
||||||
[self removeAllDelegatesFromList:&keyboardDelegates_];
|
[self removeAllDelegatesFromList:&keyboardDelegates_];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) addTouchDelegate:(id<TouchEventDelegate>) delegate priority:(NSInteger)priority
|
-(void) addTouchDelegate:(id<CCTouchEventDelegate>) delegate priority:(NSInteger)priority
|
||||||
{
|
{
|
||||||
NSUInteger flags = 0;
|
NSUInteger flags = 0;
|
||||||
|
|
||||||
|
|
|
@ -73,14 +73,6 @@ typedef enum {
|
||||||
kTexture2DPixelFormat_Default = kTexture2DPixelFormat_RGBA8888,
|
kTexture2DPixelFormat_Default = kTexture2DPixelFormat_RGBA8888,
|
||||||
|
|
||||||
// backward compatibility stuff
|
// backward compatibility stuff
|
||||||
kTexture2DPixelFormat_Automatic = kTexture2DPixelFormat_Automatic,
|
|
||||||
kTexture2DPixelFormat_RGBA8888 = kTexture2DPixelFormat_RGBA8888,
|
|
||||||
kTexture2DPixelFormat_RGB888 = kTexture2DPixelFormat_RGB888,
|
|
||||||
kTexture2DPixelFormat_RGB565 = kTexture2DPixelFormat_RGB565,
|
|
||||||
kTexture2DPixelFormat_A8 = kTexture2DPixelFormat_A8,
|
|
||||||
kTexture2DPixelFormat_RGBA4444 = kTexture2DPixelFormat_RGBA4444,
|
|
||||||
kTexture2DPixelFormat_RGB5A1 = kTexture2DPixelFormat_RGB5A1,
|
|
||||||
kTexture2DPixelFormat_Default = kTexture2DPixelFormat_Default
|
|
||||||
|
|
||||||
} Texture2DPixelFormat;
|
} Texture2DPixelFormat;
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ THE SOFTWARE.
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
|
||||||
@interface Window : NSWindow
|
@interface CCWindow : NSWindow
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
- (id) initWithFrame:(NSRect)frame fullscreen:(BOOL)fullscreen;
|
- (id) initWithFrame:(NSRect)frame fullscreen:(BOOL)fullscreen;
|
||||||
|
|
|
@ -65,7 +65,7 @@ THE SOFTWARE.
|
||||||
// exit fullscreen if user pressed esc
|
// exit fullscreen if user pressed esc
|
||||||
if([event keyCode] == 53)
|
if([event keyCode] == 53)
|
||||||
{
|
{
|
||||||
EAGLView* eaglView = [EAGLView sharedEGLView];
|
CCEAGLView* eaglView = [CCEAGLView sharedEGLView];
|
||||||
|
|
||||||
// cancel full screen
|
// cancel full screen
|
||||||
if( [eaglView isFullScreen] )
|
if( [eaglView isFullScreen] )
|
||||||
|
|
|
@ -30,7 +30,7 @@ THE SOFTWARE.
|
||||||
|
|
||||||
//PROTOCOLS:
|
//PROTOCOLS:
|
||||||
|
|
||||||
@protocol MacEventDelegate <NSObject>
|
@protocol CCMacEventDelegate <NSObject>
|
||||||
// Mouse
|
// Mouse
|
||||||
- (void)mouseDown:(NSEvent *)theEvent;
|
- (void)mouseDown:(NSEvent *)theEvent;
|
||||||
- (void)mouseUp:(NSEvent *)theEvent;
|
- (void)mouseUp:(NSEvent *)theEvent;
|
||||||
|
@ -68,8 +68,8 @@ THE SOFTWARE.
|
||||||
|
|
||||||
Only available for Mac OS X
|
Only available for Mac OS X
|
||||||
*/
|
*/
|
||||||
@interface EAGLView : NSOpenGLView {
|
@interface CCEAGLView : NSOpenGLView {
|
||||||
id<MacEventDelegate> eventDelegate_;
|
id<CCMacEventDelegate> eventDelegate_;
|
||||||
|
|
||||||
BOOL isFullScreen_;
|
BOOL isFullScreen_;
|
||||||
NSWindow *fullScreenWindow_;
|
NSWindow *fullScreenWindow_;
|
||||||
|
@ -82,7 +82,7 @@ THE SOFTWARE.
|
||||||
float frameZoomFactor_;
|
float frameZoomFactor_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (nonatomic, readwrite, assign) id<MacEventDelegate> eventDelegate;
|
@property (nonatomic, readwrite, assign) id<CCMacEventDelegate> eventDelegate;
|
||||||
|
|
||||||
// whether or not the view is in fullscreen mode
|
// whether or not the view is in fullscreen mode
|
||||||
@property (nonatomic, readonly) BOOL isFullScreen;
|
@property (nonatomic, readonly) BOOL isFullScreen;
|
||||||
|
|
|
@ -42,9 +42,9 @@ THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
//USING_NS_CC;
|
//USING_NS_CC;
|
||||||
static EAGLView *view;
|
static CCEAGLView *view;
|
||||||
|
|
||||||
@implementation EAGLView
|
@implementation CCEAGLView
|
||||||
|
|
||||||
@synthesize eventDelegate = eventDelegate_, isFullScreen = isFullScreen_, frameZoomFactor=frameZoomFactor_;
|
@synthesize eventDelegate = eventDelegate_, isFullScreen = isFullScreen_, frameZoomFactor=frameZoomFactor_;
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ static EAGLView *view;
|
||||||
[self setOpenGLContext:context];
|
[self setOpenGLContext:context];
|
||||||
|
|
||||||
// event delegate
|
// event delegate
|
||||||
eventDelegate_ = [EventDispatcher sharedDispatcher];
|
eventDelegate_ = [CCEventDispatcher sharedDispatcher];
|
||||||
}
|
}
|
||||||
|
|
||||||
cocos2d::EGLView::sharedOpenGLView()->setFrameSize(frameRect.size.width, frameRect.size.height);
|
cocos2d::EGLView::sharedOpenGLView()->setFrameSize(frameRect.size.width, frameRect.size.height);
|
||||||
|
@ -95,7 +95,7 @@ static EAGLView *view;
|
||||||
|
|
||||||
- (id) initWithFrame:(NSRect)frameRect pixelFormat:(NSOpenGLPixelFormat *)format{
|
- (id) initWithFrame:(NSRect)frameRect pixelFormat:(NSOpenGLPixelFormat *)format{
|
||||||
// event delegate
|
// event delegate
|
||||||
eventDelegate_ = [EventDispatcher sharedDispatcher];
|
eventDelegate_ = [CCEventDispatcher sharedDispatcher];
|
||||||
|
|
||||||
cocos2d::EGLView::sharedOpenGLView()->setFrameSize(frameRect.size.width, frameRect.size.height);
|
cocos2d::EGLView::sharedOpenGLView()->setFrameSize(frameRect.size.width, frameRect.size.height);
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ static EAGLView *view;
|
||||||
if (isFullScreen_ == fullscreen)
|
if (isFullScreen_ == fullscreen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
EAGLView *openGLview = [[self class] sharedEGLView];
|
CCEAGLView *openGLview = [[self class] sharedEGLView];
|
||||||
|
|
||||||
if( fullscreen ) {
|
if( fullscreen ) {
|
||||||
originalWinRect_ = [openGLview frame];
|
originalWinRect_ = [openGLview frame];
|
||||||
|
@ -249,7 +249,7 @@ static EAGLView *view;
|
||||||
NSRect displayRect = [[NSScreen mainScreen] frame];
|
NSRect displayRect = [[NSScreen mainScreen] frame];
|
||||||
|
|
||||||
// Create a screen-sized window on the display you want to take over
|
// Create a screen-sized window on the display you want to take over
|
||||||
fullScreenWindow_ = [[Window alloc] initWithFrame:displayRect fullscreen:YES];
|
fullScreenWindow_ = [[CCWindow alloc] initWithFrame:displayRect fullscreen:YES];
|
||||||
|
|
||||||
// Remove glView from window
|
// Remove glView from window
|
||||||
[openGLview removeFromSuperview];
|
[openGLview removeFromSuperview];
|
||||||
|
|
|
@ -36,16 +36,16 @@
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
@interface CustomUITextField : UITextField
|
@interface CCCustomUITextField : UITextField
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
@interface EditBoxImplIOS_objc : NSObject <UITextFieldDelegate>
|
@interface CCEditBoxImplIOS_objc : NSObject <UITextFieldDelegate>
|
||||||
{
|
{
|
||||||
CustomUITextField* textField_;
|
CCCustomUITextField* textField_;
|
||||||
void* editBox_;
|
void* editBox_;
|
||||||
BOOL editState_;
|
BOOL editState_;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ private:
|
||||||
Size _contentSize;
|
Size _contentSize;
|
||||||
Point _position;
|
Point _position;
|
||||||
Point _anchorPoint;
|
Point _anchorPoint;
|
||||||
EditBoxImplIOS_objc* _systemControl;
|
CCEditBoxImplIOS_objc* _systemControl;
|
||||||
int _maxTextLength;
|
int _maxTextLength;
|
||||||
bool _inRetinaMode;
|
bool _inRetinaMode;
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,9 +35,9 @@
|
||||||
|
|
||||||
static const int CC_EDIT_BOX_PADDING = 5;
|
static const int CC_EDIT_BOX_PADDING = 5;
|
||||||
|
|
||||||
@implementation CustomUITextField
|
@implementation CCCustomUITextField
|
||||||
- (CGRect)textRectForBounds:(CGRect)bounds {
|
- (CGRect)textRectForBounds:(CGRect)bounds {
|
||||||
float padding = CC_EDIT_BOX_PADDING * cocos2d::EGLView::sharedOpenGLView()->getScaleX() / [[EAGLView sharedEGLView] contentScaleFactor ];
|
float padding = CC_EDIT_BOX_PADDING * cocos2d::EGLView::sharedOpenGLView()->getScaleX() / [[CCEAGLView sharedEGLView] contentScaleFactor ];
|
||||||
return CGRectMake(bounds.origin.x + padding, bounds.origin.y + padding,
|
return CGRectMake(bounds.origin.x + padding, bounds.origin.y + padding,
|
||||||
bounds.size.width - padding*2, bounds.size.height - padding*2);
|
bounds.size.width - padding*2, bounds.size.height - padding*2);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ static const int CC_EDIT_BOX_PADDING = 5;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
@implementation EditBoxImplIOS_objc
|
@implementation CCEditBoxImplIOS_objc
|
||||||
|
|
||||||
@synthesize textField = textField_;
|
@synthesize textField = textField_;
|
||||||
@synthesize editState = editState_;
|
@synthesize editState = editState_;
|
||||||
|
@ -69,7 +69,7 @@ static const int CC_EDIT_BOX_PADDING = 5;
|
||||||
{
|
{
|
||||||
if (self == nil) break;
|
if (self == nil) break;
|
||||||
editState_ = NO;
|
editState_ = NO;
|
||||||
self.textField = [[[CustomUITextField alloc] initWithFrame: frameRect] autorelease];
|
self.textField = [[[CCCustomUITextField alloc] initWithFrame: frameRect] autorelease];
|
||||||
if (!textField_) break;
|
if (!textField_) break;
|
||||||
[textField_ setTextColor:[UIColor whiteColor]];
|
[textField_ setTextColor:[UIColor whiteColor]];
|
||||||
textField_.font = [UIFont systemFontOfSize:frameRect.size.height*2/3]; //TODO need to delete hard code here.
|
textField_.font = [UIFont systemFontOfSize:frameRect.size.height*2/3]; //TODO need to delete hard code here.
|
||||||
|
@ -91,7 +91,7 @@ static const int CC_EDIT_BOX_PADDING = 5;
|
||||||
|
|
||||||
-(void) doAnimationWhenKeyboardMoveWithDuration:(float)duration distance:(float)distance
|
-(void) doAnimationWhenKeyboardMoveWithDuration:(float)duration distance:(float)distance
|
||||||
{
|
{
|
||||||
id eglView = [EAGLView sharedEGLView];
|
id eglView = [CCEAGLView sharedEGLView];
|
||||||
[eglView doAnimationWhenKeyboardMoveWithDuration:duration distance:distance];
|
[eglView doAnimationWhenKeyboardMoveWithDuration:duration distance:distance];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ static const int CC_EDIT_BOX_PADDING = 5;
|
||||||
|
|
||||||
-(void) openKeyboard
|
-(void) openKeyboard
|
||||||
{
|
{
|
||||||
[[EAGLView sharedEGLView] addSubview:textField_];
|
[[CCEAGLView sharedEGLView] addSubview:textField_];
|
||||||
[textField_ becomeFirstResponder];
|
[textField_ becomeFirstResponder];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ static const int CC_EDIT_BOX_PADDING = 5;
|
||||||
|
|
||||||
-(void)animationSelector
|
-(void)animationSelector
|
||||||
{
|
{
|
||||||
id eglView = [EAGLView sharedEGLView];
|
id eglView = [CCEAGLView sharedEGLView];
|
||||||
[eglView doAnimationWhenAnotherEditBeClicked];
|
[eglView doAnimationWhenAnotherEditBeClicked];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ static const int CC_EDIT_BOX_PADDING = 5;
|
||||||
{
|
{
|
||||||
CCLOG("textFieldShouldBeginEditing...");
|
CCLOG("textFieldShouldBeginEditing...");
|
||||||
editState_ = YES;
|
editState_ = YES;
|
||||||
id eglView = [EAGLView sharedEGLView];
|
id eglView = [CCEAGLView sharedEGLView];
|
||||||
if ([eglView isKeyboardShown])
|
if ([eglView isKeyboardShown])
|
||||||
{
|
{
|
||||||
[self performSelector:@selector(animationSelector) withObject:nil afterDelay:0.0f];
|
[self performSelector:@selector(animationSelector) withObject:nil afterDelay:0.0f];
|
||||||
|
@ -254,7 +254,7 @@ EditBoxImplIOS::EditBoxImplIOS(EditBox* pEditText)
|
||||||
, _anchorPoint(ccp(0.5f, 0.5f))
|
, _anchorPoint(ccp(0.5f, 0.5f))
|
||||||
, _maxTextLength(-1)
|
, _maxTextLength(-1)
|
||||||
{
|
{
|
||||||
_inRetinaMode = [[EAGLView sharedEGLView] contentScaleFactor] == 2.0f ? true : false;
|
_inRetinaMode = [[CCEAGLView sharedEGLView] contentScaleFactor] == 2.0f ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditBoxImplIOS::~EditBoxImplIOS()
|
EditBoxImplIOS::~EditBoxImplIOS()
|
||||||
|
@ -284,7 +284,7 @@ bool EditBoxImplIOS::initWithSize(const Size& size)
|
||||||
rect.size.height /= 2.0f;
|
rect.size.height /= 2.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
_systemControl = [[EditBoxImplIOS_objc alloc] initWithFrame:rect editBox:this];
|
_systemControl = [[CCEditBoxImplIOS_objc alloc] initWithFrame:rect editBox:this];
|
||||||
if (!_systemControl) break;
|
if (!_systemControl) break;
|
||||||
|
|
||||||
initInactiveLabels(size);
|
initInactiveLabels(size);
|
||||||
|
@ -510,7 +510,7 @@ void EditBoxImplIOS::setPlaceHolder(const char* pText)
|
||||||
static CGPoint convertDesignCoordToScreenCoord(const Point& designCoord, bool bInRetinaMode)
|
static CGPoint convertDesignCoordToScreenCoord(const Point& designCoord, bool bInRetinaMode)
|
||||||
{
|
{
|
||||||
EGLViewProtocol* eglView = EGLView::sharedOpenGLView();
|
EGLViewProtocol* eglView = EGLView::sharedOpenGLView();
|
||||||
float viewH = (float)[[EAGLView sharedEGLView] getHeight];
|
float viewH = (float)[[CCEAGLView sharedEGLView] getHeight];
|
||||||
|
|
||||||
Point visiblePos = ccp(designCoord.x * eglView->getScaleX(), designCoord.y * eglView->getScaleY());
|
Point visiblePos = ccp(designCoord.x * eglView->getScaleX(), designCoord.y * eglView->getScaleY());
|
||||||
Point screenGLPos = ccpAdd(visiblePos, eglView->getViewPortRect().origin);
|
Point screenGLPos = ccpAdd(visiblePos, eglView->getViewPortRect().origin);
|
||||||
|
|
|
@ -36,15 +36,15 @@
|
||||||
#include "ExtensionMacros.h"
|
#include "ExtensionMacros.h"
|
||||||
#include "CCEditBoxImpl.h"
|
#include "CCEditBoxImpl.h"
|
||||||
|
|
||||||
@interface CustomNSTextField : NSTextField
|
@interface CCCustomNSTextField : NSTextField
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface EditBoxImplMac : NSObject <NSTextFieldDelegate>
|
@interface CCEditBoxImplMac : NSObject <NSTextFieldDelegate>
|
||||||
{
|
{
|
||||||
CustomNSTextField* textField_;
|
CCCustomNSTextField* textField_;
|
||||||
void* editBox_;
|
void* editBox_;
|
||||||
BOOL editState_;
|
BOOL editState_;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ private:
|
||||||
Point _anchorPoint;
|
Point _anchorPoint;
|
||||||
int _maxTextLength;
|
int _maxTextLength;
|
||||||
bool _inRetinaMode;
|
bool _inRetinaMode;
|
||||||
EditBoxImplMac* _sysEdit;
|
CCEditBoxImplMac* _sysEdit;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
#define getEditBoxImplMac() ((cocos2d::extension::EditBoxImplMac*)editBox_)
|
#define getEditBoxImplMac() ((cocos2d::extension::EditBoxImplMac*)editBox_)
|
||||||
|
|
||||||
@implementation CustomNSTextField
|
@implementation CCCustomNSTextField
|
||||||
|
|
||||||
- (CGRect)textRectForBounds:(CGRect)bounds {
|
- (CGRect)textRectForBounds:(CGRect)bounds {
|
||||||
float padding = 5.0f;
|
float padding = 5.0f;
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
@implementation EditBoxImplMac
|
@implementation CCEditBoxImplMac
|
||||||
|
|
||||||
@synthesize textField = textField_;
|
@synthesize textField = textField_;
|
||||||
@synthesize editState = editState_;
|
@synthesize editState = editState_;
|
||||||
|
@ -74,7 +74,7 @@
|
||||||
{
|
{
|
||||||
if (self == nil) break;
|
if (self == nil) break;
|
||||||
editState_ = NO;
|
editState_ = NO;
|
||||||
self.textField = [[[CustomNSTextField alloc] initWithFrame: frameRect] autorelease];
|
self.textField = [[[CCCustomNSTextField alloc] initWithFrame: frameRect] autorelease];
|
||||||
if (!textField_) break;
|
if (!textField_) break;
|
||||||
[textField_ setTextColor:[NSColor whiteColor]];
|
[textField_ setTextColor:[NSColor whiteColor]];
|
||||||
textField_.font = [NSFont systemFontOfSize:frameRect.size.height*2/3]; //TODO need to delete hard code here.
|
textField_.font = [NSFont systemFontOfSize:frameRect.size.height*2/3]; //TODO need to delete hard code here.
|
||||||
|
@ -84,7 +84,7 @@
|
||||||
[textField_ setDelegate:self];
|
[textField_ setDelegate:self];
|
||||||
self.editBox = editBox;
|
self.editBox = editBox;
|
||||||
|
|
||||||
[[EAGLView sharedEGLView] addSubview:textField_];
|
[[CCEAGLView sharedEGLView] addSubview:textField_];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}while(0);
|
}while(0);
|
||||||
|
@ -94,7 +94,7 @@
|
||||||
|
|
||||||
-(void) doAnimationWhenKeyboardMoveWithDuration:(float)duration distance:(float)distance
|
-(void) doAnimationWhenKeyboardMoveWithDuration:(float)duration distance:(float)distance
|
||||||
{
|
{
|
||||||
id eglView = [EAGLView sharedEGLView];
|
id eglView = [CCEAGLView sharedEGLView];
|
||||||
[eglView doAnimationWhenKeyboardMoveWithDuration:duration distance:distance];
|
[eglView doAnimationWhenKeyboardMoveWithDuration:duration distance:distance];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ bool EditBoxImplMac::initWithSize(const Size& size)
|
||||||
rect.size.height /= 2.0f;
|
rect.size.height /= 2.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
_sysEdit = [[EditBoxImplMac alloc] initWithFrame:rect editBox:this];
|
_sysEdit = [[CCEditBoxImplMac alloc] initWithFrame:rect editBox:this];
|
||||||
|
|
||||||
if (!_sysEdit)
|
if (!_sysEdit)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -29,7 +29,7 @@ static AppDelegate s_sharedApplication;
|
||||||
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
|
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
|
||||||
|
|
||||||
// Init the EAGLView
|
// Init the EAGLView
|
||||||
EAGLView *__glView = [EAGLView viewWithFrame: [window bounds]
|
CCEAGLView *__glView = [CCEAGLView viewWithFrame: [window bounds]
|
||||||
pixelFormat: kEAGLColorFormatRGB565
|
pixelFormat: kEAGLColorFormatRGB565
|
||||||
depthFormat: GL_DEPTH24_STENCIL8_OES
|
depthFormat: GL_DEPTH24_STENCIL8_OES
|
||||||
preserveBackbuffer: NO
|
preserveBackbuffer: NO
|
||||||
|
|
|
@ -30,11 +30,11 @@
|
||||||
@interface AppController : NSObject <NSApplicationDelegate>
|
@interface AppController : NSObject <NSApplicationDelegate>
|
||||||
{
|
{
|
||||||
NSWindow *window;
|
NSWindow *window;
|
||||||
EAGLView *glView;
|
CCEAGLView *glView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (nonatomic, assign) IBOutlet NSWindow* window;
|
@property (nonatomic, assign) IBOutlet NSWindow* window;
|
||||||
@property (nonatomic, assign) IBOutlet EAGLView* glView;
|
@property (nonatomic, assign) IBOutlet CCEAGLView* glView;
|
||||||
|
|
||||||
-(IBAction) toggleFullScreen:(id)sender;
|
-(IBAction) toggleFullScreen:(id)sender;
|
||||||
-(IBAction) exitFullScreen:(id)sender;
|
-(IBAction) exitFullScreen:(id)sender;
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
|
|
||||||
// allocate our GL view
|
// allocate our GL view
|
||||||
// (isn't there already a shared EAGLView?)
|
// (isn't there already a shared EAGLView?)
|
||||||
glView = [[EAGLView alloc] initWithFrame:rect pixelFormat:pixelFormat];
|
glView = [[CCEAGLView alloc] initWithFrame:rect pixelFormat:pixelFormat];
|
||||||
|
|
||||||
// set window parameters
|
// set window parameters
|
||||||
[window becomeFirstResponder];
|
[window becomeFirstResponder];
|
||||||
|
@ -81,13 +81,13 @@
|
||||||
|
|
||||||
-(IBAction) toggleFullScreen:(id)sender
|
-(IBAction) toggleFullScreen:(id)sender
|
||||||
{
|
{
|
||||||
EAGLView* pView = [EAGLView sharedEGLView];
|
CCEAGLView* pView = [CCEAGLView sharedEGLView];
|
||||||
[pView setFullScreen:!pView.isFullScreen];
|
[pView setFullScreen:!pView.isFullScreen];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) exitFullScreen:(id)sender
|
-(IBAction) exitFullScreen:(id)sender
|
||||||
{
|
{
|
||||||
[[EAGLView sharedEGLView] setFullScreen:NO];
|
[[CCEAGLView sharedEGLView] setFullScreen:NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in New Issue