Formatting of mm files

This commit is contained in:
BastiaanOlij 2017-04-09 21:22:40 +10:00
parent 21727657ff
commit 5c2ddb299b
12 changed files with 1097 additions and 1220 deletions

1
.gitattributes vendored
View file

@ -4,6 +4,7 @@
drivers/* linguist-vendored drivers/* linguist-vendored
*.cpp eol=lf *.cpp eol=lf
*.mm eol=lf
*.h eol=lf *.h eol=lf
*.py eol=lf *.py eol=lf
*.hpp eol=lf *.hpp eol=lf

View file

@ -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;
@ -125,8 +122,7 @@ static int frame_count = 0;
NSString* uuid; NSString* uuid;
if ([[UIDevice currentDevice]respondsToSelector:@selector(identifierForVendor)]) { if ([[UIDevice currentDevice]respondsToSelector:@selector(identifierForVendor)]) {
uuid = [UIDevice currentDevice].identifierForVendor.UUIDString; uuid = [UIDevice currentDevice].identifierForVendor.UUIDString;
}else{ } else {
// before iOS 6, so just generate an identifier and store it // before iOS 6, so just generate an identifier and store it
uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"identiferForVendor"]; uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"identiferForVendor"];
if( !uuid ) { if( !uuid ) {
@ -143,7 +139,7 @@ static int frame_count = 0;
/* /*
case 1: { case 1: {
++frame_count; ++frame_count;
} break; }; break;
*/ */
case 1: { case 1: {
@ -174,11 +170,11 @@ static int frame_count = 0;
// do stuff // do stuff
} }
} break; }; break;
/* /*
case 3: { case 3: {
++frame_count; ++frame_count;
} break; }; break;
*/ */
case 2: { case 2: {
@ -243,7 +239,7 @@ static int frame_count = 0;
bool quit_request = OSIPhone::get_singleton()->iterate(); bool quit_request = OSIPhone::get_singleton()->iterate();
}; };
}; }; break;
}; };
}; };
@ -313,12 +309,10 @@ static int frame_count = 0;
#ifdef MODULE_GAME_ANALYTICS_ENABLED #ifdef MODULE_GAME_ANALYTICS_ENABLED
printf("********************* didFinishLaunchingWithOptions\n"); printf("********************* didFinishLaunchingWithOptions\n");
if(!GlobalConfig::get_singleton()->has("mobileapptracker/advertiser_id")) if (!GlobalConfig::get_singleton()->has("mobileapptracker/advertiser_id")) {
{
return; return;
} }
if(!GlobalConfig::get_singleton()->has("mobileapptracker/conversion_key")) if (!GlobalConfig::get_singleton()->has("mobileapptracker/conversion_key")) {
{
return; return;
} }
@ -329,8 +323,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.
@ -356,35 +349,32 @@ 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");
@ -392,6 +382,7 @@ 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();
@ -450,8 +441,7 @@ static int frame_count = 0;
#endif #endif
} }
- (void)dealloc - (void)dealloc {
{
[window release]; [window release];
[super dealloc]; [super dealloc];
} }

View file

@ -49,18 +49,18 @@ extern "C" {
GameCenter* GameCenter::instance = NULL; GameCenter* GameCenter::instance = NULL;
void GameCenter::_bind_methods() { void GameCenter::_bind_methods() {
ClassDB::bind_method(D_METHOD("connect"),&GameCenter::connect); ClassDB::bind_method(D_METHOD("connect"), &GameCenter::connect);
ClassDB::bind_method(D_METHOD("is_connected"),&GameCenter::is_connected); ClassDB::bind_method(D_METHOD("is_connected"), &GameCenter::is_connected);
ClassDB::bind_method(D_METHOD("post_score"),&GameCenter::post_score); ClassDB::bind_method(D_METHOD("post_score"), &GameCenter::post_score);
ClassDB::bind_method(D_METHOD("award_achievement"),&GameCenter::award_achievement); ClassDB::bind_method(D_METHOD("award_achievement"), &GameCenter::award_achievement);
ClassDB::bind_method(D_METHOD("reset_achievements"),&GameCenter::reset_achievements); ClassDB::bind_method(D_METHOD("reset_achievements"), &GameCenter::reset_achievements);
ClassDB::bind_method(D_METHOD("request_achievements"),&GameCenter::request_achievements); ClassDB::bind_method(D_METHOD("request_achievements"), &GameCenter::request_achievements);
ClassDB::bind_method(D_METHOD("request_achievement_descriptions"),&GameCenter::request_achievement_descriptions); ClassDB::bind_method(D_METHOD("request_achievement_descriptions"), &GameCenter::request_achievement_descriptions);
ClassDB::bind_method(D_METHOD("show_game_center"),&GameCenter::show_game_center); ClassDB::bind_method(D_METHOD("show_game_center"), &GameCenter::show_game_center);
ClassDB::bind_method(D_METHOD("get_pending_event_count"),&GameCenter::get_pending_event_count); ClassDB::bind_method(D_METHOD("get_pending_event_count"), &GameCenter::get_pending_event_count);
ClassDB::bind_method(D_METHOD("pop_pending_event"),&GameCenter::pop_pending_event); ClassDB::bind_method(D_METHOD("pop_pending_event"), &GameCenter::pop_pending_event);
}; };
@ -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;
@ -191,7 +189,7 @@ void GameCenter::request_achievement_descriptions() {
Array hidden; Array hidden;
Array replayable; Array replayable;
for (int i=0; i<[descriptions count]; i++) { for (int i = 0; i < [descriptions count]; i++) {
GKAchievementDescription* description = [descriptions objectAtIndex:i]; GKAchievementDescription* description = [descriptions objectAtIndex:i];
@ -266,8 +264,7 @@ void GameCenter::request_achievements() {
void GameCenter::reset_achievements() { void GameCenter::reset_achievements() {
[GKAchievement resetAchievementsWithCompletionHandler:^(NSError *error) [GKAchievement resetAchievementsWithCompletionHandler:^(NSError *error) {
{
Dictionary ret; Dictionary ret;
ret["type"] = "reset_achievements"; ret["type"] = "reset_achievements";
if (error == nil) { if (error == nil) {
@ -292,17 +289,13 @@ Error GameCenter::show_game_center(Variant p_params) {
String view_name = params["view"]; String view_name = params["view"];
if (view_name == "default") { if (view_name == "default") {
view_state = GKGameCenterViewControllerStateDefault; view_state = GKGameCenterViewControllerStateDefault;
} } else if (view_name == "leaderboards") {
else if (view_name == "leaderboards") {
view_state = GKGameCenterViewControllerStateLeaderboards; view_state = GKGameCenterViewControllerStateLeaderboards;
} } else if (view_name == "achievements") {
else if (view_name == "achievements") {
view_state = GKGameCenterViewControllerStateAchievements; view_state = GKGameCenterViewControllerStateAchievements;
} } else if (view_name == "challenges") {
else if (view_name == "challenges") {
view_state = GKGameCenterViewControllerStateChallenges; view_state = GKGameCenterViewControllerStateChallenges;
} } else {
else {
return ERR_INVALID_PARAMETER; return ERR_INVALID_PARAMETER;
} }
} }

View file

@ -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,14 +242,12 @@ 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]))
{ {
@ -262,8 +256,7 @@ static void clear_touches() {
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 +270,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:kEAGLRenderingAPIOpenGLES3]; context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
if(!context || ![EAGLContext setCurrentContext:context] || ![self createFramebuffer]) if(!context || ![EAGLContext setCurrentContext:context] || ![self createFramebuffer]) {
{
[self release]; [self release];
return nil; return nil;
} }
@ -288,14 +280,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 +296,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 +306,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 +333,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,8 +353,7 @@ 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);
@ -380,8 +366,7 @@ static void clear_touches() {
} }
} }
- (void)startAnimation - (void)startAnimation {
{
if (active) if (active)
return; return;
active = TRUE; active = TRUE;
@ -397,19 +382,16 @@ 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;
@ -418,22 +400,19 @@ static void clear_touches() {
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++) {
@ -524,8 +499,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++) {
@ -582,8 +556,7 @@ static void clear_touches() {
printf("inserting text with character %i\n", character[0]); printf("inserting text with character %i\n", character[0]);
}; };
- (void)audioRouteChangeListenerCallback:(NSNotification*)notification - (void)audioRouteChangeListenerCallback:(NSNotification*)notification {
{
printf("*********** route changed!\n"); printf("*********** route changed!\n");
NSDictionary *interuptionDict = notification.userInfo; NSDictionary *interuptionDict = notification.userInfo;
@ -591,12 +564,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,19 +579,18 @@ 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);
@ -641,21 +613,19 @@ static void clear_touches() {
return self; return self;
} }
// -(BOOL)automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers { //- (BOOL)automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers {
// return YES; // return YES;
// } //}
// - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{ //- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
// return YES; // return YES;
// } //}
// 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];
} }
@ -665,8 +635,7 @@ static void clear_touches() {
[super dealloc]; [super dealloc];
} }
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
change:(NSDictionary *)change context:(void *)context {
if (object == _instance.avPlayerItem && [keyPath isEqualToString:@"status"]) { if (object == _instance.avPlayerItem && [keyPath isEqualToString:@"status"]) {
if (_instance.avPlayerItem.status == AVPlayerStatusFailed || _instance.avPlayer.status == AVPlayerStatusFailed) { if (_instance.avPlayerItem.status == AVPlayerStatusFailed || _instance.avPlayer.status == AVPlayerStatusFailed) {

View file

@ -45,14 +45,14 @@ extern "C" {
ICloud* ICloud::instance = NULL; ICloud* ICloud::instance = NULL;
void ICloud::_bind_methods() { void ICloud::_bind_methods() {
ClassDB::bind_method(D_METHOD("remove_key"),&ICloud::remove_key); ClassDB::bind_method(D_METHOD("remove_key"), &ICloud::remove_key);
ClassDB::bind_method(D_METHOD("set_key_values"),&ICloud::set_key_values); ClassDB::bind_method(D_METHOD("set_key_values"), &ICloud::set_key_values);
ClassDB::bind_method(D_METHOD("get_key_value"),&ICloud::get_key_value); ClassDB::bind_method(D_METHOD("get_key_value"), &ICloud::get_key_value);
ClassDB::bind_method(D_METHOD("synchronize_key_values"),&ICloud::synchronize_key_values); ClassDB::bind_method(D_METHOD("synchronize_key_values"), &ICloud::synchronize_key_values);
ClassDB::bind_method(D_METHOD("get_all_key_values"),&ICloud::get_all_key_values); ClassDB::bind_method(D_METHOD("get_all_key_values"), &ICloud::get_all_key_values);
ClassDB::bind_method(D_METHOD("get_pending_event_count"),&ICloud::get_pending_event_count); ClassDB::bind_method(D_METHOD("get_pending_event_count"), &ICloud::get_pending_event_count);
ClassDB::bind_method(D_METHOD("pop_pending_event"),&ICloud::pop_pending_event); ClassDB::bind_method(D_METHOD("pop_pending_event"), &ICloud::pop_pending_event);
}; };
int ICloud::get_pending_event_count() { int ICloud::get_pending_event_count() {
@ -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]]) {
PoolByteArray ret; PoolByteArray 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::POOL_BYTE_ARRAY) {
else if (v.get_type() == Variant::POOL_BYTE_ARRAY) {
PoolByteArray arr = v; PoolByteArray arr = v;
PoolByteArray::Read r = arr.read(); PoolByteArray::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";
} }

View file

@ -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]);
@ -205,13 +203,12 @@ Error InAppStore::request_product_info(Variant p_params) {
receipt = transaction.transactionReceipt; receipt = transaction.transactionReceipt;
} }
}else{ } else {
receipt = transaction.transactionReceipt; receipt = transaction.transactionReceipt;
} }
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,16 +220,15 @@ 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];
} }
#ifdef MODULE_FUSEBOXX_ENABLED #ifdef MODULE_FUSEBOXX_ENABLED
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]);
@ -249,11 +245,9 @@ Error InAppStore::request_product_info(Variant p_params) {
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;
}; };
}; };
}; };

View file

@ -33,7 +33,7 @@
void iOS::_bind_methods() { void iOS::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_rate_url","app_id"),&iOS::get_rate_url); ClassDB::bind_method(D_METHOD("get_rate_url","app_id"), &iOS::get_rate_url);
}; };
String iOS::get_rate_url(int p_app_id) const { String iOS::get_rate_url(int p_app_id) const {
@ -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;
} }

View file

@ -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;

View file

@ -33,10 +33,10 @@
extern "C" { extern "C" {
int add_path(int, char**); int add_path(int, char**);
int add_cmdline(int, char**); int add_cmdline(int, char**);
int add_path(int p_argc, char** p_args) { int add_path(int p_argc, char** p_args) {
NSString* str = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_path"]; NSString* str = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_path"];
if (!str) if (!str)
@ -48,9 +48,9 @@ int add_path(int p_argc, char** p_args) {
p_args[p_argc] = NULL; p_args[p_argc] = NULL;
return p_argc; return p_argc;
}; };
int add_cmdline(int p_argc, char** p_args) { int add_cmdline(int p_argc, char** p_args) {
NSArray* arr = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_cmdline"]; NSArray* arr = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_cmdline"];
if (!arr) if (!arr)
@ -68,7 +68,7 @@ int add_cmdline(int p_argc, char** p_args) {
p_args[p_argc] = NULL; p_args[p_argc] = NULL;
return p_argc; return p_argc;
}; };
}; };
@ -128,8 +128,7 @@ int add_cmdline(int p_argc, char** p_args) {
} }
}; };
- (BOOL)prefersStatusBarHidden - (BOOL)prefersStatusBarHidden {
{
return YES; return YES;
} }

View file

@ -47,7 +47,7 @@ int main(int argc, char** argv) {
}; };
if (argc>=1 && argv[0][0]=='/') { if (argc >= 1 && argv[0][0] == '/') {
//potentially launched from finder //potentially launched from finder
int len = strlen(argv[0]); int len = strlen(argv[0]);
while (len--) { while (len--) {
@ -76,19 +76,18 @@ int main(int argc, char** argv) {
free(pathinfo); free(pathinfo);
} }
} }
OS_OSX os; OS_OSX os;
Error err = Main::setup(argv[0],argc-first_arg,&argv[first_arg]); Error err = Main::setup(argv[0], argc-first_arg,&argv[first_arg]);
if (err!=OK) if (err!=OK)
return 255; return 255;
if (Main::start()) if (Main::start())
os.run(); // it is actually the OS that decides how to run os.run(); // it is actually the OS that decides how to run
Main::cleanup(); Main::cleanup();
return 0; return 0;

View file

@ -42,8 +42,7 @@ static int global_argc;
static char **global_argv; static char **global_argv;
static BOOL gCalledAppMainline = FALSE; static BOOL gCalledAppMainline = FALSE;
static NSString *getApplicationName(void) static NSString *getApplicationName(void) {
{
const NSDictionary *dict; const NSDictionary *dict;
NSString *appName = 0; NSString *appName = 0;
@ -61,8 +60,7 @@ static NSString *getApplicationName(void)
/* The main class of the application, the application's delegate */ /* The main class of the application, the application's delegate */
@implementation GodotMain @implementation GodotMain
static void setApplicationMenu(void) static void setApplicationMenu(void) {
{
/* warning: this code is very odd */ /* warning: this code is very odd */
NSMenu *appleMenu; NSMenu *appleMenu;
NSMenuItem *menuItem; NSMenuItem *menuItem;
@ -106,8 +104,7 @@ static void setApplicationMenu(void)
} }
/* Create a window menu */ /* Create a window menu */
static void setupWindowMenu(void) static void setupWindowMenu(void) {
{
NSMenu *windowMenu; NSMenu *windowMenu;
NSMenuItem *windowMenuItem; NSMenuItem *windowMenuItem;
NSMenuItem *menuItem; NSMenuItem *menuItem;
@ -133,8 +130,7 @@ static void setupWindowMenu(void)
} }
/* Replacement for NSApplicationMain */ /* Replacement for NSApplicationMain */
static void CustomApplicationMain (int argc, char **argv) static void CustomApplicationMain (int argc, char **argv) {
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
GodotMain *main; GodotMain *main;
@ -159,8 +155,7 @@ static void CustomApplicationMain (int argc, char **argv)
extern int godot_main(int argc, char** argv); extern int godot_main(int argc, char** argv);
/* Called when the internal event loop has just started running */ /* Called when the internal event loop has just started running */
- (void) applicationDidFinishLaunching: (NSNotification *) note - (void) applicationDidFinishLaunching: (NSNotification *) note {
{
int status; int status;
/* Hand off to main application code */ /* Hand off to main application code */
@ -177,8 +172,7 @@ extern int godot_main(int argc, char** argv);
#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 */
/* This is passed if we are launched by double-clicking */ /* This is passed if we are launched by double-clicking */
if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) { if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {

File diff suppressed because it is too large Load diff