#import "LeaderboardBridge.h"
#include <asl.h>
#include <stdio.h>
#include <GameKit/GameKit.h>
@implementation LeaderboardBridge
const int EVENT_OTHER_SOCIAL = 70;
extern UIView *g_glView;
extern "C" NSString* findOption( const char* _key );
extern bool F_DsMapAdd_Internal(int _index, char* _pKey, double _value);
extern bool F_DsMapAdd_Internal(int _index, char* _pKey, char* _pValue);
extern int CreateDsMap( int _num, ... );
extern void CreateAsynEventWithDSMap(int dsmapindex, int event_index);
enum {
LBPlayerRank = 700,
LBFailedToGetRank = 701,
};
- (void) getPlayerRank:(char *)leaderboardId {
NSLog(@"Getting local player rank");
int dsMapIndex = CreateDsMap(0);
GKLeaderboard *leaderboardRequest = [[GKLeaderboard alloc] init];
leaderboardRequest.identifier = [NSString stringWithFormat:@"%s", leaderboardId];
if (leaderboardRequest != nil) {
[leaderboardRequest loadScoresWithCompletionHandler:^(NSArray *scores, NSError *error) {
if (error != nil) {
NSLog(@"%@", error);
F_DsMapAdd_Internal(dsMapIndex, (char *)"type", LBFailedToGetRank);
}
else {
F_DsMapAdd_Internal(dsMapIndex, (char *)"type", LBPlayerRank);
F_DsMapAdd_Internal(dsMapIndex, (char *)"rank", (int)leaderboardRequest.localPlayerScore.rank);
}
CreateAsynEventWithDSMap(dsMapIndex, EVENT_OTHER_SOCIAL);
}];
}
else {
F_DsMapAdd_Internal(dsMapIndex, (char *)"type", LBFailedToGetRank);
CreateAsynEventWithDSMap(dsMapIndex, EVENT_OTHER_SOCIAL);
}
}
@end