Files

67 lines
2.3 KiB
C++
Raw Permalink Normal View History

// Fill out your copyright notice in the Description page of Project Settings.
2025-07-17 19:21:32 +02:00
#include "DTFluxUtils.h"
#include "DTFluxCoreSubsystem.h"
#include "DTFluxUtilitiesModule.h"
2025-07-13 01:18:31 +02:00
FText UFTDFluxUtils::GetFormatedName(const int& Bib, const int MaxChar, const FString Separator,
const FString OverFlowChar)
{
UDTFluxCoreSubsystem* CoreSubsystem = GEngine->GetEngineSubsystem<UDTFluxCoreSubsystem>();
2025-07-15 05:17:30 +02:00
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,
2025-07-13 01:18:31 +02:00
const FString Separator,
const FString OverFlowChar)
{
2025-07-13 01:18:31 +02:00
return Participant.GetFormattedNameText(MaxChar, Separator, OverFlowChar);
}
void UFTDFluxUtils::GetFullName(const int Bib, FText& OutFullName)
{
OutFullName = FText();
UDTFluxCoreSubsystem* CoreSubsystem = GEngine->GetEngineSubsystem<UDTFluxCoreSubsystem>();
2025-07-15 05:13:31 +02:00
if(CoreSubsystem != nullptr)
{
2025-07-15 05:13:31 +02:00
FDTFluxParticipant Participant;
if(CoreSubsystem->GetParticipant(Bib, Participant))
{
2025-07-15 05:13:31 +02:00
FString FormattedName = "";
if (Participant.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;
}
2025-07-15 05:13:31 +02:00
UE_LOG(logDTFluxUtilities, Warning, TEXT("Participant not found with Bib %i"), Bib);
}
UE_LOG(logDTFluxUtilities, Error, TEXT("DTFluxCoreSubsystem not available"));
}
2025-07-17 19:21:32 +02:00
2025-07-18 02:22:40 +02:00
TArray<FDTFluxSplitSensorInfo> UFTDFluxUtils::SortSplitRankingsByRank(const TArray<FDTFluxSplitSensorInfo>& Rankings)
2025-07-17 19:21:32 +02:00
{
2025-07-18 02:22:40 +02:00
TArray<FDTFluxSplitSensorInfo> CopyRankings = Rankings;
CopyRankings.Sort([](const FDTFluxSplitSensorInfo& A, const FDTFluxSplitSensorInfo& B)
2025-07-17 19:21:32 +02:00
{
return A.Rank < B.Rank;
});
2025-07-18 02:22:40 +02:00
return CopyRankings;
2025-07-17 19:21:32 +02:00
}