Преглед на файлове

Adding Game Center support for IOS and OSX

Dale Ducharme преди 12 години
родител
ревизия
b9fa8e77e7

+ 1 - 3
gameplay/.cproject

@@ -24,7 +24,6 @@
 								<option id="com.qnx.qcc.option.compiler.defines.1481323494" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
 									<listOptionValue builtIn="false" value="BT_USE_NEON"/>
-									<listOptionValue builtIn="false" value="GP_USE_SOCIAL"/>
 									<listOptionValue builtIn="false" value="GP_USE_GAMEPAD"/>
 								</option>
 								<option id="com.qnx.qcc.option.compiler.includePath.2133604142" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
@@ -89,7 +88,6 @@
 								<option id="com.qnx.qcc.option.compiler.defines.398688299" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
 									<listOptionValue builtIn="false" value="BT_USE_NEON"/>
-									<listOptionValue builtIn="false" value="GP_USE_SOCIAL"/>
 									<listOptionValue builtIn="false" value="GP_USE_GAMEPAD"/>
 								</option>
 								<option id="com.qnx.qcc.option.compiler.includePath.1670164593" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
@@ -149,7 +147,7 @@
 								<option id="com.qnx.qcc.option.compiler.security.1671403331" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.compiler.defines.1863269886" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
-									<listOptionValue builtIn="false" value="GP_USE_SOCIAL"/>
+									<listOptionValue builtIn="false" value="BT_USE_NEON"/>
 									<listOptionValue builtIn="false" value="GP_USE_GAMEPAD"/>
 								</option>
 								<option id="com.qnx.qcc.option.compiler.includePath.847642559" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">

+ 18 - 0
gameplay/gameplay.xcodeproj/project.pbxproj

@@ -621,6 +621,12 @@
 		5B2BC7601512514500D176CD /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5B2BC75E1512514500D176CD /* OpenGL.framework */; };
 		5B2BC7621512514D00D176CD /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5B2BC7611512514D00D176CD /* QuartzCore.framework */; };
 		5B2BC7641512516B00D176CD /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5B2BC7631512516B00D176CD /* libz.dylib */; };
+		6290E04518223C4A00A28FB9 /* GameCenterSocialSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 6290E04318223C4A00A28FB9 /* GameCenterSocialSession.h */; };
+		6290E04618223C4A00A28FB9 /* GameCenterSocialSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 6290E04318223C4A00A28FB9 /* GameCenterSocialSession.h */; };
+		6290E04718223C4A00A28FB9 /* GameCenterSocialSession.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6290E04418223C4A00A28FB9 /* GameCenterSocialSession.mm */; };
+		6290E04818223C4A00A28FB9 /* GameCenterSocialSession.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6290E04418223C4A00A28FB9 /* GameCenterSocialSession.mm */; };
+		6290E04A18223DCC00A28FB9 /* GameKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6290E04918223DCC00A28FB9 /* GameKit.framework */; };
+		6290E04C18223DDD00A28FB9 /* GameKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6290E04B18223DDD00A28FB9 /* GameKit.framework */; };
 		BD2636E516CF5B7400CFE15F /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BD2636DF16CF5B7400CFE15F /* CoreMotion.framework */; };
 		BD2636E616CF5B7400CFE15F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BD2636E016CF5B7400CFE15F /* Foundation.framework */; };
 		BD2636E716CF5B7400CFE15F /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BD2636E116CF5B7400CFE15F /* OpenAL.framework */; };
@@ -1281,6 +1287,10 @@
 		5B5DB93114C25BA5007755DB /* libogg.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libogg.a; path = "../external-deps/oggvorbis/lib/ios/armv7s/libogg.a"; sourceTree = "<group>"; };
 		5B5DB93214C25BA5007755DB /* libvorbis.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libvorbis.a; path = "../external-deps/oggvorbis/lib/ios/armv7s/libvorbis.a"; sourceTree = "<group>"; };
 		5BC4E7D4150F8C3C00CBE1C0 /* res */ = {isa = PBXFileReference; lastKnownFileType = folder; path = res; sourceTree = "<group>"; };
+		6290E04318223C4A00A28FB9 /* GameCenterSocialSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameCenterSocialSession.h; sourceTree = "<group>"; };
+		6290E04418223C4A00A28FB9 /* GameCenterSocialSession.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GameCenterSocialSession.mm; sourceTree = "<group>"; };
+		6290E04918223DCC00A28FB9 /* GameKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/GameKit.framework; sourceTree = DEVELOPER_DIR; };
+		6290E04B18223DDD00A28FB9 /* GameKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameKit.framework; path = System/Library/Frameworks/GameKit.framework; sourceTree = SDKROOT; };
 		BD2636DF16CF5B7400CFE15F /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/CoreMotion.framework; sourceTree = DEVELOPER_DIR; };
 		BD2636E016CF5B7400CFE15F /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
 		BD2636E116CF5B7400CFE15F /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/OpenAL.framework; sourceTree = DEVELOPER_DIR; };
@@ -1294,6 +1304,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				6290E04C18223DDD00A28FB9 /* GameKit.framework in Frameworks */,
 				5B21E99616153890006EBEAC /* IOKit.framework in Frameworks */,
 				5B2BC7641512516B00D176CD /* libz.dylib in Frameworks */,
 				5B2BC7621512514D00D176CD /* QuartzCore.framework in Frameworks */,
@@ -1307,6 +1318,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				6290E04A18223DCC00A28FB9 /* GameKit.framework in Frameworks */,
 				BD2636E516CF5B7400CFE15F /* CoreMotion.framework in Frameworks */,
 				BD2636E616CF5B7400CFE15F /* Foundation.framework in Frameworks */,
 				BD2636E716CF5B7400CFE15F /* OpenAL.framework in Frameworks */,
@@ -1996,6 +2008,8 @@
 		42CC55331809A4EE00AAD8AD /* social */ = {
 			isa = PBXGroup;
 			children = (
+				6290E04318223C4A00A28FB9 /* GameCenterSocialSession.h */,
+				6290E04418223C4A00A28FB9 /* GameCenterSocialSession.mm */,
 				42CC55341809A4EE00AAD8AD /* GooglePlaySocialSession.cpp */,
 				42CC55351809A4EE00AAD8AD /* GooglePlaySocialSession.h */,
 				42CC55361809A4EE00AAD8AD /* ScoreloopSocialSession.cpp */,
@@ -2017,6 +2031,7 @@
 		5B04C5FD14BFE52300EB0071 /* iOS */ = {
 			isa = PBXGroup;
 			children = (
+				6290E04918223DCC00A28FB9 /* GameKit.framework */,
 				BD2636DF16CF5B7400CFE15F /* CoreMotion.framework */,
 				BD2636E016CF5B7400CFE15F /* Foundation.framework */,
 				BD2636E116CF5B7400CFE15F /* OpenAL.framework */,
@@ -2030,6 +2045,7 @@
 		5B04C5FE14BFE52F00EB0071 /* MacOSX */ = {
 			isa = PBXGroup;
 			children = (
+				6290E04B18223DDD00A28FB9 /* GameKit.framework */,
 				5B21E99516153890006EBEAC /* IOKit.framework */,
 				5B2BC7611512514D00D176CD /* QuartzCore.framework */,
 				5B2BC75D1512514500D176CD /* OpenAL.framework */,
@@ -2240,6 +2256,7 @@
 				42CC562C1809A4EF00AAD8AD /* Logger.cpp in Sources */,
 				420BBD761817416F00C7B720 /* lua_MouseMouseEvent.cpp in Sources */,
 				420BBE3E1817416F00C7B720 /* lua_RenderTarget.cpp in Sources */,
+				6290E04718223C4A00A28FB9 /* GameCenterSocialSession.mm in Sources */,
 				42CC56281809A4EF00AAD8AD /* Light.cpp in Sources */,
 				420BBD8E1817416F00C7B720 /* lua_Pass.cpp in Sources */,
 				42CC59041809A4EF00AAD8AD /* MaterialParameter.cpp in Sources */,
@@ -2551,6 +2568,7 @@
 				42CC59D31809A4EF00AAD8AD /* SocialPlayer.cpp in Sources */,
 				420BBD771817416F00C7B720 /* lua_MouseMouseEvent.cpp in Sources */,
 				420BBE3F1817416F00C7B720 /* lua_RenderTarget.cpp in Sources */,
+				6290E04818223C4A00A28FB9 /* GameCenterSocialSession.mm in Sources */,
 				42CC562D1809A4EF00AAD8AD /* Logger.cpp in Sources */,
 				42CC56291809A4EF00AAD8AD /* Light.cpp in Sources */,
 				420BBD8F1817416F00C7B720 /* lua_Pass.cpp in Sources */,

+ 5 - 0
gameplay/src/Base.h

@@ -304,6 +304,11 @@ typedef GLuint RenderBufferHandle;
     typedef unsigned long SocialAchievementHandle;
     typedef unsigned long SocialScoreHandle;
     typedef unsigned long SocialChallengeHandle;
+#elif defined(__APPLE__)
+    typedef void* SocialPlayerHandle;
+    typedef void* SocialAchievementHandle;
+    typedef void* SocialScoreHandle;
+    typedef void* SocialChallengeHandle;
 #else
     typedef unsigned int SocialPlayerHandle;
     typedef unsigned int SocialAchievementHandle;

+ 1 - 1
gameplay/src/Game.cpp

@@ -197,7 +197,7 @@ void Game::shutdown()
         _aiController->finalize();
         SAFE_DELETE(_aiController);
 
-        _socialController->initialize();
+        _socialController->finalize();
         SAFE_DELETE(_socialController);
 
         // Note: we do not clean up the script controller here

+ 5 - 3
gameplay/src/PlatformBlackBerry.cpp

@@ -601,7 +601,7 @@ void Platform::pollGamepadState(Gamepad* gamepad)
             screen_get_device_property_iv(gamepad->_handle, SCREEN_PROPERTY_ANALOG1, analog);
             break;
         }
-        
+
         // So far we've tested two gamepads with analog sticks on BlackBerry:
         // the SteelSeries FREE, and the iControlPad.
         // Both return values between -128 and +127, with the y axis starting from
@@ -1009,7 +1009,7 @@ Platform* Platform::create(Game* game)
     screenDevs = (screen_device_t*)calloc(count, sizeof(screen_device_t));
     screen_get_context_property_pv(__screenContext, SCREEN_PROPERTY_DEVICES, (void**)screenDevs);
 
-	for (int i = 0; i < count; i++) 
+	for (int i = 0; i < count; i++)
     {
 	    int type;
         screen_get_device_property_iv(screenDevs[i], SCREEN_PROPERTY_TYPE, &type);
@@ -1086,7 +1086,7 @@ int Platform::enterMessagePump()
     while (true)
     {
         bps_event_t* event = NULL;
-        
+
         while (true)
         {
             rc = bps_get_event(&event, 1);
@@ -1095,9 +1095,11 @@ int Platform::enterMessagePump()
             if (event == NULL)
                 break;
 
+#ifdef GP_USE_SOCIAL
             // if the social controller needs to deal with the event do that here
             if (Game::getInstance()->getSocialController()->handleEvent(event))
             	break;
+#endif
 
             domain = bps_event_get_domain(event);
 

+ 10 - 1
gameplay/src/PlatformMacOSX.mm

@@ -13,6 +13,7 @@
 #import <OpenGL/OpenGL.h>
 #import <mach/mach_time.h>
 #import <Foundation/Foundation.h>
+#import <GameKit/GameKit.h>
 
 // These should probably be moved to a platform common file
 #define SONY_USB_VENDOR_ID              0x054c
@@ -1553,8 +1554,10 @@ int getUnicode(int key)
 @end
 
 @interface FullscreenWindow : NSWindow
-{ 
+{
 }
+
+- (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController;
 @end
 
 @implementation FullscreenWindow
@@ -1562,6 +1565,12 @@ int getUnicode(int key)
 {
     return YES;
 }
+
+- (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController
+{
+    GKDialogController *sdc = [GKDialogController sharedDialogController];
+    [sdc dismiss: self];
+}
 @end
 
 

+ 6 - 0
gameplay/src/PlatformiOS.mm

@@ -8,6 +8,7 @@
 #include "ScriptController.h"
 #include <unistd.h>
 #import <UIKit/UIKit.h>
+#import <GameKit/GameKit.h>
 #import <QuartzCore/QuartzCore.h>
 #import <CoreMotion/CoreMotion.h>
 #import <OpenGLES/EAGL.h>
@@ -749,6 +750,7 @@ int getUnicode(int key);
 @interface ViewController : UIViewController
 - (void)startUpdating;
 - (void)stopUpdating;
+- (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController;
 @end
 
 
@@ -821,6 +823,10 @@ int getUnicode(int key);
     [(View*)self.view stopUpdating];
 }
 
+- (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController
+{
+    [self dismissViewControllerAnimated:YES completion:nil];
+}
 @end
 
 

+ 18 - 0
gameplay/src/SocialController.cpp

@@ -3,6 +3,7 @@
 #include "Game.h"
 #include "social/ScoreloopSocialSession.h"
 #include "social/GooglePlaySocialSession.h"
+#include "social/GameCenterSocialSession.h"
 
 namespace gameplay
 {
@@ -85,6 +86,23 @@ void SocialController::authenticate(SocialSessionListener* listener)
     {
         listener->authenticateEvent(SocialSessionListener::ERROR_INITIALIZATION, NULL);
     }
+#elif defined(__APPLE__)
+    Properties* socialProperties = Game::getInstance()->getConfig()->getNamespace("social", true);
+    const char* providerStr = "";
+
+    if (socialProperties)
+    {
+    	providerStr = socialProperties->getString("provider");
+    }
+
+    if (strcmp(providerStr, "GameCenter") == 0)
+    {
+        _session = GameCenterSocialSession::authenticate(listener, socialProperties);
+    }
+    else
+    {
+        listener->authenticateEvent(SocialSessionListener::ERROR_INITIALIZATION, NULL);
+    }
 #endif
 #endif
 }

+ 1 - 1
gameplay/src/SocialController.h

@@ -18,7 +18,7 @@ namespace gameplay
   @verbatim
     social
     {
-         provider = Scoreloop | GooglePlay
+         provider = Scoreloop | GooglePlay | GameCenter
          id  = d346c484-12aa-49a2-a0a0-de2f87492d72
          secret = aAa+DehBfyGO/CYaE3nWomgu7SIbWFczUih+Qwf3/n7u0y3nyq5Hag==
          version = 1.0

+ 18 - 6
gameplay/src/SocialSession.h

@@ -50,7 +50,7 @@ public:
 
     virtual void submitAchievement(const char* achievementId, unsigned int value, bool achieved=false) = 0;
 
-    virtual void incrementAchievement(const char* achievementId, unsigned int increment=1) = 0;
+    virtual void incrementAchievement(const char* achievementId, unsigned int totalSteps=1) = 0;
 
     virtual void synchronizeAchievements() = 0;
 
@@ -74,7 +74,9 @@ public:
 
     virtual void submitScore(const char* leaderboardId, float value) = 0;
 
-    virtual void submitChallenge(const SocialPlayer *player, unsigned int wager, float score, const char* leaderboardId=0) = 0;
+    virtual void submitChallenge(const SocialPlayer *player, float score, const char* leaderboardId=0, unsigned int wager=0) = 0;
+
+    virtual void submitAchievementChallenge(const SocialPlayer *player, const char* achievementId=0, unsigned int wager=0) = 0;
 
     virtual void loadChallenges(bool showOpenChallengesOnly=true) = 0;
 
@@ -84,16 +86,26 @@ public:
 
     virtual void submitSavedData(const char* key, std::string data) = 0;
 
-    virtual void displayLeaderboard(const char* leaderboardId) = 0;
+    virtual void displayLeaderboard(const char* leaderboardId) const = 0;
+
+    virtual void displayAchievements() const = 0;
 
-    virtual void displayAchievements() = 0;
+    virtual void displayChallenges() const = 0;
 
-    virtual void displayChallenges() = 0;
+    virtual void displayChallengeSubmit(const SocialChallenge *challenge, float score) const = 0;
 
-    virtual void displayChallengeSubmit(const SocialChallenge *challenge, float score) = 0;
+    virtual void displayPopup(const char *string, const char *title=0) const = 0;
 
     virtual bool handleEvent(void *event) { return true; }
 
+    virtual bool supportsChallenges() const = 0;
+
+    virtual bool supportsAchievementChallenges() const = 0;
+
+    virtual bool supportsMultiplayer() const = 0;
+
+    virtual bool supportsTurns() const = 0;
+
 protected:
 
     /**

+ 64 - 51
gameplay/src/social/GooglePlaySocialSession.cpp

@@ -5,11 +5,11 @@
 #include <android_native_app_glue.h>
 #include <android/log.h>
 
-extern struct android_app* __state;
-
 namespace gameplay
 {
 
+// Externally referenced global variable.
+struct android_app* __state;
 
 GooglePlaySocialSession* GooglePlaySocialSession::_session = NULL;
 
@@ -34,6 +34,7 @@ SocialSessionListener* GooglePlaySocialSession::getListener()
 
 SocialSession *GooglePlaySocialSession::authenticate(SocialSessionListener* listener, Properties* properties)
 {
+#if 0
     if (!_session)
     {
 		_session = new GooglePlaySocialSession();
@@ -71,6 +72,7 @@ SocialSession *GooglePlaySocialSession::authenticate(SocialSessionListener* list
 
 		jvm->DetachCurrentThread();
     }
+#endif
 
     return _session;
 }
@@ -80,101 +82,112 @@ const SocialPlayer& GooglePlaySocialSession::getUser() const
 	return _user;
 }
 
-/**
- * @see SocialSession::loadFriends
- */
 void GooglePlaySocialSession::loadFriends()
 {
 }
 
-/**
- * @see SocialSession::loadAchievements
- */
+void GooglePlaySocialSession::loadAchievementData()
+{
+
+}
+
 void GooglePlaySocialSession::loadAchievements()
 {
+
+}
+
+const SocialAchievement* GooglePlaySocialSession::getAchievement(const char* achievementId) const
+{
+    uint size = _achievements.size();
+
+    for (uint i = 0; i < size; i++)
+    {
+        if (strcmp(_achievements[i].name.data(), achievementId) == 0)
+            return &_achievements[i];
+    }
+    return 0;
 }
 
-/**
- * @see SocialSession::submitAchievement
- */
 void GooglePlaySocialSession::submitAchievement(const char* achievementId, unsigned int value, bool achieved)
 {
+
 }
 
-/**
- * @see SocialSession::incrementAchievement
- */
-void GooglePlaySocialSession::incrementAchievement(const char* achievementId, unsigned int increment)
+void GooglePlaySocialSession::incrementAchievement(const char* achievementId, unsigned int totalSteps)
 {
+
 }
 
-/**
-  * @see SocialSession::synchronizeAchievements
-  */
 void GooglePlaySocialSession::synchronizeAchievements()
 {
 }
 
-/**
- * @see SocialSession::loadScores
- */
-void GooglePlaySocialSession::loadScores(const char* leaderboardId, SocialSession::CommunityScope community, SocialSession::TimeScope time, const SocialPlayer& player, unsigned int count)
+void GooglePlaySocialSession::loadScores(const char* leaderboardId, SocialSession::CommunityScope community, SocialSession::TimeScope time, unsigned int start, unsigned int count)
 {
+
 }
 
-/**
- * @see SocialSession::loadScores
- */
-void GooglePlaySocialSession::loadScores(const char* leaderboardId, SocialSession::CommunityScope community, SocialSession::TimeScope time, unsigned int start, unsigned int count)
+void GooglePlaySocialSession::loadScores(const char* leaderboardId, SocialSession::CommunityScope community, SocialSession::TimeScope time, const SocialPlayer& player, unsigned int count)
 {
+
 }
 
-/**
- * @see SocialSession::submitScore
- */
 void GooglePlaySocialSession::submitScore(const char* leaderboardId, float score)
 {
+
+}
+
+void GooglePlaySocialSession::submitChallenge(const SocialPlayer *player, float score, const char* leaderboardId, unsigned int wager)
+{
+    SocialChallenge challenge;
+    _listener->submitChallengeEvent(SocialSessionListener::ERROR_NOT_SUPPORTED, challenge);
 }
 
-/**
-  * @see SocialSession::submitChallenge
-  */
-void GooglePlaySocialSession::submitChallenge(const SocialPlayer *player, unsigned int wager, float score, const char* leaderboardId)
+void GooglePlaySocialSession::submitAchievementChallenge(const SocialPlayer *player, const char* achievementId, unsigned int wager)
 {
+    SocialChallenge challenge;
+    _listener->submitChallengeEvent(SocialSessionListener::ERROR_NOT_SUPPORTED, challenge);
 }
 
-/**
-  * @see SocialSession::loadChallenges
-  */
 void GooglePlaySocialSession::loadChallenges(bool showOpenChallengesOnly)
 {
+	_listener->loadChallengesEvent(SocialSessionListener::ERROR_NOT_SUPPORTED, _challenges);
 }
 
-/**
-  * @see SocialSession::acceptChallenge
-  */
+
 void GooglePlaySocialSession::replyToChallenge(const SocialChallenge *challenge, bool accept)
 {
 }
 
-/**
- * @see SocialSession::requestSavedData
- */
-void GooglePlaySocialSession::loadSavedData(const char* key) {}
+void GooglePlaySocialSession::loadSavedData(const char* key)
+{
+}
 
-/**
- * @see SocialSession::submitSavedData
- */
-void GooglePlaySocialSession::submitSavedData(const char* key, std::string data) {}
+void GooglePlaySocialSession::submitSavedData(const char* key, std::string data)
+{
 
-void GooglePlaySocialSession::displayLeaderboard(const char* leaderboardId) {}
+}
 
-void GooglePlaySocialSession::displayAchievements() {}
+void GooglePlaySocialSession::displayLeaderboard(const char* leaderboardId) const
+{
+}
 
-void GooglePlaySocialSession::displayChallenges() {}
+void GooglePlaySocialSession::displayAchievements() const
+{
+}
+
+void GooglePlaySocialSession::displayChallenges() const
+{
+}
 
-void GooglePlaySocialSession::displayChallengeSubmit(const SocialChallenge *challenge, float score) {}
+void GooglePlaySocialSession::displayChallengeSubmit(const SocialChallenge *challenge, float score) const
+{
+}
 
+void GooglePlaySocialSession::displayPopup(const char *popupMessage, const char *title) const
+{
+
+}
 
 }
 

+ 109 - 76
gameplay/src/social/GooglePlaySocialSession.h

@@ -29,6 +29,12 @@ namespace gameplay
              medium = 1
              hard = 2
          }
+
+         achievement_mappings
+         {
+             // Format: myAchievementKey =  DestinationAchievementID
+             gameplay.spaceship.winchallenge = destination.spaceship.winchallengeid
+         }
     }
  *
  * Note: Ensure your bar-descriptor.xml has:
@@ -44,95 +50,137 @@ class GooglePlaySocialSession : public SocialSession
 public:
 
     /**
-     * @see SocialSession::getListener
-     */
-    SocialSessionListener* getListener();
+      * @see SocialSession::getListener
+      */
+     SocialSessionListener* getListener();
 
-    /**
-     * Initializes the session with the local client definition for this game.
-     *
-     * @param listener The listener for responses for this session
-     * @param properties The properties to initialize this session with for this game.
-     */
-    static SocialSession *authenticate(SocialSessionListener* listener, Properties* properties);
+     /**
+      * Initializes the session with the local client definition for this game.
+      *
+      * @param listener The listener for responses for this session
+      * @param properties The properties to initialize this session with for this game.
+      */
+     static SocialSession *authenticate(SocialSessionListener* listener, Properties* properties);
 
-    /**
-     * @see SocialSession::getUser
-     */
-    const SocialPlayer& getUser() const;
+     /**
+      * @see SocialSession::getUser
+      */
+     const SocialPlayer& getUser() const;
 
-    /**
-     * @see SocialSession::loadFriends
-     */
-    void loadFriends();
+     /**
+      * @see SocialSession::loadFriends
+      */
+     void loadFriends();
 
-    /**
-     * @see SocialSession::loadAchievements
-     */
-    void loadAchievements();
+     /**
+      * @see SocialSession::loadAchievements
+      */
+     void loadAchievements();
 
-    /**
-     * @see SocialSession::submitAchievement
-     */
-    void submitAchievement(const char* achievementId, unsigned int value, bool achieved=false);
+     /**
+      * @see SocialSession::submitAchievement
+      */
+     void submitAchievement(const char* achievementId, unsigned int value, bool achieved=false);
 
-    /**
-     * @see SocialSession::incrementAchievement
-     */
-    void incrementAchievement(const char* achievementId, unsigned int increment=1);
+     /**
+      * @see SocialSession::incrementAchievement
+      */
+     void incrementAchievement(const char* achievementId, unsigned int totalSteps=1);
 
-    /**
+     /**
       * @see SocialSession::syncAchievements
       */
-    void synchronizeAchievements();
+     void synchronizeAchievements();
 
-    /**
-     * @see SocialSession::loadScores
-     */
-    void loadScores(const char* leaderboardId, CommunityScope community, TimeScope time, const SocialPlayer& player, unsigned int count);
+     /**
+      * @see SocialSession::loadScores
+      */
+     void loadScores(const char* leaderboardId, CommunityScope community, TimeScope time, const SocialPlayer& player, unsigned int count);
 
-    /**
-     * @see SocialSession::loadScores
-     */
-    void loadScores(const char* leaderboardId, CommunityScope community, TimeScope time, unsigned int start, unsigned int count);
+     /**
+      * @see SocialSession::loadScores
+      */
+     void loadScores(const char* leaderboardId, CommunityScope community, TimeScope time, unsigned int start, unsigned int count);
 
-    /**
-     * @see SocialSession::submitScore
-     */
-    void submitScore(const char* leaderboardId, float score);
+     /**
+      * @see SocialSession::submitScore
+      */
+     void submitScore(const char* leaderboardId, float score);
 
-    /**
+     /**
       * @see SocialSession::submitChallenge
       */
-    void submitChallenge(const SocialPlayer *player, unsigned int wager, float score, const char* leaderboardId=0);
+     void submitChallenge(const SocialPlayer *player, float score, const char* leaderboardId, unsigned int wager=0);
 
-    /**
+     /**
+      * @see SocialSession::submitAchievementChallenge
+      */
+     void submitAchievementChallenge(const SocialPlayer *player, const char* achievementId, unsigned int wager=0);
+
+     /**
       * @see SocialSession::loadChallenges
       */
-    void loadChallenges(bool showOpenChallengesOnly=true);
+     void loadChallenges(bool showOpenChallengesOnly=true);
 
-    /**
+     /**
       * @see SocialSession::acceptChallenge
       */
-    void replyToChallenge(const SocialChallenge *challenge, bool accept);
+     void replyToChallenge(const SocialChallenge *challenge, bool accept);
 
     /**
      * @see SocialSession::requestSavedData
      */
     void loadSavedData(const char* key);
-
+    
     /**
      * @see SocialSession::submitSavedData
      */
     void submitSavedData(const char* key, std::string data);
-
-    void displayLeaderboard(const char* leaderboardId);
-
-    void displayAchievements();
-
-    void displayChallenges();
-
-    void displayChallengeSubmit(const SocialChallenge *challenge, float score);
+    
+    /**
+     * @see SocialSession::displayLeaderboard
+     */
+    void displayLeaderboard(const char* leaderboardId) const;
+    
+    /**
+     * @see SocialSession::displayAchievements
+     */
+    void displayAchievements() const;
+    
+    /**
+     * @see SocialSession::displayChallenges
+     */
+    void displayChallenges() const;
+    
+    /**
+     * @see SocialSession::displayChallengeSubmit
+     */
+    void displayChallengeSubmit(const SocialChallenge *challenge, float score) const;
+    
+    /**
+     * @see SocialSession::displayPopup
+     */
+    void displayPopup(const char *string, const char *title) const;
+    
+    /**
+     * @see SocialSession::supportsChallenges
+     */
+    bool supportsChallenges() const { return true; }
+    
+    /**
+     * @see SocialSession::supportsAchievementChallenges
+     */
+    bool supportsAchievementChallenges() const { return false; }
+    
+    /**
+     * @see SocialSession::supportsMultiplayer
+     */
+    bool supportsMultiplayer() const { return false; }
+    
+    /**
+     * @see SocialSession::supportsTurns
+     */
+    bool supportsTurns() const { return false; }
 
 
 protected:
@@ -148,26 +196,10 @@ private:
      * Destructor
      */
     virtual ~GooglePlaySocialSession();
-#if 0
-
-    static void userCallback(void* cookie, unsigned int result);
-
-    static void uiCallback(void *cookie, SCUI_Result_t result, const void *data);
-
-    static void loadFriendsCallback(void* cookie, SC_Error_t result);
-
-    static void loadAchievementsCallback(void* cookie, SC_Error_t result);
-
-    static void submitAchievementCallback(void* cookie, SC_Error_t result);
-
-    static void loadScoresCallback(void* cookie, SC_Error_t result);
-
-    static void submitScoreCallback(void* cookie, SC_Error_t result);
 
     const SocialAchievement* getAchievement(const char* achievementId) const;
+    void loadAchievementData();
 
-    SocialChallenge &addChallenge(SC_Challenge_h challenge);
-#endif
     static GooglePlaySocialSession* _session;
 
     enum UserOp
@@ -192,6 +224,7 @@ private:
     std::vector<SocialPlayer> _friends;
     std::vector<SocialAchievement> _achievements;
     std::vector<SocialScore> _scores;
+    std::vector<SocialChallenge> _challenges;
 };
 
 }

+ 32 - 7
gameplay/src/social/ScoreloopSocialSession.cpp

@@ -2,6 +2,7 @@
 
 #include "Base.h"
 #include "ScoreloopSocialSession.h"
+#include <bps/dialog.h>
 
 namespace gameplay
 {
@@ -867,7 +868,7 @@ void ScoreloopSocialSession::submitScoreCallback(void* cookie, SC_Error_t result
     session->_pendingSubmitScoreResponse = false;
 }
 
-void ScoreloopSocialSession::submitChallenge(const SocialPlayer *player, unsigned int wager, float score, const char* leaderboardId)
+void ScoreloopSocialSession::submitChallenge(const SocialPlayer *player, float score, const char* leaderboardId, unsigned int wager)
 {
 	SocialChallenge challenge;
 
@@ -968,6 +969,15 @@ void ScoreloopSocialSession::submitChallenge(const SocialPlayer *player, unsigne
 //	_listener->submitChallengeEvent(SocialSessionListener::SUCESS, challenge);
 }
 
+/**
+ * @see SocialSession::submitChallenge
+ */
+void ScoreloopSocialSession::submitAchievementChallenge(const SocialPlayer *player, const char* achievementId, unsigned int wager)
+{
+	SocialChallenge challenge;
+    _listener->submitChallengeEvent(SocialSessionListener::ERROR_NOT_SUPPORTED, challenge);
+}
+
 void ScoreloopSocialSession::submitChallengeCallback(void* cookie, SC_Error_t result)
 {
     ScoreloopSocialSession* session = (ScoreloopSocialSession*)cookie;
@@ -1187,8 +1197,6 @@ void ScoreloopSocialSession::loadChallengesCallback(void* cookie, SC_Error_t res
 {
     ScoreloopSocialSession* session = (ScoreloopSocialSession*)cookie;
 
-
-fprintf(stderr, "loadChallengesCallback is called!\n");
     switch (result)
     {
     	case SC_OK:
@@ -1274,7 +1282,7 @@ void ScoreloopSocialSession::submitSavedData(const char* key, std::string data)
     }
 }
 
-void ScoreloopSocialSession::displayLeaderboard(const char* leaderboardId)
+void ScoreloopSocialSession::displayLeaderboard(const char* leaderboardId) const
 {
 	SC_Error_t rc;
 	int mode = 0;
@@ -1303,7 +1311,7 @@ void ScoreloopSocialSession::displayLeaderboard(const char* leaderboardId)
 	}
 }
 
-void ScoreloopSocialSession::displayAchievements()
+void ScoreloopSocialSession::displayAchievements() const
 {
 	SC_Error_t rc;
 
@@ -1321,7 +1329,7 @@ void ScoreloopSocialSession::displayAchievements()
 	}
 }
 
-void ScoreloopSocialSession::displayChallenges()
+void ScoreloopSocialSession::displayChallenges() const
 {
 	fprintf(stderr, "displayChallenges has been called\n");
     SC_Error_t rc = SC_NOT_IMPLEMENTED_YET;
@@ -1349,7 +1357,7 @@ void ScoreloopSocialSession::displayChallenges()
     }
 }
 
-void ScoreloopSocialSession::displayChallengeSubmit(const SocialChallenge *challenge, float score)
+void ScoreloopSocialSession::displayChallengeSubmit(const SocialChallenge *challenge, float score) const
 {
 	SC_Error_t rc = SC_NOT_IMPLEMENTED_YET;
 
@@ -1389,6 +1397,23 @@ void ScoreloopSocialSession::displayChallengeSubmit(const SocialChallenge *chall
     }
 }
 
+void ScoreloopSocialSession::displayPopup(const char *popupMessage, const char *title) const
+{
+	dialog_instance_t dialog = 0;
+
+	dialog_create_toast(&dialog);
+
+	dialog_set_group_id(dialog, "dialogId");
+
+	dialog_set_toast_position(dialog, DIALOG_POSITION_TOP_CENTER);
+	dialog_set_toast_message_text(dialog, popupMessage);
+    
+    if (title)
+        dialog_set_title_text(dialog, title);
+
+	dialog_show(dialog);
+}
+
 }
 
 #endif

+ 48 - 6
gameplay/src/social/ScoreloopSocialSession.h

@@ -83,7 +83,7 @@ public:
     /**
      * @see SocialSession::incrementAchievement
      */
-    void incrementAchievement(const char* achievementId, unsigned int increment=1);
+    void incrementAchievement(const char* achievementId, unsigned int totalSteps=1);
 
     /**
       * @see SocialSession::syncAchievements
@@ -108,7 +108,12 @@ public:
     /**
       * @see SocialSession::submitChallenge
       */
-    void submitChallenge(const SocialPlayer *player, unsigned int wager, float score, const char* leaderboardId=0);
+    void submitChallenge(const SocialPlayer *player, float score, const char* leaderboardId, unsigned int wager=0);
+
+    /**
+       * @see SocialSession::submitAchievementChallenge
+       */
+     void submitAchievementChallenge(const SocialPlayer *player, const char* achievementId, unsigned int wager=0);
 
     /**
       * @see SocialSession::loadChallenges
@@ -130,13 +135,50 @@ public:
      */
     void submitSavedData(const char* key, std::string data);
 
-    void displayLeaderboard(const char* leaderboardId);
+    /**
+     * @see SocialSession::displayLeaderboard
+     */
+    void displayLeaderboard(const char* leaderboardId) const;
 
-    void displayAchievements();
+    /**
+     * @see SocialSession::displayAchievements
+     */
+    void displayAchievements() const;
 
-    void displayChallenges();
+    /**
+     * @see SocialSession::displayChallenges
+     */
+    void displayChallenges() const;
+
+    /**
+     * @see SocialSession::displayChallengeSubmit
+     */
+    void displayChallengeSubmit(const SocialChallenge *challenge, float score) const;
 
-    void displayChallengeSubmit(const SocialChallenge *challenge, float score);
+    /**
+     * @see SocialSession::displayPopup
+     */
+    void displayPopup(const char *string, const char *title) const;
+
+    /**
+     * @see SocialSession::supportsChallenges
+     */
+    bool supportsChallenges() const { return true; }
+
+    /**
+     * @see SocialSession::supportsAchievementChallenges
+     */
+    bool supportsAchievementChallenges() const { return false; }
+
+    /**
+     * @see SocialSession::supportsMultiplayer
+     */
+    bool supportsMultiplayer() const { return false; }
+
+    /**
+     * @see SocialSession::supportsTurns
+     */
+    bool supportsTurns() const { return false; }
 
 protected:
 

+ 0 - 3
samples/spaceship/.cproject

@@ -25,7 +25,6 @@
 								<option id="com.qnx.qcc.option.compiler.security.2012394098" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.compiler.defines.1031425461" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
-									<listOptionValue builtIn="false" value="GP_USE_SOCIAL"/>
 									<listOptionValue builtIn="false" value="GP_USE_GAMEPAD"/>
 								</option>
 								<option id="com.qnx.qcc.option.compiler.includePath.1786077513" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
@@ -116,7 +115,6 @@
 								<option id="com.qnx.qcc.option.compiler.security.1305913768" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.compiler.defines.1393479764" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
-									<listOptionValue builtIn="false" value="GP_USE_SOCIAL"/>
 									<listOptionValue builtIn="false" value="GP_USE_GAMEPAD"/>
 								</option>
 								<option id="com.qnx.qcc.option.compiler.includePath.1846473564" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
@@ -204,7 +202,6 @@
 								<option id="com.qnx.qcc.option.compiler.security.1801893474" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.compiler.defines.1406768557" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
-									<listOptionValue builtIn="false" value="GP_USE_SOCIAL"/>
 									<listOptionValue builtIn="false" value="GP_USE_GAMEPAD"/>
 								</option>
 								<option id="com.qnx.qcc.option.compiler.includePath.2118333103" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">

+ 2 - 2
samples/spaceship/android/AndroidManifest.xml

@@ -13,8 +13,8 @@
     <application android:icon="@drawable/icon" android:label="@string/app_name" android:hasCode="true">
 
 
-        <meta-data android:name="com.google.android.gms.games.APP_ID"
-            	   android:value="@string/app_id" />
+        <!--meta-data android:name="com.google.android.gms.games.APP_ID"
+            	   android:value="@string/app_id" /-->
             
         <!-- Our activity is the built-in NativeActivity framework class.
              This will take care of integrating with our NDK code. -->

+ 5 - 1
samples/spaceship/android/build.xml

@@ -60,9 +60,13 @@
        If this is not done in place, override ${out.dex.input.absolute.dir} */
        -->
     <target name="-post-compile">
-        <copy file="../res/airstrip28.gpb" tofile="assets/res/airstrip28.gpb"/>
+        <copy file="../res/airstrip.gpb" tofile="assets/res/airstrip.gpb"/>
         <copy file="../res/background.ogg" tofile="assets/res/background.ogg"/>
         <copy file="../res/background.png" tofile="assets/res/background.png"/>
+		<copy file="../res/challenge.form" tofile="assets/res/challenge.form"/>
+        <copy file="../res/menu.form" tofile="assets/res/menu.form"/>
+		<copy file="../res/menu.theme" tofile="assets/res/menu.theme"/>
+		<copy file="../res/menuAtlas.png" tofile="assets/res/menuAtlas.png"/>
         <copy file="../res/propulsion_glow.png" tofile="assets/res/propulsion_glow.png"/>
         <copy file="../res/spaceship.gpb" tofile="assets/res/spaceship.gpb"/>
         <copy file="../res/spaceship.wav" tofile="assets/res/spaceship.wav"/>

+ 2 - 1
samples/spaceship/bar-descriptor.xml

@@ -14,7 +14,7 @@
     <transparent>false</transparent>
   </initialWindow>
   <asset path="icon.png">icon.png</asset>
-  <asset path="res/airstrip.gpb">airstrip.gpb</asset>
+  <asset path="res/airstrip.gpb">res/airstrip.gpb</asset>
   <asset path="res/spaceship.gpb">res/spaceship.gpb</asset>
   <asset path="res/spaceship.wav">res/spaceship.wav</asset>
   <asset path="res//background.ogg">res/background.ogg</asset>
@@ -27,6 +27,7 @@
   <asset path="res/menu.theme">res/menu.theme</asset>
   <asset path="res/menuAtlas.png">res/menuAtlas.png</asset>
   <asset path="res/challenge.form">res/challenge.form</asset>
+  <asset path="scoreloop">scoreloop</asset>
   <configuration name="Device-Debug">
     <platformArchitecture>armle-v7</platformArchitecture>
     <asset path="Device-Debug/sample-spaceship" entry="true" type="Qnx/Elf">sample-spaceship</asset>

+ 31 - 1
samples/spaceship/game.config

@@ -17,6 +17,36 @@ social
      leaderboard_mappings
      {
          // Format: leaderboardId =  mode <unsigned int>
-         leaderboard = 0
+         # Game Center
+#         leaderboard = grp.spaceship.leaderboard
+     }
+     
+     achievement_mappings
+     {
+         // Format: internalId = externalId <string>
+     
+         # Scoreloop 
+         gameplay.spaceship.firsttime = rim.spaceship.firsttime
+         gameplay.spaceship.cleanrun = rim.spaceship.cleanrun
+         gameplay.spaceship.under20 = rim.spaceship.under20         
+         gameplay.spaceship.under17 = rim.spaceship.under17
+         gameplay.spaceship.under16 = rim.spaceship.under16
+         gameplay.spaceship.tentimes = rim.spaceship.tentimes
+         gameplay.spaceship.fiftytimes = rim.spaceship.fiftytimes
+         gameplay.spaceship.hundredtimes = rim.spaceship.hundredtimes
+         gameplay.spaceship.challenge = rim.spaceship.challenge
+         gameplay.spaceship.winchallenge = rim.spaceship.winchallenge
+
+		  # Game Center
+#         gameplay.spaceship.firsttime = grp.gameplay.spaceship.firsttime
+#         gameplay.spaceship.cleanrun = grp.gameplay.spaceship.cleanrun
+#         gameplay.spaceship.under20 = grp.gameplay.spaceship.under20         
+#         gameplay.spaceship.under17 = grp.gameplay.spaceship.under17
+#         gameplay.spaceship.under16 = grp.gameplay.spaceship.under16
+#         gameplay.spaceship.tentimes = grp.gameplay.spaceship.tentimes
+#         gameplay.spaceship.fiftytimes = grp.gameplay.spaceship.fiftytimes
+#         gameplay.spaceship.hundredtimes = grp.gameplay.spaceship.hundredtimes
+#         gameplay.spaceship.challenge = grp.gameplay.spaceship.challenge
+#         gameplay.spaceship.winchallenge = grp.gameplay.spaceship.winchallenge
      }
 }

+ 8 - 0
samples/spaceship/sample-spaceship.xcodeproj/project.pbxproj

@@ -41,6 +41,8 @@
 		5B43D19F14C35A0E008A5D9D /* SpaceshipGame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42CCD547146EC0AE00353661 /* SpaceshipGame.cpp */; };
 		5B43D1AF14C35A0E008A5D9D /* icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 42CCD55D146EC24F00353661 /* icon.png */; };
 		5B43D1B014C35A0E008A5D9D /* res in Resources */ = {isa = PBXBuildFile; fileRef = 42CCD55F146EC27A00353661 /* res */; };
+		6290E04E1824348500A28FB9 /* GameKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6290E04D1824348500A28FB9 /* GameKit.framework */; };
+		6290E050182434A600A28FB9 /* GameKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6290E04F182434A600A28FB9 /* GameKit.framework */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
@@ -79,6 +81,8 @@
 		42DFAB0616AD8B840000F342 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };
 		42DFAB2F16AD8CA20000F342 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/lib/libz.dylib; sourceTree = DEVELOPER_DIR; };
 		5B43D1B414C35A0E008A5D9D /* sample-spaceship-ios.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "sample-spaceship-ios.app"; sourceTree = BUILT_PRODUCTS_DIR; };
+		6290E04D1824348500A28FB9 /* GameKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameKit.framework; path = System/Library/Frameworks/GameKit.framework; sourceTree = SDKROOT; };
+		6290E04F182434A600A28FB9 /* GameKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/GameKit.framework; sourceTree = DEVELOPER_DIR; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -86,6 +90,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				6290E04E1824348500A28FB9 /* GameKit.framework in Frameworks */,
 				4284B8FD16ADA7DF00FB52B4 /* libgameplay.a in Frameworks */,
 				42CD0EF3147D932B0000361E /* libbullet.a in Frameworks */,
 				42CD0EF4147D932B0000361E /* libogg.a in Frameworks */,
@@ -106,6 +111,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				4284B8FF16ADA7F400FB52B4 /* libgameplay.a in Frameworks */,
+				6290E050182434A600A28FB9 /* GameKit.framework in Frameworks */,
 				4284B90516ADA81B00FB52B4 /* libz.dylib in Frameworks */,
 				42512C8217FB424000373866 /* libbullet.a in Frameworks */,
 				4284B90616ADA88600FB52B4 /* CoreMotion.framework in Frameworks */,
@@ -208,6 +214,7 @@
 		5B43D1B914C35A7A008A5D9D /* iOS */ = {
 			isa = PBXGroup;
 			children = (
+				6290E04D1824348500A28FB9 /* GameKit.framework */,
 				42DFAAC316AD89B80000F342 /* CoreMotion.framework */,
 				42DFAAD916AD8AD00000F342 /* Foundation.framework */,
 				42DFAB0316AD8B840000F342 /* OpenAL.framework */,
@@ -221,6 +228,7 @@
 		5B43D1BA14C35A81008A5D9D /* MacOSX */ = {
 			isa = PBXGroup;
 			children = (
+				6290E04F182434A600A28FB9 /* GameKit.framework */,
 				424CC034161FCB5B00577827 /* IOKit.framework */,
 				42CCD51A146EBF3600353661 /* Cocoa.framework */,
 				42CCD54A146EC10200353661 /* QuartzCore.framework */,

+ 42 - 60
samples/spaceship/src/SpaceshipGame.cpp

@@ -1,9 +1,5 @@
 #include "SpaceshipGame.h"
 
-#ifdef __QNX__
-#include <bps/dialog.h>
-#endif
-
 // Declare our game instance
 SpaceshipGame game;
 
@@ -69,7 +65,7 @@ SpaceshipGame::SpaceshipGame()
     : _scene(NULL), _cameraNode(NULL), _shipGroupNode(NULL), _shipNode(NULL), _propulsionNode(NULL), _glowNode(NULL),
       _stateBlock(NULL), _font(NULL), _throttle(0), _shipTilt(0), _finished(true), _finishedTime(0), _pushing(false), _time(0),
        _glowDiffuseParameter(NULL), _shipSpecularParameter(NULL), _spaceshipSound(NULL), _socialSession(NULL), _currentChallenge(NULL),
-       _challengedPlayer(NULL), _hitSomething(false), _creatingChallenge(false), _hasAcceptedChallenge(false),
+       _challengedPlayer(NULL), _hitSomething(false), _wonChallenge(false), _createdChallenge(false), _creatingChallenge(false), _hasAcceptedChallenge(false),
        _menu(NULL), _challengeForm(NULL), _friendsContainer(NULL), _challengeContainer(NULL)
 {
 }
@@ -138,7 +134,8 @@ void SpaceshipGame::initialize()
     _initialShipRot = _shipGroupNode->getRotation();
     _initialCameraPos = _cameraNode->getTranslation();
 
-    getSocialController()->authenticate(this);
+    if (getSocialController())
+    	getSocialController()->authenticate(this);
 }
 
 void SpaceshipGame::initializeSpaceship()
@@ -618,7 +615,7 @@ void SpaceshipGame::controlEvent(Control* control, EventType evt)
 			else if (_socialSession && strcmp(control->getId(), "leaderboard") == 0)
 			{
 				// Display the leaderboard.
-				_socialSession->displayLeaderboard("leaderboard");
+				_socialSession->displayLeaderboard(leaderboardName);
 			}
 			else if (_socialSession && strcmp(control->getId(), "achievements") == 0)
 			{
@@ -675,16 +672,15 @@ void SpaceshipGame::controlEvent(Control* control, EventType evt)
 
 void SpaceshipGame::postScore(double result)
 {
-fprintf(stderr, "postScore with new result %lf\n", result);
-
 	if (_socialSession)
 	{
 		_socialSession->submitScore(leaderboardName, result);
 
 		if (_creatingChallenge)
 		{
-			_socialSession->submitChallenge(_challengedPlayer, 0, result);
+			_socialSession->submitChallenge(_challengedPlayer, result);
 			_creatingChallenge = false;
+            _createdChallenge = true;
 			_challengedPlayer = 0;
 		}
 		else if (_hasAcceptedChallenge)
@@ -704,23 +700,29 @@ void SpaceshipGame::updateAchievements(double time)
 	if (_socialSession)
 	{
 		// increase the game count awards
-		_socialSession->incrementAchievement("rim.spaceship.firsttime");
-		_socialSession->incrementAchievement("rim.spaceship.tentimes");
-		_socialSession->incrementAchievement("rim.spaceship.fiftytimes");
-		_socialSession->incrementAchievement("rim.spaceship.hundredtimes");
+		_socialSession->incrementAchievement("gameplay.spaceship.firsttime", 1);
+		_socialSession->incrementAchievement("gameplay.spaceship.tentimes", 10);
+		_socialSession->incrementAchievement("gameplay.spaceship.fiftytimes", 50);
+		_socialSession->incrementAchievement("gameplay.spaceship.hundredtimes", 100);
 
 		// clean run award
 		if (!_hitSomething)
-			_socialSession->incrementAchievement("rim.spaceship.cleanrun");
+			_socialSession->submitAchievement("gameplay.spaceship.cleanrun", 100, true);
 
 		if (time < 16)
-			_socialSession->submitAchievement("rim.spaceship.under16", 1, true);
+			_socialSession->submitAchievement("gameplay.spaceship.under16", 100, true);
 
 		if (time < 17)
-			_socialSession->submitAchievement("rim.spaceship.under17", 1, true);
+			_socialSession->submitAchievement("gameplay.spaceship.under17", 100, true);
 
 		if (time < 20)
-			_socialSession->submitAchievement("rim.spaceship.under20", 1, true);
+			_socialSession->submitAchievement("gameplay.spaceship.under20", 100, true);
+
+        if (_createdChallenge)
+            _socialSession->submitAchievement("gameplay.spaceship.challenge", 100, true);
+
+        if (_wonChallenge)
+            _socialSession->submitAchievement("gameplay.spaceship.winchallenge", 100, true);
 
 		_socialSession->synchronizeAchievements();
 	}
@@ -758,7 +760,9 @@ void SpaceshipGame::authenticateEvent(ResponseCode code, SocialSession* session)
 		_socialSession->loadFriends();
 	}
 	else
+    {
 		fprintf(stderr, "Error authenticating the social session %d\n", code);
+    }
 }
 
 void SpaceshipGame::loadFriendsEvent(ResponseCode code, std::vector<SocialPlayer> friends)
@@ -793,68 +797,54 @@ void SpaceshipGame::loadAchievementsEvent(ResponseCode code, std::vector<SocialA
 		}
 	}
 	else
+    {
 		fprintf(stderr, "Error loading achievements %d\n", code);
+    }
 }
 
 void SpaceshipGame::submitAchievementEvent(ResponseCode code)
 {
-	fprintf(stderr, "submitAchievementEvent code is %d!!!\n", code);
 }
 
 void SpaceshipGame::synchronizeAchievementEvent(ResponseCode code)
 {
-	fprintf(stderr, "syncAchievementEvent code is %d!!!\n", code);
 }
 
 void SpaceshipGame::awardAchievedEvent(ResponseCode code, const SocialAchievement &achievement)
 {
 	if (code == SUCCESS)
 	{
-#ifdef __QNX__
 		char message[256];
 		sprintf(message, "You've earned the %s award.", achievement.title.data());
 
-		dialog_instance_t dialog = 0;
-
-		fprintf(stderr, "launching a dialog %s\n", message);
-
-		dialog_create_toast(&dialog);
-
-		dialog_set_group_id(dialog, "dialogId");
-
-		dialog_set_toast_position(dialog, DIALOG_POSITION_TOP_CENTER);
-		dialog_set_toast_message_text(dialog, message);
-
-		dialog_show(dialog);
-#endif
+		_socialSession->displayPopup(message);
 	}
 }
 
 void SpaceshipGame::loadScoresEvent(ResponseCode code, std::vector<SocialScore> scores)
 {
-	fprintf(stderr, "loaded Scores\n");
-
 	if (code == SUCCESS)
 	{
-	//	for (uint i = 0 ; i < scores.size(); i++)
-	//	{
-	//		fprintf(stderr, "Score %d for %s is %lf\n", i, scores[i].playerName.data(), scores[i].value);
-	//	}
+        for (int i = 0 ; i < scores.size(); i++)
+		{
+			fprintf(stderr, "Score %d for %s is %lf\n", i, scores[i].playerName.data(), scores[i].value);
+		}
 	}
 	else
-		fprintf(stderr, "error loading scores %d\n", code);
+    {
+		fprintf(stderr, "Error loading scores %d\n", code);
+    }
 }
 
 void SpaceshipGame::submitScoreEvent(ResponseCode code)
 {
-	fprintf(stderr, "finished submitting score\n");
-
-	_socialSession->loadScores("leaderboard", SocialSession::COMMUNITY_SCOPE_ALL, SocialSession::TIME_SCOPE_ALL, 1, 20);
+	_socialSession->loadScores(leaderboardName, SocialSession::COMMUNITY_SCOPE_ALL, SocialSession::TIME_SCOPE_ALL, 1, 20);
 }
 
 void SpaceshipGame::submitChallengeEvent(ResponseCode code, const SocialChallenge &challenge)
 {
-	fprintf(stderr, "SPACESHIP submittedChallengeEvent %d\n", code);
+    fprintf(stderr, "created challenge successfully\n");
+    _createdChallenge = true;
 }
 
 void SpaceshipGame::startChallengeEvent(ResponseCode code, const SocialChallenge &challenge)
@@ -870,13 +860,10 @@ void SpaceshipGame::startChallengeEvent(ResponseCode code, const SocialChallenge
 
 void SpaceshipGame::replyToChallengeEvent(ResponseCode code)
 {
-	fprintf(stderr, "SPACESHIP replyToChallengeEvent %d\n", code);
 }
 
 void SpaceshipGame::loadChallengesEvent(ResponseCode code, std::vector<SocialChallenge> challenges)
 {
-	fprintf(stderr, "loaded challenges\n");
-
 	if (code == SUCCESS)
 	{
 		_challenges.clear();
@@ -886,11 +873,16 @@ void SpaceshipGame::loadChallengesEvent(ResponseCode code, std::vector<SocialCha
 
 		for (unsigned int i = 0 ; i < challenges.size(); i++)
 		{
-			fprintf(stderr, "Challenge score %lf issued on %s by %s for %s\n", challenges[i].score, challenges[i].dateTimeIssued.c_str(), challenges[i].issuedPlayerName.c_str(), challenges[i].challengedPlayerName.c_str());
+            if (challenges[i].state == SocialChallenge::COMPLETE)
+                _wonChallenge = true;
+
+			fprintf(stderr, "Challenge score %lf issued on %s by %s for %s.  Status %d\n", challenges[i].score, challenges[i].dateTimeIssued.c_str(), challenges[i].issuedPlayerName.c_str(), challenges[i].challengedPlayerName.c_str(), challenges[i].state);
 		}
 	}
 	else
-		fprintf(stderr, "error loading challenges %d\n", code);
+    {
+		fprintf(stderr, "Error loading challenges %d\n", code);
+    }
 }
 
 void SpaceshipGame::loadSavedDataEvent(ResponseCode code, std::string data)
@@ -903,8 +895,6 @@ void SpaceshipGame::submitSavedDataEvent(ResponseCode code)
 
 void SpaceshipGame::buildFriendsChooser()
 {
-	fprintf(stderr, "build the friend chooser\n");
-
 	Theme* theme = _challengeForm->getTheme();
 	Theme::Style* buttonStyle = theme->getStyle("buttonStyle");
 
@@ -925,15 +915,10 @@ void SpaceshipGame::buildFriendsChooser()
 		_friendsContainer->addControl(button);
 		button->release();
 	}
-
-//	_friendsContainer->setScroll(Container::SCROLL_VERTICAL);
-//	_sampleSelectForm->setState(Control::FOCUS);
 }
 
 void SpaceshipGame::buildChallengeChooser()
 {
-	fprintf(stderr, "build the challenge chooser\n");
-
 	if (!_challengeContainer) return;
 #if 0
 	const std::vector<Control*> controls = _challengeContainer->getControls();
@@ -963,7 +948,4 @@ void SpaceshipGame::buildChallengeChooser()
 		_challengeContainer->addControl(button);
 		button->release();
 	}
-
-//	_challengeContainer->setScroll(Container::SCROLL_VERTICAL);
-//	_sampleSelectForm->setState(Control::FOCUS);
 }

+ 2 - 0
samples/spaceship/src/SpaceshipGame.h

@@ -249,6 +249,8 @@ private:
     std::vector<SocialPlayer> _friends;
     std::vector<SocialChallenge> _challenges;
     bool _hitSomething;
+    bool _wonChallenge;
+    bool _createdChallenge;
     bool _creatingChallenge;
     bool _hasAcceptedChallenge;