Merge pull request #8311 from BastiaanOlij/format_mm_2.1
Spaces to tabs and layout adjustments on .mm files
This commit is contained in:
commit
4b561e3e04
12 changed files with 1172 additions and 1300 deletions
1
.gitattributes
vendored
1
.gitattributes
vendored
|
@ -5,5 +5,6 @@ drivers/* linguist-vendored
|
||||||
|
|
||||||
*.cpp eol=lf
|
*.cpp eol=lf
|
||||||
*.h eol=lf
|
*.h eol=lf
|
||||||
|
*.mm eol=lf
|
||||||
*.py eol=lf
|
*.py eol=lf
|
||||||
*.hpp eol=lf
|
*.hpp eol=lf
|
||||||
|
|
|
@ -85,8 +85,7 @@ CMMotionManager *motionManager;
|
||||||
bool motionInitialised;
|
bool motionInitialised;
|
||||||
|
|
||||||
static ViewController* mainViewController = nil;
|
static ViewController* mainViewController = nil;
|
||||||
+ (ViewController*) getViewController
|
+ (ViewController*) getViewController {
|
||||||
{
|
|
||||||
return mainViewController;
|
return mainViewController;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,14 +93,12 @@ static int frame_count = 0;
|
||||||
- (void)drawView:(GLView*)view; {
|
- (void)drawView:(GLView*)view; {
|
||||||
|
|
||||||
switch (frame_count) {
|
switch (frame_count) {
|
||||||
|
|
||||||
case 0: {
|
case 0: {
|
||||||
int backingWidth;
|
int backingWidth;
|
||||||
int backingHeight;
|
int backingHeight;
|
||||||
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
|
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
|
||||||
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
|
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
|
||||||
|
|
||||||
|
|
||||||
OS::VideoMode vm;
|
OS::VideoMode vm;
|
||||||
vm.fullscreen = true;
|
vm.fullscreen = true;
|
||||||
vm.width = backingWidth;
|
vm.width = backingWidth;
|
||||||
|
@ -143,7 +140,7 @@ static int frame_count = 0;
|
||||||
/*
|
/*
|
||||||
case 1: {
|
case 1: {
|
||||||
++frame_count;
|
++frame_count;
|
||||||
} break;
|
}; break;
|
||||||
*/
|
*/
|
||||||
case 1: {
|
case 1: {
|
||||||
|
|
||||||
|
@ -174,7 +171,7 @@ static int frame_count = 0;
|
||||||
// do stuff
|
// do stuff
|
||||||
}
|
}
|
||||||
|
|
||||||
} break;
|
}; break;
|
||||||
/*
|
/*
|
||||||
case 3: {
|
case 3: {
|
||||||
++frame_count;
|
++frame_count;
|
||||||
|
@ -188,7 +185,6 @@ static int frame_count = 0;
|
||||||
}; break; // no fallthrough
|
}; break; // no fallthrough
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
|
|
||||||
if (OSIPhone::get_singleton()) {
|
if (OSIPhone::get_singleton()) {
|
||||||
if (motionInitialised) {
|
if (motionInitialised) {
|
||||||
// Just using polling approach for now, we can set this up so it sends data to us in intervals, might be better.
|
// Just using polling approach for now, we can set this up so it sends data to us in intervals, might be better.
|
||||||
|
@ -242,9 +238,7 @@ static int frame_count = 0;
|
||||||
|
|
||||||
bool quit_request = OSIPhone::get_singleton()->iterate();
|
bool quit_request = OSIPhone::get_singleton()->iterate();
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -312,12 +306,10 @@ static int frame_count = 0;
|
||||||
|
|
||||||
#ifdef MODULE_GAME_ANALYTICS_ENABLED
|
#ifdef MODULE_GAME_ANALYTICS_ENABLED
|
||||||
printf("********************* didFinishLaunchingWithOptions\n");
|
printf("********************* didFinishLaunchingWithOptions\n");
|
||||||
if(!Globals::get_singleton()->has("mobileapptracker/advertiser_id"))
|
if (!Globals::get_singleton()->has("mobileapptracker/advertiser_id")) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!Globals::get_singleton()->has("mobileapptracker/conversion_key"))
|
if (!Globals::get_singleton()->has("mobileapptracker/conversion_key")) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,8 +320,7 @@ static int frame_count = 0;
|
||||||
NSString * conversion_key = [NSString stringWithUTF8String:convkey.utf8().get_data()];
|
NSString * conversion_key = [NSString stringWithUTF8String:convkey.utf8().get_data()];
|
||||||
|
|
||||||
// Account Configuration info - must be set
|
// Account Configuration info - must be set
|
||||||
[MobileAppTracker initializeWithMATAdvertiserId:advertiser_id
|
[MobileAppTracker initializeWithMATAdvertiserId:advertiser_id MATConversionKey:conversion_key];
|
||||||
MATConversionKey:conversion_key];
|
|
||||||
|
|
||||||
// Used to pass us the IFA, enables highly accurate 1-to-1 attribution.
|
// Used to pass us the IFA, enables highly accurate 1-to-1 attribution.
|
||||||
// Required for many advertising networks.
|
// Required for many advertising networks.
|
||||||
|
@ -337,7 +328,6 @@ static int frame_count = 0;
|
||||||
advertisingTrackingEnabled:[[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled]];
|
advertisingTrackingEnabled:[[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled]];
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
- (void)applicationWillTerminate:(UIApplication*)application {
|
- (void)applicationWillTerminate:(UIApplication*)application {
|
||||||
|
@ -355,35 +345,33 @@ static int frame_count = 0;
|
||||||
iphone_finish();
|
iphone_finish();
|
||||||
};
|
};
|
||||||
|
|
||||||
- (void)applicationDidEnterBackground:(UIApplication *)application
|
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
||||||
{
|
|
||||||
printf("********************* did enter background\n");
|
printf("********************* did enter background\n");
|
||||||
///@TODO maybe add pause motionManager? and where would we unpause it?
|
///@TODO maybe add pause motionManager? and where would we unpause it?
|
||||||
|
|
||||||
if (OS::get_singleton()->get_main_loop())
|
if (OS::get_singleton()->get_main_loop())
|
||||||
OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
|
OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
|
||||||
|
|
||||||
[view_controller.view stopAnimation];
|
[view_controller.view stopAnimation];
|
||||||
|
|
||||||
if (OS::get_singleton()->native_video_is_playing()) {
|
if (OS::get_singleton()->native_video_is_playing()) {
|
||||||
OSIPhone::get_singleton()->native_video_focus_out();
|
OSIPhone::get_singleton()->native_video_focus_out();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationWillEnterForeground:(UIApplication *)application
|
- (void)applicationWillEnterForeground:(UIApplication *)application {
|
||||||
{
|
|
||||||
printf("********************* did enter foreground\n");
|
printf("********************* did enter foreground\n");
|
||||||
//OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
|
//OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
|
||||||
[view_controller.view startAnimation];
|
[view_controller.view startAnimation];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) applicationWillResignActive:(UIApplication *)application
|
- (void) applicationWillResignActive:(UIApplication *)application {
|
||||||
{
|
|
||||||
printf("********************* will resign active\n");
|
printf("********************* will resign active\n");
|
||||||
//OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
|
//OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
|
||||||
[view_controller.view stopAnimation]; // FIXME: pause seems to be recommended elsewhere
|
[view_controller.view stopAnimation]; // FIXME: pause seems to be recommended elsewhere
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) applicationDidBecomeActive:(UIApplication *)application
|
- (void) applicationDidBecomeActive:(UIApplication *)application {
|
||||||
{
|
|
||||||
printf("********************* did become active\n");
|
printf("********************* did become active\n");
|
||||||
#ifdef MODULE_GAME_ANALYTICS_ENABLED
|
#ifdef MODULE_GAME_ANALYTICS_ENABLED
|
||||||
printf("********************* mobile app tracker found\n");
|
printf("********************* mobile app tracker found\n");
|
||||||
|
@ -391,7 +379,9 @@ static int frame_count = 0;
|
||||||
#endif
|
#endif
|
||||||
if (OS::get_singleton()->get_main_loop())
|
if (OS::get_singleton()->get_main_loop())
|
||||||
OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
|
OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
|
||||||
|
|
||||||
[view_controller.view startAnimation]; // FIXME: resume seems to be recommended elsewhere
|
[view_controller.view startAnimation]; // FIXME: resume seems to be recommended elsewhere
|
||||||
|
|
||||||
if (OSIPhone::get_singleton()->native_video_is_playing()) {
|
if (OSIPhone::get_singleton()->native_video_is_playing()) {
|
||||||
OSIPhone::get_singleton()->native_video_unpause();
|
OSIPhone::get_singleton()->native_video_unpause();
|
||||||
};
|
};
|
||||||
|
@ -449,8 +439,7 @@ static int frame_count = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc {
|
||||||
{
|
|
||||||
[window release];
|
[window release];
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,8 +82,7 @@ Error GameCenter::connect() {
|
||||||
player.authenticateHandler = (^(UIViewController *controller, NSError *error) {
|
player.authenticateHandler = (^(UIViewController *controller, NSError *error) {
|
||||||
if (controller) {
|
if (controller) {
|
||||||
[root_controller presentViewController:controller animated:YES completion:nil];
|
[root_controller presentViewController:controller animated:YES completion:nil];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Dictionary ret;
|
Dictionary ret;
|
||||||
ret["type"] = "authentication";
|
ret["type"] = "authentication";
|
||||||
if (player.isAuthenticated) {
|
if (player.isAuthenticated) {
|
||||||
|
@ -98,7 +97,6 @@ Error GameCenter::connect() {
|
||||||
|
|
||||||
pending_events.push_back(ret);
|
pending_events.push_back(ret);
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
@ -122,7 +120,6 @@ Error GameCenter::post_score(Variant p_score) {
|
||||||
ERR_FAIL_COND_V([GKScore respondsToSelector:@selector(reportScores)], ERR_UNAVAILABLE);
|
ERR_FAIL_COND_V([GKScore respondsToSelector:@selector(reportScores)], ERR_UNAVAILABLE);
|
||||||
|
|
||||||
[GKScore reportScores:@[reporter] withCompletionHandler:^(NSError* error) {
|
[GKScore reportScores:@[reporter] withCompletionHandler:^(NSError* error) {
|
||||||
|
|
||||||
Dictionary ret;
|
Dictionary ret;
|
||||||
ret["type"] = "post_score";
|
ret["type"] = "post_score";
|
||||||
if (error == nil) {
|
if (error == nil) {
|
||||||
|
@ -332,6 +329,7 @@ Error GameCenter::show_game_center(Variant p_params) {
|
||||||
void GameCenter::game_center_closed() {
|
void GameCenter::game_center_closed() {
|
||||||
|
|
||||||
Dictionary ret;
|
Dictionary ret;
|
||||||
|
|
||||||
ret["type"] = "show_game_center";
|
ret["type"] = "show_game_center";
|
||||||
ret["result"] = "ok";
|
ret["result"] = "ok";
|
||||||
pending_events.push_back(ret);
|
pending_events.push_back(ret);
|
||||||
|
|
|
@ -104,13 +104,11 @@ bool _play_video(String p_path, float p_volume, String p_audio_track, String p_s
|
||||||
AVMediaSelectionGroup *audioGroup = [_instance.avAsset mediaSelectionGroupForMediaCharacteristic: AVMediaCharacteristicAudible];
|
AVMediaSelectionGroup *audioGroup = [_instance.avAsset mediaSelectionGroupForMediaCharacteristic: AVMediaCharacteristicAudible];
|
||||||
|
|
||||||
NSMutableArray *allAudioParams = [NSMutableArray array];
|
NSMutableArray *allAudioParams = [NSMutableArray array];
|
||||||
for (id track in audioGroup.options)
|
for (id track in audioGroup.options) {
|
||||||
{
|
|
||||||
NSString* language = [[track locale] localeIdentifier];
|
NSString* language = [[track locale] localeIdentifier];
|
||||||
NSLog(@"subtitle lang: %@", language);
|
NSLog(@"subtitle lang: %@", language);
|
||||||
|
|
||||||
if ([language isEqualToString:[NSString stringWithUTF8String:p_audio_track.utf8()]])
|
if ([language isEqualToString:[NSString stringWithUTF8String:p_audio_track.utf8()]]) {
|
||||||
{
|
|
||||||
AVMutableAudioMixInputParameters *audioInputParams = [AVMutableAudioMixInputParameters audioMixInputParameters];
|
AVMutableAudioMixInputParameters *audioInputParams = [AVMutableAudioMixInputParameters audioMixInputParameters];
|
||||||
[audioInputParams setVolume:p_volume atTime:kCMTimeZero];
|
[audioInputParams setVolume:p_volume atTime:kCMTimeZero];
|
||||||
[audioInputParams setTrackID:[track trackID]];
|
[audioInputParams setTrackID:[track trackID]];
|
||||||
|
@ -129,13 +127,11 @@ bool _play_video(String p_path, float p_volume, String p_audio_track, String p_s
|
||||||
AVMediaSelectionGroup *subtitlesGroup = [_instance.avAsset mediaSelectionGroupForMediaCharacteristic: AVMediaCharacteristicLegible];
|
AVMediaSelectionGroup *subtitlesGroup = [_instance.avAsset mediaSelectionGroupForMediaCharacteristic: AVMediaCharacteristicLegible];
|
||||||
NSArray *useableTracks = [AVMediaSelectionGroup mediaSelectionOptionsFromArray:subtitlesGroup.options withoutMediaCharacteristics:[NSArray arrayWithObject:AVMediaCharacteristicContainsOnlyForcedSubtitles]];
|
NSArray *useableTracks = [AVMediaSelectionGroup mediaSelectionOptionsFromArray:subtitlesGroup.options withoutMediaCharacteristics:[NSArray arrayWithObject:AVMediaCharacteristicContainsOnlyForcedSubtitles]];
|
||||||
|
|
||||||
for (id track in useableTracks)
|
for (id track in useableTracks) {
|
||||||
{
|
|
||||||
NSString* language = [[track locale] localeIdentifier];
|
NSString* language = [[track locale] localeIdentifier];
|
||||||
NSLog(@"subtitle lang: %@", language);
|
NSLog(@"subtitle lang: %@", language);
|
||||||
|
|
||||||
if ([language isEqualToString:[NSString stringWithUTF8String:p_subtitle_track.utf8()]])
|
if ([language isEqualToString:[NSString stringWithUTF8String:p_subtitle_track.utf8()]]) {
|
||||||
{
|
|
||||||
[_instance.avPlayer.currentItem selectMediaOption:track inMediaSelectionGroup: subtitlesGroup];
|
[_instance.avPlayer.currentItem selectMediaOption:track inMediaSelectionGroup: subtitlesGroup];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -246,24 +242,20 @@ static void clear_touches() {
|
||||||
|
|
||||||
// Implement this to override the default layer class (which is [CALayer class]).
|
// Implement this to override the default layer class (which is [CALayer class]).
|
||||||
// We do this so that our view will be backed by a layer that is capable of OpenGL ES rendering.
|
// We do this so that our view will be backed by a layer that is capable of OpenGL ES rendering.
|
||||||
+ (Class) layerClass
|
+ (Class) layerClass {
|
||||||
{
|
|
||||||
return [CAEAGLLayer class];
|
return [CAEAGLLayer class];
|
||||||
}
|
}
|
||||||
|
|
||||||
//The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder:
|
//The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder:
|
||||||
- (id)initWithCoder:(NSCoder*)coder
|
- (id)initWithCoder:(NSCoder*)coder {
|
||||||
{
|
|
||||||
active = FALSE;
|
active = FALSE;
|
||||||
if((self = [super initWithCoder:coder]))
|
if((self = [super initWithCoder:coder])) {
|
||||||
{
|
|
||||||
self = [self initGLES];
|
self = [self initGLES];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(id)initGLES
|
-(id)initGLES {
|
||||||
{
|
|
||||||
// Get our backing layer
|
// Get our backing layer
|
||||||
CAEAGLLayer *eaglLayer = (CAEAGLLayer*) self.layer;
|
CAEAGLLayer *eaglLayer = (CAEAGLLayer*) self.layer;
|
||||||
|
|
||||||
|
@ -277,8 +269,7 @@ static void clear_touches() {
|
||||||
// Create our EAGLContext, and if successful make it current and create our framebuffer.
|
// Create our EAGLContext, and if successful make it current and create our framebuffer.
|
||||||
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
||||||
|
|
||||||
if(!context || ![EAGLContext setCurrentContext:context] || ![self createFramebuffer])
|
if(!context || ![EAGLContext setCurrentContext:context] || ![self createFramebuffer]) {
|
||||||
{
|
|
||||||
[self release];
|
[self release];
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
@ -288,14 +279,12 @@ static void clear_touches() {
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(id<GLViewDelegate>)delegate
|
-(id<GLViewDelegate>)delegate {
|
||||||
{
|
|
||||||
return delegate;
|
return delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the delegate, and if it needs a -setupView: call, set our internal flag so that it will be called.
|
// Update the delegate, and if it needs a -setupView: call, set our internal flag so that it will be called.
|
||||||
-(void)setDelegate:(id<GLViewDelegate>)d
|
-(void)setDelegate:(id<GLViewDelegate>)d {
|
||||||
{
|
|
||||||
delegate = d;
|
delegate = d;
|
||||||
delegateSetup = ![delegate respondsToSelector:@selector(setupView:)];
|
delegateSetup = ![delegate respondsToSelector:@selector(setupView:)];
|
||||||
}
|
}
|
||||||
|
@ -306,8 +295,7 @@ static void clear_touches() {
|
||||||
// This is the perfect opportunity to also update the framebuffer so that it is
|
// This is the perfect opportunity to also update the framebuffer so that it is
|
||||||
// the same size as our display area.
|
// the same size as our display area.
|
||||||
|
|
||||||
-(void)layoutSubviews
|
-(void)layoutSubviews {
|
||||||
{
|
|
||||||
//printf("HERE\n");
|
//printf("HERE\n");
|
||||||
[EAGLContext setCurrentContext:context];
|
[EAGLContext setCurrentContext:context];
|
||||||
[self destroyFramebuffer];
|
[self destroyFramebuffer];
|
||||||
|
@ -317,8 +305,7 @@ static void clear_touches() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)createFramebuffer
|
- (BOOL)createFramebuffer {
|
||||||
{
|
|
||||||
// Generate IDs for a framebuffer object and a color renderbuffer
|
// Generate IDs for a framebuffer object and a color renderbuffer
|
||||||
UIScreen* mainscr = [UIScreen mainScreen];
|
UIScreen* mainscr = [UIScreen mainScreen];
|
||||||
printf("******** screen size %i, %i\n", (int)mainscr.currentMode.size.width, (int)mainscr.currentMode.size.height);
|
printf("******** screen size %i, %i\n", (int)mainscr.currentMode.size.width, (int)mainscr.currentMode.size.height);
|
||||||
|
@ -345,8 +332,7 @@ static void clear_touches() {
|
||||||
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight);
|
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight);
|
||||||
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer);
|
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer);
|
||||||
|
|
||||||
if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES)
|
if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) {
|
||||||
{
|
|
||||||
NSLog(@"failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));
|
NSLog(@"failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
@ -366,24 +352,22 @@ static void clear_touches() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean up any buffers we have allocated.
|
// Clean up any buffers we have allocated.
|
||||||
- (void)destroyFramebuffer
|
- (void)destroyFramebuffer {
|
||||||
{
|
|
||||||
glDeleteFramebuffersOES(1, &viewFramebuffer);
|
glDeleteFramebuffersOES(1, &viewFramebuffer);
|
||||||
viewFramebuffer = 0;
|
viewFramebuffer = 0;
|
||||||
glDeleteRenderbuffersOES(1, &viewRenderbuffer);
|
glDeleteRenderbuffersOES(1, &viewRenderbuffer);
|
||||||
viewRenderbuffer = 0;
|
viewRenderbuffer = 0;
|
||||||
|
|
||||||
if(depthRenderbuffer)
|
if(depthRenderbuffer) {
|
||||||
{
|
|
||||||
glDeleteRenderbuffersOES(1, &depthRenderbuffer);
|
glDeleteRenderbuffersOES(1, &depthRenderbuffer);
|
||||||
depthRenderbuffer = 0;
|
depthRenderbuffer = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)startAnimation
|
- (void)startAnimation {
|
||||||
{
|
|
||||||
if (active)
|
if (active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
active = TRUE;
|
active = TRUE;
|
||||||
printf("start animation!\n");
|
printf("start animation!\n");
|
||||||
if (useCADisplayLink) {
|
if (useCADisplayLink) {
|
||||||
|
@ -397,43 +381,38 @@ static void clear_touches() {
|
||||||
|
|
||||||
// Setup DisplayLink in main thread
|
// Setup DisplayLink in main thread
|
||||||
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
|
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES];
|
animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (video_playing)
|
if (video_playing) {
|
||||||
{
|
|
||||||
_unpause_video();
|
_unpause_video();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)stopAnimation
|
- (void)stopAnimation {
|
||||||
{
|
|
||||||
if (!active)
|
if (!active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
active = FALSE;
|
active = FALSE;
|
||||||
printf("******** stop animation!\n");
|
printf("******** stop animation!\n");
|
||||||
|
|
||||||
if (useCADisplayLink) {
|
if (useCADisplayLink) {
|
||||||
[displayLink invalidate];
|
[displayLink invalidate];
|
||||||
displayLink = nil;
|
displayLink = nil;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
[animationTimer invalidate];
|
[animationTimer invalidate];
|
||||||
animationTimer = nil;
|
animationTimer = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
clear_touches();
|
clear_touches();
|
||||||
|
|
||||||
if (video_playing)
|
if (video_playing) {
|
||||||
{
|
|
||||||
// save position
|
// save position
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setAnimationInterval:(NSTimeInterval)interval
|
- (void)setAnimationInterval:(NSTimeInterval)interval {
|
||||||
{
|
|
||||||
animationInterval = interval;
|
animationInterval = interval;
|
||||||
if ((useCADisplayLink && displayLink) || (!useCADisplayLink && animationTimer)) {
|
if ((useCADisplayLink && displayLink) || (!useCADisplayLink && animationTimer)) {
|
||||||
[self stopAnimation];
|
[self stopAnimation];
|
||||||
|
@ -442,8 +421,7 @@ static void clear_touches() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updates the OpenGL view when the timer fires
|
// Updates the OpenGL view when the timer fires
|
||||||
- (void)drawView
|
- (void)drawView {
|
||||||
{
|
|
||||||
if (useCADisplayLink) {
|
if (useCADisplayLink) {
|
||||||
// Pause the CADisplayLink to avoid recursion
|
// Pause the CADisplayLink to avoid recursion
|
||||||
[displayLink setPaused: YES];
|
[displayLink setPaused: YES];
|
||||||
|
@ -464,8 +442,7 @@ static void clear_touches() {
|
||||||
[EAGLContext setCurrentContext:context];
|
[EAGLContext setCurrentContext:context];
|
||||||
|
|
||||||
// If our drawing delegate needs to have the view setup, then call -setupView: and flag that it won't need to be called again.
|
// If our drawing delegate needs to have the view setup, then call -setupView: and flag that it won't need to be called again.
|
||||||
if(!delegateSetup)
|
if(!delegateSetup) {
|
||||||
{
|
|
||||||
[delegate setupView:self];
|
[delegate setupView:self];
|
||||||
delegateSetup = YES;
|
delegateSetup = YES;
|
||||||
}
|
}
|
||||||
|
@ -484,8 +461,7 @@ static void clear_touches() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
|
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||||
{
|
|
||||||
NSArray* tlist = [[event allTouches] allObjects];
|
NSArray* tlist = [[event allTouches] allObjects];
|
||||||
for (unsigned int i=0; i< [tlist count]; i++) {
|
for (unsigned int i=0; i< [tlist count]; i++) {
|
||||||
|
|
||||||
|
@ -502,8 +478,7 @@ static void clear_touches() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
|
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||||
{
|
|
||||||
|
|
||||||
NSArray* tlist = [[event allTouches] allObjects];
|
NSArray* tlist = [[event allTouches] allObjects];
|
||||||
for (unsigned int i=0; i< [tlist count]; i++) {
|
for (unsigned int i=0; i< [tlist count]; i++) {
|
||||||
|
@ -513,6 +488,7 @@ static void clear_touches() {
|
||||||
UITouch* touch = [tlist objectAtIndex:i];
|
UITouch* touch = [tlist objectAtIndex:i];
|
||||||
if (touch.phase != UITouchPhaseMoved)
|
if (touch.phase != UITouchPhaseMoved)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int tid = get_touch_id(touch);
|
int tid = get_touch_id(touch);
|
||||||
ERR_FAIL_COND(tid == -1);
|
ERR_FAIL_COND(tid == -1);
|
||||||
int first = get_first_id(touch);
|
int first = get_first_id(touch);
|
||||||
|
@ -524,8 +500,7 @@ static void clear_touches() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
|
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||||
{
|
|
||||||
NSArray* tlist = [[event allTouches] allObjects];
|
NSArray* tlist = [[event allTouches] allObjects];
|
||||||
for (unsigned int i=0; i< [tlist count]; i++) {
|
for (unsigned int i=0; i< [tlist count]; i++) {
|
||||||
|
|
||||||
|
@ -534,6 +509,7 @@ static void clear_touches() {
|
||||||
UITouch* touch = [tlist objectAtIndex:i];
|
UITouch* touch = [tlist objectAtIndex:i];
|
||||||
if (touch.phase != UITouchPhaseEnded)
|
if (touch.phase != UITouchPhaseEnded)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int tid = get_touch_id(touch);
|
int tid = get_touch_id(touch);
|
||||||
ERR_FAIL_COND(tid == -1);
|
ERR_FAIL_COND(tid == -1);
|
||||||
int rem = remove_touch(touch);
|
int rem = remove_touch(touch);
|
||||||
|
@ -567,6 +543,7 @@ static void clear_touches() {
|
||||||
- (void)deleteBackward {
|
- (void)deleteBackward {
|
||||||
if (keyboard_text.length())
|
if (keyboard_text.length())
|
||||||
keyboard_text.erase(keyboard_text.length() - 1, 1);
|
keyboard_text.erase(keyboard_text.length() - 1, 1);
|
||||||
|
|
||||||
OSIPhone::get_singleton()->key(KEY_BACKSPACE, true);
|
OSIPhone::get_singleton()->key(KEY_BACKSPACE, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -591,12 +568,12 @@ static void clear_touches() {
|
||||||
|
|
||||||
switch (routeChangeReason) {
|
switch (routeChangeReason) {
|
||||||
|
|
||||||
case AVAudioSessionRouteChangeReasonNewDeviceAvailable:
|
case AVAudioSessionRouteChangeReasonNewDeviceAvailable: {
|
||||||
NSLog(@"AVAudioSessionRouteChangeReasonNewDeviceAvailable");
|
NSLog(@"AVAudioSessionRouteChangeReasonNewDeviceAvailable");
|
||||||
NSLog(@"Headphone/Line plugged in");
|
NSLog(@"Headphone/Line plugged in");
|
||||||
break;
|
}; break;
|
||||||
|
|
||||||
case AVAudioSessionRouteChangeReasonOldDeviceUnavailable:
|
case AVAudioSessionRouteChangeReasonOldDeviceUnavailable: {
|
||||||
NSLog(@"AVAudioSessionRouteChangeReasonOldDeviceUnavailable");
|
NSLog(@"AVAudioSessionRouteChangeReasonOldDeviceUnavailable");
|
||||||
NSLog(@"Headphone/Line was pulled. Resuming video play....");
|
NSLog(@"Headphone/Line was pulled. Resuming video play....");
|
||||||
if (_is_video_playing()) {
|
if (_is_video_playing()) {
|
||||||
|
@ -606,24 +583,22 @@ static void clear_touches() {
|
||||||
NSLog(@"resumed play");
|
NSLog(@"resumed play");
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
break;
|
}; break;
|
||||||
|
|
||||||
case AVAudioSessionRouteChangeReasonCategoryChange:
|
case AVAudioSessionRouteChangeReasonCategoryChange: {
|
||||||
// called at start - also when other audio wants to play
|
// called at start - also when other audio wants to play
|
||||||
NSLog(@"AVAudioSessionRouteChangeReasonCategoryChange");
|
NSLog(@"AVAudioSessionRouteChangeReasonCategoryChange");
|
||||||
break;
|
}; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// When created via code however, we get initWithFrame
|
// When created via code however, we get initWithFrame
|
||||||
-(id)initWithFrame:(CGRect)frame
|
-(id)initWithFrame:(CGRect)frame {
|
||||||
{
|
|
||||||
self = [super initWithFrame:frame];
|
self = [super initWithFrame:frame];
|
||||||
_instance = self;
|
_instance = self;
|
||||||
printf("after init super %p\n", self);
|
printf("after init super %p\n", self);
|
||||||
if(self != nil)
|
if(self != nil) {
|
||||||
{
|
|
||||||
self = [self initGLES];
|
self = [self initGLES];
|
||||||
printf("after init gles %p\n", self);
|
printf("after init gles %p\n", self);
|
||||||
}
|
}
|
||||||
|
@ -650,12 +625,10 @@ static void clear_touches() {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Stop animating and release resources when they are no longer needed.
|
// Stop animating and release resources when they are no longer needed.
|
||||||
- (void)dealloc
|
- (void)dealloc {
|
||||||
{
|
|
||||||
[self stopAnimation];
|
[self stopAnimation];
|
||||||
|
|
||||||
if([EAGLContext currentContext] == context)
|
if([EAGLContext currentContext] == context) {
|
||||||
{
|
|
||||||
[EAGLContext setCurrentContext:nil];
|
[EAGLContext setCurrentContext:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,8 +77,7 @@ Variant nsobject_to_variant(NSObject* object) {
|
||||||
if ([object isKindOfClass:[NSString class]]) {
|
if ([object isKindOfClass:[NSString class]]) {
|
||||||
const char* str = [(NSString*)object UTF8String];
|
const char* str = [(NSString*)object UTF8String];
|
||||||
return String::utf8(str != NULL ? str : "");
|
return String::utf8(str != NULL ? str : "");
|
||||||
}
|
} else if ([object isKindOfClass:[NSData class]]) {
|
||||||
else if ([object isKindOfClass:[NSData class]]) {
|
|
||||||
ByteArray ret;
|
ByteArray ret;
|
||||||
NSData* data = (NSData*)object;
|
NSData* data = (NSData*)object;
|
||||||
if ([data length] > 0) {
|
if ([data length] > 0) {
|
||||||
|
@ -89,8 +88,7 @@ Variant nsobject_to_variant(NSObject* object) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
} else if ([object isKindOfClass:[NSArray class]]) {
|
||||||
else if ([object isKindOfClass:[NSArray class]]) {
|
|
||||||
Array result;
|
Array result;
|
||||||
NSArray* array = (NSArray*)object;
|
NSArray* array = (NSArray*)object;
|
||||||
for (unsigned int i = 0; i < [array count]; ++i) {
|
for (unsigned int i = 0; i < [array count]; ++i) {
|
||||||
|
@ -98,8 +96,7 @@ Variant nsobject_to_variant(NSObject* object) {
|
||||||
result.push_back(nsobject_to_variant(value));
|
result.push_back(nsobject_to_variant(value));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
} else if ([object isKindOfClass:[NSDictionary class]]) {
|
||||||
else if ([object isKindOfClass:[NSDictionary class]]) {
|
|
||||||
Dictionary result;
|
Dictionary result;
|
||||||
NSDictionary* dic = (NSDictionary*)object;
|
NSDictionary* dic = (NSDictionary*)object;
|
||||||
|
|
||||||
|
@ -113,8 +110,7 @@ Variant nsobject_to_variant(NSObject* object) {
|
||||||
result[nsobject_to_variant(k)] = nsobject_to_variant(v);
|
result[nsobject_to_variant(k)] = nsobject_to_variant(v);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
} else if ([object isKindOfClass:[NSNumber class]]) {
|
||||||
else if ([object isKindOfClass:[NSNumber class]]) {
|
|
||||||
//Every type except numbers can reliably identify its type. The following is comparing to the *internal* representation, which isn't guaranteed to match the type that was used to create it, and is not advised, particularly when dealing with potential platform differences (ie, 32/64 bit)
|
//Every type except numbers can reliably identify its type. The following is comparing to the *internal* representation, which isn't guaranteed to match the type that was used to create it, and is not advised, particularly when dealing with potential platform differences (ie, 32/64 bit)
|
||||||
//To avoid errors, we'll cast as broadly as possible, and only return int or float.
|
//To avoid errors, we'll cast as broadly as possible, and only return int or float.
|
||||||
//bool, char, int, uint, longlong -> int
|
//bool, char, int, uint, longlong -> int
|
||||||
|
@ -122,37 +118,28 @@ Variant nsobject_to_variant(NSObject* object) {
|
||||||
NSNumber* num = (NSNumber*)object;
|
NSNumber* num = (NSNumber*)object;
|
||||||
if(strcmp([num objCType], @encode(BOOL)) == 0) {
|
if(strcmp([num objCType], @encode(BOOL)) == 0) {
|
||||||
return Variant((int)[num boolValue]);
|
return Variant((int)[num boolValue]);
|
||||||
}
|
} else if(strcmp([num objCType], @encode(char)) == 0) {
|
||||||
else if(strcmp([num objCType], @encode(char)) == 0) {
|
|
||||||
return Variant((int)[num charValue]);
|
return Variant((int)[num charValue]);
|
||||||
}
|
} else if(strcmp([num objCType], @encode(int)) == 0) {
|
||||||
else if(strcmp([num objCType], @encode(int)) == 0) {
|
|
||||||
return Variant([num intValue]);
|
return Variant([num intValue]);
|
||||||
}
|
} else if(strcmp([num objCType], @encode(unsigned int)) == 0) {
|
||||||
else if(strcmp([num objCType], @encode(unsigned int)) == 0) {
|
|
||||||
return Variant((int)[num unsignedIntValue]);
|
return Variant((int)[num unsignedIntValue]);
|
||||||
}
|
} else if(strcmp([num objCType], @encode(long long)) == 0) {
|
||||||
else if(strcmp([num objCType], @encode(long long)) == 0) {
|
|
||||||
return Variant((int)[num longValue]);
|
return Variant((int)[num longValue]);
|
||||||
}
|
} else if(strcmp([num objCType], @encode(float)) == 0) {
|
||||||
else if(strcmp([num objCType], @encode(float)) == 0) {
|
|
||||||
return Variant([num floatValue]);
|
return Variant([num floatValue]);
|
||||||
}
|
} else if(strcmp([num objCType], @encode(double)) == 0) {
|
||||||
else if(strcmp([num objCType], @encode(double)) == 0) {
|
|
||||||
return Variant((float)[num doubleValue]);
|
return Variant((float)[num doubleValue]);
|
||||||
}
|
}
|
||||||
}
|
} else if ([object isKindOfClass:[NSDate class]]) {
|
||||||
else if ([object isKindOfClass:[NSDate class]]) {
|
|
||||||
//this is a type that icloud supports...but how did you submit it in the first place?
|
//this is a type that icloud supports...but how did you submit it in the first place?
|
||||||
//I guess this is a type that *might* show up, if you were, say, trying to make your game
|
//I guess this is a type that *might* show up, if you were, say, trying to make your game
|
||||||
//compatible with existing cloud data written by another engine's version of your game
|
//compatible with existing cloud data written by another engine's version of your game
|
||||||
WARN_PRINT("NSDate unsupported, returning null Variant")
|
WARN_PRINT("NSDate unsupported, returning null Variant")
|
||||||
return Variant();
|
return Variant();
|
||||||
}
|
} else if ([object isKindOfClass:[NSNull class]] or object == nil) {
|
||||||
else if ([object isKindOfClass:[NSNull class]] or object == nil) {
|
|
||||||
return Variant();
|
return Variant();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
WARN_PRINT("Trying to convert unknown NSObject type to Variant");
|
WARN_PRINT("Trying to convert unknown NSObject type to Variant");
|
||||||
return Variant();
|
return Variant();
|
||||||
}
|
}
|
||||||
|
@ -161,17 +148,13 @@ Variant nsobject_to_variant(NSObject* object) {
|
||||||
NSObject* variant_to_nsobject(Variant v) {
|
NSObject* variant_to_nsobject(Variant v) {
|
||||||
if (v.get_type() == Variant::STRING) {
|
if (v.get_type() == Variant::STRING) {
|
||||||
return [[[NSString alloc] initWithUTF8String:((String)v).utf8().get_data()] autorelease];
|
return [[[NSString alloc] initWithUTF8String:((String)v).utf8().get_data()] autorelease];
|
||||||
}
|
} else if (v.get_type() == Variant::REAL) {
|
||||||
else if (v.get_type() == Variant::REAL) {
|
|
||||||
return [NSNumber numberWithDouble:(double)v];
|
return [NSNumber numberWithDouble:(double)v];
|
||||||
}
|
} else if (v.get_type() == Variant::INT) {
|
||||||
else if (v.get_type() == Variant::INT) {
|
|
||||||
return [NSNumber numberWithLongLong:(long)(int)v];
|
return [NSNumber numberWithLongLong:(long)(int)v];
|
||||||
}
|
} else if (v.get_type() == Variant::BOOL) {
|
||||||
else if (v.get_type() == Variant::BOOL) {
|
|
||||||
return [NSNumber numberWithBool:BOOL((bool)v)];
|
return [NSNumber numberWithBool:BOOL((bool)v)];
|
||||||
}
|
} else if (v.get_type() == Variant::DICTIONARY) {
|
||||||
else if (v.get_type() == Variant::DICTIONARY) {
|
|
||||||
NSMutableDictionary* result = [[[NSMutableDictionary alloc] init] autorelease];
|
NSMutableDictionary* result = [[[NSMutableDictionary alloc] init] autorelease];
|
||||||
Dictionary dic = v;
|
Dictionary dic = v;
|
||||||
Array keys = dic.keys();
|
Array keys = dic.keys();
|
||||||
|
@ -186,8 +169,7 @@ NSObject* variant_to_nsobject(Variant v) {
|
||||||
[result setObject:value forKey:key];
|
[result setObject:value forKey:key];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
} else if (v.get_type() == Variant::ARRAY) {
|
||||||
else if (v.get_type() == Variant::ARRAY) {
|
|
||||||
NSMutableArray* result = [[[NSMutableArray alloc] init] autorelease];
|
NSMutableArray* result = [[[NSMutableArray alloc] init] autorelease];
|
||||||
Array arr = v;
|
Array arr = v;
|
||||||
for (unsigned int i = 0; i < arr.size(); ++i) {
|
for (unsigned int i = 0; i < arr.size(); ++i) {
|
||||||
|
@ -199,8 +181,7 @@ NSObject* variant_to_nsobject(Variant v) {
|
||||||
[result addObject:value];
|
[result addObject:value];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
} else if (v.get_type() == Variant::RAW_ARRAY) {
|
||||||
else if (v.get_type() == Variant::RAW_ARRAY) {
|
|
||||||
ByteArray arr = v;
|
ByteArray arr = v;
|
||||||
ByteArray::Read r = arr.read();
|
ByteArray::Read r = arr.read();
|
||||||
NSData* result = [NSData dataWithBytes:r.ptr() length:arr.size()];
|
NSData* result = [NSData dataWithBytes:r.ptr() length:arr.size()];
|
||||||
|
@ -297,8 +278,7 @@ Error ICloud::synchronize_key_values() {
|
||||||
BOOL result = [store synchronize];
|
BOOL result = [store synchronize];
|
||||||
if (result == YES) {
|
if (result == YES) {
|
||||||
return OK;
|
return OK;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return FAILED;
|
return FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -341,14 +321,11 @@ ICloud::ICloud() {
|
||||||
|
|
||||||
if (change == NSUbiquitousKeyValueStoreServerChange) {
|
if (change == NSUbiquitousKeyValueStoreServerChange) {
|
||||||
reason = "server";
|
reason = "server";
|
||||||
}
|
} else if (change == NSUbiquitousKeyValueStoreInitialSyncChange) {
|
||||||
else if (change == NSUbiquitousKeyValueStoreInitialSyncChange) {
|
|
||||||
reason = "initial_sync";
|
reason = "initial_sync";
|
||||||
}
|
} else if (change == NSUbiquitousKeyValueStoreQuotaViolationChange) {
|
||||||
else if (change == NSUbiquitousKeyValueStoreQuotaViolationChange) {
|
|
||||||
reason = "quota_violation";
|
reason = "quota_violation";
|
||||||
}
|
} else if (change == NSUbiquitousKeyValueStoreAccountChange) {
|
||||||
else if (change == NSUbiquitousKeyValueStoreAccountChange) {
|
|
||||||
reason = "account";
|
reason = "account";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,8 +51,7 @@ NSMutableDictionary* pending_transactions = [NSMutableDictionary dictionary];
|
||||||
// SKProduct extension
|
// SKProduct extension
|
||||||
//----------------------------------//
|
//----------------------------------//
|
||||||
@implementation SKProduct (LocalizedPrice)
|
@implementation SKProduct (LocalizedPrice)
|
||||||
- (NSString *)localizedPrice
|
- (NSString *)localizedPrice {
|
||||||
{
|
|
||||||
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
|
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
|
||||||
[numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
|
[numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
|
||||||
[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
|
[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
|
||||||
|
@ -169,7 +168,6 @@ Error InAppStore::request_product_info(Variant p_params) {
|
||||||
for (SKPaymentTransaction* transaction in transactions) {
|
for (SKPaymentTransaction* transaction in transactions) {
|
||||||
|
|
||||||
switch (transaction.transactionState) {
|
switch (transaction.transactionState) {
|
||||||
|
|
||||||
case SKPaymentTransactionStatePurchased: {
|
case SKPaymentTransactionStatePurchased: {
|
||||||
printf("status purchased!\n");
|
printf("status purchased!\n");
|
||||||
String pid = String::utf8([transaction.payment.productIdentifier UTF8String]);
|
String pid = String::utf8([transaction.payment.productIdentifier UTF8String]);
|
||||||
|
@ -210,8 +208,7 @@ Error InAppStore::request_product_info(Variant p_params) {
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString* receipt_to_send = nil;
|
NSString* receipt_to_send = nil;
|
||||||
if (receipt != nil)
|
if (receipt != nil) {
|
||||||
{
|
|
||||||
receipt_to_send = [receipt description];
|
receipt_to_send = [receipt description];
|
||||||
}
|
}
|
||||||
Dictionary receipt_ret;
|
Dictionary receipt_ret;
|
||||||
|
@ -223,8 +220,7 @@ Error InAppStore::request_product_info(Variant p_params) {
|
||||||
|
|
||||||
if (auto_finish_transactions){
|
if (auto_finish_transactions){
|
||||||
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
|
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
[pending_transactions setObject:transaction forKey:transaction.payment.productIdentifier];
|
[pending_transactions setObject:transaction forKey:transaction.payment.productIdentifier];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,7 +228,7 @@ Error InAppStore::request_product_info(Variant p_params) {
|
||||||
printf("Registering transaction on Fuseboxx!\n");
|
printf("Registering transaction on Fuseboxx!\n");
|
||||||
[FuseSDK registerInAppPurchase: transaction];
|
[FuseSDK registerInAppPurchase: transaction];
|
||||||
#endif
|
#endif
|
||||||
} break;
|
}; break;
|
||||||
case SKPaymentTransactionStateFailed: {
|
case SKPaymentTransactionStateFailed: {
|
||||||
printf("status transaction failed!\n");
|
printf("status transaction failed!\n");
|
||||||
String pid = String::utf8([transaction.payment.productIdentifier UTF8String]);
|
String pid = String::utf8([transaction.payment.productIdentifier UTF8String]);
|
||||||
|
@ -242,18 +238,17 @@ Error InAppStore::request_product_info(Variant p_params) {
|
||||||
ret["product_id"] = pid;
|
ret["product_id"] = pid;
|
||||||
InAppStore::get_singleton()->_post_event(ret);
|
InAppStore::get_singleton()->_post_event(ret);
|
||||||
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
|
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
|
||||||
} break;
|
}; break;
|
||||||
case SKPaymentTransactionStateRestored: {
|
case SKPaymentTransactionStateRestored: {
|
||||||
printf("status transaction restored!\n");
|
printf("status transaction restored!\n");
|
||||||
String pid = String::utf8([transaction.originalTransaction.payment.productIdentifier UTF8String]);
|
String pid = String::utf8([transaction.originalTransaction.payment.productIdentifier UTF8String]);
|
||||||
InAppStore::get_singleton()->_record_purchase(pid);
|
InAppStore::get_singleton()->_record_purchase(pid);
|
||||||
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
|
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
|
||||||
} break;
|
}; break;
|
||||||
|
default: {
|
||||||
default:
|
|
||||||
printf("status default %i!\n", (int)transaction.transactionState);
|
printf("status default %i!\n", (int)transaction.transactionState);
|
||||||
|
|
||||||
break;
|
}; break;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -44,14 +44,11 @@ String iOS::get_rate_url(int p_app_id) const {
|
||||||
//ios7 before
|
//ios7 before
|
||||||
String ret = templ;
|
String ret = templ;
|
||||||
|
|
||||||
|
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0 && [[[UIDevice currentDevice] systemVersion] floatValue] < 7.1) {
|
||||||
// iOS 7 needs a different templateReviewURL @see https://github.com/arashpayan/appirater/issues/131
|
// iOS 7 needs a different templateReviewURL @see https://github.com/arashpayan/appirater/issues/131
|
||||||
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0 && [[[UIDevice currentDevice] systemVersion] floatValue] < 7.1)
|
|
||||||
{
|
|
||||||
ret = templ_iOS7;
|
ret = templ_iOS7;
|
||||||
}
|
} else if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
|
||||||
// iOS 8 needs a different templateReviewURL also @see https://github.com/arashpayan/appirater/issues/182
|
// iOS 8 needs a different templateReviewURL also @see https://github.com/arashpayan/appirater/issues/182
|
||||||
else if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
|
|
||||||
{
|
|
||||||
ret = templ_iOS8;
|
ret = templ_iOS8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,7 @@
|
||||||
int gargc;
|
int gargc;
|
||||||
char** gargv;
|
char** gargv;
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[]) {
|
||||||
{
|
|
||||||
printf("*********** main.m\n");
|
printf("*********** main.m\n");
|
||||||
gargc = argc;
|
gargc = argc;
|
||||||
gargv = argv;
|
gargv = argv;
|
||||||
|
|
|
@ -128,8 +128,7 @@ int add_cmdline(int p_argc, char** p_args) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
- (BOOL)prefersStatusBarHidden
|
- (BOOL)prefersStatusBarHidden {
|
||||||
{
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,9 +75,6 @@ int main(int argc, char** argv) {
|
||||||
free(path);
|
free(path);
|
||||||
free(pathinfo);
|
free(pathinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OS_OSX os;
|
OS_OSX os;
|
||||||
|
|
|
@ -176,7 +176,6 @@ extern int godot_main(int argc, char** argv);
|
||||||
#undef main
|
#undef main
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int main (int argc, char **argv)
|
int main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
/* Copy the arguments into a global variable */
|
/* Copy the arguments into a global variable */
|
||||||
|
|
|
@ -95,11 +95,9 @@ static NSRect convertRectToBacking(NSRect contentRect) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static InputModifierState translateFlags(NSUInteger flags)
|
static InputModifierState translateFlags(NSUInteger flags) {
|
||||||
{
|
|
||||||
InputModifierState mod;
|
InputModifierState mod;
|
||||||
|
|
||||||
|
|
||||||
mod.shift = (flags & NSShiftKeyMask);
|
mod.shift = (flags & NSShiftKeyMask);
|
||||||
mod.control = (flags & NSControlKeyMask);
|
mod.control = (flags & NSControlKeyMask);
|
||||||
mod.alt = (flags & NSAlternateKeyMask);
|
mod.alt = (flags & NSAlternateKeyMask);
|
||||||
|
@ -123,8 +121,7 @@ static int button_mask=0;
|
||||||
// From http://cocoadev.com/index.pl?GameKeyboardHandlingAlmost
|
// From http://cocoadev.com/index.pl?GameKeyboardHandlingAlmost
|
||||||
// This works around an AppKit bug, where key up events while holding
|
// This works around an AppKit bug, where key up events while holding
|
||||||
// down the command key don't get sent to the key window.
|
// down the command key don't get sent to the key window.
|
||||||
- (void)sendEvent:(NSEvent *)event
|
- (void)sendEvent:(NSEvent *)event {
|
||||||
{
|
|
||||||
if ([event type] == NSKeyUp && ([event modifierFlags] & NSCommandKeyMask))
|
if ([event type] == NSKeyUp && ([event modifierFlags] & NSCommandKeyMask))
|
||||||
[[self keyWindow] sendEvent:event];
|
[[self keyWindow] sendEvent:event];
|
||||||
else
|
else
|
||||||
|
@ -138,25 +135,23 @@ static int button_mask=0;
|
||||||
|
|
||||||
@implementation GodotApplicationDelegate
|
@implementation GodotApplicationDelegate
|
||||||
|
|
||||||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
|
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender {
|
||||||
{
|
|
||||||
if (OS_OSX::singleton->get_main_loop())
|
if (OS_OSX::singleton->get_main_loop())
|
||||||
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST);
|
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST);
|
||||||
|
|
||||||
return NSTerminateCancel;
|
return NSTerminateCancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationDidHide:(NSNotification *)notification
|
- (void)applicationDidHide:(NSNotification *)notification {
|
||||||
{
|
/*
|
||||||
/* _Godotwindow* window;
|
_Godotwindow* window;
|
||||||
|
|
||||||
for (window = _Godot.windowListHead; window; window = window->next)
|
for (window = _Godot.windowListHead; window; window = window->next)
|
||||||
_GodotInputWindowVisibility(window, GL_FALSE);
|
_GodotInputWindowVisibility(window, GL_FALSE);
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationDidUnhide:(NSNotification *)notification
|
- (void)applicationDidUnhide:(NSNotification *)notification {
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
_Godotwindow* window;
|
_Godotwindow* window;
|
||||||
|
|
||||||
|
@ -168,15 +163,13 @@ static int button_mask=0;
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationDidChangeScreenParameters:(NSNotification *) notification
|
- (void)applicationDidChangeScreenParameters:(NSNotification *) notification {
|
||||||
{
|
|
||||||
//_GodotInputMonitorChange();
|
//_GodotInputMonitorChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface GodotWindowDelegate : NSObject
|
@interface GodotWindowDelegate : NSObject {
|
||||||
{
|
|
||||||
//_Godotwindow* window;
|
//_Godotwindow* window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,20 +177,14 @@ static int button_mask=0;
|
||||||
|
|
||||||
@implementation GodotWindowDelegate
|
@implementation GodotWindowDelegate
|
||||||
|
|
||||||
|
- (BOOL)windowShouldClose:(id)sender {
|
||||||
- (BOOL)windowShouldClose:(id)sender
|
|
||||||
{
|
|
||||||
//_GodotInputWindowCloseRequest(window);
|
//_GodotInputWindowCloseRequest(window);
|
||||||
if (OS_OSX::singleton->get_main_loop())
|
if (OS_OSX::singleton->get_main_loop())
|
||||||
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST);
|
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST);
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)windowDidResize:(NSNotification *)notification {
|
||||||
|
|
||||||
|
|
||||||
- (void)windowDidResize:(NSNotification *)notification
|
|
||||||
{
|
|
||||||
[OS_OSX::singleton->context update];
|
[OS_OSX::singleton->context update];
|
||||||
|
|
||||||
const NSRect contentRect = [OS_OSX::singleton->window_view frame];
|
const NSRect contentRect = [OS_OSX::singleton->window_view frame];
|
||||||
|
@ -206,7 +193,6 @@ static int button_mask=0;
|
||||||
OS_OSX::singleton->window_size.width = fbRect.size.width*OS_OSX::singleton->display_scale;
|
OS_OSX::singleton->window_size.width = fbRect.size.width*OS_OSX::singleton->display_scale;
|
||||||
OS_OSX::singleton->window_size.height = fbRect.size.height*OS_OSX::singleton->display_scale;
|
OS_OSX::singleton->window_size.height = fbRect.size.height*OS_OSX::singleton->display_scale;
|
||||||
|
|
||||||
|
|
||||||
//_GodotInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
|
//_GodotInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
|
||||||
//_GodotInputWindowSize(window, contentRect.size.width, contentRect.size.height);
|
//_GodotInputWindowSize(window, contentRect.size.width, contentRect.size.height);
|
||||||
//_GodotInputWindowDamage(window);
|
//_GodotInputWindowDamage(window);
|
||||||
|
@ -215,8 +201,7 @@ static int button_mask=0;
|
||||||
// centerCursor(window);
|
// centerCursor(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidMove:(NSNotification *)notification
|
- (void)windowDidMove:(NSNotification *)notification {
|
||||||
{
|
|
||||||
//[window->nsgl.context update];
|
//[window->nsgl.context update];
|
||||||
|
|
||||||
//int x, y;
|
//int x, y;
|
||||||
|
@ -227,32 +212,27 @@ static int button_mask=0;
|
||||||
// centerCursor(window);
|
// centerCursor(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidBecomeKey:(NSNotification *)notification
|
- (void)windowDidBecomeKey:(NSNotification *)notification {
|
||||||
{
|
|
||||||
//_GodotInputWindowFocus(window, GL_TRUE);
|
//_GodotInputWindowFocus(window, GL_TRUE);
|
||||||
//_GodotPlatformSetCursorMode(window, window->cursorMode);
|
//_GodotPlatformSetCursorMode(window, window->cursorMode);
|
||||||
if (OS_OSX::singleton->get_main_loop())
|
if (OS_OSX::singleton->get_main_loop())
|
||||||
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
|
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidResignKey:(NSNotification *)notification
|
- (void)windowDidResignKey:(NSNotification *)notification {
|
||||||
{
|
|
||||||
//_GodotInputWindowFocus(window, GL_FALSE);
|
//_GodotInputWindowFocus(window, GL_FALSE);
|
||||||
//_GodotPlatformSetCursorMode(window, Godot_CURSOR_NORMAL);
|
//_GodotPlatformSetCursorMode(window, Godot_CURSOR_NORMAL);
|
||||||
if (OS_OSX::singleton->get_main_loop())
|
if (OS_OSX::singleton->get_main_loop())
|
||||||
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
|
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidMiniaturize:(NSNotification*)notification
|
- (void)windowDidMiniaturize:(NSNotification*)notification {
|
||||||
{
|
|
||||||
OS_OSX::singleton->wm_minimized(true);
|
OS_OSX::singleton->wm_minimized(true);
|
||||||
if (OS_OSX::singleton->get_main_loop())
|
if (OS_OSX::singleton->get_main_loop())
|
||||||
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
|
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
|
||||||
};
|
};
|
||||||
|
|
||||||
- (void)windowDidDeminiaturize:(NSNotification*)notification
|
- (void)windowDidDeminiaturize:(NSNotification*)notification {
|
||||||
{
|
|
||||||
|
|
||||||
OS_OSX::singleton->wm_minimized(false);
|
OS_OSX::singleton->wm_minimized(false);
|
||||||
if (OS_OSX::singleton->get_main_loop())
|
if (OS_OSX::singleton->get_main_loop())
|
||||||
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
|
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
|
||||||
|
@ -260,33 +240,27 @@ static int button_mask=0;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface GodotContentView : NSView
|
@interface GodotContentView : NSView {
|
||||||
{
|
|
||||||
NSTrackingArea* trackingArea;
|
NSTrackingArea* trackingArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation GodotContentView
|
@implementation GodotContentView
|
||||||
|
|
||||||
+ (void)initialize
|
+ (void)initialize {
|
||||||
{
|
if (self == [GodotContentView class]) {
|
||||||
if (self == [GodotContentView class])
|
/*
|
||||||
{
|
if (_glfw.ns.cursor == nil) {
|
||||||
/* if (_glfw.ns.cursor == nil)
|
|
||||||
{
|
|
||||||
NSImage* data = [[NSImage alloc] initWithSize:NSMakeSize(1, 1)];
|
NSImage* data = [[NSImage alloc] initWithSize:NSMakeSize(1, 1)];
|
||||||
_glfw.ns.cursor = [[NSCursor alloc] initWithImage:data
|
_glfw.ns.cursor = [[NSCursor alloc] initWithImage:data hotSpot:NSZeroPoint];
|
||||||
hotSpot:NSZeroPoint];
|
|
||||||
[data release];
|
[data release];
|
||||||
}*/
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)init
|
- (id)init {
|
||||||
{
|
|
||||||
self = [super init];
|
self = [super init];
|
||||||
trackingArea = nil;
|
trackingArea = nil;
|
||||||
[self updateTrackingAreas];
|
[self updateTrackingAreas];
|
||||||
|
@ -294,9 +268,7 @@ static int button_mask=0;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(void)dealloc {
|
||||||
-(void)dealloc
|
|
||||||
{
|
|
||||||
[trackingArea release];
|
[trackingArea release];
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
@ -310,8 +282,6 @@ static int button_mask=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender {
|
- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender {
|
||||||
|
|
||||||
|
|
||||||
NSPasteboard *pboard = [sender draggingPasteboard];
|
NSPasteboard *pboard = [sender draggingPasteboard];
|
||||||
NSArray *filenames = [pboard propertyListForType:NSFilenamesPboardType];
|
NSArray *filenames = [pboard propertyListForType:NSFilenamesPboardType];
|
||||||
|
|
||||||
|
@ -323,8 +293,6 @@ static int button_mask=0;
|
||||||
ret.parse_utf8(utfs);
|
ret.parse_utf8(utfs);
|
||||||
free(utfs);
|
free(utfs);
|
||||||
files.push_back(ret);
|
files.push_back(ret);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (files.size()) {
|
if (files.size()) {
|
||||||
|
@ -336,29 +304,23 @@ static int button_mask=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (BOOL)isOpaque
|
- (BOOL)isOpaque {
|
||||||
{
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)canBecomeKeyView
|
- (BOOL)canBecomeKeyView {
|
||||||
{
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)acceptsFirstResponder
|
- (BOOL)acceptsFirstResponder {
|
||||||
{
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)cursorUpdate:(NSEvent *)event
|
- (void)cursorUpdate:(NSEvent *)event {
|
||||||
{
|
|
||||||
// setModeCursor(window, window->cursorMode);
|
// setModeCursor(window, window->cursorMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseDown:(NSEvent *)event
|
- (void)mouseDown:(NSEvent *)event {
|
||||||
{
|
|
||||||
|
|
||||||
//print_line("mouse down:");
|
//print_line("mouse down:");
|
||||||
button_mask|=BUTTON_MASK_LEFT;
|
button_mask|=BUTTON_MASK_LEFT;
|
||||||
InputEvent ev;
|
InputEvent ev;
|
||||||
|
@ -374,21 +336,19 @@ static int button_mask=0;
|
||||||
ev.mouse_button.mod = translateFlags([event modifierFlags]);
|
ev.mouse_button.mod = translateFlags([event modifierFlags]);
|
||||||
OS_OSX::singleton->push_input(ev);
|
OS_OSX::singleton->push_input(ev);
|
||||||
|
|
||||||
|
/*
|
||||||
/* _glfwInputMouseClick(window,
|
_glfwInputMouseClick(window,
|
||||||
GLFW_MOUSE_BUTTON_LEFT,
|
GLFW_MOUSE_BUTTON_LEFT,
|
||||||
GLFW_PRESS,
|
GLFW_PRESS,
|
||||||
translateFlags([event modifierFlags]));*/
|
translateFlags([event modifierFlags]));
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseDragged:(NSEvent *)event
|
- (void)mouseDragged:(NSEvent *)event {
|
||||||
{
|
|
||||||
[self mouseMoved:event];
|
[self mouseMoved:event];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseUp:(NSEvent *)event
|
- (void)mouseUp:(NSEvent *)event {
|
||||||
{
|
|
||||||
|
|
||||||
button_mask &= ~BUTTON_MASK_LEFT;
|
button_mask &= ~BUTTON_MASK_LEFT;
|
||||||
InputEvent ev;
|
InputEvent ev;
|
||||||
ev.type=InputEvent::MOUSE_BUTTON;
|
ev.type=InputEvent::MOUSE_BUTTON;
|
||||||
|
@ -402,14 +362,15 @@ static int button_mask=0;
|
||||||
ev.mouse_button.mod = translateFlags([event modifierFlags]);
|
ev.mouse_button.mod = translateFlags([event modifierFlags]);
|
||||||
OS_OSX::singleton->push_input(ev);
|
OS_OSX::singleton->push_input(ev);
|
||||||
|
|
||||||
/* _glfwInputMouseClick(window,
|
/*
|
||||||
|
_glfwInputMouseClick(window,
|
||||||
GLFW_MOUSE_BUTTON_LEFT,
|
GLFW_MOUSE_BUTTON_LEFT,
|
||||||
GLFW_RELEASE,
|
GLFW_RELEASE,
|
||||||
translateFlags([event modifierFlags]));*/
|
translateFlags([event modifierFlags]));
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseMoved:(NSEvent *)event
|
- (void)mouseMoved:(NSEvent *)event {
|
||||||
{
|
|
||||||
|
|
||||||
InputEvent ev;
|
InputEvent ev;
|
||||||
ev.type=InputEvent::MOUSE_MOTION;
|
ev.type=InputEvent::MOUSE_MOTION;
|
||||||
|
@ -431,20 +392,19 @@ static int button_mask=0;
|
||||||
OS_OSX::singleton->input->set_mouse_pos(Point2(mouse_x,mouse_y));
|
OS_OSX::singleton->input->set_mouse_pos(Point2(mouse_x,mouse_y));
|
||||||
OS_OSX::singleton->push_input(ev);
|
OS_OSX::singleton->push_input(ev);
|
||||||
|
|
||||||
|
/*
|
||||||
/* if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||||
_glfwInputCursorMotion(window, [event deltaX], [event deltaY]);
|
_glfwInputCursorMotion(window, [event deltaX], [event deltaY]);
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
const NSRect contentRect = [window->ns.view frame];
|
const NSRect contentRect = [window->ns.view frame];
|
||||||
const NSPoint p = [event locationInWindow];
|
const NSPoint p = [event locationInWindow];
|
||||||
|
|
||||||
_glfwInputCursorMotion(window, p.x, contentRect.size.height - p.y);
|
_glfwInputCursorMotion(window, p.x, contentRect.size.height - p.y);
|
||||||
}*/
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)rightMouseDown:(NSEvent *)event
|
- (void)rightMouseDown:(NSEvent *)event {
|
||||||
{
|
|
||||||
|
|
||||||
button_mask |= BUTTON_MASK_RIGHT;
|
button_mask |= BUTTON_MASK_RIGHT;
|
||||||
InputEvent ev;
|
InputEvent ev;
|
||||||
|
@ -459,19 +419,19 @@ static int button_mask=0;
|
||||||
ev.mouse_button.mod = translateFlags([event modifierFlags]);
|
ev.mouse_button.mod = translateFlags([event modifierFlags]);
|
||||||
OS_OSX::singleton->push_input(ev);
|
OS_OSX::singleton->push_input(ev);
|
||||||
|
|
||||||
/* _glfwInputMouseClick(window,
|
/*
|
||||||
|
_glfwInputMouseClick(window,
|
||||||
GLFW_MOUSE_BUTTON_RIGHT,
|
GLFW_MOUSE_BUTTON_RIGHT,
|
||||||
GLFW_PRESS,
|
GLFW_PRESS,
|
||||||
translateFlags([event modifierFlags]));*/
|
translateFlags([event modifierFlags]));
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)rightMouseDragged:(NSEvent *)event
|
- (void)rightMouseDragged:(NSEvent *)event {
|
||||||
{
|
|
||||||
[self mouseMoved:event];
|
[self mouseMoved:event];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)rightMouseUp:(NSEvent *)event
|
- (void)rightMouseUp:(NSEvent *)event {
|
||||||
{
|
|
||||||
|
|
||||||
button_mask &= ~BUTTON_MASK_RIGHT;
|
button_mask &= ~BUTTON_MASK_RIGHT;
|
||||||
InputEvent ev;
|
InputEvent ev;
|
||||||
|
@ -486,14 +446,15 @@ static int button_mask=0;
|
||||||
ev.mouse_button.mod = translateFlags([event modifierFlags]);
|
ev.mouse_button.mod = translateFlags([event modifierFlags]);
|
||||||
OS_OSX::singleton->push_input(ev);
|
OS_OSX::singleton->push_input(ev);
|
||||||
|
|
||||||
/*_glfwInputMouseClick(window,
|
/*
|
||||||
|
_glfwInputMouseClick(window,
|
||||||
GLFW_MOUSE_BUTTON_RIGHT,
|
GLFW_MOUSE_BUTTON_RIGHT,
|
||||||
GLFW_RELEASE,
|
GLFW_RELEASE,
|
||||||
translateFlags([event modifierFlags]));*/
|
translateFlags([event modifierFlags]));
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)otherMouseDown:(NSEvent *)event
|
- (void)otherMouseDown:(NSEvent *)event {
|
||||||
{
|
|
||||||
|
|
||||||
if ((int) [event buttonNumber]!=2)
|
if ((int) [event buttonNumber]!=2)
|
||||||
return;
|
return;
|
||||||
|
@ -511,19 +472,19 @@ static int button_mask=0;
|
||||||
ev.mouse_button.mod = translateFlags([event modifierFlags]);
|
ev.mouse_button.mod = translateFlags([event modifierFlags]);
|
||||||
OS_OSX::singleton->push_input(ev);
|
OS_OSX::singleton->push_input(ev);
|
||||||
|
|
||||||
/*_glfwInputMouseClick(window,
|
/*
|
||||||
|
_glfwInputMouseClick(window,
|
||||||
(int) [event buttonNumber],
|
(int) [event buttonNumber],
|
||||||
GLFW_PRESS,
|
GLFW_PRESS,
|
||||||
translateFlags([event modifierFlags]));*/
|
translateFlags([event modifierFlags]));
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)otherMouseDragged:(NSEvent *)event
|
- (void)otherMouseDragged:(NSEvent *)event {
|
||||||
{
|
|
||||||
[self mouseMoved:event];
|
[self mouseMoved:event];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)otherMouseUp:(NSEvent *)event
|
- (void)otherMouseUp:(NSEvent *)event {
|
||||||
{
|
|
||||||
|
|
||||||
if ((int) [event buttonNumber]!=2)
|
if ((int) [event buttonNumber]!=2)
|
||||||
return;
|
return;
|
||||||
|
@ -540,48 +501,52 @@ static int button_mask=0;
|
||||||
ev.mouse_button.button_mask = button_mask;
|
ev.mouse_button.button_mask = button_mask;
|
||||||
ev.mouse_button.mod = translateFlags([event modifierFlags]);
|
ev.mouse_button.mod = translateFlags([event modifierFlags]);
|
||||||
OS_OSX::singleton->push_input(ev);
|
OS_OSX::singleton->push_input(ev);
|
||||||
/* _glfwInputMouseClick(window,
|
|
||||||
|
/*
|
||||||
|
_glfwInputMouseClick(window,
|
||||||
(int) [event buttonNumber],
|
(int) [event buttonNumber],
|
||||||
GLFW_RELEASE,
|
GLFW_RELEASE,
|
||||||
translateFlags([event modifierFlags]));*/
|
translateFlags([event modifierFlags]));
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseExited:(NSEvent *)event
|
- (void)mouseExited:(NSEvent *)event {
|
||||||
{
|
|
||||||
if (!OS_OSX::singleton)
|
if (!OS_OSX::singleton)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (OS_OSX::singleton->main_loop && OS_OSX::singleton->mouse_mode!=OS::MOUSE_MODE_CAPTURED)
|
if (OS_OSX::singleton->main_loop && OS_OSX::singleton->mouse_mode!=OS::MOUSE_MODE_CAPTURED)
|
||||||
OS_OSX::singleton->main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_EXIT);
|
OS_OSX::singleton->main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_EXIT);
|
||||||
|
|
||||||
if (OS_OSX::singleton->input)
|
if (OS_OSX::singleton->input)
|
||||||
OS_OSX::singleton->input->set_mouse_in_window(false);
|
OS_OSX::singleton->input->set_mouse_in_window(false);
|
||||||
|
|
||||||
//_glfwInputCursorEnter(window, GL_FALSE);
|
//_glfwInputCursorEnter(window, GL_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseEntered:(NSEvent *)event
|
- (void)mouseEntered:(NSEvent *)event {
|
||||||
{
|
|
||||||
//_glfwInputCursorEnter(window, GL_TRUE);
|
//_glfwInputCursorEnter(window, GL_TRUE);
|
||||||
if (!OS_OSX::singleton)
|
if (!OS_OSX::singleton)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (OS_OSX::singleton->main_loop && OS_OSX::singleton->mouse_mode!=OS::MOUSE_MODE_CAPTURED)
|
if (OS_OSX::singleton->main_loop && OS_OSX::singleton->mouse_mode!=OS::MOUSE_MODE_CAPTURED)
|
||||||
OS_OSX::singleton->main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_ENTER);
|
OS_OSX::singleton->main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_ENTER);
|
||||||
|
|
||||||
if (OS_OSX::singleton->input)
|
if (OS_OSX::singleton->input)
|
||||||
OS_OSX::singleton->input->set_mouse_in_window(true);
|
OS_OSX::singleton->input->set_mouse_in_window(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)viewDidChangeBackingProperties
|
- (void)viewDidChangeBackingProperties {
|
||||||
{
|
/*
|
||||||
/* const NSRect contentRect = [window->ns.view frame];
|
const NSRect contentRect = [window->ns.view frame];
|
||||||
const NSRect fbRect = convertRectToBacking(window, contentRect);
|
const NSRect fbRect = convertRectToBacking(window, contentRect);
|
||||||
|
|
||||||
_glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);*/
|
_glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateTrackingAreas
|
- (void)updateTrackingAreas {
|
||||||
{
|
if (trackingArea != nil) {
|
||||||
if (trackingArea != nil)
|
|
||||||
{
|
|
||||||
[self removeTrackingArea:trackingArea];
|
[self removeTrackingArea:trackingArea];
|
||||||
[trackingArea release];
|
[trackingArea release];
|
||||||
}
|
}
|
||||||
|
@ -602,11 +567,9 @@ static int button_mask=0;
|
||||||
|
|
||||||
// Translates a OS X keycode to a Godot keycode
|
// Translates a OS X keycode to a Godot keycode
|
||||||
//
|
//
|
||||||
static int translateKey(unsigned int key)
|
static int translateKey(unsigned int key) {
|
||||||
{
|
|
||||||
// Keyboard symbol translation table
|
// Keyboard symbol translation table
|
||||||
static const unsigned int table[128] =
|
static const unsigned int table[128] = {
|
||||||
{
|
|
||||||
/* 00 */ KEY_A,
|
/* 00 */ KEY_A,
|
||||||
/* 01 */ KEY_S,
|
/* 01 */ KEY_S,
|
||||||
/* 02 */ KEY_D,
|
/* 02 */ KEY_D,
|
||||||
|
@ -742,8 +705,8 @@ static int translateKey(unsigned int key)
|
||||||
|
|
||||||
return table[key];
|
return table[key];
|
||||||
}
|
}
|
||||||
- (void)keyDown:(NSEvent *)event
|
|
||||||
{
|
- (void)keyDown:(NSEvent *)event {
|
||||||
InputEvent ev;
|
InputEvent ev;
|
||||||
ev.type = InputEvent::KEY;
|
ev.type = InputEvent::KEY;
|
||||||
ev.key.pressed = true;
|
ev.key.pressed = true;
|
||||||
|
@ -754,23 +717,18 @@ static int translateKey(unsigned int key)
|
||||||
NSString* characters = [event characters];
|
NSString* characters = [event characters];
|
||||||
NSUInteger i, length = [characters length];
|
NSUInteger i, length = [characters length];
|
||||||
|
|
||||||
|
|
||||||
if (length > 0 && keycode_has_unicode(ev.key.scancode)) {
|
if (length > 0 && keycode_has_unicode(ev.key.scancode)) {
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < length; i++) {
|
for (i = 0; i < length; i++) {
|
||||||
ev.key.unicode=[characters characterAtIndex:i];
|
ev.key.unicode=[characters characterAtIndex:i];
|
||||||
OS_OSX::singleton->push_input(ev);
|
OS_OSX::singleton->push_input(ev);
|
||||||
ev.key.scancode=0;
|
ev.key.scancode=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
OS_OSX::singleton->push_input(ev);
|
OS_OSX::singleton->push_input(ev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)flagsChanged:(NSEvent *)event
|
- (void)flagsChanged:(NSEvent *)event {
|
||||||
{
|
|
||||||
InputEvent ev;
|
InputEvent ev;
|
||||||
int key = [event keyCode];
|
int key = [event keyCode];
|
||||||
int mod = [event modifierFlags];
|
int mod = [event modifierFlags];
|
||||||
|
@ -815,8 +773,7 @@ static int translateKey(unsigned int key)
|
||||||
OS_OSX::singleton->push_input(ev);
|
OS_OSX::singleton->push_input(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)keyUp:(NSEvent *)event
|
- (void)keyUp:(NSEvent *)event {
|
||||||
{
|
|
||||||
|
|
||||||
InputEvent ev;
|
InputEvent ev;
|
||||||
ev.type = InputEvent::KEY;
|
ev.type = InputEvent::KEY;
|
||||||
|
@ -825,36 +782,34 @@ static int translateKey(unsigned int key)
|
||||||
ev.key.scancode = latin_keyboard_keycode_convert(translateKey([event keyCode]));
|
ev.key.scancode = latin_keyboard_keycode_convert(translateKey([event keyCode]));
|
||||||
OS_OSX::singleton->push_input(ev);
|
OS_OSX::singleton->push_input(ev);
|
||||||
|
|
||||||
|
/*
|
||||||
/* const int key = translateKey([event keyCode]);
|
const int key = translateKey([event keyCode]);
|
||||||
const int mods = translateFlags([event modifierFlags]);
|
const int mods = translateFlags([event modifierFlags]);
|
||||||
_glfwInputKey(window, key, [event keyCode], GLFW_RELEASE, mods);*/
|
_glfwInputKey(window, key, [event keyCode], GLFW_RELEASE, mods);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)scrollWheel:(NSEvent *)event
|
- (void)scrollWheel:(NSEvent *)event{
|
||||||
{
|
|
||||||
|
|
||||||
double deltaX, deltaY;
|
double deltaX, deltaY;
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||||
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)
|
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
|
||||||
{
|
|
||||||
deltaX = [event scrollingDeltaX];
|
deltaX = [event scrollingDeltaX];
|
||||||
deltaY = [event scrollingDeltaY];
|
deltaY = [event scrollingDeltaY];
|
||||||
|
|
||||||
if ([event hasPreciseScrollingDeltas])
|
if ([event hasPreciseScrollingDeltas]) {
|
||||||
{
|
|
||||||
deltaX *= 0.1;
|
deltaX *= 0.1;
|
||||||
deltaY *= 0.1;
|
deltaY *= 0.1;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
|
||||||
{
|
|
||||||
deltaX = [event deltaX];
|
deltaX = [event deltaX];
|
||||||
deltaY = [event deltaY];
|
deltaY = [event deltaY];
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
deltaX = [event deltaX];
|
||||||
|
deltaY = [event deltaY];
|
||||||
|
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
||||||
|
|
||||||
if (fabs(deltaY)) {
|
if (fabs(deltaY)) {
|
||||||
|
|
||||||
|
@ -873,7 +828,6 @@ static int translateKey(unsigned int key)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fabs(deltaX)) {
|
if (fabs(deltaX)) {
|
||||||
|
|
||||||
InputEvent ev;
|
InputEvent ev;
|
||||||
ev.type=InputEvent::MOUSE_BUTTON;
|
ev.type=InputEvent::MOUSE_BUTTON;
|
||||||
ev.mouse_button.button_index = deltaX < 0 ? BUTTON_WHEEL_RIGHT : BUTTON_WHEEL_LEFT;
|
ev.mouse_button.button_index = deltaX < 0 ? BUTTON_WHEEL_RIGHT : BUTTON_WHEEL_LEFT;
|
||||||
|
@ -896,9 +850,7 @@ static int translateKey(unsigned int key)
|
||||||
|
|
||||||
@implementation GodotWindow
|
@implementation GodotWindow
|
||||||
|
|
||||||
|
- (BOOL)canBecomeKeyWindow {
|
||||||
- (BOOL)canBecomeKeyWindow
|
|
||||||
{
|
|
||||||
// Required for NSBorderlessWindowMask windows
|
// Required for NSBorderlessWindowMask windows
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@ -907,11 +859,10 @@ static int translateKey(unsigned int key)
|
||||||
|
|
||||||
|
|
||||||
int OS_OSX::get_video_driver_count() const {
|
int OS_OSX::get_video_driver_count() const {
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
const char * OS_OSX::get_video_driver_name(int p_driver) const {
|
|
||||||
|
|
||||||
|
const char * OS_OSX::get_video_driver_name(int p_driver) const {
|
||||||
return "GLES2";
|
return "GLES2";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -925,7 +876,6 @@ OS::VideoMode OS_OSX::get_default_video_mode() const {
|
||||||
return vm;
|
return vm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OS_OSX::initialize_core() {
|
void OS_OSX::initialize_core() {
|
||||||
|
|
||||||
OS_Unix::initialize_core();
|
OS_Unix::initialize_core();
|
||||||
|
@ -973,7 +923,6 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
|
||||||
|
|
||||||
unsigned int styleMask = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | (p_desired.resizable?NSResizableWindowMask:0);
|
unsigned int styleMask = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | (p_desired.resizable?NSResizableWindowMask:0);
|
||||||
|
|
||||||
|
|
||||||
window_object = [[GodotWindow alloc]
|
window_object = [[GodotWindow alloc]
|
||||||
initWithContentRect:NSMakeRect(0, 0, p_desired.width/display_scale, p_desired.height/display_scale)
|
initWithContentRect:NSMakeRect(0, 0, p_desired.width/display_scale, p_desired.height/display_scale)
|
||||||
styleMask:styleMask
|
styleMask:styleMask
|
||||||
|
@ -1012,8 +961,6 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
|
||||||
int colorBits = 32;
|
int colorBits = 32;
|
||||||
|
|
||||||
// Fail if a robustness strategy was requested
|
// Fail if a robustness strategy was requested
|
||||||
|
|
||||||
|
|
||||||
#define ADD_ATTR(x) { attributes[attributeCount++] = x; }
|
#define ADD_ATTR(x) { attributes[attributeCount++] = x; }
|
||||||
#define ADD_ATTR2(x, y) { ADD_ATTR(x); ADD_ATTR(y); }
|
#define ADD_ATTR2(x, y) { ADD_ATTR(x); ADD_ATTR(y); }
|
||||||
|
|
||||||
|
@ -1030,21 +977,26 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
|
||||||
|
|
||||||
ADD_ATTR2(NSOpenGLPFAColorSize, colorBits);
|
ADD_ATTR2(NSOpenGLPFAColorSize, colorBits);
|
||||||
|
|
||||||
/* if (fbconfig->alphaBits > 0)
|
/*
|
||||||
ADD_ATTR2(NSOpenGLPFAAlphaSize, fbconfig->alphaBits);*/
|
if (fbconfig->alphaBits > 0)
|
||||||
|
ADD_ATTR2(NSOpenGLPFAAlphaSize, fbconfig->alphaBits);
|
||||||
|
*/
|
||||||
|
|
||||||
ADD_ATTR2(NSOpenGLPFADepthSize, 24);
|
ADD_ATTR2(NSOpenGLPFADepthSize, 24);
|
||||||
|
|
||||||
ADD_ATTR2(NSOpenGLPFAStencilSize, 8);
|
ADD_ATTR2(NSOpenGLPFAStencilSize, 8);
|
||||||
|
|
||||||
/*if (fbconfig->stereo)
|
/*
|
||||||
ADD_ATTR(NSOpenGLPFAStereo);*/
|
if (fbconfig->stereo)
|
||||||
|
ADD_ATTR(NSOpenGLPFAStereo);
|
||||||
|
*/
|
||||||
|
|
||||||
/* if (fbconfig->samples > 0)
|
/*
|
||||||
{
|
if (fbconfig->samples > 0) {
|
||||||
ADD_ATTR2(NSOpenGLPFASampleBuffers, 1);
|
ADD_ATTR2(NSOpenGLPFASampleBuffers, 1);
|
||||||
ADD_ATTR2(NSOpenGLPFASamples, fbconfig->samples);
|
ADD_ATTR2(NSOpenGLPFASamples, fbconfig->samples);
|
||||||
}*/
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// NOTE: All NSOpenGLPixelFormats on the relevant cards support sRGB
|
// NOTE: All NSOpenGLPixelFormats on the relevant cards support sRGB
|
||||||
// frambuffer, so there's no need (and no way) to request it
|
// frambuffer, so there's no need (and no way) to request it
|
||||||
|
@ -1057,13 +1009,10 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
|
||||||
pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
|
pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
|
||||||
ERR_FAIL_COND( pixelFormat == nil);
|
ERR_FAIL_COND( pixelFormat == nil);
|
||||||
|
|
||||||
|
context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil];
|
||||||
context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat
|
|
||||||
shareContext:nil];
|
|
||||||
|
|
||||||
ERR_FAIL_COND(context==nil);
|
ERR_FAIL_COND(context==nil);
|
||||||
|
|
||||||
|
|
||||||
[context setView:window_view];
|
[context setView:window_view];
|
||||||
|
|
||||||
[context makeCurrentContext];
|
[context makeCurrentContext];
|
||||||
|
@ -1081,19 +1030,16 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
|
||||||
|
|
||||||
bool use_gl2=p_video_driver!=1;
|
bool use_gl2=p_video_driver!=1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AudioDriverManagerSW::add_driver(&audio_driver_osx);
|
AudioDriverManagerSW::add_driver(&audio_driver_osx);
|
||||||
|
|
||||||
|
|
||||||
rasterizer = instance_RasterizerGLES2();
|
rasterizer = instance_RasterizerGLES2();
|
||||||
|
|
||||||
visual_server = memnew( VisualServerRaster(rasterizer) );
|
visual_server = memnew( VisualServerRaster(rasterizer) );
|
||||||
|
|
||||||
if (get_render_thread_mode()!=RENDER_THREAD_UNSAFE) {
|
if (get_render_thread_mode()!=RENDER_THREAD_UNSAFE) {
|
||||||
|
|
||||||
visual_server =memnew(VisualServerWrapMT(visual_server,get_render_thread_mode()==RENDER_SEPARATE_THREAD));
|
visual_server =memnew(VisualServerWrapMT(visual_server,get_render_thread_mode()==RENDER_SEPARATE_THREAD));
|
||||||
}
|
}
|
||||||
|
|
||||||
visual_server->init();
|
visual_server->init();
|
||||||
visual_server->cursor_set_visible(false, 0);
|
visual_server->cursor_set_visible(false, 0);
|
||||||
|
|
||||||
|
@ -1116,7 +1062,6 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
|
||||||
spatial_sound_2d_server = memnew( SpatialSound2DServerSW );
|
spatial_sound_2d_server = memnew( SpatialSound2DServerSW );
|
||||||
spatial_sound_2d_server->init();
|
spatial_sound_2d_server->init();
|
||||||
|
|
||||||
//
|
|
||||||
physics_server = memnew( PhysicsServerSW );
|
physics_server = memnew( PhysicsServerSW );
|
||||||
physics_server->init();
|
physics_server->init();
|
||||||
//physics_2d_server = memnew( Physics2DServerSW );
|
//physics_2d_server = memnew( Physics2DServerSW );
|
||||||
|
@ -1157,6 +1102,7 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
|
||||||
};
|
};
|
||||||
restore_rect = Rect2(get_window_position(), get_window_size());
|
restore_rect = Rect2(get_window_position(), get_window_size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void OS_OSX::finalize() {
|
void OS_OSX::finalize() {
|
||||||
|
|
||||||
CFNotificationCenterRemoveObserver(CFNotificationCenterGetDistributedCenter(), NULL, kTISNotifySelectedKeyboardInputSourceChanged, NULL);
|
CFNotificationCenterRemoveObserver(CFNotificationCenterGetDistributedCenter(), NULL, kTISNotifySelectedKeyboardInputSourceChanged, NULL);
|
||||||
|
@ -1186,8 +1132,6 @@ void OS_OSX::finalize() {
|
||||||
memdelete(physics_2d_server);
|
memdelete(physics_2d_server);
|
||||||
|
|
||||||
screens.clear();
|
screens.clear();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OS_OSX::set_main_loop( MainLoop * p_main_loop ) {
|
void OS_OSX::set_main_loop( MainLoop * p_main_loop ) {
|
||||||
|
@ -1201,6 +1145,7 @@ void OS_OSX::delete_main_loop() {
|
||||||
|
|
||||||
if (!main_loop)
|
if (!main_loop)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
memdelete(main_loop);
|
memdelete(main_loop);
|
||||||
main_loop=NULL;
|
main_loop=NULL;
|
||||||
}
|
}
|
||||||
|
@ -1259,9 +1204,11 @@ void OS_OSX::set_cursor_shape(CursorShape p_shape) {
|
||||||
void OS_OSX::set_mouse_show(bool p_show) {
|
void OS_OSX::set_mouse_show(bool p_show) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OS_OSX::set_mouse_grab(bool p_grab) {
|
void OS_OSX::set_mouse_grab(bool p_grab) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OS_OSX::is_mouse_grab_enabled() const {
|
bool OS_OSX::is_mouse_grab_enabled() const {
|
||||||
|
|
||||||
return mouse_grab;
|
return mouse_grab;
|
||||||
|
@ -1273,8 +1220,8 @@ void OS_OSX::warp_mouse_pos(const Point2& p_to) {
|
||||||
if (mouse_mode == MOUSE_MODE_CAPTURED){
|
if (mouse_mode == MOUSE_MODE_CAPTURED){
|
||||||
mouse_x = p_to.x;
|
mouse_x = p_to.x;
|
||||||
mouse_y = p_to.y;
|
mouse_y = p_to.y;
|
||||||
}
|
} else {
|
||||||
else{ //set OS position
|
//set OS position
|
||||||
|
|
||||||
/* this code has not been tested, please be a kind soul and fix it if it fails! */
|
/* this code has not been tested, please be a kind soul and fix it if it fails! */
|
||||||
|
|
||||||
|
@ -1302,9 +1249,11 @@ Point2 OS_OSX::get_mouse_pos() const {
|
||||||
|
|
||||||
return Vector2(mouse_x,mouse_y);
|
return Vector2(mouse_x,mouse_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
int OS_OSX::get_mouse_button_state() const {
|
int OS_OSX::get_mouse_button_state() const {
|
||||||
return button_mask;
|
return button_mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OS_OSX::set_window_title(const String& p_title) {
|
void OS_OSX::set_window_title(const String& p_title) {
|
||||||
|
|
||||||
[window_object setTitle:[NSString stringWithUTF8String:p_title.utf8().get_data()]];
|
[window_object setTitle:[NSString stringWithUTF8String:p_title.utf8().get_data()]];
|
||||||
|
@ -1369,18 +1318,17 @@ void OS_OSX::set_clipboard(const String& p_text) {
|
||||||
[pasteboard setString:[NSString stringWithUTF8String:p_text.utf8().get_data()]
|
[pasteboard setString:[NSString stringWithUTF8String:p_text.utf8().get_data()]
|
||||||
forType:NSStringPboardType];
|
forType:NSStringPboardType];
|
||||||
}
|
}
|
||||||
|
|
||||||
String OS_OSX::get_clipboard() const {
|
String OS_OSX::get_clipboard() const {
|
||||||
|
|
||||||
NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
|
NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
|
||||||
|
|
||||||
if (![[pasteboard types] containsObject:NSStringPboardType])
|
if (![[pasteboard types] containsObject:NSStringPboardType]) {
|
||||||
{
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString* object = [pasteboard stringForType:NSStringPboardType];
|
NSString* object = [pasteboard stringForType:NSStringPboardType];
|
||||||
if (!object)
|
if (!object) {
|
||||||
{
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1397,6 +1345,7 @@ void OS_OSX::release_rendering_thread() {
|
||||||
[NSOpenGLContext clearCurrentContext];
|
[NSOpenGLContext clearCurrentContext];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OS_OSX::make_rendering_thread() {
|
void OS_OSX::make_rendering_thread() {
|
||||||
|
|
||||||
[context makeCurrentContext];
|
[context makeCurrentContext];
|
||||||
|
@ -1437,11 +1386,11 @@ OS::VideoMode OS_OSX::get_video_mode(int p_screen) const {
|
||||||
|
|
||||||
return vm;
|
return vm;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OS_OSX::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) const {
|
void OS_OSX::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) const {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int OS_OSX::get_screen_count() const {
|
int OS_OSX::get_screen_count() const {
|
||||||
|
|
||||||
return screens.size();
|
return screens.size();
|
||||||
|
@ -1509,6 +1458,7 @@ void OS_OSX::set_window_size(const Size2 p_size) {
|
||||||
size.y+= [[NSStatusBar systemStatusBar] thickness];
|
size.y+= [[NSStatusBar systemStatusBar] thickness];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
NSRect frame = [window_object frame];
|
NSRect frame = [window_object frame];
|
||||||
[window_object setFrame:NSMakeRect(frame.origin.x, frame.origin.y, size.x, size.y) display:YES];
|
[window_object setFrame:NSMakeRect(frame.origin.x, frame.origin.y, size.x, size.y) display:YES];
|
||||||
};
|
};
|
||||||
|
@ -1659,6 +1609,7 @@ static NSString *createStringForKeys(const CGKeyCode *keyCode, int length) {
|
||||||
|
|
||||||
return (NSString *)output;
|
return (NSString *)output;
|
||||||
}
|
}
|
||||||
|
|
||||||
OS::LatinKeyboardVariant OS_OSX::get_latin_keyboard_variant() const {
|
OS::LatinKeyboardVariant OS_OSX::get_latin_keyboard_variant() const {
|
||||||
|
|
||||||
static LatinKeyboardVariant layout = LATIN_KEYBOARD_QWERTY;
|
static LatinKeyboardVariant layout = LATIN_KEYBOARD_QWERTY;
|
||||||
|
@ -1708,8 +1659,6 @@ void OS_OSX::process_events() {
|
||||||
autoreleasePool = [[NSAutoreleasePool alloc] init];
|
autoreleasePool = [[NSAutoreleasePool alloc] init];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void OS_OSX::push_input(const InputEvent& p_event) {
|
void OS_OSX::push_input(const InputEvent& p_event) {
|
||||||
|
|
||||||
InputEvent ev=p_event;
|
InputEvent ev=p_event;
|
||||||
|
@ -1793,13 +1742,13 @@ OS_OSX::OS_OSX() {
|
||||||
|
|
||||||
CGEventSourceSetLocalEventsSuppressionInterval(eventSource, 0.0);
|
CGEventSourceSetLocalEventsSuppressionInterval(eventSource, 0.0);
|
||||||
|
|
||||||
|
/*
|
||||||
/*if (pthread_key_create(&_Godot.nsgl.current, NULL) != 0)
|
if (pthread_key_create(&_Godot.nsgl.current, NULL) != 0) {
|
||||||
{
|
|
||||||
_GodotInputError(Godot_PLATFORM_ERROR,
|
_GodotInputError(Godot_PLATFORM_ERROR,
|
||||||
"NSGL: Failed to create context TLS");
|
"NSGL: Failed to create context TLS");
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}*/
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
framework = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
|
framework = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
|
||||||
ERR_FAIL_COND(!framework);
|
ERR_FAIL_COND(!framework);
|
||||||
|
@ -1823,7 +1772,6 @@ OS_OSX::OS_OSX() {
|
||||||
ERR_FAIL_COND(!delegate);
|
ERR_FAIL_COND(!delegate);
|
||||||
[NSApp setDelegate:delegate];
|
[NSApp setDelegate:delegate];
|
||||||
|
|
||||||
|
|
||||||
last_id = 1;
|
last_id = 1;
|
||||||
cursor_shape = CURSOR_ARROW;
|
cursor_shape = CURSOR_ARROW;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue