PICO Unreal Platform SDK
Pico_Leaderboards.h
1// Copyright 2022 Pico Technology Co., Ltd.All rights reserved.
2// This plugin incorporates portions of the Unreal® Engine. Unreal® is a trademark or registered trademark of Epic Games, Inc.In the United States of America and elsewhere.
3// Unreal® Engine, Copyright 1998 – 2022, Epic Games, Inc.All rights reserved.
4#pragma once
5
6#include "CoreMinimal.h"
7#include "UObject/NoExportTypes.h"
8#include "PPF_Platform.h"
9#include "OnlineSubsystemPicoNames.h"
10#include "OnlineSubsystemPico.h"
11#include "Pico_User.h"
12#include "Pico_Leaderboards.generated.h"
13
15
16DECLARE_LOG_CATEGORY_EXTERN(PicoLeaderboards, Log, All);
17
18class UPico_Leaderboard;
19class UPico_LeaderboardEntry;
20class UPico_LeaderboardEntryArray;
21class UPico_LeaderboardArray;
22class UPico_User;
23
24
28DECLARE_DYNAMIC_DELEGATE_ThreeParams(FGet, bool, bIsError, const FString&, ErrorMessage, UPico_LeaderboardArray*, LeaderboardList);
29DECLARE_DYNAMIC_DELEGATE_ThreeParams(FGetEntries, bool, bIsError, const FString&, ErrorMessage, UPico_LeaderboardEntryArray*, LeaderboardEntryList);
30DECLARE_DYNAMIC_DELEGATE_ThreeParams(FGetEntriesAfterRank, bool, bIsError, const FString&, ErrorMessage, UPico_LeaderboardEntryArray*, LeaderboardEntryList);
31DECLARE_DYNAMIC_DELEGATE_ThreeParams(FGetEntriesByIds, bool, bIsError, const FString&, ErrorMessage, UPico_LeaderboardEntryArray*, LeaderboardEntryList);
32DECLARE_DYNAMIC_DELEGATE_ThreeParams(FWriteEntry, bool, bIsError, const FString&, ErrorMessage, bool, WriteResult);
33DECLARE_DYNAMIC_DELEGATE_ThreeParams(FWriteEntryWithSupplementaryMetric, bool, bIsError, const FString&, ErrorMessage, bool, WriteResult); // todo WriteResult
34
46class ONLINESUBSYSTEMPICO_API FPicoLeaderboardsInterface
47{
48private:
49
50 FOnlineSubsystemPico& PicoSubsystem;
51
52public:
53 FPicoLeaderboardsInterface(FOnlineSubsystemPico& InSubsystem);
55
56 FGet GetDelegate;
57 FGetEntries GetEntriesDelegate;
58 FGetEntriesAfterRank GetEntriesAfterRankDelegate;
59 FGetEntriesByIds GetEntriesByIdsDelegate;
60 FWriteEntry WriteEntryDelegate;
61 FWriteEntryWithSupplementaryMetric WriteEntryWithSupplementaryMetricDelegate;
62
72 bool Get(const FString& LeaderboardName, FGet InGetDelegate);
73
102 bool GetEntries(const FString& LeaderboardName, int PageIdx, int PageSize, ppfLeaderboardFilterType Filter, ppfLeaderboardStartAt StartAt, FGetEntries InGetEntriesDelegate);
103
117 bool GetEntriesAfterRank(const FString& LeaderboardName, int PageIdx, int PageSize, unsigned long long AfterRank, FGetEntriesAfterRank InGetEntriesAfterRankDelegate);
118
143 bool GetEntriesByIds(const FString& LeaderboardName, int PageIdx, int PageSize, ppfLeaderboardStartAt StartAt, const TArray<FString>& UserIDs, FGetEntriesByIds InGetEntriesByIdsDelegate);
144
159 bool WriteEntry(const FString& LeaderboardName, const int64& Score, const FString& ExtraData, bool ForceUpdate, FWriteEntry InWriteEntryDelegate);
160
176 bool WriteEntryWithSupplementaryMetric(const FString& LeaderboardName, const int64& Score, const int64& SupplementaryMetric, const FString& ExtraData, bool ForceUpdate, FWriteEntryWithSupplementaryMetric InWriteEntryWithSupplementaryMetricDelegate);
177
178};
194UCLASS()
195class ONLINESUBSYSTEMPICO_API UOnlinePicoLeaderboardsFunction : public UBlueprintFunctionLibrary
196{
197 GENERATED_BODY()
198
199
200public:
201
212 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|Leaderboards")
213 static void Get(UObject* WorldContextObject, const FString& LeaderboardName, FGet InGetDelegate);
214
244 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|Leaderboards")
245 static void GetEntries(UObject* WorldContextObject, const FString& LeaderboardName, int PageIdx, int PageSize, ELeaderboardFilterType Filter, ELeaderboardStartAt StartAt, FGetEntries InGetEntriesDelegate);
246
261 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|Leaderboards")
262 static void GetEntriesAfterRank(UObject* WorldContextObject, const FString& LeaderboardName, int PageIdx, int PageSize, const FString& AfterRank, FGetEntriesAfterRank InGetEntriesAfterRankDelegate);
263
289 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|Leaderboards")
290 static void GetEntriesByIds(UObject* WorldContextObject, const FString& LeaderboardName, int PageIdx, int PageSize, ELeaderboardStartAt StartAt, const TArray<FString>& UserIDs, FGetEntriesByIds InGetEntriesByIdsDelegate);
291
307 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|Leaderboards")
308 static void WriteEntry(UObject* WorldContextObject, const FString& LeaderboardName, const FString& Score, const FString& ExtraData, bool ForceUpdate, FWriteEntry InWriteEntryDelegate);
309
326 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "OnlinePico|Leaderboards")
327 static void WriteEntryWithSupplementaryMetric(UObject* WorldContextObject, const FString& LeaderboardName, const FString& Score, const FString& SupplementaryMetric, const FString& ExtraData, bool ForceUpdate, FWriteEntryWithSupplementaryMetric InWriteEntryWithSupplementaryMetricDelegate);
328
329};
330 // end of BP_Leaderboards // end of BlueprintFunction
333
334
335//
336UCLASS(BlueprintType)
337class ONLINESUBSYSTEMPICO_API UPico_LeaderboardEntry : public UObject
338{
339
340 GENERATED_BODY()
341
342public:
343 void InitParams(ppfLeaderboardEntryHandle ppfLeaderboardEntryHandle);
344
345private:
346 uint64_t ID = 0;
347 FString DisplayScore = FString();
348 int Rank = 0;
349 long Score = 0;
350 FPicoSupplementaryMetric SupplementaryMetricOptional;
351 unsigned long long Timestamp = 0;
352 UPROPERTY()
353 UPico_User* User = nullptr;
354 TArray<uint8> ExtraData;
355public:
356
357 UFUNCTION(BlueprintPure, Category = "Pico Platform|Leaderboards|Leaderboard Entry")
358 FString GetID();
359 UFUNCTION(BlueprintPure, Category = "Pico Platform|Leaderboards|Leaderboard Entry")
360 FString GetDisplayScore();
361 UFUNCTION(BlueprintPure, Category = "Pico Platform|Leaderboards|Leaderboard Entry")
362 int32 GetRank();
363 UFUNCTION(BlueprintPure, Category = "Pico Platform|Leaderboards|Leaderboard Entry")
364 int64 GetScore();
365 UFUNCTION(BlueprintPure, Category = "Pico Platform|Leaderboards|Leaderboard Entry")
366 FPicoSupplementaryMetric GetSupplementaryMetricOptional();
367 UFUNCTION(BlueprintPure, Category = "Pico Platform|Leaderboards|Leaderboard Entry")
368 FString GetTimestamp();
369 UFUNCTION(BlueprintPure, Category = "Pico Platform|Leaderboards|Leaderboard Entry")
370 FDateTime GetTimestampDateTime();
371 UFUNCTION(BlueprintPure, Category = "Pico Platform|Leaderboards|Leaderboard Entry")
372 UPico_User* GetUser();
373 UFUNCTION(BlueprintPure, Category = "Pico Platform|Leaderboards|Leaderboard Entry")
374 FString GetExtraDataString();
375
376};
377UCLASS(BlueprintType)
378class ONLINESUBSYSTEMPICO_API UPico_Leaderboard : public UObject
379{
380
381 GENERATED_BODY()
382
383public:
384 void InitParams(ppfLeaderboard* ppfLeaderboardHandle);
385
386private:
387 FString ApiName = FString();
388 uint64_t ID = 0;
389 FPicoDestination DestinationOptional;
390public:
391
392 UFUNCTION(BlueprintPure, Category = "Pico Platform|Leaderboards|Leaderboard")
393 FString GetApiName();
394
395 UFUNCTION(BlueprintPure, Category = "Pico Platform|Leaderboards|Leaderboard")
396 FString GetID();
397
398 UFUNCTION(BlueprintPure, Category = "Pico Platform|Leaderboards|Leaderboard")
399 FPicoDestination GetDestinationOptional();
400};
401
402UCLASS(BlueprintType)
403class ONLINESUBSYSTEMPICO_API UPico_LeaderboardEntryArray : public UObject
404{
405 GENERATED_BODY()
406private:
407 UPROPERTY()
408 TArray<UPico_LeaderboardEntry*> LeaderboardEntryArray;
409 FString NextPageParam = FString();
410 int32 Size = 0;
411 bool bHasNextPage;
412 int32 TotalSize = 0;
413public:
414 void InitParams(ppfLeaderboardEntryArrayHandle InppfLeaderboardEntryArrayHandle);
415
416 UFUNCTION(BlueprintPure, Category = "Pico Platform|Leaderboards|Leaderboard Entry Array")
417 UPico_LeaderboardEntry* GetElement(int32 Index);
418
419 UFUNCTION(BlueprintPure, Category = "Pico Platform|Leaderboards|Leaderboard Entry Array")
420 FString GetNextPageParam();
421
422 UFUNCTION(BlueprintPure, Category = "Pico Platform|Leaderboards|Leaderboard Entry Array")
423 int32 GetSize();
424
425 UFUNCTION(BlueprintPure, Category = "Pico Platform|Leaderboards|Leaderboard Entry Array")
426 int32 GetTotalSize();
427
428 UFUNCTION(BlueprintPure, Category = "Pico Platform|Leaderboards|Leaderboard Entry Array")
429 bool HasNextPage();
430};
431
432UCLASS(BlueprintType)
433class ONLINESUBSYSTEMPICO_API UPico_LeaderboardArray : public UObject
434{
435
436 GENERATED_BODY()
437private:
438 UPROPERTY()
439 TArray<UPico_Leaderboard*> LeaderboardArray;
440 FString NextPageParam = FString();
441 int32 Size = 0;
442 bool bHasNextPage;
443
444public:
445 void InitParams(ppfLeaderboardArrayHandle InppfLeaderboardArrayHandle);
446
447 UFUNCTION(BlueprintPure, Category = "Pico Platform|Leaderboards|Leaderboard Definition Array")
448 UPico_Leaderboard* GetElement(int32 Index);
449
450 UFUNCTION(BlueprintPure, Category = "Pico Platform|Leaderboards|Leaderboard Definition Array")
451 FString GetNextPageParam();
452
453 UFUNCTION(BlueprintPure, Category = "Pico Platform|Leaderboards|Leaderboard Definition Array")
454 int32 GetSize();
455
456 UFUNCTION(BlueprintPure, Category = "Pico Platform|Leaderboards|Leaderboard Definition Array")
457 bool HasNextPage();
458};
PicoLeaderboardsInterface class.
Definition: Pico_Leaderboards.h:47
bool WriteEntry(const FString &LeaderboardName, const int64 &Score, const FString &ExtraData, bool ForceUpdate, FWriteEntry InWriteEntryDelegate)
Writes a user's score to the leaderboard.
bool WriteEntryWithSupplementaryMetric(const FString &LeaderboardName, const int64 &Score, const int64 &SupplementaryMetric, const FString &ExtraData, bool ForceUpdate, FWriteEntryWithSupplementaryMetric InWriteEntryWithSupplementaryMetricDelegate)
Adds custom contents when writing a user's score to a leaderboard.
bool GetEntries(const FString &LeaderboardName, int PageIdx, int PageSize, ppfLeaderboardFilterType Filter, ppfLeaderboardStartAt StartAt, FGetEntries InGetEntriesDelegate)
Gets a list of leaderboard entries.
bool GetEntriesAfterRank(const FString &LeaderboardName, int PageIdx, int PageSize, unsigned long long AfterRank, FGetEntriesAfterRank InGetEntriesAfterRankDelegate)
Gets the leaderboard entries after a specified ranking.
bool GetEntriesByIds(const FString &LeaderboardName, int PageIdx, int PageSize, ppfLeaderboardStartAt StartAt, const TArray< FString > &UserIDs, FGetEntriesByIds InGetEntriesByIdsDelegate)
Gets the leaderboard entries for a specified user.
bool Get(const FString &LeaderboardName, FGet InGetDelegate)
Gets a specified leaderboard.
OnlinePicoLeaderboards Blueprint Function class.
Definition: Pico_Leaderboards.h:196
ELeaderboardStartAt
The type of sorting to use when getting leaderboard or challenge entries.
Definition: OnlineSubsystemPicoNames.h:648
ELeaderboardFilterType
The type of filter to use when using leaderboards or challenges.
Definition: OnlineSubsystemPicoNames.h:664
The destination information.
Definition: OnlineSubsystemPicoNames.h:199
Supplementary metrics for leaderboards.
Definition: OnlineSubsystemPicoNames.h:674