Compare commits
3 Commits
1c04ae6bd7
...
0a175f7813
| Author | SHA1 | Date | |
|---|---|---|---|
| 0a175f7813 | |||
| 4bbdf43ffa | |||
| 51e5898d4b |
@ -338,7 +338,8 @@ void SDTFluxStatusWidget::PopulateComboBoxItems()
|
||||
{
|
||||
FString Separator = " | ";
|
||||
FString RootSeparator = " -> ";
|
||||
TArray<FDTFluxContest> DataFromSubsystem = DTFluxCore->GetContests();
|
||||
TArray<FDTFluxContest> DataFromSubsystem = TArray<FDTFluxContest>();
|
||||
DTFluxCore->GetContests(DataFromSubsystem);
|
||||
|
||||
for (const auto& Contest : DataFromSubsystem)
|
||||
{
|
||||
|
||||
@ -13,6 +13,11 @@ UDTFluxModelAsset::UDTFluxModelAsset(const FObjectInitializer& ObjectInitializer
|
||||
void UDTFluxModelAsset::AddContest(const FDTFluxContest& Contest)
|
||||
{
|
||||
Contests.Add(Contest.Name, Contest);
|
||||
// initialisation
|
||||
for (const auto& Stage : Contest.Stages)
|
||||
{
|
||||
FinishedStagesCache.Add(FDTFluxStageKey(Contest.ContestId, Stage.StageId), Stage.IsFinished());
|
||||
}
|
||||
}
|
||||
|
||||
bool UDTFluxModelAsset::GetContestById(const int InContestId, FDTFluxContest& OutContest)
|
||||
@ -132,6 +137,32 @@ bool UDTFluxModelAsset::GetParticipantByBib(int Bib, FDTFluxParticipant& OutPart
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UDTFluxModelAsset::IsStageFinished(FDTFluxStageKey StageKey)
|
||||
{
|
||||
if (!FinishedStagesCache.Contains(StageKey))
|
||||
{
|
||||
if (FinishedStagesCache[StageKey])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
//maybe stage is finished because we have not be able to set it ?
|
||||
return CheckStageIsFinished(StageKey);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool UDTFluxModelAsset::CheckStageIsFinished(FDTFluxStageKey StageKey)
|
||||
{
|
||||
FDTFluxStage Stage;
|
||||
if (GetStage(StageKey, Stage))
|
||||
{
|
||||
FinishedStagesCache.Add(StageKey, Stage.IsFinished());
|
||||
return FinishedStagesCache[StageKey];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void UDTFluxModelAsset::UpdateOrCreateStageRanking(const FDTFluxStageRankings& InStageRankings)
|
||||
{
|
||||
|
||||
@ -2,6 +2,11 @@
|
||||
|
||||
#include "Types/Struct/DTFluxRaceDataStructs.h"
|
||||
|
||||
bool FDTFluxStage::IsFinished() const
|
||||
{
|
||||
return EndTime <= FDateTime::Now();
|
||||
}
|
||||
|
||||
bool FDTFluxContest::IsFinished() const
|
||||
{
|
||||
return EndTime <= FDateTime::Now();
|
||||
@ -62,6 +67,3 @@ bool FDTFluxContest::GetStage(const int StageID, FDTFluxStage& OutStage) const
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -3,6 +3,12 @@
|
||||
#include "Types/Struct/DTFluxRankingStructs.h"
|
||||
#include "DTFluxCoreModule.h"
|
||||
|
||||
bool FDTFluxBaseRankings::IsSealed(const FDateTime EndTime) const
|
||||
|
||||
{
|
||||
return ReceivedAt >= EndTime;
|
||||
}
|
||||
|
||||
void FDTFluxContestRanking::Dump() const
|
||||
{
|
||||
UE_LOG(logDTFluxCore, Log,
|
||||
|
||||
@ -89,4 +89,13 @@ public:
|
||||
|
||||
UFUNCTION(BlueprintCallable, CallInEditor, Category="DTFlux|Participant")
|
||||
bool GetParticipantByBib(int Bib, FDTFluxParticipant& OutParticipant);
|
||||
|
||||
UFUNCTION()
|
||||
bool IsStageFinished(FDTFluxStageKey StageKey);
|
||||
|
||||
private:
|
||||
UPROPERTY()
|
||||
TMap<FDTFluxStageKey, bool /*bIsFinished*/> FinishedStagesCache;
|
||||
UFUNCTION()
|
||||
bool CheckStageIsFinished(FDTFluxStageKey StageKey);
|
||||
};
|
||||
|
||||
@ -51,6 +51,7 @@ public:
|
||||
FDateTime EndTime;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
|
||||
FDateTime CutOff;
|
||||
bool IsFinished() const;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -98,4 +99,4 @@ public:
|
||||
UPROPERTY()
|
||||
// ReSharper disable once IdentifierTypo
|
||||
TArray<FDTFluxContest> Datas;
|
||||
};
|
||||
};
|
||||
|
||||
@ -8,6 +8,18 @@
|
||||
#include "DTFluxRankingStructs.generated.h"
|
||||
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct DTFLUXCORE_API FDTFluxBaseRankings
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", VisibleAnywhere)
|
||||
FDateTime ReceivedAt = FDateTime::Now();
|
||||
|
||||
bool IsSealed(const FDateTime EndTime) const;
|
||||
};
|
||||
|
||||
/**
|
||||
* @struct FDTFluxContestRanking
|
||||
* Representing a contest ranking for a participant
|
||||
@ -37,7 +49,7 @@ public:
|
||||
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FDTFluxContestRankings
|
||||
struct FDTFluxContestRankings : public FDTFluxBaseRankings
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
@ -94,7 +106,7 @@ public:
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FDTFluxDetailedRankings
|
||||
struct FDTFluxDetailedRankings : public FDTFluxBaseRankings
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
|
||||
@ -185,6 +185,46 @@ void UDTFluxCoreSubsystem::RegisterDelegates()
|
||||
}
|
||||
}
|
||||
|
||||
bool UDTFluxCoreSubsystem::IsStageRankingSealed(FDTFluxStageKey StageKey)
|
||||
{
|
||||
FDTFluxStageRankings StageRankings;
|
||||
if (GetStageRankingsWithKey(StageKey, StageRankings))
|
||||
{
|
||||
FDTFluxStage Stage;
|
||||
if (GetStageDefinition(StageKey, Stage))
|
||||
{
|
||||
return StageRankings.IsSealed(Stage.EndTime);
|
||||
}
|
||||
UE_LOG(logDTFluxCoreSubsystem, Error, TEXT("Unable to find Stage %i"), StageKey.StageId);
|
||||
return false;
|
||||
}
|
||||
UE_LOG(logDTFluxCoreSubsystem, Error, TEXT("Unable to find StageRankings for StageKey %i"), StageKey.StageId);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UDTFluxCoreSubsystem::IsContestRankingSealed(int ContestId)
|
||||
{
|
||||
if (DataStorage)
|
||||
{
|
||||
FDTFluxContestRankings ContestRankings;
|
||||
if (GetContestRankings(ContestId, ContestRankings))
|
||||
{
|
||||
FDTFluxContest Contest;
|
||||
if (GetContestForId(ContestId, Contest))
|
||||
{
|
||||
return ContestRankings.IsSealed(Contest.EndTime);
|
||||
}
|
||||
UE_LOG(logDTFluxCoreSubsystem, Error, TEXT("Unable to find Contest %i"), ContestId);
|
||||
return false;
|
||||
}
|
||||
UE_LOG(logDTFluxCoreSubsystem, Error, TEXT("Unable to find ContestRankings for ContestId %i"), ContestId);
|
||||
return false;
|
||||
}
|
||||
UE_LOG(logDTFluxCoreSubsystem, Error, TEXT("DataStorage not available"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void UDTFluxCoreSubsystem::ProcessRaceData(const FDTFluxRaceData& RaceDataDefinition)
|
||||
{
|
||||
if (RaceDataDefinition.Datas.Num() > 0)
|
||||
@ -288,6 +328,138 @@ void UDTFluxCoreSubsystem::SendRequest(const FString& Message)
|
||||
}
|
||||
}
|
||||
|
||||
FGuid UDTFluxCoreSubsystem::InitContestRankingsDisplay(const int ContestId)
|
||||
{
|
||||
if (NetworkSubsystem)
|
||||
{
|
||||
if (DataStorage)
|
||||
{
|
||||
// no need to request StageRankings;
|
||||
if (IsContestRankingSealed(ContestId))
|
||||
{
|
||||
const FGuid DisplayRequestId = FGuid::NewGuid();
|
||||
OnContestRankingDisplayReady.Broadcast(DisplayRequestId, true);
|
||||
return DisplayRequestId;
|
||||
}
|
||||
else
|
||||
{
|
||||
FOnDTFluxRequestSuccess OnSuccess = FOnDTFluxRequestSuccess::CreateLambda(
|
||||
[this](const FDTFluxTrackedRequest& Request)
|
||||
{
|
||||
FDTFluxContestRankings Rankings = FDTFluxContestRankings();
|
||||
if (Request.ParsedResponse.IsSet())
|
||||
{
|
||||
TSharedPtr<FDTFluxServerResponse> ResponsePtr = Request.ParsedResponse.GetValue();
|
||||
ResponsePtr->ParseContestRanking(Rankings);
|
||||
this->DataStorage->AddContestRanking(Rankings);
|
||||
this->OnContestRankingDisplayReady.Broadcast(Request.RequestId, true);
|
||||
return;
|
||||
}
|
||||
this->OnStageRankingDisplayReady.Broadcast(Request.RequestId, false);
|
||||
});
|
||||
FOnDTFluxRequestError OnError = FOnDTFluxRequestError::CreateLambda(
|
||||
[this](const FDTFluxTrackedRequest& InReq, const FString& InError)
|
||||
{
|
||||
this->OnStageRankingDisplayReady.Broadcast(InReq.RequestId, false);
|
||||
});
|
||||
FGuid DisplayRequestId = NetworkSubsystem->SendTrackedRequestWithCallbacks(
|
||||
EDTFluxApiDataType::ContestRanking, ContestId, -1, -1, OnSuccess, OnError, true);
|
||||
return DisplayRequestId;
|
||||
}
|
||||
}
|
||||
UE_LOG(logDTFluxCoreSubsystem, Error, TEXT("DTFluxDatastorage unavailable ..."));
|
||||
OnContestRankingDisplayReady.Broadcast(FGuid(), false);
|
||||
return FGuid();
|
||||
}
|
||||
UE_LOG(logDTFluxCoreSubsystem, Error, TEXT("DTFluxNetworkSubsystem unavailable ..."));
|
||||
OnContestRankingDisplayReady.Broadcast(FGuid(), false);
|
||||
return FGuid();
|
||||
}
|
||||
|
||||
FGuid UDTFluxCoreSubsystem::InitStageRankingsDisplay(const int ContestId, const int StageId)
|
||||
{
|
||||
if (NetworkSubsystem)
|
||||
{
|
||||
if (DataStorage)
|
||||
{
|
||||
// no need to request StageRankings;
|
||||
if (IsStageRankingSealed(FDTFluxStageKey(ContestId, StageId)))
|
||||
{
|
||||
const FGuid DisplayRequestId = FGuid::NewGuid();
|
||||
OnStageRankingDisplayReady.Broadcast(DisplayRequestId, true);
|
||||
return DisplayRequestId;
|
||||
}
|
||||
else
|
||||
{
|
||||
FOnDTFluxRequestSuccess OnSuccess = FOnDTFluxRequestSuccess::CreateLambda(
|
||||
[this](const FDTFluxTrackedRequest& Request)
|
||||
{
|
||||
FDTFluxStageRankings Rankings = FDTFluxStageRankings();
|
||||
if (Request.ParsedResponse.IsSet())
|
||||
{
|
||||
TSharedPtr<FDTFluxServerResponse> ResponsePtr = Request.ParsedResponse.GetValue();
|
||||
ResponsePtr->ParseStageRanking(Rankings);
|
||||
this->DataStorage->AddStageRanking(Rankings);
|
||||
this->OnStageRankingDisplayReady.Broadcast(Request.RequestId, true);
|
||||
return;
|
||||
}
|
||||
this->OnStageRankingDisplayReady.Broadcast(Request.RequestId, false);
|
||||
});
|
||||
FOnDTFluxRequestError OnError = FOnDTFluxRequestError::CreateLambda(
|
||||
[this](const FDTFluxTrackedRequest& InReq, const FString& InError)
|
||||
{
|
||||
this->OnStageRankingDisplayReady.Broadcast(InReq.RequestId, false);
|
||||
});
|
||||
FGuid DisplayRequestId = NetworkSubsystem->SendTrackedRequestWithCallbacks(
|
||||
EDTFluxApiDataType::StageRanking, ContestId, StageId, -1, OnSuccess, OnError, true);
|
||||
return DisplayRequestId;
|
||||
}
|
||||
}
|
||||
}
|
||||
UE_LOG(logDTFluxCoreSubsystem, Error, TEXT("DTFluxNetworkSubsystem unavailable ..."));
|
||||
const FGuid RequestId = FGuid::NewGuid();
|
||||
OnStageRankingDisplayReady.Broadcast(RequestId, false);
|
||||
return RequestId;
|
||||
}
|
||||
|
||||
FGuid UDTFluxCoreSubsystem::InitSplitRankingsDisplay(const int ContestId, const int StageId, const int SplitId)
|
||||
{
|
||||
if (NetworkSubsystem)
|
||||
{
|
||||
if (DataStorage)
|
||||
{
|
||||
FOnDTFluxRequestSuccess OnSuccess = FOnDTFluxRequestSuccess::CreateLambda(
|
||||
[this](const FDTFluxTrackedRequest& Request)
|
||||
{
|
||||
FDTFluxSplitRankings Rankings = FDTFluxSplitRankings();
|
||||
if (Request.ParsedResponse.IsSet())
|
||||
{
|
||||
TSharedPtr<FDTFluxServerResponse> ResponsePtr = Request.ParsedResponse.GetValue();
|
||||
ResponsePtr->ParseSplitRanking(Rankings);
|
||||
this->DataStorage->AddSplitRanking(Rankings);
|
||||
this->OnSplitRankingDisplayReady.Broadcast(Request.RequestId, true);
|
||||
return;
|
||||
}
|
||||
this->OnSplitRankingDisplayReady.Broadcast(Request.RequestId, false);
|
||||
});
|
||||
FOnDTFluxRequestError OnError = FOnDTFluxRequestError::CreateLambda(
|
||||
[this](const FDTFluxTrackedRequest& InReq, const FString& InError)
|
||||
{
|
||||
this->OnSplitRankingDisplayReady.Broadcast(InReq.RequestId, false);
|
||||
});
|
||||
FGuid DisplayRequestId = NetworkSubsystem->SendTrackedRequestWithCallbacks(
|
||||
EDTFluxApiDataType::ContestRanking, ContestId, StageId, SplitId, OnSuccess, OnError, true);
|
||||
return DisplayRequestId;
|
||||
}
|
||||
UE_LOG(logDTFluxCoreSubsystem, Error, TEXT("DTFluxDatastorage unavailable ..."));
|
||||
OnSplitRankingDisplayReady.Broadcast(FGuid(), false);
|
||||
return FGuid();
|
||||
}
|
||||
UE_LOG(logDTFluxCoreSubsystem, Error, TEXT("DTFluxNetworkSubsystem unavailable ..."));
|
||||
OnSplitRankingDisplayReady.Broadcast(FGuid(), false);
|
||||
return FGuid();
|
||||
}
|
||||
|
||||
bool UDTFluxCoreSubsystem::GetStageRankingForBib(const int ContestId, const int StageId, const int Bib,
|
||||
FDTFluxStageRanking& OutStageRanking)
|
||||
{
|
||||
@ -491,7 +663,6 @@ TArray<FGuid> UDTFluxCoreSubsystem::TrackedRequestStageRankings(const TArray<FDT
|
||||
UE_LOG(logDTFluxCoreSubsystem, Error, TEXT("StageRanking Request [%s] Error %s"),
|
||||
*InReq.RequestId.ToString(), *InError);
|
||||
});
|
||||
// if Contest is not ended
|
||||
for (auto StageKey : ForStages)
|
||||
{
|
||||
FGuid ContestRequest = NetworkSubsystem->SendTrackedRequestWithCallbacks(EDTFluxApiDataType::StageRanking,
|
||||
@ -554,24 +725,30 @@ TArray<int> UDTFluxCoreSubsystem::GetCurrentContestsId()
|
||||
return GetContestsIdForTime(FDateTime::Now());
|
||||
}
|
||||
|
||||
TArray<FDTFluxContest> UDTFluxCoreSubsystem::GetCurrentContests()
|
||||
bool UDTFluxCoreSubsystem::GetCurrentContests(TArray<FDTFluxContest>& OutContests)
|
||||
{
|
||||
return GetContestsForTime(FDateTime::Now());
|
||||
return GetContestsForTime(FDateTime::Now(), OutContests);
|
||||
}
|
||||
|
||||
TArray<int> UDTFluxCoreSubsystem::GetContestsIdForTime(const FDateTime Time) const
|
||||
TArray<int> UDTFluxCoreSubsystem::GetContestsIdForTime(const FDateTime Time)
|
||||
{
|
||||
TArray<int> Contests;
|
||||
for (const auto& Pair : DataStorage->Contests)
|
||||
if (DataStorage)
|
||||
{
|
||||
FDTFluxContest Contest = Pair.Value;
|
||||
int ContestId = Contest.ContestId;
|
||||
if (Contest.Date < Time && Contest.EndTime > Time)
|
||||
TArray<FDTFluxContest> Contests;
|
||||
if (GetContestsForTime(Time, Contests))
|
||||
{
|
||||
Contests.Add(ContestId);
|
||||
TArray<int> ContestIds = TArray<int>();
|
||||
for (const auto& Contest : Contests)
|
||||
{
|
||||
ContestIds.Add(Contest.ContestId);
|
||||
}
|
||||
return ContestIds;
|
||||
}
|
||||
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("No Contest running for Time [%s]"), *Time.ToString());
|
||||
return TArray<int>();
|
||||
}
|
||||
return Contests;
|
||||
UE_LOG(logDTFluxCoreSubsystem, Error, TEXT("DataStorage not available"));
|
||||
return TArray<int>();
|
||||
}
|
||||
|
||||
bool UDTFluxCoreSubsystem::GetContestForId(const int Id, FDTFluxContest& OutContest)
|
||||
@ -588,32 +765,119 @@ bool UDTFluxCoreSubsystem::GetContestForId(const int Id, FDTFluxContest& OutCont
|
||||
return false;
|
||||
}
|
||||
|
||||
TArray<FDTFluxContest> UDTFluxCoreSubsystem::GetContestsForTime(const FDateTime Time)
|
||||
{
|
||||
TArray<FDTFluxContest> Contests;
|
||||
for (const auto& Pair : DataStorage->Contests)
|
||||
{
|
||||
FDTFluxContest Contest = Pair.Value;
|
||||
int ContestId = Contest.ContestId;
|
||||
if (Contest.Date < Time && Contest.EndTime > Time)
|
||||
{
|
||||
Contests.Add(Contest);
|
||||
}
|
||||
}
|
||||
return Contests;
|
||||
}
|
||||
|
||||
void UDTFluxCoreSubsystem::RequestRankingsForStages(TArray<FDTFluxStage> RequestedStages) const
|
||||
{
|
||||
}
|
||||
|
||||
TArray<FDTFluxContest> UDTFluxCoreSubsystem::GetContests()
|
||||
bool UDTFluxCoreSubsystem::GetContestsForTime(const FDateTime Time, TArray<FDTFluxContest>& OutContests)
|
||||
{
|
||||
if (DataStorage)
|
||||
{
|
||||
TArray<FDTFluxContest> OutContests;
|
||||
DataStorage->Contests.GenerateValueArray(OutContests);
|
||||
return OutContests;
|
||||
OutContests.Empty();
|
||||
for (const auto& Pair : DataStorage->Contests)
|
||||
{
|
||||
FDTFluxContest Contest = Pair.Value;
|
||||
int ContestId = Contest.ContestId;
|
||||
|
||||
//ils ont commencé.
|
||||
if (Contest.Date < Time && Contest.EndTime > Time)
|
||||
{
|
||||
// ils sont finis
|
||||
if (!Contest.IsFinished())
|
||||
{
|
||||
OutContests.Add(Contest);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!OutContests.IsEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("No Contest running for Time [%s]"), *Time.ToString());
|
||||
}
|
||||
return TArray<FDTFluxContest>();
|
||||
UE_LOG(logDTFluxCoreSubsystem, Error, TEXT("DataStorage not available"));
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UDTFluxCoreSubsystem::GetContests(TArray<FDTFluxContest>& OutContests)
|
||||
{
|
||||
OutContests.Empty();
|
||||
if (DataStorage)
|
||||
{
|
||||
DataStorage->Contests.GenerateValueArray(OutContests);
|
||||
return !OutContests.IsEmpty();
|
||||
}
|
||||
UE_LOG(logDTFluxCoreSubsystem, Error, TEXT("DataStorage not available"));
|
||||
return false;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@ -41,6 +41,25 @@ public:
|
||||
UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem")
|
||||
FOnStageRankings OnStageRankings;
|
||||
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnContestRankingDisplayReady, const FGuid, RequestId, const bool,
|
||||
bSuccesRequest);
|
||||
|
||||
UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem")
|
||||
FOnContestRankingDisplayReady OnContestRankingDisplayReady;
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnStageRankingDisplayReady, const FGuid, RequestId, const bool,
|
||||
bSuccesRequest);
|
||||
|
||||
UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem")
|
||||
FOnStageRankingDisplayReady OnStageRankingDisplayReady;
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnSplitRankingDisplayReady, const FGuid, RequestId, const bool,
|
||||
bSuccesRequest);
|
||||
|
||||
UPROPERTY(BlueprintAssignable, Category="DTFlux|Core Subsystem")
|
||||
FOnSplitRankingDisplayReady OnSplitRankingDisplayReady;
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnContestRankings, const int, ContestId, FDTFluxContestRankings,
|
||||
ContestRankings);
|
||||
|
||||
@ -74,147 +93,73 @@ public:
|
||||
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Core Subsystem")
|
||||
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
|
||||
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Core Subsystem")
|
||||
bool bShouldKeepRankings = true;
|
||||
|
||||
UFUNCTION()
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
FGuid InitContestRankingsDisplay(const int ContestIds);
|
||||
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
FGuid InitStageRankingsDisplay(const int ContestId, const int StageId);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
FGuid InitSplitRankingsDisplay(const int ContestId, const int StageId, const int SplitId);
|
||||
|
||||
|
||||
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(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
TArray<int> GetCurrentContestsId();
|
||||
UFUNCTION()
|
||||
TArray<FDTFluxContest> GetCurrentContests();
|
||||
UFUNCTION()
|
||||
TArray<int> GetContestsIdForTime(const FDateTime Time) const;
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
bool GetCurrentContests(TArray<FDTFluxContest>& OutContests);
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
TArray<int> GetContestsIdForTime(const FDateTime Time);
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
bool GetContestForId(const int Id, FDTFluxContest& OutContest);
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
TArray<FDTFluxContest> GetContestsForTime(const FDateTime Time);
|
||||
|
||||
UFUNCTION()
|
||||
void RequestRankingsForStages(const TArray<FDTFluxStage> RequestedStages) const;
|
||||
UFUNCTION()
|
||||
TArray<FDTFluxContest> GetContests();
|
||||
|
||||
bool GetContestsForTime(const FDateTime Time, TArray<FDTFluxContest>& OutContests);
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
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)
|
||||
}
|
||||
|
||||
bool GetContests(TArray<FDTFluxContest>& OutContests);
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
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;
|
||||
}
|
||||
|
||||
void GetContest(const int ContestId, FDTFluxContest& OutContest);
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
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;
|
||||
}
|
||||
|
||||
bool GetStageDefinition(const FDTFluxStageKey StageKey, FDTFluxStage& OutStageDefinition);
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
void GetStage(const int ContestId, const int StageId, FDTFluxStage& OutStageDefinition)
|
||||
{
|
||||
if (GetStageDefinition(FDTFluxStageKey(ContestId, StageId),
|
||||
OutStageDefinition))
|
||||
{
|
||||
return;
|
||||
}
|
||||
OutStageDefinition = FDTFluxStage();
|
||||
}
|
||||
|
||||
bool GetSplitDefinition(const FDTFluxSplitKey SplitKey, FDTFluxSplit& OutSplitDefinition);
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
void GetSplit(const int ContestId, const int StageId, const int SplitId, FDTFluxSplit& OutSplitDefinition)
|
||||
{
|
||||
if (GetSplitDefinition(FDTFluxSplitKey(ContestId, StageId, SplitId),
|
||||
OutSplitDefinition))
|
||||
{
|
||||
return;
|
||||
}
|
||||
OutSplitDefinition = FDTFluxSplit();
|
||||
}
|
||||
void GetStage(const int ContestId, const int StageId, FDTFluxStage& OutStageDefinition);
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||
void GetSplit(const int ContestId, const int StageId, const int SplitId, FDTFluxSplit& OutSplitDefinition);
|
||||
|
||||
protected:
|
||||
// ~Subsystem Interface
|
||||
@ -251,4 +196,9 @@ private:
|
||||
void SendRequest(const FString& Message);
|
||||
UFUNCTION()
|
||||
void RegisterDelegates();
|
||||
|
||||
UFUNCTION()
|
||||
bool IsStageRankingSealed(FDTFluxStageKey StageKey);
|
||||
UFUNCTION()
|
||||
bool IsContestRankingSealed(int ContestId);
|
||||
};
|
||||
|
||||
@ -9,7 +9,7 @@ public class DTFluxUtilities : ModuleRules
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core",
|
||||
"Core"
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
#include "CoreMinimal.h"
|
||||
#include "DTFluxCore/Public/Types/Struct/DTFluxTeamListStruct.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "Types/Struct/DTFluxRankingStructs.h"
|
||||
#include "FTDFluxUtils.generated.h"
|
||||
|
||||
/**
|
||||
@ -23,4 +24,46 @@ public:
|
||||
static FText GetParticipantFormatedName(FDTFluxParticipant& Participant, const int MaxChar = 10,
|
||||
const FString Separator = ".",
|
||||
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