Added Utility Function to get FirstName And LastName of a Participant
This commit is contained in:
@ -4,15 +4,21 @@
|
|||||||
#include "FTDFluxUtils.h"
|
#include "FTDFluxUtils.h"
|
||||||
|
|
||||||
#include "DTFluxCoreSubsystem.h"
|
#include "DTFluxCoreSubsystem.h"
|
||||||
|
#include "DTFluxUtilitiesModule.h"
|
||||||
|
|
||||||
FText UFTDFluxUtils::GetFormatedName(const int& Bib, const int MaxChar, const FString Separator,
|
FText UFTDFluxUtils::GetFormatedName(const int& Bib, const int MaxChar, const FString Separator,
|
||||||
const FString OverFlowChar)
|
const FString OverFlowChar)
|
||||||
{
|
{
|
||||||
UDTFluxCoreSubsystem* CoreSubsystem = GEngine->GetEngineSubsystem<UDTFluxCoreSubsystem>();
|
UDTFluxCoreSubsystem* CoreSubsystem = GEngine->GetEngineSubsystem<UDTFluxCoreSubsystem>();
|
||||||
|
if (CoreSubsystem == nullptr)
|
||||||
|
{
|
||||||
FDTFluxParticipant OutParticipant;
|
FDTFluxParticipant OutParticipant;
|
||||||
CoreSubsystem->GetParticipant(Bib, OutParticipant);
|
CoreSubsystem->GetParticipant(Bib, OutParticipant);
|
||||||
return OutParticipant.GetFormattedNameText(MaxChar, Separator, OverFlowChar);
|
return OutParticipant.GetFormattedNameText(MaxChar, Separator, OverFlowChar);
|
||||||
}
|
}
|
||||||
|
UE_LOG(logDTFluxUtilities, Error, TEXT("DTFluxCoreSubsystem not available"));
|
||||||
|
return FText();
|
||||||
|
}
|
||||||
|
|
||||||
FText UFTDFluxUtils::GetParticipantFormatedName(FDTFluxParticipant& Participant, const int MaxChar,
|
FText UFTDFluxUtils::GetParticipantFormatedName(FDTFluxParticipant& Participant, const int MaxChar,
|
||||||
const FString Separator,
|
const FString Separator,
|
||||||
@ -20,3 +26,33 @@ FText UFTDFluxUtils::GetParticipantFormatedName(FDTFluxParticipant& Participant,
|
|||||||
{
|
{
|
||||||
return Participant.GetFormattedNameText(MaxChar, Separator, OverFlowChar);
|
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"));
|
||||||
|
}
|
||||||
|
|||||||
@ -66,4 +66,8 @@ public:
|
|||||||
OutRanking.Add(static_cast<T>(Item));
|
OutRanking.Add(static_cast<T>(Item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Utils")
|
||||||
|
static void GetFullName(const int Bib, FText& OutFullName);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user