-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGEDistributionPlatform.h
150 lines (119 loc) · 4.63 KB
/
GEDistributionPlatform.h
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
//////////////////////////////////////////////////////////////////
//
// Arturo Cepeda Pérez
// Game Engine
//
// Distribution Platform
//
// --- GEDistributionPlatform.h ---
//
//////////////////////////////////////////////////////////////////
#pragma once
#include "GESingleton.h"
#include "GEObject.h"
#include "GEDevice.h"
#include <atomic>
namespace GE { namespace Core
{
class DistributionPlatform : public Singleton<DistributionPlatform>
{
public:
struct LeaderboardEntry
{
uint16_t mPosition;
uint32_t mScore;
uint32_t mScoreDetail;
GESTLString mUserName;
const char* getUserName() const { return mUserName.c_str(); }
};
struct Leaderboard
{
ObjectName mLeaderboardName;
float mLeaderboardAge;
GESTLVector(LeaderboardEntry) mLeaderboardEntries;
Leaderboard() : mLeaderboardAge(0.0f) {}
};
struct Lobby
{
uint64_t mID;
uint64_t mOwnerID;
GESTLString mOwnerIP;
GESTLString mName;
uint16_t mOwnerPort;
bool mMember;
};
struct LobbyMember
{
uint64_t mID;
GESTLString mUserName;
};
private:
GESTLVector(Leaderboard) mLeaderboards;
GESTLVector(Lobby) mLobbies;
std::atomic<bool> mUpdatingLeaderboardScore;
std::atomic<bool> mRequestingLeaderboardScores;
std::atomic<bool> mSearchingForLobbies;
std::atomic<bool> mJoiningOrCreatingLobby;
std::atomic<uint32_t> mErrorCode;
void updateLeaderboardEntries(float pDeltaTime);
void addLeaderboardEntry(size_t pLeaderboardIndex, const LeaderboardEntry& pEntry);
public:
DistributionPlatform();
~DistributionPlatform();
bool init();
void update();
void shutdown();
const char* getPlatformName() const;
const char* getUserName() const;
SystemLanguage getLanguage() const;
// Network
bool internetConnectionAvailable() const;
bool loggedIn() const;
void logIn(std::function<void()> onFinished);
void logOut();
// Data storage
bool remoteFileExists(const char* pSubDir, const char* pName, const char* pExtension);
bool readRemoteFile(const char* pSubDir, const char* pName, const char* pExtension,
Content::ContentData* pContentData, std::function<void()> pOnFinished = nullptr);
bool writeRemoteFile(const char* pSubDir, const char* pName, const char* pExtension,
const Content::ContentData* pContentData, std::function<void(bool pSuccess)> pOnFinished = nullptr);
bool deleteRemoteFile(const char* pSubDir, const char* pName, const char* pExtension);
// Stats
void setStat(const ObjectName& pStatName, float pValue);
float getStat(const ObjectName& pStatName);
// Achievements
void unlockAchievement(const ObjectName& pAchievementName);
// Leaderboards
void updateLeaderboardScore(const ObjectName& pLeaderboardName, uint32_t pScore, uint32_t pScoreDetail);
bool updatingLeaderboardScore() const;
void resetLeaderboard(const ObjectName& pLeaderboardName);
void requestLeaderboardScores(const ObjectName& pLeaderboardName, uint16_t pFirstPosition, uint16_t pLastPosition);
void requestLeaderboardScoresAroundUser(const ObjectName& pLeaderboardName, uint16_t pPositionsCount);
bool requestingLeaderboardScores() const;
float getLeaderboardAge(const ObjectName& pLeaderboardName) const;
size_t getLeaderboardEntriesCount(const ObjectName& pLeaderboardName) const;
const LeaderboardEntry* getLeaderboardEntry(const ObjectName& pLeaderboardName, size_t pEntryIndex) const;
// DLCs
bool isDLCAvailable(const ObjectName& pDLCName) const;
void requestDLCPurchase(const char* pURL) const;
bool processingDLCPurchaseRequest() const;
// Matchmaking
void findLobbies();
bool searchingForLobbies() const;
void createLobby(const char* pName, uint32_t pMaxMembers);
void joinLobby(const Lobby* pLobby);
void leaveLobby(const Lobby* pLobby);
bool isJoinOrCreateLobbyFeatureAvailable() const;
void joinOrCreateLobby(const char* pName, uint32_t pMaxMembers);
bool joiningOrCreatingLobby() const;
size_t getLobbyMembersCount(const Lobby* pLobby) const;
bool getLobbyMember(const Lobby* pLobby, size_t pIndex, LobbyMember* pOutMember);
size_t getLobbiesCount() const;
const Lobby* getLobby(size_t pIndex) const;
// Ads
void showFullscreenAd(const char* pID);
// Error management
void resetErrorCode();
uint32_t getErrorCode() const;
};
}}