Space Plunder
Loading...
Searching...
No Matches
USetLeaderboard Class Reference

#include <SetLeaderboard.h>

Inheritance diagram for USetLeaderboard:

Static Public Member Functions

static USetLeaderboardSetLeaderboard (const FSteamLeaderboardHandle Handle, const ESteamLeaderboardUploadScoreMethod UploadMethod, const int32 NewScore, const TArray< int32 > NewScoreDetails)
 

Public Attributes

FResponseUploadLeaderboardDelegate OnSuccess
 
FResponseUploadLeaderboardDelegate OnFailure
 

Private Member Functions

virtual void Activate () override
 
void UploadLeaderboard ()
 
void OnUploadLeaderboard (LeaderboardScoreUploaded_t *pLeaderboardScoresUploaded, bool bIOFailure)
 

Private Attributes

FOnlineSubsystemSteam * SteamSubsystem
 
FSteamLeaderboardHandle LeaderboardHandle
 
ESteamLeaderboardUploadScoreMethod Method
 
int32 Score
 
TArray< int32 > ScoreDetails
 
CCallResult< USetLeaderboard, LeaderboardScoreUploaded_t > m_callUploadResult
 

Member Function Documentation

◆ Activate()

void USetLeaderboard::Activate ( )
overrideprivatevirtual
18{
19 if(SteamAPI_Init())
20 {
22 }
23 else
24 {
25 GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Failed to initialize the Steam API!"));
26 OnFailure.Broadcast(EResult::k_EResultFail);
27 RemoveFromRoot();
28 }
29}
void UploadLeaderboard()
Definition SetLeaderboard.cpp:31
FResponseUploadLeaderboardDelegate OnFailure
Definition SetLeaderboard.h:47

◆ OnUploadLeaderboard()

void USetLeaderboard::OnUploadLeaderboard ( LeaderboardScoreUploaded_t * pLeaderboardScoresUploaded,
bool bIOFailure )
private
48{
49 if(!bIOFailure)
50 {
51 AsyncTask(ENamedThreads::GameThread, [this]()
52 {
53 OnSuccess.Broadcast(EResult::k_EResultOK);
54 });
55 GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, TEXT("Leaderboards Uploaded!"));
56 if(pLeaderboardScoresUploaded->m_bSuccess)
57 {
58 UE_LOG(LogTemp,Warning,TEXT("Success Leaderboard Upload in Callback"));
59 }
60 }
61 else
62 {
63 GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Failed to Upload Leaderboard!"));
64 OnFailure.Broadcast(99);
65 }
66 RemoveFromRoot();
67}
FResponseUploadLeaderboardDelegate OnSuccess
Definition SetLeaderboard.h:44

◆ SetLeaderboard()

USetLeaderboard * USetLeaderboard::SetLeaderboard ( const FSteamLeaderboardHandle Handle,
const ESteamLeaderboardUploadScoreMethod UploadMethod,
const int32 NewScore,
const TArray< int32 > NewScoreDetails )
static
8{
9 USetLeaderboard* SelfRef = NewObject<USetLeaderboard>();
10 SelfRef->SteamSubsystem = static_cast<FOnlineSubsystemSteam*>(IOnlineSubsystem::Get());
11 SelfRef->LeaderboardHandle = Handle;
12 SelfRef->Score = NewScore;
13 SelfRef->ScoreDetails = NewScoreDetails;
14 return SelfRef;
15}
Definition SetLeaderboard.h:39
int32 Score
Definition SetLeaderboard.h:68
TArray< int32 > ScoreDetails
Definition SetLeaderboard.h:69
FOnlineSubsystemSteam * SteamSubsystem
Definition SetLeaderboard.h:61
FSteamLeaderboardHandle LeaderboardHandle
Definition SetLeaderboard.h:66

◆ UploadLeaderboard()

void USetLeaderboard::UploadLeaderboard ( )
private
32{
34 {
35 GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Invalid leaderboard handle!"));
36 OnFailure.Broadcast(EResult::k_EResultFail);
37 RemoveFromRoot();
38 return;
39 }
40 uint8 MethodIndex = static_cast<uint8>(Method);
41 const ELeaderboardUploadScoreMethod UploadMethod = static_cast<ELeaderboardUploadScoreMethod>(MethodIndex);
42 const int32* ScoreDetailsPtr = ScoreDetails.Num() > 0 ? ScoreDetails.GetData() : nullptr;
43 SteamAPICall_t hSteamAPICall = SteamUserStats()->UploadLeaderboardScore(LeaderboardHandle.Handle, k_ELeaderboardUploadScoreMethodForceUpdate, Score, ScoreDetailsPtr, ScoreDetails.Num());
45}
void OnUploadLeaderboard(LeaderboardScoreUploaded_t *pLeaderboardScoresUploaded, bool bIOFailure)
Definition SetLeaderboard.cpp:47
CCallResult< USetLeaderboard, LeaderboardScoreUploaded_t > m_callUploadResult
Definition SetLeaderboard.h:72
ESteamLeaderboardUploadScoreMethod Method
Definition SetLeaderboard.h:67
FSteamLeaderboard Handle
Definition LeaderboardData.h:71

Member Data Documentation

◆ LeaderboardHandle

FSteamLeaderboardHandle USetLeaderboard::LeaderboardHandle
private

◆ m_callUploadResult

CCallResult<USetLeaderboard, LeaderboardScoreUploaded_t> USetLeaderboard::m_callUploadResult
private

◆ Method

ESteamLeaderboardUploadScoreMethod USetLeaderboard::Method
private

◆ OnFailure

FResponseUploadLeaderboardDelegate USetLeaderboard::OnFailure

◆ OnSuccess

FResponseUploadLeaderboardDelegate USetLeaderboard::OnSuccess

◆ Score

int32 USetLeaderboard::Score
private

◆ ScoreDetails

TArray<int32> USetLeaderboard::ScoreDetails
private

◆ SteamSubsystem

FOnlineSubsystemSteam* USetLeaderboard::SteamSubsystem
private

The documentation for this class was generated from the following files: