Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to ARC, improve readability, improve README.md and fix typos #9

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
75 changes: 44 additions & 31 deletions DDGameKitHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,57 +6,70 @@

#import <GameKit/GameKit.h>

// -----------------------------------------------------------------
#define DDGAMEKIT_LOGGING 0
// -----------------------------------------------------------------

@protocol DDGameKitHelperProtocol
-(bool) compare:(int64_t)score1 to:(int64_t)score2;
-(void) onSubmitScore:(int64_t)score;
-(void) onReportAchievement:(GKAchievement*)achievement;
- (BOOL) compareScore:(int64_t)score1 toScore:(int64_t)score2;
- (void) onSubmitScore:(int64_t)score;
- (void) onReportAchievement:(GKAchievement*)achievement;
@end

// -----------------------------------------------------------------

@interface DDGameKitHelper : NSObject <GKLeaderboardViewControllerDelegate, GKAchievementViewControllerDelegate, GKGameCenterControllerDelegate>
{
id<DDGameKitHelperProtocol> delegate;
bool isGameCenterAvailable;
NSMutableDictionary* achievements;
NSMutableDictionary* scores;
NSMutableDictionary* achievementDescriptions;
NSString* currentPlayerID;
id <DDGameKitHelperProtocol> _delegate;
BOOL _isGameCenterAvailable;
NSMutableDictionary* _achievements;
NSMutableDictionary* _scores;
NSMutableDictionary* _achievementDescriptions;
NSString* _currentPlayerID;
}

@property (nonatomic, retain) id<DDGameKitHelperProtocol> delegate;
@property (nonatomic, readonly) bool isGameCenterAvailable;
// -----------------------------------------------------------------

@property (nonatomic, strong) id <DDGameKitHelperProtocol> delegate;
@property (nonatomic, readonly) BOOL isGameCenterAvailable;
@property (nonatomic, readonly) NSMutableDictionary* achievements;
@property (nonatomic, readonly) NSMutableDictionary* scores;
@property (nonatomic, readonly) NSMutableDictionary* achievementDescriptions;
@property (nonatomic, retain) NSString* currentPlayerID;

+(DDGameKitHelper*) sharedGameKitHelper;

-(void) setNotAvailable;
@property (nonatomic, strong) NSString* currentPlayerID;

-(bool) isAvailable;
// -----------------------------------------------------------------

-(void) authenticateLocalPlayer;
// Singleton instance
+ (DDGameKitHelper*) sharedGameKitHelper;

-(bool) isLocalPlayerAuthenticated;
// -----------------------------------------------------------------

-(void) submitScore:(int64_t)value category:(NSString*)category;
// Check and set availability
- (void) setNotAvailable;
- (BOOL) isAvailable;

-(void) reportAchievement:(NSString*)identifier percentComplete:(float)percent;
// Authenticate and check authentication
- (void) authenticateLocalPlayer;
- (BOOL) isLocalPlayerAuthenticated;

-(void) resetAchievements;
// Submitting score and achievements
- (void) submitScore:(int64_t)value category:(NSString*)category;
- (void) reportAchievement:(NSString*)identifier percentComplete:(float)percent;

-(void) showGameCenter;
// Resetting achievements
- (void) resetAchievements;

-(void) showLeaderboard;

-(void) showLeaderboardwithCategory:(NSString*)category timeScope:(int)tscope;

-(void) showAchievements;

-(GKAchievementDescription*) getAchievementDescription:(NSString*)identifier;
// Showing GameCenter
- (void) showGameCenter;
- (void) showLeaderboard;
- (void) showLeaderboardWithCategory:(NSString*)category timeScope:(int)tscope;
- (void) showAchievements;

// Achievement info
- (int) numberOfTotalAchievements;

- (int) numberOfCompletedAchievements;
- (GKAchievementDescription*) getAchievementDescription:(NSString*)identifier;

// -----------------------------------------------------------------
@end
// -----------------------------------------------------------------
Loading