Adds Custom DataAsset UI + Added Request buttons for RaceDatas/TeamList/Rankings request to ApiStatus Tab + Addes Tracked Requests For Rankings + Added Utils Module For Blueprint Utilities Functions
This commit is contained in:
@ -10,21 +10,31 @@ UDTFluxModelAsset::UDTFluxModelAsset(const FObjectInitializer& ObjectInitializer
|
||||
{
|
||||
}
|
||||
|
||||
void UDTFluxModelAsset::AddContest(const FDTFluxContest &Contest)
|
||||
void UDTFluxModelAsset::AddContest(const FDTFluxContest& Contest)
|
||||
{
|
||||
Contests.Add(Contest.Name, Contest);
|
||||
}
|
||||
|
||||
bool UDTFluxModelAsset::GetContestById(const int InContestId, FDTFluxContest& OutContest)
|
||||
{
|
||||
for(auto& ContestItem : Contests)
|
||||
for (auto& ContestItem : Contests)
|
||||
{
|
||||
if(ContestItem.Value.ContestId == InContestId)
|
||||
if (ContestItem.Value.ContestId == InContestId)
|
||||
{
|
||||
OutContest = ContestItem.Value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UDTFluxModelAsset::GetStage(FDTFluxStageKey StageKey, FDTFluxStage& OutStage)
|
||||
{
|
||||
FDTFluxContest TargetContest;
|
||||
int TargetStageId = StageKey.StageId;
|
||||
if (GetContestById(StageKey.ContestId, TargetContest))
|
||||
{
|
||||
return TargetContest.GetStage(TargetStageId, OutStage);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -36,19 +46,20 @@ void UDTFluxModelAsset::AddPerson(const FDTFluxPerson& InPerson)
|
||||
|
||||
void UDTFluxModelAsset::AddParticipant(const FDTFluxParticipant& InParticipant, const int ContestId)
|
||||
{
|
||||
UE_LOG(logDTFluxCore, Error, TEXT("%i Person in Participant %i"), InParticipant.GetTeammateNum(), InParticipant.Bib);
|
||||
UE_LOG(logDTFluxCore, Error, TEXT("%i Person in Participant %i"), InParticipant.GetTeammateNum(),
|
||||
InParticipant.Bib);
|
||||
FDTFluxContest TargetContest;
|
||||
if(GetContestById(ContestId, TargetContest))
|
||||
if (GetContestById(ContestId, TargetContest))
|
||||
{
|
||||
TArray<FDTFluxPerson> Teammate = InParticipant.Teammate;
|
||||
for(auto& Person : InParticipant.Teammate)
|
||||
for (auto& Person : InParticipant.Teammate)
|
||||
{
|
||||
UE_LOG(logDTFluxCore, Error, TEXT("AddParticipant() DTFlux Person %s %s %s"),
|
||||
*Person.FirstName, *Person.LastName, *Person.Gender);
|
||||
if(!PersonExists(Person))
|
||||
*Person.FirstName, *Person.LastName, *Person.Gender);
|
||||
if (!PersonExists(Person))
|
||||
{
|
||||
UE_LOG(logDTFluxCore, Error, TEXT("AddParticipant() DTFlux Person %s %s %s doesnot exists, adding..."),
|
||||
*Person.FirstName, *Person.LastName, *Person.Gender);
|
||||
*Person.FirstName, *Person.LastName, *Person.Gender);
|
||||
AddPerson(Person);
|
||||
}
|
||||
}
|
||||
@ -68,10 +79,11 @@ bool UDTFluxModelAsset::PersonExists(const FDTFluxPerson& InPerson) const
|
||||
FString UDTFluxModelAsset::GetContestNameForId(const int InContestID)
|
||||
{
|
||||
FDTFluxContest Contest;
|
||||
if(!GetContestById(InContestID, Contest))
|
||||
if (!GetContestById(InContestID, Contest))
|
||||
{
|
||||
UE_LOG(logDTFluxCore, Warning, TEXT("GetContestNameForId(%i) [unable to find a contest] result will be empty !!!"),
|
||||
InContestID);
|
||||
UE_LOG(logDTFluxCore, Warning,
|
||||
TEXT("GetContestNameForId(%i) [unable to find a contest] result will be empty !!!"),
|
||||
InContestID);
|
||||
}
|
||||
return Contest.Name;
|
||||
}
|
||||
@ -85,7 +97,7 @@ void UDTFluxModelAsset::UpdateParticipant(const FDTFluxParticipant& Participant)
|
||||
{
|
||||
// TODO : If update is on Bib we are totally lost as we search by bib.
|
||||
int Bib = Participant.Bib;
|
||||
if(Participants.Contains(Bib))
|
||||
if (Participants.Contains(Bib))
|
||||
{
|
||||
TArray<FDTFluxPerson> InTeammate = Participant.Teammate;
|
||||
Participants[Bib].Elite = Participant.Elite;
|
||||
@ -95,7 +107,7 @@ void UDTFluxModelAsset::UpdateParticipant(const FDTFluxParticipant& Participant)
|
||||
Participants[Bib].Team = Participant.Team;
|
||||
Participants[Bib].Status = Participant.Status;
|
||||
//TODO : Update Person
|
||||
for(const auto& Person : InTeammate)
|
||||
for (const auto& Person : InTeammate)
|
||||
{
|
||||
//Don't know what to do...
|
||||
}
|
||||
@ -104,12 +116,23 @@ void UDTFluxModelAsset::UpdateParticipant(const FDTFluxParticipant& Participant)
|
||||
|
||||
void UDTFluxModelAsset::UpdateParticipantStatus(const FDTFluxTeamStatusUpdate& NewParticipantStatus)
|
||||
{
|
||||
if(Participants.Contains(NewParticipantStatus.Bib))
|
||||
if (Participants.Contains(NewParticipantStatus.Bib))
|
||||
{
|
||||
Participants[NewParticipantStatus.Bib].Status = NewParticipantStatus.Status;
|
||||
}
|
||||
}
|
||||
|
||||
bool UDTFluxModelAsset::GetParticipantByBib(int Bib, FDTFluxParticipant& OutParticipant)
|
||||
{
|
||||
if (Participants.Contains(Bib))
|
||||
{
|
||||
OutParticipant = Participants[Bib];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void UDTFluxModelAsset::UpdateOrCreateStageRanking(const FDTFluxStageRankings& InStageRankings)
|
||||
{
|
||||
FDTFluxStageKey StageKey = InStageRankings.GetCompositeKey();
|
||||
|
||||
@ -18,8 +18,9 @@ bool UDTFluxParticipantFactory::CreateParticipantFomJson(const FString& JsonStri
|
||||
}
|
||||
}
|
||||
|
||||
bool UDTFluxParticipantFactory::CreateFromJsonCpp(const TSharedPtr<FJsonObject> JsonObject, FDTFluxParticipant& OutParticipant)
|
||||
bool UDTFluxParticipantFactory::CreateFromJsonCpp(const TSharedPtr<FJsonObject> JsonObject,
|
||||
FDTFluxParticipant& OutParticipant)
|
||||
{
|
||||
OutParticipant = FDTFluxParticipant::CreateFromJson(JsonObject);
|
||||
return OutParticipant == 0;
|
||||
return !OutParticipant.IsDefault();
|
||||
}
|
||||
|
||||
@ -4,8 +4,6 @@
|
||||
#include "Types/Struct/DTFluxTeamListStruct.h"
|
||||
|
||||
|
||||
|
||||
|
||||
void FDTFluxParticipant::AddTeammate(const FDTFluxPerson& Person)
|
||||
{
|
||||
Teammate.Add(Person);
|
||||
@ -15,19 +13,24 @@ void FDTFluxParticipant::AddTeammate(const FString LastName, const FString First
|
||||
{
|
||||
}
|
||||
|
||||
FText FDTFluxParticipant::GetFormattedName(const int MaxChar, const FString OverflowChars)
|
||||
FString FDTFluxParticipant::GetFormattedName(const int MaxChar, const FString OverflowChars) const
|
||||
{
|
||||
// Vérifie les cas limites
|
||||
if (MaxChar <= 0)
|
||||
{
|
||||
return FText::GetEmpty();
|
||||
return "";
|
||||
}
|
||||
FString FirstName;
|
||||
FString LastName;
|
||||
if(IsTeam())
|
||||
if (IsTeam())
|
||||
{
|
||||
LastName = Team;
|
||||
}
|
||||
else
|
||||
{
|
||||
FirstName = Teammate[0].FirstName;
|
||||
LastName = Teammate[0].LastName;
|
||||
}
|
||||
// Récupère la première lettre du prénom en majuscule
|
||||
FString Initial;
|
||||
if (!FirstName.IsEmpty())
|
||||
@ -40,6 +43,7 @@ FText FDTFluxParticipant::GetFormattedName(const int MaxChar, const FString Over
|
||||
|
||||
// Construction du nom final
|
||||
FString FullName = Initial + FormattedLastName;
|
||||
UE_LOG(logDTFluxCore, Error, TEXT("FullName for Bib %i is %s"), Bib, *FullName);
|
||||
|
||||
// Tronque si nécessaire
|
||||
if (FullName.Len() > MaxChar)
|
||||
@ -48,8 +52,7 @@ FText FDTFluxParticipant::GetFormattedName(const int MaxChar, const FString Over
|
||||
const int32 AvailableLength = MaxChar - Initial.Len();
|
||||
if (AvailableLength <= 0)
|
||||
{
|
||||
// Pas assez de place pour le nom → juste l'initiale ?
|
||||
return FText::FromString(Initial);
|
||||
return Initial;
|
||||
}
|
||||
|
||||
// Coupe le nom pour qu’il rentre dans la limite
|
||||
@ -83,41 +86,41 @@ FText FDTFluxParticipant::GetFormattedName(const int MaxChar, const FString Over
|
||||
}
|
||||
}
|
||||
|
||||
return FText::FromString(FullName);
|
||||
return FullName;
|
||||
}
|
||||
|
||||
FText FDTFluxParticipant::GetConcatFormattedName(const int MaxChar, const FString OverflowChar)
|
||||
FString FDTFluxParticipant::GetConcatFormattedName(const int MaxChar, const FString OverflowChar) const
|
||||
{
|
||||
FString BibText = FString::FromInt(Bib) + " ";
|
||||
FText FormattedName = GetFormattedName(MaxChar - BibText.Len(), OverflowChar );
|
||||
return FText::FromString(BibText + FormattedName.ToString());
|
||||
FString FormattedName = GetFormattedName(MaxChar - BibText.Len(), OverflowChar);
|
||||
return BibText + FormattedName;
|
||||
}
|
||||
|
||||
// Constructeur privé depuis JSON
|
||||
FDTFluxParticipant::FDTFluxParticipant(const TSharedPtr<FJsonObject>& JsonObject)
|
||||
: Bib(JsonObject->GetIntegerField(TEXT("bib")))
|
||||
, ContestId(JsonObject->GetIntegerField(TEXT("contestId")))
|
||||
, Category(JsonObject->GetStringField(TEXT("category")))
|
||||
, Club(JsonObject->GetStringField(TEXT("club")))
|
||||
, Elite(JsonObject->GetBoolField(TEXT("elite")))
|
||||
, Status(static_cast<EDTFluxParticipantStatusType>(JsonObject->GetIntegerField(TEXT("status"))))
|
||||
, Team(JsonObject->GetStringField(TEXT("team")))
|
||||
, bIsMassStartParticipant(false)
|
||||
, CurrentSplit(-1)
|
||||
, ContestId(JsonObject->GetIntegerField(TEXT("contestId")))
|
||||
, Category(JsonObject->GetStringField(TEXT("category")))
|
||||
, Club(JsonObject->GetStringField(TEXT("club")))
|
||||
, Elite(JsonObject->GetBoolField(TEXT("elite")))
|
||||
, Status(static_cast<EDTFluxParticipantStatusType>(JsonObject->GetIntegerField(TEXT("status"))))
|
||||
, Team(JsonObject->GetStringField(TEXT("team")))
|
||||
, bIsMassStartParticipant(false)
|
||||
, CurrentSplit(-1)
|
||||
{
|
||||
UE_LOG(logDTFluxCore, Error, TEXT("Ctor with JSON Object"))
|
||||
for(uint8 Index = 1; ; Index++)
|
||||
for (uint8 Index = 1; ; Index++)
|
||||
{
|
||||
FString FirstNameKey = Index == 1 ? "firstName" : FString::Printf(TEXT("firstName%i"), Index);
|
||||
FString LastNameKey = Index == 1 ? "lastName" : FString::Printf(TEXT("lastName%i"), Index);
|
||||
FString GenderKey = Index == 1 ? "gender" : FString::Printf(TEXT("gender%i"), Index);
|
||||
// max 10 Persons
|
||||
if(Index >= 10)
|
||||
if (Index >= 10)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (!JsonObject->HasField(FirstNameKey) && !JsonObject->HasField(LastNameKey)
|
||||
&& !JsonObject->HasField(GenderKey))
|
||||
&& !JsonObject->HasField(GenderKey))
|
||||
{
|
||||
UE_LOG(logDTFluxCore, Error, TEXT("No Corresponding Field!!!"))
|
||||
break;
|
||||
@ -134,7 +137,6 @@ FDTFluxParticipant::FDTFluxParticipant(const TSharedPtr<FJsonObject>& JsonObject
|
||||
Teammate.Add(Person);
|
||||
}
|
||||
UE_LOG(logDTFluxCore, Error, TEXT("Ctor with JSON Object Teammate is now %i long"), Teammate.Num());
|
||||
|
||||
}
|
||||
|
||||
FDTFluxParticipant FDTFluxParticipant::CreateFromJson(const TSharedPtr<FJsonObject>& JsonObject)
|
||||
@ -147,7 +149,7 @@ int FDTFluxParticipant::GetTeammateNum() const
|
||||
return Teammate.Num();
|
||||
}
|
||||
|
||||
bool FDTFluxParticipant::IsTeam()
|
||||
bool FDTFluxParticipant::IsTeam() const
|
||||
{
|
||||
return Teammate.Num() < 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Types/Struct/FDTFluxPursuitInfo.h"
|
||||
Reference in New Issue
Block a user