Added Utility Function to get FirstName And LastName of a Participant

This commit is contained in:
2025-07-15 01:11:18 +02:00
parent ae8b694f69
commit 505e4b7af2
2 changed files with 43 additions and 3 deletions

View File

@ -4,14 +4,20 @@
#include "FTDFluxUtils.h"
#include "DTFluxCoreSubsystem.h"
#include "DTFluxUtilitiesModule.h"
FText UFTDFluxUtils::GetFormatedName(const int& Bib, const int MaxChar, const FString Separator,
const FString OverFlowChar)
{
UDTFluxCoreSubsystem* CoreSubsystem = GEngine->GetEngineSubsystem<UDTFluxCoreSubsystem>();
FDTFluxParticipant OutParticipant;
CoreSubsystem->GetParticipant(Bib, OutParticipant);
return OutParticipant.GetFormattedNameText(MaxChar, Separator, OverFlowChar);
if (CoreSubsystem == nullptr)
{
FDTFluxParticipant OutParticipant;
CoreSubsystem->GetParticipant(Bib, OutParticipant);
return OutParticipant.GetFormattedNameText(MaxChar, Separator, OverFlowChar);
}
UE_LOG(logDTFluxUtilities, Error, TEXT("DTFluxCoreSubsystem not available"));
return FText();
}
FText UFTDFluxUtils::GetParticipantFormatedName(FDTFluxParticipant& Participant, const int MaxChar,
@ -20,3 +26,33 @@ FText UFTDFluxUtils::GetParticipantFormatedName(FDTFluxParticipant& Participant,
{
return Participant.GetFormattedNameText(MaxChar, Separator, OverFlowChar);
}
void UFTDFluxUtils::GetFullName(const int Bib, FText& OutFullName)
{
OutFullName = FText();
UDTFluxCoreSubsystem* CoreSubsystem = GEngine->GetEngineSubsystem<UDTFluxCoreSubsystem>();
FDTFluxParticipant Participant;
CoreSubsystem->GetParticipant(Bib, Participant);
{
FDTFluxParticipant OutParticipant;
if(CoreSubsystem->GetParticipant(Bib, OutParticipant))
{
FString FormattedName = "";
if (OutParticipant.IsTeam())
{
OutFullName = FText::FromString(Participant.Team);
return;
}
if (Participant.GetTeammate().IsEmpty())
{
UE_LOG(logDTFluxUtilities, Warning, TEXT("Non teammate found with Bib %i"), Bib)
return;
}
OutFullName = FText::FromString(FString::Printf(TEXT("%s %s"), *Participant.GetTeammate()[0].FirstName,
*Participant.GetTeammate()[0].LastName));
return;
}
UE_LOG(logDTFluxUtilities, Warning, TEXT("Participant not found with Bib %i"), Bib);
}
UE_LOG(logDTFluxUtilities, Error, TEXT("DTFluxCoreSubsystem not available"));
}

View File

@ -66,4 +66,8 @@ public:
OutRanking.Add(static_cast<T>(Item));
}
}
UFUNCTION(BlueprintCallable, Category="DTFlux|Utils")
static void GetFullName(const int Bib, FText& OutFullName);
};