diff --git a/android/AndroidManifest.template.xml b/android/AndroidManifest.template.xml index 7cbab1ad..35e2998e 100644 --- a/android/AndroidManifest.template.xml +++ b/android/AndroidManifest.template.xml @@ -15,6 +15,8 @@ android:hardwareAccelerated="true" android:largeHeap="true" android:label="Tick's Tales"> + advent + 891208148801 diff --git a/android/src/java/advent/core/GooglePlay.java b/android/src/java/advent/core/GooglePlay.java new file mode 100644 index 00000000..8f07d91c --- /dev/null +++ b/android/src/java/advent/core/GooglePlay.java @@ -0,0 +1,88 @@ +package advent.core; + +import clojure.lang.RT; +import clojure.lang.Symbol; +import java.util.ArrayList; +import java.util.List; + +import com.badlogic.gdx.backends.android.AndroidApplication; +import android.support.annotation.NonNull; + +import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration; +import com.badlogic.gdx.Game; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.assets.AssetManager; +import com.google.android.gms.games.*; +import com.google.android.gms.auth.api.signin.*; +import android.app.Activity; +import android.content.Intent; +import com.google.android.gms.tasks.OnFailureListener; +import com.google.android.gms.tasks.OnSuccessListener; +import com.google.android.gms.tasks.OnCompleteListener; +import com.google.android.gms.tasks.Task; + + +public class GooglePlay { + static GoogleSignInAccount mAccount; + + public void signIn(Activity act) { + GoogleSignInClient signInClient = GoogleSignIn.getClient(act, GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN); + Intent intent = signInClient.getSignInIntent(); + act.startActivityForResult(intent, 14562); + } + + public void signInSilently(Activity act) { + GoogleSignInClient signInClient = GoogleSignIn.getClient(act, GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN); + System.out.println("trying silent sign in"); + + signInClient.silentSignIn().addOnCompleteListener(act, + new OnCompleteListener() { + @Override + public void onComplete(@NonNull Task task) { + if (task.isSuccessful()) { + System.out.println("silent sign in succeeded."); + signedIn(task.getResult()); + } else { + } + } + }); + } + + public static void signedIn(GoogleSignInAccount acct) { + mAccount = acct; + } + + + public void showAchievements(final Activity act) { + if (mAccount != null) { + com.google.android.gms.games.Games.getAchievementsClient(act, mAccount).getAchievementsIntent() + .addOnSuccessListener(new OnSuccessListener() { + @Override + public void onSuccess(Intent intent) { + System.out.println("SUCCESS"); + act.startActivityForResult(intent, 0); + } + }) + .addOnFailureListener(new OnFailureListener() { + @Override + public void onFailure(@NonNull Exception e) { + System.out.println("FAIL"); + System.out.println(e.toString()); + } + }); + } else { + signIn(act); + } + + } + + public void setAchievement(Activity act, String a) { + System.out.println("TRYING TO UNLOCK"); + System.out.println(a); + if (mAccount != null) { + System.out.println(mAccount.toString()); + com.google.android.gms.games.Games.getAchievementsClient(act, mAccount).unlock(a); + } + } + +} diff --git a/android/src/java/advent/core/MainActivity.java b/android/src/java/advent/core/MainActivity.java index 317fe416..88d64c89 100644 --- a/android/src/java/advent/core/MainActivity.java +++ b/android/src/java/advent/core/MainActivity.java @@ -16,7 +16,16 @@ import com.android.billingclient.api.BillingClient.SkuType; import com.android.billingclient.api.SkuDetails.SkuDetailsResult; import com.android.billingclient.api.BillingFlowParams; import com.android.billingclient.api.BillingFlowParams.Builder; +import android.content.Intent; +import com.google.android.gms.common.api.ApiException; import android.content.pm.*; +import com.google.android.gms.games.*; +import com.google.android.gms.auth.api.signin.*; +import com.google.android.gms.tasks.OnCompleteListener; +import com.google.android.gms.tasks.OnFailureListener; +import com.google.android.gms.tasks.OnSuccessListener; +import com.google.android.gms.tasks.Task; +import android.app.AlertDialog; public class MainActivity extends AndroidApplication { public boolean triggerPurchase() { @@ -25,6 +34,43 @@ public class MainActivity extends AndroidApplication { int returnValue = mBillingClient.launchBillingFlow(this, builder.build()); return returnValue == BillingClient.BillingResponse.OK || returnValue == BillingClient.BillingResponse.ITEM_ALREADY_OWNED; } + + @Override + protected void onResume() { + super.onResume(); + + // Since the state of the signed in user can change when the activity is not active + // it is recommended to try and sign in silently from when the app resumes. + new GooglePlay().signInSilently(this); + } + + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent intent) { + super.onActivityResult(requestCode, resultCode, intent); + if (requestCode == 14562) { + System.out.println("LOGIN RESULT"); + Task task = + GoogleSignIn.getSignedInAccountFromIntent(intent); + + try { + GoogleSignInAccount account = task.getResult(ApiException.class); + System.out.println("GOT ACCOUNT"); + System.out.println(account.toString()); + + GooglePlay.signedIn(account); + new GooglePlay().showAchievements(this); + } catch (ApiException apiException) { + System.out.println("NOT GOT ACCOUNT"); + System.out.println(apiException.toString()); + + new AlertDialog.Builder(this) + .setMessage("Could not sign in to Google Play") + .setNeutralButton("Ok", null) + .show(); + } + } + } private BillingClient mBillingClient; diff --git a/desktop/asset-work/title/google-play.png b/desktop/asset-work/title/google-play.png new file mode 100644 index 00000000..3d468daf Binary files /dev/null and b/desktop/asset-work/title/google-play.png differ diff --git a/desktop/project.clj b/desktop/project.clj index eba9df10..33520371 100644 --- a/desktop/project.clj +++ b/desktop/project.clj @@ -2,7 +2,7 @@ (def packs (into ["do"] (mapcat (fn [directory] ["run" "-m" "com.badlogic.gdx.tools.texturepacker.TexturePacker" (str "asset-work/" directory) "resources/packed/" (str directory ",")]) - ["global" "credits"] + ["title" ] #_["behindhouse" "dream" "georgia" "inside-cafeteria" "inside-jail" "outsidehouse" "safe-song" "title" "castle-gate" "ego" "held" "inside-castle" "inside-stash" "outside-castle" "screenshots" "wizard" "cat-tree" "ending-castle" "inside-antique" "inside-house" "outside-jail" "space" ]))) diff --git a/desktop/resources/packed/title.atlas b/desktop/resources/packed/title.atlas index 263815e5..3dead54d 100644 --- a/desktop/resources/packed/title.atlas +++ b/desktop/resources/packed/title.atlas @@ -46,6 +46,13 @@ dot orig: 1, 1 offset: 0, 0 index: -1 +google-play + rotate: false + xy: 324, 324 + size: 33, 39 + orig: 33, 39 + offset: 0, 0 + index: -1 logo rotate: false xy: 2, 249 @@ -55,21 +62,21 @@ logo index: -1 quill rotate: false - xy: 324, 324 + xy: 879, 978 size: 33, 39 orig: 33, 39 offset: 0, 0 index: -1 save-indicator rotate: false - xy: 879, 1010 + xy: 810, 766 size: 7, 7 orig: 7, 7 offset: 0, 0 index: -1 save-indicator-active rotate: false - xy: 810, 766 + xy: 648, 934 size: 7, 7 orig: 7, 7 offset: 0, 0 diff --git a/desktop/resources/packed/title.png b/desktop/resources/packed/title.png index 4d0cf3c5..1e9ae5a9 100644 Binary files a/desktop/resources/packed/title.png and b/desktop/resources/packed/title.png differ diff --git a/desktop/src-common/advent/achievements.clj b/desktop/src-common/advent/achievements.clj new file mode 100644 index 00000000..bfd5d04d --- /dev/null +++ b/desktop/src-common/advent/achievements.clj @@ -0,0 +1,12 @@ +(ns advent.achievements + (:import [com.badlogic.gdx Gdx Application]) + (:require [advent.steam :as steam] + [advent.utils :as utils])) + +(def android-ids {"DESTINY" "CgkIwc6UgfgZEAIQAQ"}) + +(defn set-achievement [achievement] + (utils/platformify + (.reportAchievement (advent.core.GameCenter.) achievement) + (.setAchievement (advent.core.GooglePlay.) (Gdx/app) (android-ids achievement)) + (steam/set-achievement achievement))) diff --git a/desktop/src-common/advent/screens/rooms/behind_house.clj b/desktop/src-common/advent/screens/rooms/behind_house.clj index 20b12dff..aeb5b718 100644 --- a/desktop/src-common/advent/screens/rooms/behind_house.clj +++ b/desktop/src-common/advent/screens/rooms/behind_house.clj @@ -3,6 +3,7 @@ [advent.screens.rooms.common :as common] [advent.screens.items :as items] [advent.actions :as actions] + [advent.achievements :as achievements] [advent.utils :as utils] [advent.steam :as steam] [clojure.zip :as zip] @@ -105,6 +106,7 @@ :label "Crumbly wall" :cursor :hand :script (actions/get-script entities + (achievements/set-achievement "SAFE_AND_SOUND") (cond (= :night (get-in @entities [:state :time])) (actions/talk entities :ego "The house is empty right now.") @@ -119,7 +121,7 @@ (actions/talk entities :ego "So that's the code to his safe..." :animate? false :stop? false) (actions/play-animation entities :ego :end-squat) (actions/talk entities :ego "A lot of good it'll do me to know his password while he's still there.") - (steam/set-achievement "SAFE_AND_SOUND") + (achievements/set-achievement "SAFE_AND_SOUND") (increment-safe-listens entities)) (and (get-in @entities [:state :opened-crack?]) diff --git a/desktop/src-common/advent/screens/rooms/castle_gate.clj b/desktop/src-common/advent/screens/rooms/castle_gate.clj index 2dac2f80..064bb4ee 100644 --- a/desktop/src-common/advent/screens/rooms/castle_gate.clj +++ b/desktop/src-common/advent/screens/rooms/castle_gate.clj @@ -6,6 +6,7 @@ [advent.utils :as utils] [advent.screens.dialogue :as dialogue] [advent.steam :as steam] + [advent.achievements :as achievements] [advent.tween :as tween] [clojure.zip :as zip] @@ -187,7 +188,7 @@ (actions/play-animation entities :ego :reach) (actions/do-dialogue entities :ego "There, now the vote is 35 to 34!") (actions/update-state entities #(assoc % :has-voted? true)) - (steam/set-achievement "PARDON")))) + (achievements/set-achievement "PARDON")))) (defn make-note [] {:box [97 102 111 132] diff --git a/desktop/src-common/advent/screens/rooms/cat_tree.clj b/desktop/src-common/advent/screens/rooms/cat_tree.clj index 168a9dc7..c8c52ae2 100644 --- a/desktop/src-common/advent/screens/rooms/cat_tree.clj +++ b/desktop/src-common/advent/screens/rooms/cat_tree.clj @@ -6,6 +6,7 @@ [advent.screens.rooms.common :as common] [advent.utils :as utils] [advent.steam :as steam] + [advent.achievements :as achievements] [clojure.zip :as zip] [play-clj.core :refer :all] [play-clj.ui :refer :all] @@ -411,7 +412,7 @@ (actions/give entities :kiss) (actions/do-dialogue entities :ego "A kiss for an inventory item?" :ego "Sounds like the game designer was running out of good ideas.") - (steam/set-achievement "KITTY_KISS")) + (achievements/set-achievement "KITTY_KISS")) (actions/talk entities :ego "I can't get his attention from way down here."))) :stick (actions/get-script entities (if (get-in @entities [:room :entities :ladder]) @@ -507,7 +508,7 @@ (actions/play-animation entities :owl :eye) (actions/do-dialogue entities :owl "I don't think that helped that much.") - (steam/set-achievement "BEHOLDER") + (achievements/set-achievement "BEHOLDER") (when (actions/has-obtained? entities :feather) (actions/do-dialogue entities :owl "I think I'll just stick to the monocle.")) (actions/update-state entities (fn [s] (assoc s :owl-tried-strength? true)))) diff --git a/desktop/src-common/advent/screens/rooms/common.clj b/desktop/src-common/advent/screens/rooms/common.clj index 8cae657b..9778a7d2 100644 --- a/desktop/src-common/advent/screens/rooms/common.clj +++ b/desktop/src-common/advent/screens/rooms/common.clj @@ -4,6 +4,7 @@ [advent.actions :as actions] [advent.screens.items :as items] [advent.steam :as steam] + [advent.achievements :as achievements] [advent.utils :as utils] [advent.pathfind] [advent.tween :as tween] @@ -480,7 +481,7 @@ :ego "Hey!" :ego "I won!") - (steam/set-achievement "BLOODCLOT") + (achievements/set-achievement "BLOODCLOT") (actions/glad entities) (actions/walk-straight-to entities :ego [340 55]) (actions/run-action entities diff --git a/desktop/src-common/advent/screens/rooms/dream.clj b/desktop/src-common/advent/screens/rooms/dream.clj index d2646622..68ead167 100644 --- a/desktop/src-common/advent/screens/rooms/dream.clj +++ b/desktop/src-common/advent/screens/rooms/dream.clj @@ -8,6 +8,7 @@ [advent.tween :as tween] [advent.utils :as utils] [advent.saves :as saves] + [advent.achievements :as achievements] [advent.steam :as steam] [clojure.zip :as zip] [clojure.set :as set] @@ -93,6 +94,7 @@ (defn read-sword-plaque [entities] + (actions/walk-to entities :ego [168 76] :face :left) (if-not (get-in @entities [:state :plaques-read :sword]) @@ -467,7 +469,7 @@ (actions/resume-camera entities) (actions/walk-straight-to entities :ego [79 145] :stop? false) (actions/walk-to entities :ego [159 74]) - (steam/set-achievement "DESTINY") + (achievements/set-achievement "DESTINY") (actions/do-dialogue entities :ego "Man! What a dream!" :ego "If only I could become a real knight." diff --git a/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj b/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj index 4b79b753..ca7ac652 100644 --- a/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj +++ b/desktop/src-common/advent/screens/rooms/inside_cafeteria.clj @@ -4,6 +4,7 @@ [advent.screens.items :as items] [advent.actions :as actions] [advent.steam :as steam] + [advent.achievements :as achievements] [advent.utils :as utils] [clojure.zip :as zip] [play-clj.core :refer :all] @@ -86,7 +87,7 @@ :warriors "Take thy servant's medal of strength.") (actions/give entities :medal) (actions/glad entities) - (steam/set-achievement "PRO_WRESTLER")) + (achievements/set-achievement "PRO_WRESTLER")) (do (play-battle entities :lose) (actions/do-dialogue entities diff --git a/desktop/src-common/advent/screens/rooms/inside_castle.clj b/desktop/src-common/advent/screens/rooms/inside_castle.clj index a7f86367..b8d6da27 100644 --- a/desktop/src-common/advent/screens/rooms/inside_castle.clj +++ b/desktop/src-common/advent/screens/rooms/inside_castle.clj @@ -7,6 +7,7 @@ [advent.screens.items :as items] [advent.utils :as utils] [advent.steam :as steam] + [advent.achievements :as achievements] [advent.tween :as tween] [clojure.zip :as zip] [clojure.set :as set] @@ -631,7 +632,7 @@ (actions/remove-entity entities :trophy) (actions/glad entities) (actions/talk entities :ego "Thanks!") - (steam/set-achievement "WISE_UP") + (achievements/set-achievement "WISE_UP") ) )) (brian-get-to-work entities)) diff --git a/desktop/src-common/advent/screens/rooms/inside_jail.clj b/desktop/src-common/advent/screens/rooms/inside_jail.clj index f1d3c239..47e1d193 100644 --- a/desktop/src-common/advent/screens/rooms/inside_jail.clj +++ b/desktop/src-common/advent/screens/rooms/inside_jail.clj @@ -4,6 +4,7 @@ [advent.screens.rooms.common :as common] [advent.saves :as saves] [advent.steam :as steam] + [advent.achievements :as achievements] [advent.actions :as actions] [advent.screens.items :as items] [advent.utils :as utils] @@ -201,7 +202,7 @@ :ego "But what now?" :ego "I have till sunrise before Bloodclot comes and destroys the town." :ego "Maybe Gandarf can help me!") - (steam/set-achievement "EX_CON") + (achievements/set-achievement "EX_CON") (utils/save-chapter @entities :chapter-4) ) (do diff --git a/desktop/src-common/advent/screens/rooms/outside_house.clj b/desktop/src-common/advent/screens/rooms/outside_house.clj index 7b56f0f1..6b399583 100644 --- a/desktop/src-common/advent/screens/rooms/outside_house.clj +++ b/desktop/src-common/advent/screens/rooms/outside_house.clj @@ -7,6 +7,7 @@ [advent.actions :as actions] [advent.tween :as tween] [advent.steam :as steam] + [advent.achievements :as achievements] [advent.utils :as utils] [advent.iap :as iap] [clojure.zip :as zip] @@ -724,7 +725,7 @@ (actions/play-animation entities :ego :reach) (actions/update-state entities #(assoc % :wool-count (inc (or (:wool-count %) 0)))) (when (= 3 (get-in @entities [:state :wool-count])) - (steam/set-achievement "SHEEP_HORDER")) + (achievements/set-achievement "SHEEP_HORDER")) (actions/update-entities entities #(update-in % [:room :entities :sheep] diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index 4362fac5..b1776cc0 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -17,6 +17,7 @@ [advent.saves :as saves] [advent.tween :as tween] [advent.steam :as steam] + [advent.achievements :as achievements] [advent.screens.rooms :as rooms] [advent.screens.shader :refer [v-shader pix-shader]] [advent.screens.fade :refer [fade-screen]] @@ -278,7 +279,7 @@ (Thread/sleep 500) (actions/play-animation entities :ego :sigh) (actions/talk entities :ego "You really are a sucker for punishment, aren't you?") - (steam/set-achievement "FOOLISH_LULLABY")) + (achievements/set-achievement "FOOLISH_LULLABY")) :else (do (actions/talk entities :ego "Ugh! I have Gandarf's MagiSafe 2000 tune stuck in my head.") diff --git a/desktop/src-common/advent/screens/title.clj b/desktop/src-common/advent/screens/title.clj index 793cfd9f..f239b0c1 100644 --- a/desktop/src-common/advent/screens/title.clj +++ b/desktop/src-common/advent/screens/title.clj @@ -393,6 +393,15 @@ save-object (#(utils/add-actor-to-stage screen %))) + + :google-play (doto (assoc (image-button (BaseDrawable.)) :x 1150 :y 160 :scale-x 4 :scale-y 4 :origin-x 0 :origin-y 0 :z 10 :key :google-play) + + (image-button! :add (doto (Group. ) + (.addActor (:object (doto (image (utils/atlas->texture title-atlas "google-play.png")) + (image! :set-scale 4)))))) + + save-object + (#(utils/add-actor-to-stage screen %))) :logo (assoc (utils/atlas->texture title-atlas "logo.png" ) :x 640 :y 960 :scale-x (/ 4 utils/ui-scale) :scale-y (/ 4 utils/ui-scale) :origin-x 160 :origin-y 240 :z 6) :fade (assoc (utils/atlas->texture global-atlas "black.png") :scale-x 80 @@ -537,6 +546,15 @@ (assoc :chapters-menu (->> (chapters-menu ) (utils/add-actor-to-stage screen)))) + + (= :google-play actor-key) + (utils/platformify + entities + (do + (.showAchievements (advent.core.GooglePlay.) (Gdx/app)) + entities) + entities) + (= :settings actor-key) (-> entities (utils/remove-actor-from-stage :main-menu) diff --git a/ios/robovm.xml b/ios/robovm.xml index 4ba40e05..d13e4662 100644 --- a/ios/robovm.xml +++ b/ios/robovm.xml @@ -101,5 +101,6 @@ AudioToolbox AVFoundation StoreKit + GameKit diff --git a/ios/src/java/advent/core/GameCenter.java b/ios/src/java/advent/core/GameCenter.java new file mode 100644 index 00000000..b1732393 --- /dev/null +++ b/ios/src/java/advent/core/GameCenter.java @@ -0,0 +1,159 @@ + +package advent.core; + +import java.util.ArrayList; + +import org.robovm.apple.foundation.NSArray; +import org.robovm.apple.foundation.NSError; +import org.robovm.apple.foundation.NSErrorUserInfo; +import org.robovm.apple.foundation.NSString; +import org.robovm.apple.gamekit.GKAchievement; +import org.robovm.apple.gamekit.GKAchievementViewController; +import org.robovm.apple.gamekit.GKAchievementViewControllerDelegateAdapter; +import org.robovm.apple.gamekit.GKGameCenterControllerDelegateAdapter; +import org.robovm.apple.gamekit.GKGameCenterViewController; +import org.robovm.apple.gamekit.GKGameCenterViewControllerState; +import org.robovm.apple.gamekit.GKLeaderboard; +import org.robovm.apple.gamekit.GKLeaderboardTimeScope; +import org.robovm.apple.gamekit.GKLeaderboardViewController; +import org.robovm.apple.gamekit.GKLeaderboardViewControllerDelegateAdapter; +import org.robovm.apple.gamekit.GKLocalPlayer; +import org.robovm.apple.gamekit.GKScore; +import org.robovm.apple.uikit.UIDevice; +import org.robovm.apple.uikit.UIViewController; +import org.robovm.apple.uikit.UIWindow; +import org.robovm.objc.block.VoidBlock1; +import org.robovm.objc.block.VoidBlock2; +import org.robovm.objc.block.VoidBlock3; + +@SuppressWarnings("deprecation") +public class GameCenter { + + // private final UIWindow keyWindow; + //private final GameCenterListener listener; + + /** Constructor. + * @param keyWindow KeyWindow can't be accessed from the Delegates sometimes, so we need to save a reference + * @param listener */ + /* + public GameCenter (UIWindow keyWindow, GameCenterListener listener) { + this.keyWindow = keyWindow; + this.listener = listener; + } + */ + + /** Do the login logic. If the user has never loged, a dialog will be shown. */ + public void login () { + GKLocalPlayer.getLocalPlayer().setAuthenticateHandler(new VoidBlock2() { + @Override + public void invoke (UIViewController viewController, NSError error) { + // If the device does not have an authenticated player, show the login dialog + if (viewController != null) { + System.out.println("Not logged in"); + + // keyWindow.getRootViewController().presentViewController(viewController, true, null); + } + // If the viewController is null and the player is authenticated, the login is completed + else if (GKLocalPlayer.getLocalPlayer().isAuthenticated()) { + System.out.println("Logged in"); + // listener.playerLoginCompleted(); + } + // If the viewController is null and the player is not authenticated the login has failed + else { + System.out.println("login error"); + // listener.playerLoginFailed(error); + } + } + }); + } + + /** Report an achievement completed (100 as percentComplete) + * + * @param identifier */ + public void reportAchievement (String identifier) { + reportAchievement(identifier, 100); + } + + /** Report an achievement with a percentComplete + * + * @param identifier + * @param percentComplete */ + public void reportAchievement (String identifier, double percentComplete) { + // If player is not authenticated, do nothing + if (!GKLocalPlayer.getLocalPlayer().isAuthenticated()) { + System.out.println("not authenticated"); + //listener.achievementReportFailed(buildUnauthenticatedPlayerError()); + return; + } + + GKAchievement achievement = new GKAchievement(identifier); + achievement.setPercentComplete(percentComplete); + achievement.setShowsCompletionBanner(true); + + // Create an array with the achievement + NSArray achievements = new NSArray(achievement); + + GKAchievement.reportAchievements(achievements, new VoidBlock1() { + @Override + public void invoke (NSError error) { + if (error != null) { + System.out.println("ninsuccess achievement " + error.toString()); + // listener.achievementReportFailed(error); + } else { + System.out.println("success achievement"); + // listener.achievementReportCompleted(); + } + } + }); + } + + + /* + public void loadAchievements () { + // If player is not authenticated, do nothing + if (!GKLocalPlayer.getLocalPlayer().isAuthenticated()) { + listener.achievementsLoadFailed(buildUnauthenticatedPlayerError()); + return; + } + + GKAchievement.loadAchievements(new VoidBlock2, NSError>() { + @Override + public void invoke (NSArray array, NSError error) { + if (error != null) { + listener.achievementsLoadFailed(error); + } else { + ArrayList achievements = new ArrayList(); + for (GKAchievement achievement : array) { + achievements.add(achievement); + } + listener.achievementsLoadCompleted(achievements); + } + } + }); + } + */ + + /** Reset the achievements progress for the local player. All the entries for the local player are removed from the server. */ + /* + public void resetAchievements () { + // If player is not authenticated, do nothing + if (!GKLocalPlayer.getLocalPlayer().isAuthenticated()) { + listener.achievementsResetFailed(buildUnauthenticatedPlayerError()); + return; + } + + GKAchievement.resetAchievements(new VoidBlock1() { + @Override + public void invoke (NSError error) { + if (error != null) { + listener.achievementsResetFailed(error); + } else { + listener.achievementsResetCompleted(); + } + } + }); + } + */ + + +} diff --git a/ios/src/java/advent/core/IOSLauncher.java b/ios/src/java/advent/core/IOSLauncher.java index 7368892f..4b52de9f 100644 --- a/ios/src/java/advent/core/IOSLauncher.java +++ b/ios/src/java/advent/core/IOSLauncher.java @@ -31,6 +31,7 @@ public class IOSLauncher extends IOSApplication.Delegate { protected IOSApplication createApplication() { IOSApplicationConfiguration config = new IOSApplicationConfiguration(); + new GameCenter().login(); // config.colorFormat = GLKViewDrawableColorFormat.SRGBA8888; // config.depthFormat = GLKViewDrawableDepthFormat._24; config.orientationPortrait = false;