-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGameKit.cpp
77 lines (59 loc) · 1.84 KB
/
GameKit.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//
// GameKit.cpp
// Maw Kit
//
// Created by Lluís Ulzurrun de Asanza Sàez on 17/02/16.
//
//
#include "GameKit.hpp"
#include "_GameKit.hpp"
#include <algorithm>
#include <functional>
#include "Features.hpp"
#include "KVDatabase.hpp"
namespace MK {
namespace GameKit {
void init( std::function<void( void )> callback )
{
if ( MK::Features::GameKitLeaderboards || MK::Features::GameKitAchievements ) {
_init();
if ( callback != nullptr ) {
callback();
}
}
}
void requestScore( const LeaderboardIndex &leaderboardID, VoidLongLongBoolCB callback )
{
if ( !MK::Features::GameKitLeaderboards ) return;
_requestScore( int( leaderboardID ), callback );
}
void requestFriendsScores( const LeaderboardIndex &leaderboardID,
std::function<void( std::map<std::string, unsigned long long>, bool )>
callback )
{
if ( !MK::Features::GameKitLeaderboards ) return;
_requestFriendsScores( int( leaderboardID ), callback );
}
void submitScore( const long long score, const LeaderboardIndex &leaderboardID )
{
if ( !MK::Features::GameKitLeaderboards ) return;
_submitScore( score, int( leaderboardID ) );
}
void showLeaderboard( const LeaderboardIndex &leaderbaordID )
{
if ( !MK::Features::GameKitLeaderboards ) return;
_showLeaderboard( int( leaderbaordID ) );
}
void reportAchievementProgress( const AchievementIndex &achievementID, const float progress )
{
if ( !MK::Features::GameKitAchievements ) return;
_reportAchievementProgress( int( achievementID ),
std::min( 1.0, static_cast<double>( progress ) ) );
}
void requestAchievement( const AchievementIndex &achievementID, std::function<void( float, bool )> callback )
{
if ( !MK::Features::GameKitAchievements ) return;
_requestAchievement( int( achievementID ), callback );
}
}; // namespace GameKit
}; // namespace MK