Update FormatedName functionality now just truncates and adds OverflowChar + fixing getter Split, Stage, Contest
This commit is contained in:
@ -70,7 +70,8 @@ FDTFluxParticipant::FDTFluxParticipant(const TSharedPtr<FJsonObject>& JsonObject
|
||||
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))
|
||||
if (!JsonObject->HasField(FirstNameKey) && !JsonObject->HasField(LastNameKey) && !JsonObject->
|
||||
HasField(GenderKey))
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -157,16 +158,15 @@ const TArray<FDTFluxPerson>& FDTFluxParticipant::GetTeammate() const
|
||||
return Teammate;
|
||||
}
|
||||
|
||||
FString FDTFluxParticipant::GetFormattedName(const int MaxChar, const FString& Separator, const FString& OverflowChar) const
|
||||
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())
|
||||
@ -197,42 +197,13 @@ FString FDTFluxParticipant::GetFormattedName(const int MaxChar, const FString& S
|
||||
{
|
||||
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;
|
||||
return FullName.Left(MaxChar) + OverflowChar;
|
||||
}
|
||||
|
||||
FString FDTFluxParticipant::GetConcatFormattedName(const int MaxChar, const FString& Separator,
|
||||
@ -250,7 +221,8 @@ FString FDTFluxParticipant::GetConcatFormattedName(const int MaxChar, const FStr
|
||||
return BibText + FormattedName;
|
||||
}
|
||||
|
||||
FText FDTFluxParticipant::GetFormattedNameText(const int MaxChar, const FString& Separator, const FString& OverflowChar) const
|
||||
FText FDTFluxParticipant::GetFormattedNameText(const int MaxChar, const FString& Separator,
|
||||
const FString& OverflowChar) const
|
||||
{
|
||||
return FText::FromString(GetFormattedName(MaxChar, Separator, OverflowChar));
|
||||
}
|
||||
|
||||
@ -129,12 +129,15 @@ public:
|
||||
FDTFluxContest ContestDefinition;
|
||||
if (GetContestForId(ContestId, ContestDefinition))
|
||||
{
|
||||
if (ContestDefinition.Stages.IsValidIndex(StageId))
|
||||
for (auto& Stage : ContestDefinition.Stages)
|
||||
{
|
||||
OutStageDefinition = ContestDefinition.Stages[StageId];
|
||||
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)
|
||||
@ -149,12 +152,15 @@ public:
|
||||
FDTFluxContest ContestDefinition;
|
||||
if (GetContestForId(ContestId, ContestDefinition))
|
||||
{
|
||||
if (ContestDefinition.Splits.IsValidIndex(SplitId))
|
||||
for (auto& Split : ContestDefinition.Splits)
|
||||
{
|
||||
OutSplitDefinition = ContestDefinition.Splits[SplitId];
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user