forked from freshplanet/ANE-Google-Play-Game-Services
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
13 changed files
with
282 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...onscript/src/com/freshplanet/ane/AirGooglePlayGames/AirGooglePlayGamesLeaderboardEvent.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.freshplanet.ane.AirGooglePlayGames | ||
{ | ||
import flash.events.Event; | ||
|
||
public class AirGooglePlayGamesLeaderboardEvent extends Event | ||
{ | ||
|
||
public static const LEADERBOARD_LOADED:String = "AirGooglePlayGamesLeaderboardEvent.leaderboard_loaded"; | ||
public static const LEADERBOARD_LOADING_FAILED:String = "AirGooglePlayGamesLeaderboardEvent.leaderboard_loading_failed"; | ||
|
||
public var leaderboard:GSLeaderboard; | ||
|
||
public function AirGooglePlayGamesLeaderboardEvent( type:String, leaderboard:GSLeaderboard ) | ||
{ | ||
|
||
super( type ); | ||
|
||
this.leaderboard = leaderboard; | ||
|
||
} | ||
|
||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
actionscript/src/com/freshplanet/ane/AirGooglePlayGames/GSLeaderboard.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.freshplanet.ane.AirGooglePlayGames | ||
{ | ||
public class GSLeaderboard | ||
{ | ||
|
||
private var _scores:Vector.<GSScore>; | ||
public function get scores():Vector.<GSScore> { return _scores.slice(); } | ||
|
||
public function GSLeaderboard() | ||
{ | ||
|
||
_scores = new <GSScore>[]; | ||
|
||
} | ||
|
||
public static function fromJSONObject( jsonArray:Array ):GSLeaderboard { | ||
|
||
var leaderboard:GSLeaderboard = new GSLeaderboard(); | ||
|
||
for each ( var scoreObject:Object in jsonArray ) { | ||
leaderboard._scores.push( GSScore.fromJSONObject( scoreObject ) ); | ||
} | ||
|
||
return leaderboard; | ||
|
||
} | ||
|
||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
actionscript/src/com/freshplanet/ane/AirGooglePlayGames/GSPlayer.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.freshplanet.ane.AirGooglePlayGames | ||
{ | ||
public class GSPlayer | ||
{ | ||
|
||
private var _id:String; | ||
public function get id():String { return _id; } | ||
private var _displayName:String; | ||
public function get displayName():String { return _displayName; } | ||
private var _picture:String; | ||
public function get picture():String { return _picture; } | ||
|
||
public function GSPlayer( id:String, displayName:String, picture:String = null ) | ||
{ | ||
|
||
_id = id; | ||
_displayName = displayName; | ||
_picture = picture; | ||
|
||
} | ||
|
||
public static function fromJSONObject( jsonObject:Object ):GSPlayer { | ||
|
||
if( jsonObject.id == null ) return null; | ||
|
||
return new GSPlayer( jsonObject.id, jsonObject.displayName, jsonObject.picture ); | ||
|
||
} | ||
|
||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
actionscript/src/com/freshplanet/ane/AirGooglePlayGames/GSScore.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.freshplanet.ane.AirGooglePlayGames | ||
{ | ||
public class GSScore | ||
{ | ||
|
||
private var _value:int; | ||
public function get value():int { return _value; } | ||
private var _rank:int; | ||
public function get rank():int { return _rank; } | ||
private var _player:GSPlayer; | ||
public function get player():GSPlayer { return _player; } | ||
|
||
public function GSScore( value:int, rank:int, player:GSPlayer ) | ||
{ | ||
|
||
_value = value; | ||
_rank = rank; | ||
_player = player; | ||
|
||
} | ||
|
||
public static function fromJSONObject( jsonObject:Object ):GSScore { | ||
|
||
var player:GSPlayer = GSPlayer.fromJSONObject( jsonObject.player ); | ||
|
||
if( player == null ) return null; | ||
|
||
return new GSScore( jsonObject.value, jsonObject.rank, player ); | ||
|
||
} | ||
|
||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
android/src/com/freshplanet/googleplaygames/ScoresLoadedListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.freshplanet.googleplaygames; | ||
|
||
import com.google.android.gms.common.api.ResultCallback; | ||
import com.google.android.gms.games.Games; | ||
import com.google.android.gms.games.PageDirection; | ||
import com.google.android.gms.games.leaderboard.LeaderboardScoreBuffer; | ||
import com.google.android.gms.games.leaderboard.Leaderboards; | ||
|
||
/** | ||
* Created by renaud on 09/09/2014. | ||
*/ | ||
class ScoresLoadedListener implements ResultCallback<Leaderboards.LoadScoresResult> { | ||
|
||
private int currentBufferSize = 0; | ||
|
||
public void ScoresLoadedListener() {} | ||
|
||
public void onResult( Leaderboards.LoadScoresResult scoresResult ) { | ||
|
||
|
||
LeaderboardScoreBuffer scores = scoresResult.getScores(); | ||
|
||
if( scores.getCount() == currentBufferSize ) { | ||
Extension.context.onLeaderboardLoaded(scores); | ||
} | ||
else { | ||
currentBufferSize = scores.getCount(); | ||
Games.Leaderboards.loadMoreScores( Extension.context.getApiClient(), scores, 25, PageDirection.NEXT ).setResultCallback( this ); | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.