Added Sort Ranking
This commit is contained in:
65
Source/DTFluxUtilities/Private/DTFluxUtils.cpp
Normal file
65
Source/DTFluxUtilities/Private/DTFluxUtils.cpp
Normal file
@ -0,0 +1,65 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "DTFluxUtils.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>();
|
||||
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,
|
||||
const FString Separator,
|
||||
const FString OverFlowChar)
|
||||
{
|
||||
return Participant.GetFormattedNameText(MaxChar, Separator, OverFlowChar);
|
||||
}
|
||||
|
||||
void UFTDFluxUtils::GetFullName(const int Bib, FText& OutFullName)
|
||||
{
|
||||
OutFullName = FText();
|
||||
UDTFluxCoreSubsystem* CoreSubsystem = GEngine->GetEngineSubsystem<UDTFluxCoreSubsystem>();
|
||||
if(CoreSubsystem != nullptr)
|
||||
{
|
||||
FDTFluxParticipant Participant;
|
||||
if(CoreSubsystem->GetParticipant(Bib, Participant))
|
||||
{
|
||||
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;
|
||||
}
|
||||
UE_LOG(logDTFluxUtilities, Warning, TEXT("Participant not found with Bib %i"), Bib);
|
||||
}
|
||||
UE_LOG(logDTFluxUtilities, Error, TEXT("DTFluxCoreSubsystem not available"));
|
||||
}
|
||||
|
||||
void UFTDFluxUtils::SortSplitRankingsByRank(TArray<FDTFluxSplitRanking>& Rankings)
|
||||
{
|
||||
Rankings.Sort([](const FDTFluxSplitRanking& A, const FDTFluxSplitRanking& B)
|
||||
{
|
||||
return A.Rank < B.Rank;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user