Added Utility Function to get FirstName And LastName of a Participant
This commit is contained in:
@ -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"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user