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