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);
|
FString GenderKey = Index == 1 ? TEXT("gender") : FString::Printf(TEXT("gender%d"), Index);
|
||||||
|
|
||||||
// Vérifie si au moins un des champs existe
|
// 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;
|
break;
|
||||||
}
|
}
|
||||||
@ -157,16 +158,15 @@ const TArray<FDTFluxPerson>& FDTFluxParticipant::GetTeammate() const
|
|||||||
return Teammate;
|
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)
|
if (MaxChar <= 0)
|
||||||
{
|
{
|
||||||
return TEXT("");
|
return TEXT("");
|
||||||
}
|
}
|
||||||
|
|
||||||
FString FirstName;
|
FString FirstName;
|
||||||
FString LastName;
|
FString LastName;
|
||||||
|
|
||||||
if (IsTeam())
|
if (IsTeam())
|
||||||
{
|
{
|
||||||
if (!Team.IsEmpty())
|
if (!Team.IsEmpty())
|
||||||
@ -197,42 +197,13 @@ FString FDTFluxParticipant::GetFormattedName(const int MaxChar, const FString& S
|
|||||||
{
|
{
|
||||||
Initial = FirstName.Left(1).ToUpper() + Separator;
|
Initial = FirstName.Left(1).ToUpper() + Separator;
|
||||||
}
|
}
|
||||||
|
|
||||||
FString FormattedLastName = LastName.ToUpper();
|
FString FormattedLastName = LastName.ToUpper();
|
||||||
FString FullName = Initial + FormattedLastName;
|
FString FullName = Initial + FormattedLastName;
|
||||||
|
|
||||||
if (FullName.Len() <= MaxChar)
|
if (FullName.Len() <= MaxChar)
|
||||||
{
|
{
|
||||||
return FullName;
|
return FullName;
|
||||||
}
|
}
|
||||||
|
return FullName.Left(MaxChar) + OverflowChar;
|
||||||
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,
|
FString FDTFluxParticipant::GetConcatFormattedName(const int MaxChar, const FString& Separator,
|
||||||
@ -250,7 +221,8 @@ FString FDTFluxParticipant::GetConcatFormattedName(const int MaxChar, const FStr
|
|||||||
return BibText + FormattedName;
|
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));
|
return FText::FromString(GetFormattedName(MaxChar, Separator, OverflowChar));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -129,12 +129,15 @@ public:
|
|||||||
FDTFluxContest ContestDefinition;
|
FDTFluxContest ContestDefinition;
|
||||||
if (GetContestForId(ContestId, 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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
OutStageDefinition = FDTFluxStage();
|
OutStageDefinition = FDTFluxStage();
|
||||||
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("ContestId %d, StageId %d not found in ContestDefinition"),
|
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("ContestId %d, StageId %d not found in ContestDefinition"),
|
||||||
ContestId, StageId)
|
ContestId, StageId)
|
||||||
@ -149,12 +152,15 @@ public:
|
|||||||
FDTFluxContest ContestDefinition;
|
FDTFluxContest ContestDefinition;
|
||||||
if (GetContestForId(ContestId, 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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
OutSplitDefinition = FDTFluxSplit();
|
OutSplitDefinition = FDTFluxSplit();
|
||||||
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("ContestId %d, SplitId %d not found in ContestDefinition"),
|
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("ContestId %d, SplitId %d not found in ContestDefinition"),
|
||||||
ContestId, SplitId);
|
ContestId, SplitId);
|
||||||
|
|||||||
Reference in New Issue
Block a user