From fdaa2920eb21fff3320a17e9239e04dfadecdb00 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 18 Apr 2015 14:38:54 -0300 Subject: Updated copyright year in all headers --- platform/iphone/Appirater.h | 2 +- platform/iphone/app_delegate.h | 2 +- platform/iphone/app_delegate.mm | 2 +- platform/iphone/audio_driver_iphone.cpp | 2 +- platform/iphone/audio_driver_iphone.h | 2 +- platform/iphone/game_center.h | 2 +- platform/iphone/game_center.mm | 2 +- platform/iphone/gl_view.h | 2 +- platform/iphone/gl_view.mm | 2 +- platform/iphone/godot_iphone.cpp | 2 +- platform/iphone/in_app_store.h | 2 +- platform/iphone/in_app_store.mm | 2 +- platform/iphone/os_iphone.cpp | 2 +- platform/iphone/os_iphone.h | 2 +- platform/iphone/platform_config.h | 2 +- platform/iphone/rasterizer_iphone.cpp | 2 +- platform/iphone/rasterizer_iphone.h | 2 +- platform/iphone/view_controller.h | 2 +- platform/iphone/view_controller.mm | 2 +- 19 files changed, 19 insertions(+), 19 deletions(-) (limited to 'platform/iphone') diff --git a/platform/iphone/Appirater.h b/platform/iphone/Appirater.h index d11b2f7793..f0bf2c01d5 100644 --- a/platform/iphone/Appirater.h +++ b/platform/iphone/Appirater.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/iphone/app_delegate.h b/platform/iphone/app_delegate.h index 9437e04738..0d20f886cc 100644 --- a/platform/iphone/app_delegate.h +++ b/platform/iphone/app_delegate.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm index fe11b672ac..2c7a0a0790 100644 --- a/platform/iphone/app_delegate.mm +++ b/platform/iphone/app_delegate.mm @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/iphone/audio_driver_iphone.cpp b/platform/iphone/audio_driver_iphone.cpp index c3ba0e6944..a95cb436a7 100644 --- a/platform/iphone/audio_driver_iphone.cpp +++ b/platform/iphone/audio_driver_iphone.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/iphone/audio_driver_iphone.h b/platform/iphone/audio_driver_iphone.h index 05fa741282..5d406940a3 100644 --- a/platform/iphone/audio_driver_iphone.h +++ b/platform/iphone/audio_driver_iphone.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/iphone/game_center.h b/platform/iphone/game_center.h index df1d980c04..1f4820a3c2 100644 --- a/platform/iphone/game_center.h +++ b/platform/iphone/game_center.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/iphone/game_center.mm b/platform/iphone/game_center.mm index d517ddd105..fd1e5f3be7 100644 --- a/platform/iphone/game_center.mm +++ b/platform/iphone/game_center.mm @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/iphone/gl_view.h b/platform/iphone/gl_view.h index 04334991fd..c58c863510 100755 --- a/platform/iphone/gl_view.h +++ b/platform/iphone/gl_view.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm index 3d6c48ffaf..55185aa49d 100755 --- a/platform/iphone/gl_view.mm +++ b/platform/iphone/gl_view.mm @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/iphone/godot_iphone.cpp b/platform/iphone/godot_iphone.cpp index b86af007f8..b7b9b747b4 100644 --- a/platform/iphone/godot_iphone.cpp +++ b/platform/iphone/godot_iphone.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/iphone/in_app_store.h b/platform/iphone/in_app_store.h index 656d126ead..585cd19538 100644 --- a/platform/iphone/in_app_store.h +++ b/platform/iphone/in_app_store.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/iphone/in_app_store.mm b/platform/iphone/in_app_store.mm index f3640c3076..1d40b1762e 100644 --- a/platform/iphone/in_app_store.mm +++ b/platform/iphone/in_app_store.mm @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp index 06b48318ec..bf85ecc9dd 100644 --- a/platform/iphone/os_iphone.cpp +++ b/platform/iphone/os_iphone.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h index 2585a26479..721db36f41 100644 --- a/platform/iphone/os_iphone.h +++ b/platform/iphone/os_iphone.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/iphone/platform_config.h b/platform/iphone/platform_config.h index 3d6300d8e0..3cc74099c0 100644 --- a/platform/iphone/platform_config.h +++ b/platform/iphone/platform_config.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/iphone/rasterizer_iphone.cpp b/platform/iphone/rasterizer_iphone.cpp index 4674a5143c..d2a0777af8 100644 --- a/platform/iphone/rasterizer_iphone.cpp +++ b/platform/iphone/rasterizer_iphone.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/iphone/rasterizer_iphone.h b/platform/iphone/rasterizer_iphone.h index 41dbbdaa5a..2a630e597a 100644 --- a/platform/iphone/rasterizer_iphone.h +++ b/platform/iphone/rasterizer_iphone.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/iphone/view_controller.h b/platform/iphone/view_controller.h index 7c4a107bb8..9432aebd97 100644 --- a/platform/iphone/view_controller.h +++ b/platform/iphone/view_controller.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/platform/iphone/view_controller.mm b/platform/iphone/view_controller.mm index eb331a61de..a5ca689e61 100644 --- a/platform/iphone/view_controller.mm +++ b/platform/iphone/view_controller.mm @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ -- cgit v1.2.3 From 93e797f1649cfbdd5748956feb245ee27c75c996 Mon Sep 17 00:00:00 2001 From: romulox_x Date: Sat, 23 May 2015 03:17:52 -0700 Subject: Fixed null pointer bug in ios store. added functions to game center to reset the user's achievements, request all the achievements they've made progress on, request descriptions of all possible achievements, and show the built in game center overlay. Upgraded all (I think) deprecated functions to ios 6 versions. as per discussion with reduz on IRC, ios 6 is now the official lowest supported iOS version. compatibility could be added, but it's so obsolete, it's tough to argue for continuing to support it. some naming of functions and dictionary parameters might need to change. I just named them whatever made sense to me :) --- platform/iphone/game_center.h | 4 + platform/iphone/game_center.mm | 214 ++++++++++++++++++++++++++++++++++--- platform/iphone/in_app_store.mm | 2 +- platform/iphone/view_controller.h | 3 +- platform/iphone/view_controller.mm | 6 +- 5 files changed, 209 insertions(+), 20 deletions(-) (limited to 'platform/iphone') diff --git a/platform/iphone/game_center.h b/platform/iphone/game_center.h index 1f4820a3c2..4fe13db8fc 100644 --- a/platform/iphone/game_center.h +++ b/platform/iphone/game_center.h @@ -51,6 +51,10 @@ public: Error post_score(Variant p_score); Error award_achievement(Variant p_params); + void reset_achievements(); + void request_achievements(); + void request_achievement_descriptions(); + Error show_game_center(Variant p_params); int get_pending_event_count(); Variant pop_pending_event(); diff --git a/platform/iphone/game_center.mm b/platform/iphone/game_center.mm index fd1e5f3be7..a058536685 100644 --- a/platform/iphone/game_center.mm +++ b/platform/iphone/game_center.mm @@ -32,6 +32,7 @@ extern "C" { #import +#import "app_delegate.h" }; GameCenter* GameCenter::instance = NULL; @@ -42,6 +43,10 @@ void GameCenter::_bind_methods() { ObjectTypeDB::bind_method(_MD("post_score"),&GameCenter::post_score); ObjectTypeDB::bind_method(_MD("award_achievement"),&GameCenter::award_achievement); + ObjectTypeDB::bind_method(_MD("reset_achievements"),&GameCenter::reset_achievements); + ObjectTypeDB::bind_method(_MD("request_achievements"),&GameCenter::request_achievements); + ObjectTypeDB::bind_method(_MD("request_achievement_descriptions"),&GameCenter::request_achievement_descriptions); + ObjectTypeDB::bind_method(_MD("show_game_center"),&GameCenter::show_game_center); ObjectTypeDB::bind_method(_MD("get_pending_event_count"),&GameCenter::get_pending_event_count); ObjectTypeDB::bind_method(_MD("pop_pending_event"),&GameCenter::pop_pending_event); @@ -50,23 +55,41 @@ void GameCenter::_bind_methods() { Error GameCenter::connect() { - GKLocalPlayer* player = [GKLocalPlayer localPlayer]; - [player authenticateWithCompletionHandler:^(NSError* error) { + //if this class isn't available, game center isn't implemented + if ((NSClassFromString(@"GKLocalPlayer")) == nil) { + GameCenter::get_singleton()->connected = false; + return ERR_UNAVAILABLE; + } - Dictionary ret; - ret["type"] = "authentication"; - if (player.isAuthenticated) { - ret["result"] = "ok"; - GameCenter::get_singleton()->connected = true; - } else { - ret["result"] = "error"; - ret["error_code"] = error.code; - ret["error_description"] = [error.localizedDescription UTF8String]; - GameCenter::get_singleton()->connected = false; - }; + GKLocalPlayer* player = [GKLocalPlayer localPlayer]; + ERR_FAIL_COND_V(![player respondsToSelector:@selector(authenticateHandler)], ERR_UNAVAILABLE); + + ViewController *root_controller=(ViewController *)((AppDelegate *)[[UIApplication sharedApplication] delegate]).window.rootViewController; + ERR_FAIL_COND_V(!root_controller, FAILED); + + //this handler is called serveral times. first when the view needs to be shown, then again after the view is cancelled or the user logs in. or if the user's already logged in, it's called just once to confirm they're authenticated. This is why no result needs to be specified in the presentViewController phase. in this case, more calls to this function will follow. + player.authenticateHandler = (^(UIViewController *controller, NSError *error) { + if (controller) { + [root_controller presentViewController:controller animated:YES completion:nil]; + } + else { + Dictionary ret; + ret["type"] = "authentication"; + if (player.isAuthenticated) { + ret["result"] = "ok"; + GameCenter::get_singleton()->connected = true; + } else { + ret["result"] = "error"; + ret["error_code"] = error.code; + ret["error_description"] = [error.localizedDescription UTF8String]; + GameCenter::get_singleton()->connected = false; + }; + + pending_events.push_back(ret); + }; + + }); - pending_events.push_back(ret); - }]; return OK; }; @@ -85,7 +108,9 @@ Error GameCenter::post_score(Variant p_score) { GKScore* reporter = [[[GKScore alloc] initWithCategory:cat_str] autorelease]; reporter.value = score; - [reporter reportScoreWithCompletionHandler:^(NSError* error) { + ERR_FAIL_COND_V([GKScore respondsToSelector:@selector(reportScores)], ERR_UNAVAILABLE); + + [GKScore reportScores:@[reporter] withCompletionHandler:^(NSError* error) { Dictionary ret; ret["type"] = "post_score"; @@ -114,8 +139,15 @@ Error GameCenter::award_achievement(Variant p_params) { GKAchievement* achievement = [[[GKAchievement alloc] initWithIdentifier: name_str] autorelease]; ERR_FAIL_COND_V(!achievement, FAILED); + ERR_FAIL_COND_V([GKAchievement respondsToSelector:@selector(reportAchievements)], ERR_UNAVAILABLE); + achievement.percentComplete = progress; - [achievement reportAchievementWithCompletionHandler:^(NSError* error) { + achievement.showsCompletionBanner = NO; + if (params.has("show_completion_banner")) { + achievement.showsCompletionBanner = params["show_completion_banner"] ? YES : NO; + } + + [GKAchievement reportAchievements:@[achievement] withCompletionHandler:^(NSError *error) { Dictionary ret; ret["type"] = "award_achievement"; @@ -132,6 +164,154 @@ Error GameCenter::award_achievement(Variant p_params) { return OK; }; +void GameCenter::request_achievement_descriptions() { + + [GKAchievementDescription loadAchievementDescriptionsWithCompletionHandler:^(NSArray *descriptions, NSError *error) { + + Dictionary ret; + ret["type"] = "achievement_descriptions"; + if (error == nil) { + ret["result"] = "ok"; + StringArray names; + StringArray titles; + StringArray unachieved_descriptions; + StringArray achieved_descriptions; + IntArray maximum_points; + IntArray hidden; + IntArray replayable; + + for (int i=0; i<[descriptions count]; i++) { + + GKAchievementDescription* description = [descriptions objectAtIndex:i]; + + const char* str = [description.identifier UTF8String]; + names.push_back(String::utf8(str != NULL ? str : "")); + + str = [description.title UTF8String]; + titles.push_back(String::utf8(str != NULL ? str : "")); + + str = [description.unachievedDescription UTF8String]; + unachieved_descriptions.push_back(String::utf8(str != NULL ? str : "")); + + str = [description.achievedDescription UTF8String]; + achieved_descriptions.push_back(String::utf8(str != NULL ? str : "")); + + maximum_points.push_back(description.maximumPoints); + + hidden.push_back(description.hidden == YES ? 1 : 0); + + replayable.push_back(description.replayable == YES ? 1 : 0); + } + + ret["names"] = names; + + } else { + ret["result"] = "error"; + ret["error_code"] = error.code; + }; + + pending_events.push_back(ret); + }]; +}; + + +void GameCenter::request_achievements() { + + [GKAchievement loadAchievementsWithCompletionHandler:^(NSArray *achievements, NSError *error) { + + Dictionary ret; + ret["type"] = "achievements"; + if (error == nil) { + ret["result"] = "ok"; + StringArray names; + RealArray percentages; + + for (int i=0; i<[achievements count]; i++) { + + GKAchievement* achievement = [achievements objectAtIndex:i]; + const char* str = [achievement.identifier UTF8String]; + names.push_back(String::utf8(str != NULL ? str : "")); + + percentages.push_back(achievement.percentComplete); + } + + ret["names"] = names; + ret["progresses"] = percentages; + + } else { + ret["result"] = "error"; + ret["error_code"] = error.code; + }; + + pending_events.push_back(ret); + }]; +}; + +void GameCenter::reset_achievements() { + + [GKAchievement resetAchievementsWithCompletionHandler:^(NSError *error) + { + Dictionary ret; + ret["type"] = "reset_achievements"; + if (error == nil) { + ret["result"] = "ok"; + } else { + ret["result"] = "error"; + ret["error_code"] = error.code; + }; + + pending_events.push_back(ret); + }]; +}; + +Error GameCenter::show_game_center(Variant p_params) { + + ERR_FAIL_COND_V(!NSProtocolFromString(@"GKGameCenterControllerDelegate"), FAILED); + + Dictionary params = p_params; + + GKGameCenterViewControllerState view_state = GKGameCenterViewControllerStateDefault; + if (params.has("view")) { + String view_name = params["view"]; + if (view_name == "default") { + view_state = GKGameCenterViewControllerStateDefault; + } + else if (view_name == "leaderboards") { + view_state = GKGameCenterViewControllerStateLeaderboards; + } + else if (view_name == "achievements") { + view_state = GKGameCenterViewControllerStateAchievements; + } + else if (view_name == "challenges") { + view_state = GKGameCenterViewControllerStateChallenges; + } + else { + return ERR_INVALID_PARAMETER; + } + } + + GKGameCenterViewController *controller = [[GKGameCenterViewController alloc] init]; + ERR_FAIL_COND_V(!controller, FAILED); + + ViewController *root_controller=(ViewController *)((AppDelegate *)[[UIApplication sharedApplication] delegate]).window.rootViewController; + ERR_FAIL_COND_V(!root_controller, FAILED); + + controller.gameCenterDelegate = root_controller; + controller.viewState = view_state; + if (view_state == GKGameCenterViewControllerStateLeaderboards) { + controller.leaderboardIdentifier = nil; + if (params.has("leaderboard_name")) { + String name = params["leaderboard_name"]; + NSString* name_str = [[[NSString alloc] initWithUTF8String:name.utf8().get_data()] autorelease]; + controller.leaderboardIdentifier = name_str; + } + } + + [root_controller presentViewController: controller animated: YES completion:nil]; + + return OK; +}; + int GameCenter::get_pending_event_count() { return pending_events.size(); diff --git a/platform/iphone/in_app_store.mm b/platform/iphone/in_app_store.mm index 1d40b1762e..e3ba6bbd73 100644 --- a/platform/iphone/in_app_store.mm +++ b/platform/iphone/in_app_store.mm @@ -210,7 +210,7 @@ Error InAppStore::request_product_info(Variant p_params) { receipt_to_send = [receipt description]; } Dictionary receipt_ret; - receipt_ret["receipt"] = String::utf8([receipt_to_send UTF8String]); + receipt_ret["receipt"] = String::utf8(receipt_to_send != nil ? [receipt_to_send UTF8String] : ""); receipt_ret["sdk"] = sdk_version; ret["receipt"] = receipt_ret; diff --git a/platform/iphone/view_controller.h b/platform/iphone/view_controller.h index 9432aebd97..0cee2f6fbf 100644 --- a/platform/iphone/view_controller.h +++ b/platform/iphone/view_controller.h @@ -27,8 +27,9 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #import +#import -@interface ViewController : UIViewController { +@interface ViewController : UIViewController { }; diff --git a/platform/iphone/view_controller.mm b/platform/iphone/view_controller.mm index a5ca689e61..f04264cfd9 100644 --- a/platform/iphone/view_controller.mm +++ b/platform/iphone/view_controller.mm @@ -124,10 +124,14 @@ int add_cmdline(int p_argc, char** p_args) { } }; - - (BOOL)prefersStatusBarHidden { return YES; } +- (void) gameCenterViewControllerDidFinish:(GKGameCenterViewController*) gameCenterViewController { + printf("in finish"); + [gameCenterViewController dismissViewControllerAnimated:YES completion:nil]; +} + @end -- cgit v1.2.3 From 94638e7bfeec8feac553ecd80cd7e4efff04f2a5 Mon Sep 17 00:00:00 2001 From: romulox_x Date: Sat, 23 May 2015 19:04:02 -0700 Subject: added data to descriptions dictionary that was missing. Made the elements that sound weird as plurals consistently singular. changed int arrays to bool arrays in descriptions --- platform/iphone/game_center.mm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'platform/iphone') diff --git a/platform/iphone/game_center.mm b/platform/iphone/game_center.mm index a058536685..9b4018a4ba 100644 --- a/platform/iphone/game_center.mm +++ b/platform/iphone/game_center.mm @@ -177,8 +177,8 @@ void GameCenter::request_achievement_descriptions() { StringArray unachieved_descriptions; StringArray achieved_descriptions; IntArray maximum_points; - IntArray hidden; - IntArray replayable; + Array hidden; + Array replayable; for (int i=0; i<[descriptions count]; i++) { @@ -198,12 +198,18 @@ void GameCenter::request_achievement_descriptions() { maximum_points.push_back(description.maximumPoints); - hidden.push_back(description.hidden == YES ? 1 : 0); + hidden.push_back(description.hidden == YES); - replayable.push_back(description.replayable == YES ? 1 : 0); + replayable.push_back(description.replayable == YES); } ret["names"] = names; + ret["titles"] = titles; + ret["unachieved_descriptions"] = unachieved_descriptions; + ret["achieved_descriptions"] = achieved_descriptions; + ret["maximum_points"] = maximum_points; + ret["hidden"] = hidden; + ret["replayable"] = replayable; } else { ret["result"] = "error"; @@ -236,7 +242,7 @@ void GameCenter::request_achievements() { } ret["names"] = names; - ret["progresses"] = percentages; + ret["progress"] = percentages; } else { ret["result"] = "error"; -- cgit v1.2.3 From 95cd9b1ad54f799d9513911e4cebc5bafc135d97 Mon Sep 17 00:00:00 2001 From: romulox_x Date: Sat, 23 May 2015 23:22:20 -0700 Subject: added response event for game center overlay closing --- platform/iphone/game_center.h | 2 ++ platform/iphone/game_center.mm | 10 +++++++++- platform/iphone/view_controller.mm | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) (limited to 'platform/iphone') diff --git a/platform/iphone/game_center.h b/platform/iphone/game_center.h index 4fe13db8fc..8f180d1638 100644 --- a/platform/iphone/game_center.h +++ b/platform/iphone/game_center.h @@ -56,6 +56,8 @@ public: void request_achievement_descriptions(); Error show_game_center(Variant p_params); + void game_center_closed(); + int get_pending_event_count(); Variant pop_pending_event(); diff --git a/platform/iphone/game_center.mm b/platform/iphone/game_center.mm index 9b4018a4ba..79c056776d 100644 --- a/platform/iphone/game_center.mm +++ b/platform/iphone/game_center.mm @@ -314,10 +314,18 @@ Error GameCenter::show_game_center(Variant p_params) { } [root_controller presentViewController: controller animated: YES completion:nil]; - + return OK; }; +void GameCenter::game_center_closed() { + + Dictionary ret; + ret["type"] = "show_game_center"; + ret["result"] = "ok"; + pending_events.push_back(ret); +} + int GameCenter::get_pending_event_count() { return pending_events.size(); diff --git a/platform/iphone/view_controller.mm b/platform/iphone/view_controller.mm index f04264cfd9..bc9950979e 100644 --- a/platform/iphone/view_controller.mm +++ b/platform/iphone/view_controller.mm @@ -130,7 +130,8 @@ int add_cmdline(int p_argc, char** p_args) { } - (void) gameCenterViewControllerDidFinish:(GKGameCenterViewController*) gameCenterViewController { - printf("in finish"); + //[gameCenterViewController dismissViewControllerAnimated:YES completion:^{GameCenter::get_singleton()->game_center_closed();}];//version for signaling when overlay is completely gone + GameCenter::get_singleton()->game_center_closed(); [gameCenterViewController dismissViewControllerAnimated:YES completion:nil]; } -- cgit v1.2.3 From 9df77d276593ef7082e3971d1c180b8f74b0cb2e Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 26 May 2015 01:05:08 -0300 Subject: ability to run 2D physics in a thread also, 2D physics is now thread safe too. see physics_2d/thread_model --- platform/iphone/os_iphone.cpp | 3 ++- platform/iphone/os_iphone.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'platform/iphone') diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp index bf85ecc9dd..ade1c292a4 100644 --- a/platform/iphone/os_iphone.cpp +++ b/platform/iphone/os_iphone.cpp @@ -136,7 +136,8 @@ void OSIPhone::initialize(const VideoMode& p_desired,int p_video_driver,int p_au // physics_server = memnew( PhysicsServerSW ); physics_server->init(); - physics_2d_server = memnew( Physics2DServerSW ); + //physics_2d_server = memnew( Physics2DServerSW ); + physics_2d_server = Physics2DServerWrapMT::init_server(); physics_2d_server->init(); input = memnew( InputDefault ); diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h index 721db36f41..844f067552 100644 --- a/platform/iphone/os_iphone.h +++ b/platform/iphone/os_iphone.h @@ -38,6 +38,7 @@ #include "servers/visual/rasterizer.h" #include "servers/physics/physics_server_sw.h" #include "servers/physics_2d/physics_2d_server_sw.h" +#include "servers/physics_2d/physics_2d_server_wrap_mt.h" #include "servers/audio/audio_server_sw.h" #include "servers/audio/sample_manager_sw.h" #include "servers/spatial_sound/spatial_sound_server_sw.h" -- cgit v1.2.3 From ef173a2c9cd95e5a72419427c3cb7818b7bf9088 Mon Sep 17 00:00:00 2001 From: romulox_x Date: Wed, 3 Jun 2015 21:57:33 -0700 Subject: improved calculation of screen resolution on ios --- platform/iphone/gl_view.mm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'platform/iphone') diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm index 55185aa49d..3309fd0820 100755 --- a/platform/iphone/gl_view.mm +++ b/platform/iphone/gl_view.mm @@ -352,8 +352,9 @@ static void clear_touches() { // Generate IDs for a framebuffer object and a color renderbuffer UIScreen* mainscr = [UIScreen mainScreen]; printf("******** screen size %i, %i\n", (int)mainscr.currentMode.size.width, (int)mainscr.currentMode.size.height); - if (mainscr.currentMode.size.width == 640 || mainscr.currentMode.size.width == 960) // modern iphone, can go to 640x960 - self.contentScaleFactor = 2.0; + float minPointSize = MIN(mainscr.bounds.size.width, mainscr.bounds.size.height); + float minScreenSize = MIN(mainscr.currentMode.size.width, mainscr.currentMode.size.height); + self.contentScaleFactor = minScreenSize / minPointSize; glGenFramebuffersOES(1, &viewFramebuffer); glGenRenderbuffersOES(1, &viewRenderbuffer); -- cgit v1.2.3 From 55b34e05b3d735a84e1af9833e19c0b816c18252 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 30 Jun 2015 11:28:43 -0300 Subject: -some changes by okam --- platform/iphone/app_delegate.mm | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'platform/iphone') diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm index 2c7a0a0790..dba37ab1b8 100644 --- a/platform/iphone/app_delegate.mm +++ b/platform/iphone/app_delegate.mm @@ -138,6 +138,29 @@ static int frame_count = 0; Main::setup2(); ++frame_count; + // this might be necessary before here + for (NSString* key in [[NSBundle mainBundle] infoDictionary]) { + NSObject* value = [xyz objectForKey:key]; + String ukey = String::utf8([key UTF8String]); + + // we need a NSObject to Variant conversor + + if ([value isKindOfClass:[NSString class]]) { + NSString* str = (NSString*)value; + String uval = String::utf8([str UTF8String]); + + Globals::get_singleton()->set("Info.plist/"+ukey, uval); + + } else if ([value isKindOfClass:[NSNumber class]]) { + + NSNumber* n = (NSNumber*)value; + double dval = [n doubleValue]; + + Globals::get_singleton()->set("Info.plist/"+ukey, dval); + }; + // do stuff + } + } break; /* case 3: { -- cgit v1.2.3 From 1d22b0265bff3a7c3e5fe1d0e062f9fe27fc53af Mon Sep 17 00:00:00 2001 From: romulox_x Date: Wed, 1 Jul 2015 23:07:01 -0700 Subject: fixed ios compilation error --- platform/iphone/app_delegate.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'platform/iphone') diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm index dba37ab1b8..3c79137171 100644 --- a/platform/iphone/app_delegate.mm +++ b/platform/iphone/app_delegate.mm @@ -140,7 +140,7 @@ static int frame_count = 0; // this might be necessary before here for (NSString* key in [[NSBundle mainBundle] infoDictionary]) { - NSObject* value = [xyz objectForKey:key]; + NSObject* value = [[[NSBundle mainBundle] infoDictionary] objectForKey:key]; String ukey = String::utf8([key UTF8String]); // we need a NSObject to Variant conversor -- cgit v1.2.3