Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Rubberduckycooly
GitHub Repository: Rubberduckycooly/RSDKv5-Decompilation
Path: blob/master/RSDKv5/RSDK/User/Core/UserLeaderboards.hpp
1168 views
1
#ifndef USER_LEADERBOARDS_H
2
#define USER_LEADERBOARDS_H
3
4
namespace RSDK
5
{
6
namespace SKU
7
{
8
struct LeaderboardID {
9
int32 idPS4; // leaderboard id (PS4)
10
int32 idUnknown; // leaderboard id (unknown platform)
11
int32 idSwitch; // leaderboard id (switch)
12
const char *idXbox; // Xbox One Leaderboard id (making an assumption based on the MS docs)
13
const char *idPC; // Leaderboard id (as a string, used for PC platforms)
14
};
15
16
struct LeaderboardAvail {
17
int32 start;
18
int32 length;
19
};
20
21
struct LeaderboardEntry {
22
String username;
23
#if RETRO_REV02
24
String userID;
25
#endif
26
int32 globalRank;
27
int32 score;
28
bool32 isUser;
29
int32 status;
30
};
31
32
#if RETRO_REV02
33
enum LeaderboardLoadTypes {
34
LEADERBOARD_LOAD_INIT,
35
LEADERBOARD_LOAD_PREV,
36
LEADERBOARD_LOAD_NEXT,
37
};
38
39
struct UserLeaderboards;
40
struct LeaderboardLoadList;
41
42
struct LeaderboardLoadInfo {
43
LeaderboardLoadList *parent;
44
int32 status;
45
LeaderboardAvail avail;
46
LeaderboardEntry entries[20];
47
uint8 disableLoadPrev;
48
uint8 disableLoadNext;
49
LeaderboardLoadInfo *prev;
50
LeaderboardLoadInfo *next;
51
int32 unused;
52
};
53
54
struct LeaderboardLoadList {
55
LeaderboardLoadInfo *InitLoadInfo();
56
void Clear();
57
void AddLoadInfoPrev(LeaderboardLoadInfo *info);
58
void AddLoadInfoNext(LeaderboardLoadInfo *info);
59
void RemoveLoadInfoPrev();
60
void RemoveLoadInfoNext();
61
62
UserLeaderboards *parent;
63
void *unused;
64
int32 count;
65
LeaderboardLoadInfo *prev;
66
LeaderboardLoadInfo *next;
67
LeaderboardLoadInfo *last;
68
};
69
70
struct LeaderboardEntryInfo {
71
void Setup();
72
void HandleTimers();
73
void LoadLeaderboardEntries(int32 start, uint32 length, int32 type);
74
75
UserLeaderboards *parent;
76
LeaderboardLoadList *loadList;
77
LeaderboardLoadTypes loadType;
78
LeaderboardAvail loadSize;
79
LeaderboardAvail viewSize;
80
LeaderboardEntry *entries[200];
81
};
82
83
// This is the base struct, it serves as the base for any API-specific stats
84
// This struct should never be removed
85
struct UserLeaderboards {
86
UserLeaderboards()
87
{
88
memset(&loadList, 0, sizeof(loadList));
89
memset(&entryInfo, 0, sizeof(entryInfo));
90
91
loadList.parent = this;
92
entryInfo.loadList = &loadList;
93
entryInfo.parent = this;
94
}
95
96
virtual ~UserLeaderboards() = default;
97
98
virtual void StageLoad()
99
{
100
this->currentLeaderboard = NULL;
101
this->status = STATUS_NONE;
102
103
this->loadList.prev = NULL;
104
this->loadList.next = NULL;
105
this->loadList.last = NULL;
106
this->loadList.count = 0;
107
this->loadList.unused = 0;
108
109
this->entryInfo.Setup();
110
}
111
virtual void FrameInit() { entryInfo.HandleTimers(); }
112
virtual void OnUnknownEvent() {}
113
#if RETRO_VER_EGS
114
virtual bool32 CheckLeaderboardsEnabled() { return true; }
115
#endif
116
virtual int32 InitLeaderboards() { return 0; }
117
virtual void FetchLeaderboard(LeaderboardID *leaderboard, bool32 isUser) {}
118
virtual void LoadLeaderboards(LeaderboardLoadInfo *info) {}
119
virtual void TrackScore(LeaderboardID *leaderboard, int32 score, void (*callback)(bool32 success, int32 rank)) {}
120
virtual int32 GetStatus() { return this->status; }
121
122
LeaderboardID *currentLeaderboard;
123
LeaderboardLoadList loadList;
124
LeaderboardEntryInfo entryInfo;
125
int32 status = STATUS_NONE;
126
int32 userRank = 0;
127
bool32 isUser = false;
128
};
129
#endif
130
131
// Start custom leaderboard code
132
// this is added because we don't have access to any store APIs that would otherwise use this feature
133
struct LeaderboardInfo {
134
char name[0x40];
135
int32 score;
136
};
137
138
extern std::vector<LeaderboardInfo> leaderboardList;
139
140
// End custom leaderboard code
141
142
#if RETRO_REV02
143
extern UserLeaderboards *leaderboards;
144
145
// ====================
146
// API Cores
147
// ====================
148
149
// Dummy API
150
#if RETRO_USERCORE_DUMMY
151
#include "RSDK/User/Dummy/DummyLeaderboards.hpp"
152
#endif
153
154
// Steam API
155
#if RETRO_USERCORE_STEAM
156
#include "RSDK/User/Steam/SteamLeaderboards.hpp"
157
#endif
158
159
// Epic Games API
160
#if RETRO_USERCORE_EOS
161
#include "RSDK/User/EOS/EOSLeaderboards.hpp"
162
#endif
163
164
// Switch API
165
#if RETRO_USERCORE_NX
166
#include "RSDK/User/NX/NXLeaderboards.hpp"
167
#endif
168
169
inline void InitLeaderboards() { leaderboards->InitLeaderboards(); }
170
#if RETRO_VER_EGS
171
inline bool32 CheckLeaderboardsEnabled() { return leaderboards->CheckLeaderboardsEnabled(); }
172
#endif
173
inline void FetchLeaderboard(LeaderboardID *leaderboard, bool32 isUser) { leaderboards->FetchLeaderboard(leaderboard, isUser); }
174
inline void TrackScore(LeaderboardID *leaderboard, int32 score, void (*callback)(bool32 success, int32 rank))
175
{
176
leaderboards->TrackScore(leaderboard, score, callback);
177
}
178
inline int32 GetLeaderboardsStatus() { return leaderboards->GetStatus(); }
179
180
inline LeaderboardAvail LeaderboardEntryViewSize() { return leaderboards->entryInfo.viewSize; }
181
inline LeaderboardAvail LeaderboardEntryLoadSize() { return leaderboards->entryInfo.loadSize; }
182
inline void LoadLeaderboardEntries(int32 start, uint32 length, int32 type) { leaderboards->entryInfo.LoadLeaderboardEntries(start, length, type); }
183
void ResetLeaderboardInfo();
184
LeaderboardEntry *ReadLeaderboardEntry(int32 entryID);
185
#endif
186
187
} // namespace SKU
188
} // namespace RSDK
189
190
#endif // USER_LEADERBOARDS_H
191
192