Core Structure cleaning
This commit is contained in:
@ -1,3 +1,67 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#include "Types/Struct/DTFluxRaceDataStructs.h"
|
||||
|
||||
bool FDTFluxContest::IsFinished() const
|
||||
{
|
||||
return EndTime <= FDateTime::Now();
|
||||
}
|
||||
|
||||
void FDTFluxContest::UpdateEndTime()
|
||||
{
|
||||
TArray<FDTFluxStage> TempStages = Stages;
|
||||
TempStages.Sort([](const FDTFluxStage& A, const FDTFluxStage& B)
|
||||
{
|
||||
return A.EndTime < B.EndTime;
|
||||
});
|
||||
EndTime = TempStages.Last().EndTime;
|
||||
}
|
||||
|
||||
int FDTFluxContest::GetLastStageId()
|
||||
{
|
||||
if (LastStageId <= 0)
|
||||
{
|
||||
UpdateLastStageId();
|
||||
}
|
||||
return LastStageId;
|
||||
}
|
||||
|
||||
void FDTFluxContest::UpdateLastStageId()
|
||||
{
|
||||
TArray<FDTFluxStage> TempStages = Stages;
|
||||
TempStages.Sort([](const FDTFluxStage& A, const FDTFluxStage& B)
|
||||
{
|
||||
return A.StageId < B.StageId;
|
||||
});
|
||||
LastStageId = TempStages.Last().StageId;
|
||||
}
|
||||
|
||||
FDTFluxStage& FDTFluxContest::GetLastStage() const
|
||||
{
|
||||
TArray<FDTFluxStage> TempStages = Stages;
|
||||
TempStages.Sort([](const FDTFluxStage& A, const FDTFluxStage& B)
|
||||
{
|
||||
return A.StageId < B.StageId;
|
||||
});
|
||||
return TempStages.Last();
|
||||
}
|
||||
|
||||
bool FDTFluxContest::GetStage(const int StageID, FDTFluxStage& OutStage) const
|
||||
{
|
||||
if (Stages.Num() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (const FDTFluxStage& Stage : Stages)
|
||||
{
|
||||
if (Stage.StageId == StageID)
|
||||
{
|
||||
OutStage = Stage;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,140 +1,145 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Types/Struct/DTFluxTeamListStruct.h"
|
||||
|
||||
#include "DTFluxCoreModule.h"
|
||||
#include "Dom/JsonObject.h"
|
||||
|
||||
// ===================================
|
||||
// FDTFluxPerson Implementation
|
||||
// ===================================
|
||||
|
||||
void FDTFluxParticipant::AddTeammate(const FDTFluxPerson& Person)
|
||||
bool FDTFluxPerson::operator==(const FDTFluxPerson& Right) const
|
||||
{
|
||||
Teammate.Add(Person);
|
||||
return GetNormalizedString() == Right.GetNormalizedString();
|
||||
}
|
||||
|
||||
void FDTFluxParticipant::AddTeammate(const FString LastName, const FString FirstName, const FString Gender)
|
||||
bool FDTFluxPerson::operator!=(const FDTFluxPerson& Right) const
|
||||
{
|
||||
return !(*this == Right);
|
||||
}
|
||||
|
||||
FString FDTFluxParticipant::GetFormattedName(const int MaxChar, const FString Separator,
|
||||
const FString OverflowChars) const
|
||||
bool FDTFluxPerson::operator==(const int Length) const
|
||||
{
|
||||
{
|
||||
if (MaxChar <= 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
FString FirstName;
|
||||
FString LastName;
|
||||
if (IsTeam())
|
||||
{
|
||||
LastName = Team;
|
||||
}
|
||||
else
|
||||
{
|
||||
FirstName = Teammate[0].FirstName;
|
||||
LastName = Teammate[0].LastName;
|
||||
}
|
||||
FString Initial;
|
||||
if (!FirstName.IsEmpty())
|
||||
{
|
||||
Initial = FirstName.Left(1).ToUpper() + Separator;
|
||||
}
|
||||
|
||||
FString FormattedLastName = LastName.ToUpper();
|
||||
|
||||
FString FullName = Initial + FormattedLastName;
|
||||
UE_LOG(logDTFluxCore, VeryVerbose, TEXT("FullName for Bib %i is %s"), Bib, *FullName);
|
||||
|
||||
if (FullName.Len() <= MaxChar)
|
||||
{
|
||||
return FullName;
|
||||
}
|
||||
|
||||
const int32 OverflowLength = OverflowChars.Len();
|
||||
|
||||
if (OverflowLength > MaxChar)
|
||||
{
|
||||
return FullName.Left(MaxChar);
|
||||
}
|
||||
|
||||
if (Initial.Len() + OverflowLength > MaxChar)
|
||||
{
|
||||
return FullName.Left(MaxChar);
|
||||
}
|
||||
|
||||
const int32 AvailableForLastName = MaxChar - Initial.Len() - OverflowLength;
|
||||
|
||||
if (AvailableForLastName <= 0)
|
||||
{
|
||||
return FullName.Left(MaxChar);
|
||||
}
|
||||
|
||||
FString TruncatedName = Initial + FormattedLastName.Left(AvailableForLastName) + OverflowChars;
|
||||
|
||||
if (TruncatedName.Len() > MaxChar)
|
||||
{
|
||||
return TruncatedName.Left(MaxChar);
|
||||
}
|
||||
|
||||
return TruncatedName;
|
||||
}
|
||||
return GetNormalizedString().Len() == Length;
|
||||
}
|
||||
|
||||
FString FDTFluxParticipant::GetConcatFormattedName(const int MaxChar, const FString Separator,
|
||||
const FString OverflowChar, const FString BibSeparator) const
|
||||
bool FDTFluxPerson::operator!=(const int Length) const
|
||||
{
|
||||
FString BibText = FString::FromInt(Bib) + BibSeparator;
|
||||
FString FormattedName = GetFormattedName(MaxChar - BibText.Len(), Separator, OverflowChar);
|
||||
return BibText + FormattedName;
|
||||
return !(*this == Length);
|
||||
}
|
||||
|
||||
FString FDTFluxPerson::GetNormalizedString() const
|
||||
{
|
||||
return FirstName.ToLower() + LastName.ToLower() + Gender.ToLower();
|
||||
}
|
||||
|
||||
bool FDTFluxPerson::IsValid() const
|
||||
{
|
||||
return !FirstName.TrimStartAndEnd().IsEmpty() &&
|
||||
!LastName.TrimStartAndEnd().IsEmpty() &&
|
||||
!Gender.TrimStartAndEnd().IsEmpty();
|
||||
}
|
||||
|
||||
FDTFluxParticipant::FDTFluxParticipant()
|
||||
: Bib(-1)
|
||||
, ContestId(-1)
|
||||
, Elite(false)
|
||||
, Status(static_cast<EDTFluxParticipantStatusType>(0))
|
||||
, bIsMassStartParticipant(false)
|
||||
, CurrentSplit(-1)
|
||||
{
|
||||
Teammate.Reset();
|
||||
}
|
||||
|
||||
// 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")))
|
||||
, CurrentSplit(-1)
|
||||
{
|
||||
UE_LOG(logDTFluxCore, Error, TEXT("Ctor with JSON Object"))
|
||||
for (uint8 Index = 1; ; Index++)
|
||||
UE_LOG(logDTFluxCore, Log, TEXT("Creating participant from JSON - Bib: %d, Contest: %d"), Bib, ContestId);
|
||||
|
||||
for (uint8 Index = 1; Index <= 10; 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)
|
||||
FString FirstNameKey = Index == 1 ? TEXT("firstName") : FString::Printf(TEXT("firstName%d"), Index);
|
||||
FString LastNameKey = Index == 1 ? TEXT("lastName") : FString::Printf(TEXT("lastName%d"), Index);
|
||||
FString GenderKey = Index == 1 ? TEXT("gender") : FString::Printf(TEXT("gender%d"), Index);
|
||||
|
||||
// Vérifie si au moins un des champs existe
|
||||
if (!JsonObject->HasField(FirstNameKey) && !JsonObject->HasField(LastNameKey) && !JsonObject->HasField(GenderKey))
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (!JsonObject->HasField(FirstNameKey) && !JsonObject->HasField(LastNameKey)
|
||||
&& !JsonObject->HasField(GenderKey))
|
||||
{
|
||||
UE_LOG(logDTFluxCore, Error, TEXT("No Corresponding Field!!!"))
|
||||
break;
|
||||
}
|
||||
|
||||
const FString FirstName = JsonObject->GetStringField(FirstNameKey);
|
||||
const FString LastName = JsonObject->GetStringField(LastNameKey);
|
||||
const FString Gender = JsonObject->GetStringField(GenderKey);
|
||||
if (FirstName.IsEmpty() && LastName.IsEmpty())
|
||||
|
||||
if (FirstName.TrimStartAndEnd().IsEmpty() && LastName.TrimStartAndEnd().IsEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
FDTFluxPerson Person;
|
||||
Person.FirstName = FirstName;
|
||||
Person.LastName = LastName;
|
||||
Person.Gender = Gender;
|
||||
Teammate.Add(Person);
|
||||
Person.FirstName = FirstName.TrimStartAndEnd();
|
||||
Person.LastName = LastName.TrimStartAndEnd();
|
||||
Person.Gender = Gender.TrimStartAndEnd();
|
||||
|
||||
if (Person.IsValid())
|
||||
{
|
||||
Teammate.Add(Person);
|
||||
UE_LOG(logDTFluxCore, Verbose, TEXT("Added person %d: %s %s (%s)"),
|
||||
Index, *Person.FirstName, *Person.LastName, *Person.Gender);
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(logDTFluxCore, Warning, TEXT("Invalid person data at index %d: '%s' '%s' '%s'"),
|
||||
Index, *FirstName, *LastName, *Gender);
|
||||
}
|
||||
}
|
||||
UE_LOG(logDTFluxCore, Error, TEXT("Ctor with JSON Object Teammate is now %i long"), Teammate.Num());
|
||||
|
||||
UE_LOG(logDTFluxCore, Log, TEXT("Participant created with %d teammates"), Teammate.Num());
|
||||
}
|
||||
|
||||
FDTFluxParticipant FDTFluxParticipant::CreateFromJson(const TSharedPtr<FJsonObject>& JsonObject)
|
||||
bool FDTFluxParticipant::IsDefault() const
|
||||
{
|
||||
return FDTFluxParticipant(JsonObject);
|
||||
return Bib == -1
|
||||
&& ContestId == -1
|
||||
&& Category.IsEmpty()
|
||||
&& Club.IsEmpty()
|
||||
&& !Elite
|
||||
&& Status == static_cast<EDTFluxParticipantStatusType>(0)
|
||||
&& Team.IsEmpty()
|
||||
&& !bIsMassStartParticipant
|
||||
&& CurrentSplit == -1
|
||||
&& Teammate.IsEmpty();
|
||||
}
|
||||
|
||||
void FDTFluxParticipant::AddTeammate(const FDTFluxPerson& Person)
|
||||
{
|
||||
if (Person.IsValid())
|
||||
{
|
||||
Teammate.Add(Person);
|
||||
UE_LOG(logDTFluxCore, Verbose, TEXT("Added teammate: %s %s"), *Person.FirstName, *Person.LastName);
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(logDTFluxCore, Warning, TEXT("Cannot add invalid teammate: %s %s"), *Person.FirstName, *Person.LastName);
|
||||
}
|
||||
}
|
||||
|
||||
void FDTFluxParticipant::AddTeammate(const FString& LastName, const FString& FirstName, const FString& Gender)
|
||||
{
|
||||
FDTFluxPerson Person;
|
||||
Person.FirstName = FirstName.TrimStartAndEnd();
|
||||
Person.LastName = LastName.TrimStartAndEnd();
|
||||
Person.Gender = Gender.TrimStartAndEnd();
|
||||
|
||||
AddTeammate(Person);
|
||||
}
|
||||
|
||||
int FDTFluxParticipant::GetTeammateNum() const
|
||||
@ -144,5 +149,157 @@ int FDTFluxParticipant::GetTeammateNum() const
|
||||
|
||||
bool FDTFluxParticipant::IsTeam() const
|
||||
{
|
||||
return Teammate.Num() < 1;
|
||||
return Teammate.Num() > 1;
|
||||
}
|
||||
|
||||
const TArray<FDTFluxPerson>& FDTFluxParticipant::GetTeammate() const
|
||||
{
|
||||
return Teammate;
|
||||
}
|
||||
|
||||
FString FDTFluxParticipant::GetFormattedName(const int MaxChar, const FString& Separator, const FString& OverflowChar) const
|
||||
{
|
||||
if (MaxChar <= 0)
|
||||
{
|
||||
return TEXT("");
|
||||
}
|
||||
|
||||
FString FirstName;
|
||||
FString LastName;
|
||||
|
||||
if (IsTeam())
|
||||
{
|
||||
if (!Team.IsEmpty())
|
||||
{
|
||||
LastName = Team;
|
||||
}
|
||||
else
|
||||
{
|
||||
TArray<FString> Names;
|
||||
for (const FDTFluxPerson& Person : Teammate)
|
||||
{
|
||||
Names.Add(Person.LastName);
|
||||
}
|
||||
LastName = FString::Join(Names, TEXT("/"));
|
||||
}
|
||||
}
|
||||
else if (Teammate.Num() > 0)
|
||||
{
|
||||
FirstName = Teammate[0].FirstName;
|
||||
LastName = Teammate[0].LastName;
|
||||
}
|
||||
else
|
||||
{
|
||||
LastName = TEXT("Unknown");
|
||||
}
|
||||
FString Initial;
|
||||
if (!FirstName.IsEmpty())
|
||||
{
|
||||
Initial = FirstName.Left(1).ToUpper() + Separator;
|
||||
}
|
||||
|
||||
FString FormattedLastName = LastName.ToUpper();
|
||||
FString FullName = Initial + FormattedLastName;
|
||||
|
||||
if (FullName.Len() <= MaxChar)
|
||||
{
|
||||
return FullName;
|
||||
}
|
||||
|
||||
const int32 OverflowLength = OverflowChar.Len();
|
||||
|
||||
if (OverflowLength > MaxChar)
|
||||
{
|
||||
return FullName.Left(MaxChar);
|
||||
}
|
||||
|
||||
if (Initial.Len() + OverflowLength > MaxChar)
|
||||
{
|
||||
return FullName.Left(MaxChar);
|
||||
}
|
||||
|
||||
const int32 AvailableForLastName = MaxChar - Initial.Len() - OverflowLength;
|
||||
|
||||
if (AvailableForLastName <= 0)
|
||||
{
|
||||
return FullName.Left(MaxChar);
|
||||
}
|
||||
|
||||
FString TruncatedName = Initial + FormattedLastName.Left(AvailableForLastName) + OverflowChar;
|
||||
|
||||
if (TruncatedName.Len() > MaxChar)
|
||||
{
|
||||
return TruncatedName.Left(MaxChar);
|
||||
}
|
||||
|
||||
return TruncatedName;
|
||||
}
|
||||
|
||||
FString FDTFluxParticipant::GetConcatFormattedName(const int MaxChar, const FString& Separator,
|
||||
const FString& OverflowChar, const FString& BibSeparator) const
|
||||
{
|
||||
FString BibText = FString::FromInt(Bib) + BibSeparator;
|
||||
int32 RemainingChars = MaxChar - BibText.Len();
|
||||
|
||||
if (RemainingChars <= 0)
|
||||
{
|
||||
return BibText.Left(MaxChar);
|
||||
}
|
||||
|
||||
FString FormattedName = GetFormattedName(RemainingChars, Separator, OverflowChar);
|
||||
return BibText + FormattedName;
|
||||
}
|
||||
|
||||
FText FDTFluxParticipant::GetFormattedNameText(const int MaxChar, const FString& Separator, const FString& OverflowChar) const
|
||||
{
|
||||
return FText::FromString(GetFormattedName(MaxChar, Separator, OverflowChar));
|
||||
}
|
||||
|
||||
FText FDTFluxParticipant::GetConcatFormattedNameText(const int MaxChar, const FString& Separator,
|
||||
const FString& OverflowChar, const FString& BibSeparator) const
|
||||
{
|
||||
return FText::FromString(GetConcatFormattedName(MaxChar, Separator, OverflowChar, BibSeparator));
|
||||
}
|
||||
|
||||
FString FDTFluxParticipant::GetFormattedName(const FDTFluxParticipant& Participant, const int MaxChar,
|
||||
const FString& Separator, const FString& OverflowChar)
|
||||
{
|
||||
return Participant.GetFormattedName(MaxChar, Separator, OverflowChar);
|
||||
}
|
||||
|
||||
FString FDTFluxParticipant::GetConcatFormattedName(const FDTFluxParticipant& Participant, const int MaxChar,
|
||||
const FString& Separator, const FString& OverflowChar,
|
||||
const FString& BibSeparator)
|
||||
{
|
||||
return Participant.GetConcatFormattedName(MaxChar, Separator, OverflowChar, BibSeparator);
|
||||
}
|
||||
|
||||
FText FDTFluxParticipant::GetFormattedNameText(const FDTFluxParticipant& Participant, const int MaxChar,
|
||||
const FString& Separator, const FString& OverflowChar)
|
||||
{
|
||||
return Participant.GetFormattedNameText(MaxChar, Separator, OverflowChar);
|
||||
}
|
||||
|
||||
FText FDTFluxParticipant::GetConcatFormattedNameText(const FDTFluxParticipant& Participant, const int MaxChar,
|
||||
const FString& Separator, const FString& OverflowChar,
|
||||
const FString& BibSeparator)
|
||||
{
|
||||
return Participant.GetConcatFormattedNameText(MaxChar, Separator, OverflowChar, BibSeparator);
|
||||
}
|
||||
|
||||
FDTFluxParticipant FDTFluxParticipant::CreateFromJson(const TSharedPtr<FJsonObject>& JsonObject)
|
||||
{
|
||||
if (!JsonObject.IsValid())
|
||||
{
|
||||
UE_LOG(logDTFluxCore, Error, TEXT("Cannot create participant from invalid JSON object"));
|
||||
return FDTFluxParticipant();
|
||||
}
|
||||
|
||||
return FDTFluxParticipant(JsonObject);
|
||||
}
|
||||
|
||||
FDTFluxTeamStatusUpdate::FDTFluxTeamStatusUpdate(const int InBib, const int InStatus)
|
||||
: Bib(InBib)
|
||||
, Status(static_cast<EDTFluxParticipantStatusType>(InStatus))
|
||||
{
|
||||
}
|
||||
@ -89,68 +89,6 @@ public:
|
||||
bool GetStage(const int StageID, FDTFluxStage& OutStage) const;
|
||||
};
|
||||
|
||||
inline bool FDTFluxContest::IsFinished() const
|
||||
{
|
||||
return EndTime <= FDateTime::Now();
|
||||
}
|
||||
|
||||
inline void FDTFluxContest::UpdateEndTime()
|
||||
{
|
||||
TArray<FDTFluxStage> TempStages = Stages;
|
||||
TempStages.Sort([](const FDTFluxStage& A, const FDTFluxStage& B)
|
||||
{
|
||||
return A.EndTime < B.EndTime;
|
||||
});
|
||||
EndTime = TempStages.Last().EndTime;
|
||||
}
|
||||
|
||||
inline int FDTFluxContest::GetLastStageId()
|
||||
{
|
||||
if (LastStageId <= 0)
|
||||
{
|
||||
UpdateLastStageId();
|
||||
}
|
||||
return LastStageId;
|
||||
}
|
||||
|
||||
inline void FDTFluxContest::UpdateLastStageId()
|
||||
{
|
||||
TArray<FDTFluxStage> TempStages = Stages;
|
||||
TempStages.Sort([](const FDTFluxStage& A, const FDTFluxStage& B)
|
||||
{
|
||||
return A.StageId < B.StageId;
|
||||
});
|
||||
LastStageId = TempStages.Last().StageId;
|
||||
}
|
||||
|
||||
inline FDTFluxStage& FDTFluxContest::GetLastStage() const
|
||||
{
|
||||
TArray<FDTFluxStage> TempStages = Stages;
|
||||
TempStages.Sort([](const FDTFluxStage& A, const FDTFluxStage& B)
|
||||
{
|
||||
return A.StageId < B.StageId;
|
||||
});
|
||||
return TempStages.Last();
|
||||
}
|
||||
|
||||
inline bool FDTFluxContest::GetStage(const int StageID, FDTFluxStage& OutStage) const
|
||||
{
|
||||
if (Stages.Num() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (const FDTFluxStage& Stage : Stages)
|
||||
{
|
||||
if (Stage.StageId == StageID)
|
||||
{
|
||||
OutStage = Stage;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
USTRUCT()
|
||||
struct DTFLUXCORE_API FDTFluxRaceData
|
||||
{
|
||||
@ -160,4 +98,4 @@ public:
|
||||
UPROPERTY()
|
||||
// ReSharper disable once IdentifierTypo
|
||||
TArray<FDTFluxContest> Datas;
|
||||
};
|
||||
};
|
||||
@ -7,6 +7,10 @@
|
||||
#include "Types/Enum/DTFluxModelEnums.h"
|
||||
#include "DTFluxTeamListStruct.generated.h"
|
||||
|
||||
// Forward declarations
|
||||
class UDTFluxModelAsset;
|
||||
class UDTFluxParticipantFactory;
|
||||
|
||||
USTRUCT()
|
||||
struct DTFLUXCORE_API FDTFluxTeamListItemDefinition
|
||||
{
|
||||
@ -15,76 +19,78 @@ struct DTFLUXCORE_API FDTFluxTeamListItemDefinition
|
||||
public:
|
||||
UPROPERTY()
|
||||
FString Type = "team-list-item";
|
||||
|
||||
UPROPERTY()
|
||||
int ContestId;
|
||||
int ContestId = 0;
|
||||
|
||||
UPROPERTY()
|
||||
int Bib;
|
||||
int Bib = 0;
|
||||
|
||||
UPROPERTY()
|
||||
FString FirstName;
|
||||
|
||||
UPROPERTY()
|
||||
FString LastName;
|
||||
|
||||
UPROPERTY()
|
||||
FString FirstName2 = "";
|
||||
|
||||
UPROPERTY()
|
||||
FString LastName2 = "";
|
||||
|
||||
UPROPERTY()
|
||||
FString Team = "";
|
||||
|
||||
UPROPERTY()
|
||||
FString Gender;
|
||||
|
||||
UPROPERTY()
|
||||
FString Gender2;
|
||||
|
||||
UPROPERTY()
|
||||
bool Elite;
|
||||
bool Elite = false;
|
||||
|
||||
UPROPERTY()
|
||||
FString Category;
|
||||
|
||||
UPROPERTY()
|
||||
int Status;
|
||||
int Status = 0;
|
||||
|
||||
UPROPERTY()
|
||||
FString Club;
|
||||
};
|
||||
|
||||
|
||||
USTRUCT(BlueprintType, Category="DTFlux|Model")
|
||||
struct DTFLUXCORE_API FDTFluxPerson
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model", EditAnywhere)
|
||||
FString FirstName;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model", EditAnywhere)
|
||||
FString LastName;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model", EditAnywhere)
|
||||
FString Gender;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model", EditAnywhere)
|
||||
FString FunctionLine1 = TEXT("");
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model", EditAnywhere)
|
||||
FString FunctionLine2 = TEXT("");
|
||||
|
||||
bool operator==(const FDTFluxPerson& Right) const
|
||||
{
|
||||
return FirstName.ToLower() + LastName.ToLower() + Gender.ToLower()
|
||||
== Right.FirstName.ToLower() + Right.LastName.ToLower() + Right.Gender.ToLower();
|
||||
}
|
||||
bool operator==(const FDTFluxPerson& Right) const;
|
||||
bool operator!=(const FDTFluxPerson& Right) const;
|
||||
bool operator==(const int Length) const;
|
||||
bool operator!=(const int Length) const;
|
||||
|
||||
bool operator==(const int Length) const
|
||||
{
|
||||
return (FirstName.ToLower() + LastName.ToLower() + Gender.ToLower()).Len() == Length;
|
||||
}
|
||||
FString GetNormalizedString() const;
|
||||
|
||||
bool operator!=(const int Length) const
|
||||
{
|
||||
return !(*this == Length);
|
||||
}
|
||||
|
||||
bool operator!=(const FDTFluxPerson& Right) const
|
||||
{
|
||||
return FirstName.ToLower() + LastName.ToLower() + Gender.ToLower()
|
||||
!= Right.FirstName.ToLower() + Right.LastName.ToLower() + Right.Gender.ToLower();
|
||||
}
|
||||
bool IsValid() const;
|
||||
};
|
||||
|
||||
|
||||
USTRUCT(BlueprintType, Category="DTFlux|Model")
|
||||
struct DTFLUXCORE_API FDTFluxParticipant
|
||||
{
|
||||
@ -94,129 +100,98 @@ struct DTFLUXCORE_API FDTFluxParticipant
|
||||
friend class UDTFluxParticipantFactory;
|
||||
|
||||
public:
|
||||
// Constructeur public par défaut requis par Unreal
|
||||
FDTFluxParticipant()
|
||||
: Bib(-1)
|
||||
, ContestId(-1)
|
||||
, Elite(false)
|
||||
, Status(static_cast<EDTFluxParticipantStatusType>(0))
|
||||
, bIsMassStartParticipant(false)
|
||||
, CurrentSplit(-1)
|
||||
{
|
||||
Teammate.Reset();
|
||||
}
|
||||
FDTFluxParticipant();
|
||||
|
||||
|
||||
/**
|
||||
* Vérifie si le participant est dans son état par défaut (non initialisé)
|
||||
* @return True si tous les champs sont à leur valeur par défaut
|
||||
*/
|
||||
bool IsDefault() const
|
||||
{
|
||||
return Bib == -1
|
||||
&& ContestId == -1
|
||||
&& Category.IsEmpty()
|
||||
&& Club.IsEmpty()
|
||||
&& !Elite
|
||||
&& Status == static_cast<EDTFluxParticipantStatusType>(0)
|
||||
&& Team.IsEmpty()
|
||||
&& !bIsMassStartParticipant
|
||||
&& CurrentSplit == -1
|
||||
&& Teammate.IsEmpty();
|
||||
}
|
||||
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category="DTFlux|model", EditAnywhere)
|
||||
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", EditAnywhere)
|
||||
int Bib = -1;
|
||||
UPROPERTY(BlueprintReadOnly, Category="DTFlux|model", EditAnywhere)
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", EditAnywhere)
|
||||
int ContestId = -1;
|
||||
UPROPERTY(BlueprintReadOnly, Category="DTFlux|model", EditAnywhere)
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category="DTFlux|Model", EditAnywhere)
|
||||
FString Category;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model", EditAnywhere)
|
||||
FString Club;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
|
||||
bool Elite;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model", EditAnywhere)
|
||||
bool Elite = false;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model", EditAnywhere)
|
||||
EDTFluxParticipantStatusType Status;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model", EditAnywhere)
|
||||
FString Team;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model", EditAnywhere)
|
||||
bool bIsMassStartParticipant = false;
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model")
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Model")
|
||||
int CurrentSplit = -1;
|
||||
|
||||
// void Dump() const;
|
||||
bool IsDefault() const;
|
||||
|
||||
void AddTeammate(const FDTFluxPerson& Person);
|
||||
void AddTeammate(const FString LastName, const FString FirstName, const FString Gender);
|
||||
void AddTeammate(const FString& LastName, const FString& FirstName, const FString& Gender);
|
||||
|
||||
FText GetFormattedNameText(const int MaxChar = 15, const FString Separator = FString(". "),
|
||||
const FString OverflowChar = FString("...")) const
|
||||
{
|
||||
return FText::FromString(GetFormattedName(MaxChar, OverflowChar));
|
||||
};
|
||||
int GetTeammateNum() const;
|
||||
|
||||
FText GetConcatFormattedNameText(const int MaxChar = 20, const FString Separator = FString(". "),
|
||||
const FString OverflowChar = FString("..."),
|
||||
const FString BibSeparator = FString(". ")) const
|
||||
{
|
||||
return FText::FromString(GetConcatFormattedName(MaxChar, Separator, OverflowChar, BibSeparator));
|
||||
};
|
||||
FString GetFormattedName(const int MaxChar = 15, const FString Separator = FString(". "),
|
||||
const FString OverflowChar = FString("...")) const;
|
||||
FString GetConcatFormattedName(const int MaxChar = 20, const FString Separator = FString(". "),
|
||||
const FString OverflowChar = FString("..."),
|
||||
const FString BibSeparator = FString(". ")) const;
|
||||
bool IsTeam() const;
|
||||
|
||||
static FString GetFormattedName(const FDTFluxParticipant& Participant, const int MaxChar = 15,
|
||||
const FString Separator = FString(". "),
|
||||
const FString OverflowChar = FString("..."))
|
||||
{
|
||||
return Participant.GetFormattedName(MaxChar, Separator, OverflowChar);
|
||||
};
|
||||
|
||||
static FString GetConcatFormattedName(const FDTFluxParticipant& Participant, const int MaxChar = 15,
|
||||
const FString Separator = FString(". "),
|
||||
const FString OverflowChar = FString("..."),
|
||||
const FString BibSeparator = FString(". "))
|
||||
{
|
||||
return Participant.GetConcatFormattedName(MaxChar, Separator, OverflowChar, BibSeparator);
|
||||
};
|
||||
const TArray<FDTFluxPerson>& GetTeammate() const;
|
||||
|
||||
static FText GetFormattedNameText(const FDTFluxParticipant& Participant, const int MaxChar = 15,
|
||||
const FString Separator = FString(". "),
|
||||
const FString OverflowChar = FString("..."))
|
||||
{
|
||||
return Participant.GetFormattedNameText(MaxChar, Separator, OverflowChar);
|
||||
};
|
||||
FString GetFormattedName(const int MaxChar = 15,
|
||||
const FString& Separator = FString(". "),
|
||||
const FString& OverflowChar = FString("...")) const;
|
||||
|
||||
static FText GetConcatFormattedNameText(const FDTFluxParticipant& Participant, const int MaxChar = 15,
|
||||
const FString Separator = FString(". "),
|
||||
const FString OverflowChar = FString("..."),
|
||||
const FString BibSeparator = FString(". "))
|
||||
{
|
||||
return Participant.GetConcatFormattedNameText(MaxChar, Separator, OverflowChar, BibSeparator);
|
||||
};
|
||||
const TArray<FDTFluxPerson> GetTeammate() const { return Teammate; }
|
||||
FString GetConcatFormattedName(const int MaxChar = 20,
|
||||
const FString& Separator = FString(". "),
|
||||
const FString& OverflowChar = FString("..."),
|
||||
const FString& BibSeparator = FString(". ")) const;
|
||||
|
||||
private:
|
||||
// --- Constructeur privé ---
|
||||
explicit FDTFluxParticipant(const TSharedPtr<FJsonObject>& JsonObject);
|
||||
FText GetFormattedNameText(const int MaxChar = 15,
|
||||
const FString& Separator = FString(". "),
|
||||
const FString& OverflowChar = FString("...")) const;
|
||||
|
||||
FText GetConcatFormattedNameText(const int MaxChar = 20,
|
||||
const FString& Separator = FString(". "),
|
||||
const FString& OverflowChar = FString("..."),
|
||||
const FString& BibSeparator = FString(". ")) const;
|
||||
|
||||
static FString GetFormattedName(const FDTFluxParticipant& Participant,
|
||||
const int MaxChar = 15,
|
||||
const FString& Separator = FString(". "),
|
||||
const FString& OverflowChar = FString("..."));
|
||||
|
||||
static FString GetConcatFormattedName(const FDTFluxParticipant& Participant,
|
||||
const int MaxChar = 15,
|
||||
const FString& Separator = FString(". "),
|
||||
const FString& OverflowChar = FString("..."),
|
||||
const FString& BibSeparator = FString(". "));
|
||||
|
||||
static FText GetFormattedNameText(const FDTFluxParticipant& Participant,
|
||||
const int MaxChar = 15,
|
||||
const FString& Separator = FString(". "),
|
||||
const FString& OverflowChar = FString("..."));
|
||||
|
||||
static FText GetConcatFormattedNameText(const FDTFluxParticipant& Participant,
|
||||
const int MaxChar = 15,
|
||||
const FString& Separator = FString(". "),
|
||||
const FString& OverflowChar = FString("..."),
|
||||
const FString& BibSeparator = FString(". "));
|
||||
|
||||
static FDTFluxParticipant CreateFromJson(const TSharedPtr<FJsonObject>& JsonObject);
|
||||
|
||||
protected:
|
||||
UPROPERTY(Category="DTFlux|model", VisibleAnywhere)
|
||||
UPROPERTY(Category="DTFlux|Model", VisibleAnywhere)
|
||||
TArray<FDTFluxPerson> Teammate;
|
||||
// Méthode publique pour construire à partir d'un JSON (utilisée par la factory)
|
||||
static FDTFluxParticipant CreateFromJson(const TSharedPtr<FJsonObject>& JsonObject);
|
||||
int GetTeammateNum() const;
|
||||
bool IsTeam() const;
|
||||
|
||||
private:
|
||||
explicit FDTFluxParticipant(const TSharedPtr<FJsonObject>& JsonObject);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @struct FDTFluxTeamListDefinition
|
||||
* Struct representing the Participant List definition
|
||||
* Used to exchange data between Objects in the system
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct DTFLUXCORE_API FDTFluxTeamListDefinition
|
||||
{
|
||||
@ -224,27 +199,22 @@ struct DTFLUXCORE_API FDTFluxTeamListDefinition
|
||||
|
||||
public:
|
||||
UPROPERTY()
|
||||
// ReSharper disable once IdentifierTypo
|
||||
TArray<FDTFluxParticipant> Participants;
|
||||
};
|
||||
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FDTFluxTeamStatusUpdate
|
||||
struct DTFLUXCORE_API FDTFluxTeamStatusUpdate
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
FDTFluxTeamStatusUpdate() = default;
|
||||
|
||||
FDTFluxTeamStatusUpdate(const int InBib, const int InStatus)
|
||||
: Bib(InBib)
|
||||
, Status(static_cast<EDTFluxParticipantStatusType>(InStatus))
|
||||
{
|
||||
};
|
||||
|
||||
FDTFluxTeamStatusUpdate(const int InBib, const int InStatus);
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Participant")
|
||||
int Bib = -1;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Participant")
|
||||
EDTFluxParticipantStatusType Status = EDTFluxParticipantStatusType::Unknown;
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user