Cosmetic CoreSubsystem cleaning + Added DTFluxDetailedRanking Casting functions
This commit is contained in:
@ -617,3 +617,78 @@ TArray<FDTFluxContest> UDTFluxCoreSubsystem::GetContests()
|
|||||||
}
|
}
|
||||||
return TArray<FDTFluxContest>();
|
return TArray<FDTFluxContest>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UDTFluxCoreSubsystem::GetContest(const int ContestId, FDTFluxContest& OutContest)
|
||||||
|
{
|
||||||
|
OutContest = FDTFluxContest();
|
||||||
|
if (GetContestForId(ContestId, OutContest))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("ContestId %d not found in ContestDefinition"), ContestId)
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UDTFluxCoreSubsystem::GetStageDefinition(const FDTFluxStageKey StageKey, FDTFluxStage& OutStageDefinition)
|
||||||
|
{
|
||||||
|
int ContestId = StageKey.ContestId;
|
||||||
|
int StageId = StageKey.StageId;
|
||||||
|
FDTFluxContest ContestDefinition;
|
||||||
|
if (GetContestForId(ContestId, ContestDefinition))
|
||||||
|
{
|
||||||
|
for (auto& Stage : ContestDefinition.Stages)
|
||||||
|
{
|
||||||
|
if (Stage.StageId == StageId)
|
||||||
|
{
|
||||||
|
OutStageDefinition = Stage;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
OutStageDefinition = FDTFluxStage();
|
||||||
|
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("ContestId %d, StageId %d not found in ContestDefinition"),
|
||||||
|
ContestId, StageId)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UDTFluxCoreSubsystem::GetSplitDefinition(const FDTFluxSplitKey SplitKey, FDTFluxSplit& OutSplitDefinition)
|
||||||
|
{
|
||||||
|
int ContestId = SplitKey.ContestId;
|
||||||
|
int SplitId = SplitKey.SplitId;
|
||||||
|
FDTFluxContest ContestDefinition;
|
||||||
|
if (GetContestForId(ContestId, ContestDefinition))
|
||||||
|
{
|
||||||
|
for (auto& Split : ContestDefinition.Splits)
|
||||||
|
{
|
||||||
|
if (Split.SplitId == SplitId)
|
||||||
|
{
|
||||||
|
OutSplitDefinition = Split;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
OutSplitDefinition = FDTFluxSplit();
|
||||||
|
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("ContestId %d, SplitId %d not found in ContestDefinition"),
|
||||||
|
ContestId, SplitId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UDTFluxCoreSubsystem::GetStage(const int ContestId, const int StageId, FDTFluxStage& OutStageDefinition)
|
||||||
|
{
|
||||||
|
if (GetStageDefinition(FDTFluxStageKey(ContestId, StageId),
|
||||||
|
OutStageDefinition))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
OutStageDefinition = FDTFluxStage();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UDTFluxCoreSubsystem::GetSplit(const int ContestId, const int StageId, const int SplitId,
|
||||||
|
FDTFluxSplit& OutSplitDefinition)
|
||||||
|
{
|
||||||
|
if (GetSplitDefinition(FDTFluxSplitKey(ContestId, StageId, SplitId),
|
||||||
|
OutSplitDefinition))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
OutSplitDefinition = FDTFluxSplit();
|
||||||
|
}
|
||||||
|
|||||||
@ -74,53 +74,39 @@ public:
|
|||||||
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Core Subsystem")
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Core Subsystem")
|
||||||
FOnWinner OnWinner;
|
FOnWinner OnWinner;
|
||||||
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
|
||||||
bool GetStageRankingForBib(const int ContestId, const int StageId, const int Bib,
|
|
||||||
FDTFluxStageRanking& OutStageRankings);
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
|
||||||
bool GetSplitRankingForBib(const int ContestId, const int StageId, const int SplitId, const int Bib,
|
|
||||||
FDTFluxSplitRanking& OutSplitRankings);
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
|
||||||
bool GetContestRanking(const int ContestId, FDTFluxContestRanking& OutContestRanking);
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
|
||||||
bool GetContestRankings(const int ContestId, FDTFluxContestRankings& OutContestRankings);
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
|
||||||
bool GetStageRankings(const int ContestId, const int StageId, FDTFluxStageRankings& OutStageRankings);
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
|
||||||
bool GetSplitRankings(const int ContestId, const int StageId, const int SplitId,
|
|
||||||
FDTFluxSplitRankings& OutSplitRankings);
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
|
||||||
bool GetStageRankingsWithKey(const FDTFluxStageKey StageKey, FDTFluxStageRankings& OutStageRankings,
|
|
||||||
const bool bShouldUseCached = true);
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
|
||||||
bool GetSplitRankingsWithKey(const FDTFluxSplitKey SplitKey, FDTFluxSplitRankings& OutSplitRankings,
|
|
||||||
const bool bShouldUseCached = true);
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
|
||||||
TArray<FGuid> TrackedRequestContestRankings(const TArray<int> ForContests, bool bEnableCache = true);
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
|
||||||
TArray<FGuid> TrackedRequestStageRankings(const TArray<FDTFluxStageKey> ForStages, bool bEnableCache = true);
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
|
||||||
TArray<FGuid> TrackedRequestSplitRankings(const TArray<FDTFluxSplitKey> ForSplits, bool bEnableCache = true);
|
|
||||||
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
|
||||||
bool GetParticipant(int InBib, FDTFluxParticipant& OutParticipant);
|
|
||||||
|
|
||||||
//TODO : this must be a ProjectSetting
|
//TODO : this must be a ProjectSetting
|
||||||
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Core Subsystem")
|
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Core Subsystem")
|
||||||
bool bShouldKeepRankings = true;
|
bool bShouldKeepRankings = true;
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||||
|
bool GetStageRankingForBib(const int ContestId, const int StageId, const int Bib,
|
||||||
|
FDTFluxStageRanking& OutStageRankings);
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||||
|
bool GetSplitRankingForBib(const int ContestId, const int StageId, const int SplitId, const int Bib,
|
||||||
|
FDTFluxSplitRanking& OutSplitRankings);
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||||
|
bool GetContestRanking(const int ContestId, FDTFluxContestRanking& OutContestRanking);
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||||
|
bool GetContestRankings(const int ContestId, FDTFluxContestRankings& OutContestRankings);
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||||
|
bool GetStageRankings(const int ContestId, const int StageId, FDTFluxStageRankings& OutStageRankings);
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||||
|
bool GetSplitRankings(const int ContestId, const int StageId, const int SplitId,
|
||||||
|
FDTFluxSplitRankings& OutSplitRankings);
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||||
|
bool GetStageRankingsWithKey(const FDTFluxStageKey StageKey, FDTFluxStageRankings& OutStageRankings,
|
||||||
|
const bool bShouldUseCached = true);
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||||
|
bool GetSplitRankingsWithKey(const FDTFluxSplitKey SplitKey, FDTFluxSplitRankings& OutSplitRankings,
|
||||||
|
const bool bShouldUseCached = true);
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||||
|
TArray<FGuid> TrackedRequestContestRankings(const TArray<int> ForContests, bool bEnableCache = true);
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||||
|
TArray<FGuid> TrackedRequestStageRankings(const TArray<FDTFluxStageKey> ForStages, bool bEnableCache = true);
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||||
|
TArray<FGuid> TrackedRequestSplitRankings(const TArray<FDTFluxSplitKey> ForSplits, bool bEnableCache = true);
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||||
|
bool GetParticipant(int InBib, FDTFluxParticipant& OutParticipant);
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
TArray<int> GetCurrentContestsId();
|
TArray<int> GetCurrentContestsId();
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
@ -131,90 +117,20 @@ public:
|
|||||||
bool GetContestForId(const int Id, FDTFluxContest& OutContest);
|
bool GetContestForId(const int Id, FDTFluxContest& OutContest);
|
||||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||||
TArray<FDTFluxContest> GetContestsForTime(const FDateTime Time);
|
TArray<FDTFluxContest> GetContestsForTime(const FDateTime Time);
|
||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void RequestRankingsForStages(const TArray<FDTFluxStage> RequestedStages) const;
|
void RequestRankingsForStages(const TArray<FDTFluxStage> RequestedStages) const;
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
TArray<FDTFluxContest> GetContests();
|
TArray<FDTFluxContest> GetContests();
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||||
void GetContest(const int ContestId, FDTFluxContest& OutContest)
|
void GetContest(const int ContestId, FDTFluxContest& OutContest);
|
||||||
{
|
|
||||||
OutContest = FDTFluxContest();
|
|
||||||
if (GetContestForId(ContestId, OutContest))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("ContestId %d not found in ContestDefinition"), ContestId)
|
|
||||||
}
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||||
bool GetStageDefinition(const FDTFluxStageKey StageKey, FDTFluxStage& OutStageDefinition)
|
bool GetStageDefinition(const FDTFluxStageKey StageKey, FDTFluxStage& OutStageDefinition);
|
||||||
{
|
|
||||||
int ContestId = StageKey.ContestId;
|
|
||||||
int StageId = StageKey.StageId;
|
|
||||||
FDTFluxContest ContestDefinition;
|
|
||||||
if (GetContestForId(ContestId, ContestDefinition))
|
|
||||||
{
|
|
||||||
for (auto& Stage : ContestDefinition.Stages)
|
|
||||||
{
|
|
||||||
if (Stage.StageId == StageId)
|
|
||||||
{
|
|
||||||
OutStageDefinition = Stage;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
OutStageDefinition = FDTFluxStage();
|
|
||||||
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("ContestId %d, StageId %d not found in ContestDefinition"),
|
|
||||||
ContestId, StageId)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||||
bool GetSplitDefinition(const FDTFluxSplitKey SplitKey, FDTFluxSplit& OutSplitDefinition)
|
bool GetSplitDefinition(const FDTFluxSplitKey SplitKey, FDTFluxSplit& OutSplitDefinition);
|
||||||
{
|
|
||||||
int ContestId = SplitKey.ContestId;
|
|
||||||
int SplitId = SplitKey.SplitId;
|
|
||||||
FDTFluxContest ContestDefinition;
|
|
||||||
if (GetContestForId(ContestId, ContestDefinition))
|
|
||||||
{
|
|
||||||
for (auto& Split : ContestDefinition.Splits)
|
|
||||||
{
|
|
||||||
if (Split.SplitId == SplitId)
|
|
||||||
{
|
|
||||||
OutSplitDefinition = Split;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
OutSplitDefinition = FDTFluxSplit();
|
|
||||||
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("ContestId %d, SplitId %d not found in ContestDefinition"),
|
|
||||||
ContestId, SplitId);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||||
void GetStage(const int ContestId, const int StageId, FDTFluxStage& OutStageDefinition)
|
void GetStage(const int ContestId, const int StageId, FDTFluxStage& OutStageDefinition);
|
||||||
{
|
|
||||||
if (GetStageDefinition(FDTFluxStageKey(ContestId, StageId),
|
|
||||||
OutStageDefinition))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
OutStageDefinition = FDTFluxStage();
|
|
||||||
}
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||||
void GetSplit(const int ContestId, const int StageId, const int SplitId, FDTFluxSplit& OutSplitDefinition)
|
void GetSplit(const int ContestId, const int StageId, const int SplitId, FDTFluxSplit& OutSplitDefinition);
|
||||||
{
|
|
||||||
if (GetSplitDefinition(FDTFluxSplitKey(ContestId, StageId, SplitId),
|
|
||||||
OutSplitDefinition))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
OutSplitDefinition = FDTFluxSplit();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// ~Subsystem Interface
|
// ~Subsystem Interface
|
||||||
|
|||||||
@ -9,7 +9,7 @@ public class DTFluxUtilities : ModuleRules
|
|||||||
PublicDependencyModuleNames.AddRange(
|
PublicDependencyModuleNames.AddRange(
|
||||||
new string[]
|
new string[]
|
||||||
{
|
{
|
||||||
"Core",
|
"Core"
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "DTFluxCore/Public/Types/Struct/DTFluxTeamListStruct.h"
|
#include "DTFluxCore/Public/Types/Struct/DTFluxTeamListStruct.h"
|
||||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||||
|
#include "Types/Struct/DTFluxRankingStructs.h"
|
||||||
#include "FTDFluxUtils.generated.h"
|
#include "FTDFluxUtils.generated.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,4 +24,46 @@ public:
|
|||||||
static FText GetParticipantFormatedName(FDTFluxParticipant& Participant, const int MaxChar = 10,
|
static FText GetParticipantFormatedName(FDTFluxParticipant& Participant, const int MaxChar = 10,
|
||||||
const FString Separator = ".",
|
const FString Separator = ".",
|
||||||
const FString OverFlowChar = "...");
|
const FString OverFlowChar = "...");
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Utils", Meta=(Keywords="convert, StageRankings, DTFlux"))
|
||||||
|
static void CastToDTFluxStageRanking(const FDTFluxDetailedRankingItem& ItemRanking, FDTFluxStageRanking& OutRanking)
|
||||||
|
{
|
||||||
|
CastRankingItem<FDTFluxStageRanking>(ItemRanking, OutRanking);
|
||||||
|
}
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Utils", Meta=(Keywords="convert, StageRankings, DTFlux"))
|
||||||
|
static void CastToDTFluxStageRankingArray(const TArray<FDTFluxDetailedRankingItem>& ItemRanking,
|
||||||
|
TArray<FDTFluxStageRanking>& OutRanking)
|
||||||
|
{
|
||||||
|
CastRankingArray<FDTFluxStageRanking>(ItemRanking, OutRanking);
|
||||||
|
}
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Utils", Meta=(Keywords="convert, StageRankings, DTFlux"))
|
||||||
|
static void CastToDTFluxSplitRanking(const FDTFluxDetailedRankingItem& ItemRanking, FDTFluxSplitRanking& OutRanking)
|
||||||
|
{
|
||||||
|
CastRankingItem<FDTFluxSplitRanking>(ItemRanking, OutRanking);
|
||||||
|
}
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Utils", Meta=(Keywords="convert, StageRankings, DTFlux"))
|
||||||
|
static void CastToDTFluxSplitRankingArray(const TArray<FDTFluxDetailedRankingItem>& ItemRanking,
|
||||||
|
TArray<FDTFluxSplitRanking>& OutRanking)
|
||||||
|
{
|
||||||
|
CastRankingArray<FDTFluxSplitRanking>(ItemRanking, OutRanking);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
static void CastRankingItem(const FDTFluxDetailedRankingItem& ItemRanking, T& OutRanking)
|
||||||
|
{
|
||||||
|
OutRanking = static_cast<T>(ItemRanking);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
static void CastRankingArray(const TArray<FDTFluxDetailedRankingItem>& ItemRanking, TArray<T>& OutRanking)
|
||||||
|
{
|
||||||
|
OutRanking.Empty();
|
||||||
|
for (auto& Item : ItemRanking)
|
||||||
|
{
|
||||||
|
OutRanking.Add(static_cast<T>(Item));
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user