Adding Status and Last server response handled but not tested

This commit is contained in:
2025-07-03 17:28:51 +02:00
parent 2855fa1e98
commit fa5493adcf
43 changed files with 2035 additions and 379 deletions

View File

@ -5,6 +5,7 @@
#include "CoreMinimal.h"
#include "UObject/Object.h"
#include "Dom/JsonObject.h"
#include "Types/Struct/DTFluxCompositeKey.h"
#include "Types/Struct/DTFluxRaceDataStructs.h"
#include "DTFluxModelAsset.generated.h"
@ -37,10 +38,10 @@ public:
TMap<int /*ContestId*/, FDTFluxContestRankings> ContestRankings;
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
TArray<FDTFluxStageRankings> StageRankings;
TMap<FDTFluxStageKey, FDTFluxStageRankings> StageRankings;
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
TArray<FDTFluxStageRankings> SplitRankings;
TMap<FDTFluxSplitKey, FDTFluxSplitRankings> SplitRankings;
UFUNCTION(BlueprintCallable, CallInEditor, Category="DTFlux|ModelAsset")
void AddContest(const FDTFluxContest &Contest);
@ -60,11 +61,17 @@ public:
UFUNCTION(BlueprintCallable, Category="DTFlux|Contest|Utils")
FString GetContestNameForId(const int InContestID);
UFUNCTION(BlueprintCallable, Category="DTFlux|Contest|Utils")
bool UpdateStageRanking(const FDTFluxStageRankings& InStageRankings);
UFUNCTION(BlueprintCallable, Category="DTFlux|Stage")
void UpdateOrCreateStageRanking(const FDTFluxStageRankings& InStageRankings);
UFUNCTION(BlueprintCallable, Category="DTFlux|Contest|Utils")
bool UpdateSplitRanking(const FDTFluxStageRankings& InStageRankings);
UFUNCTION(BlueprintCallable, Category="DTFlux|Stage")
void AddStageRanking(const FDTFluxStageRankings& InStageRankings);
UFUNCTION(BlueprintCallable, Category="DTFlux|Split")
void UpdateOrCreateSplitRanking(const FDTFluxSplitRankings& InSplitRankings);
UFUNCTION(BlueprintCallable, Category="DTFlux|Split")
void AddSplitRanking(const FDTFluxSplitRankings& InSplitRanking);
UFUNCTION()
void AddContestRanking(const FDTFluxContestRankings& NewContestRankings);

View File

@ -3,6 +3,7 @@
#pragma once
#include "CoreMinimal.h"
#include "DTFluxCoreEnum.generated.h"
UENUM(BlueprintType)
@ -22,5 +23,7 @@ enum class EDTFluxConnectionStatus : uint8
{
Unset = 0 UMETA(DisplayName="Unset"),
Connected = 1 << 0 UMETA(DisplayName="Connected"),
Error = 2 << 1 UMETA(DisplayName="Error")
Error = 1 << 1 UMETA(DisplayName="Error"),
Closed = 1 << 2 UMETA(DisplayName="Closed"),
NotConnected= 1 << 3 UMETA(DisplayName="NotConnected")
};

View File

@ -11,12 +11,13 @@
UENUM(BlueprintType, Category="DTFlux|Model")
enum class EDTFluxParticipantStatusType : uint8
{
Normal = 0 UMETA(DisplayName="Normal"),
OutOfRace = 1 UMETA(DisplayName="HorsCourse"),
DSQ = 2 UMETA(DisplayName="Disqualifié"),
DNF = 3 UMETA(DisplayName="Abandon"),
DNS = 4 UMETA(DisplayName="NonPartant"),
NotLinedUp = 5 UMETA(DisplayName="NonPresentAuDépart"),
Normal = 0 UMETA(DisplayName="Normal"),
OutOfRace = 1 UMETA(DisplayName="HorsCourse"),
DSQ = 2 UMETA(DisplayName="Disqualifié"),
DNF = 3 UMETA(DisplayName="Abandon"),
DNS = 4 UMETA(DisplayName="NonPartant"),
NotLinedUp = 5 UMETA(DisplayName="NonPresentAuDépart"),
Unknown = 1 << 4 UMETA(DisplayName="Unknown")
};

View File

@ -0,0 +1,63 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Types/Struct/DTFluxPursuitStructs.h"
#include "Types/Struct/DTFluxRankingStructs.h"
#include "UObject/Object.h"
#include "DTFluxPursuitManager.generated.h"
/**
*
*/
UCLASS(BlueprintType)
class DTFLUXCORE_API UDTFluxPursuitManager : public UObject
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"), Transient)
TArray<FDTFluxPursuit> PursuitParticipants;
UPROPERTY(BlueprintReadOnly, EditAnywhere, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
FDateTime MassStart;
UPROPERTY(BlueprintReadOnly, EditAnywhere, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
int ContestId;
UPROPERTY(BlueprintReadOnly, EditAnywhere, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
int StageId;
UFUNCTION(BlueprintCallable, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
void InitForStage(const FDTFluxStageRankings& StageRankings);
UFUNCTION(BlueprintCallable, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
TArray<FDTFluxPursuit> GetNextPursuits(int MaxPursuit);
UFUNCTION(BlueprintCallable, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
TArray<FDTFluxPursuit> GetPursuits(int FromIndex = 0, int MaxPursuit=10);
UFUNCTION(BlueprintCallable, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
FDateTime GetMassStart();
UFUNCTION(BlueprintCallable, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
static FText GetFormattedName(FDTFluxPursuit& InPursuit, const int MaxChar = 10, const FString OverflowChar = FString(TEXT("...")));
UFUNCTION(BlueprintCallable, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
static FText DisplayPursuit(FDTFluxPursuit& InPursuit, const int MaxWidth = 14, const FString NameOverflowChar = FString(TEXT("...")));
UFUNCTION(BlueprintCallable, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
static bool IsUnique(const FDTFluxPursuit& InPursuit);
protected:
private:
UPROPERTY(VisibleAnywhere, Category="DTFlux|Pursuit", meta=(Keywords="Poursuit pursuit poursuit"))
int CurrentIndex;
};

View File

@ -0,0 +1,23 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "Types/Struct/DTFluxTeamListStruct.h"
#include "UDTFluxParticipantFactory.generated.h"
/**
*
*/
UCLASS()
class DTFLUXCORE_API UDTFluxParticipantFactory : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, Category="DTFlux|Factory")
static bool CreateParticipantFomJson(const FString& JsonString, FDTFluxParticipant& OutParticipant );
static bool CreateFromJsonCpp(const TSharedPtr<FJsonObject> JsonObject, FDTFluxParticipant& OutParticipant);
};

View File

@ -0,0 +1,100 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "UObject/Object.h"
#include "DTFluxCompositeKey.generated.h"
/**
*
*/
USTRUCT(BlueprintType)
struct DTFLUXCORE_API FDTFluxStageKey
{
GENERATED_BODY()
FDTFluxStageKey() = default;
FDTFluxStageKey(const int InContestId, const int InStageId )
:ContestId(InContestId)
, StageId(InStageId){};
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="DTFlux|Model")
int ContestId = -1;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="DTFlux|Model")
int StageId = -1;
friend uint32 GetTypeHash(const FDTFluxStageKey& Key)
{
return HashCombine(
GetTypeHash(Key.ContestId),
GetTypeHash(Key.StageId)
);
}
bool operator==(const FDTFluxStageKey& Other) const
{
return ContestId == Other.ContestId && StageId == Other.StageId;
}
FString GetDisplayName() const
{
return FString::Printf(TEXT("Contest%i -| Stage%i"), ContestId, StageId);
}
FText GetTooltipText() const
{
return FText::Format(INVTEXT("Contest{0}|Stage{1}"),
FText::AsNumber(ContestId),
FText::AsNumber(StageId));
}
};
/**
*
*/
USTRUCT(BlueprintType)
struct DTFLUXCORE_API FDTFluxSplitKey
{
GENERATED_BODY()
FDTFluxSplitKey() = default;
FDTFluxSplitKey(const int InContestId, const int InStageId, const int InSplitId )
:ContestId(InContestId)
, StageId(InStageId)
, SplitId(InSplitId){};
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="DTFlux|Model")
int ContestId = -1;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="DTFlux|Model")
int StageId = -1;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="DTFlux|Model")
int SplitId = -1;
friend uint32 GetTypeHash(const FDTFluxSplitKey& Key)
{
return HashCombine(
GetTypeHash(Key.ContestId),
GetTypeHash(Key.StageId),
GetTypeHash(Key.SplitId)
);
}
bool operator==(const FDTFluxSplitKey& Other) const
{
return ContestId == Other.ContestId && StageId == Other.StageId && SplitId == Other.SplitId;
}
FString GetDisplayName() const
{
return FString::Printf(TEXT("Contest%i | Stage%i | Split%i"), ContestId, StageId, SplitId);
}
FText GetTooltipText() const
{
return FText::Format(INVTEXT("Contest{0}|Stage{1}|Split{2}"),
FText::AsNumber(ContestId),
FText::AsNumber(StageId),
FText::AsNumber(SplitId)
);
}
};

View File

@ -0,0 +1,38 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "DTFluxTeamListStruct.h"
#include "DTFluxPursuitStructs.generated.h"
/**
*
*/
USTRUCT(BlueprintType, Blueprintable)
struct DTFLUXCORE_API FDTFluxPursuit
{
GENERATED_BODY()
public:
FDTFluxPursuit();
FDTFluxPursuit(const TArray<FDTFluxParticipant>& InParticipants) : Participants(InParticipants){};
~FDTFluxPursuit();
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category="DTFlux|Pursuit")
TArray<FDTFluxParticipant> Participants;
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category="DTFlux|Pursuit")
FDateTime StartTime;
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category="DTFlux|Pursuit")
int IndexMultiple = 0;
FText GetFormattedName(const int MaxChar = 15, const FString OverflowChar = FString(TEXT("...")));
FText DisplayPursuit(const int MaxWidth = 20, const FString NameOverflowChar = FString(TEXT("...")));
bool IsUnique() const;
};

View File

@ -3,6 +3,7 @@
#pragma once
#include "CoreMinimal.h"
#include "DTFluxCompositeKey.h"
#include "UObject/Object.h"
#include "DTFluxRankingStructs.generated.h"
@ -58,7 +59,7 @@ public:
* Representing a stage ranking for a participant
*/
USTRUCT(BlueprintType, Category="DTFlux|Model")
struct DTFLUXCORE_API FDTFluxStageRanking
struct DTFLUXCORE_API FDTFluxDetailedRankingItem
{
GENERATED_BODY()
public:
@ -91,19 +92,76 @@ public:
};
USTRUCT(BlueprintType)
struct FDTFluxStageRankings
struct FDTFluxDetailedRankings
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadWrite,Category="DTFlux|Model|Ranking", VisibleAnywhere)
TArray<FDTFluxStageRanking> Rankings;
UPROPERTY(BlueprintReadWrite,Category="DTFlux|Model|Ranking", VisibleAnywhere)
int ContestId;
UPROPERTY(BlueprintReadWrite,Category="DTFlux|Model|Ranking", VisibleAnywhere)
int StageId;
UPROPERTY(BlueprintReadWrite,Category="DTFlux|Model|Ranking", VisibleAnywhere)
int SplitId;
TArray<FDTFluxDetailedRankingItem> Rankings;
};
/**
* @struct FDTFluxStageRanking
* Representing a stage ranking for a participant
* This struct is only a cosmetic Struct
*/
USTRUCT(BlueprintType)
struct FDTFluxStageRanking : public FDTFluxDetailedRankingItem
{
GENERATED_BODY()
};
/**
* @struct FDTFluxSplitRanking
* Representing a split ranking for a participant
* This struct is only a cosmetic Struct
*/
USTRUCT(BlueprintType, Category="DTFlux|Model")
struct DTFLUXCORE_API FDTFluxSplitRanking : public FDTFluxStageRanking
{
GENERATED_BODY()
};
/**
* @struct FDTFluxStageRankings
* StageRanking Container Struct
*/
USTRUCT(BlueprintType)
struct FDTFluxStageRankings : public FDTFluxDetailedRankings
{
GENERATED_BODY()
inline FDTFluxStageKey GetKeyFrom(const FDTFluxStageRankings& InRankings)
{
return FDTFluxStageKey(InRankings.ContestId, InRankings.StageId);
}
inline FDTFluxStageKey GetCompositeKey() const
{
return FDTFluxStageKey(ContestId, StageId);
}
};
USTRUCT(BlueprintType)
struct FDTFluxSplitRankings : public FDTFluxDetailedRankings
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadWrite,Category="DTFlux|Model|Ranking", VisibleAnywhere)
int SplitId;
inline static FDTFluxSplitKey GetKeyFrom(const FDTFluxSplitRankings& InRankings)
{
return FDTFluxSplitKey(InRankings.ContestId, InRankings.StageId, InRankings.SplitId);
}
inline FDTFluxSplitKey GetCompositeKey() const
{
return FDTFluxSplitKey(ContestId, StageId, SplitId);
}
};

View File

@ -0,0 +1,37 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "DTFluxTeamListStruct.h"
#include "UObject/Object.h"
#include "DTFluxSplitSensor.generated.h"
/**
*
*/
USTRUCT(BlueprintType)
struct FDTFluxSplitSensorInfo
{
GENERATED_BODY()
public:
FDTFluxSplitSensorInfo() = default;
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
int Bib = -1;
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
int ContestId = -1;
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
int StageId = -1;
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
int SplitId = -1;
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
FString Time = "";
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
FString Gap = "-";
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
int Rank;
};

View File

@ -43,20 +43,7 @@ public:
FString Club;
};
/**
* @struct FDTFluxTeamListDefinition
* Struct representing the Participant List definition
* Used to exchange data between Objects in the system
*/
USTRUCT(BlueprintType)
struct DTFLUXCORE_API FDTFluxTeamListDefinition
{
GENERATED_BODY()
public:
UPROPERTY()
// ReSharper disable once IdentifierTypo
TArray<FDTFluxTeamListItemDefinition> Datas;
};
@ -101,14 +88,36 @@ USTRUCT(BlueprintType, Category="DTFlux|Model")
struct DTFLUXCORE_API FDTFluxParticipant
{
GENERATED_BODY()
friend class UDTFluxModelAsset;
friend class UDTFluxParticipantFactory;
public:
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
int Bib = -1;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
FDTFluxPerson Person1;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
FDTFluxPerson Person2;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
// Constructeur public par défaut requis par Unreal
FDTFluxParticipant()
: Bib(-1)
,ContestId(-1)
, Elite(false)
, Status(static_cast<EDTFluxParticipantStatusType>(0))
, bIsMassStartParticipant(false)
, LastSplitId(0)
{
Teammate.Reset();
}
bool operator == ( int Rhs) const
{
return Rhs == 0 && Bib == -1 && Team.IsEmpty() && Club.IsEmpty() && ContestId == -1
&& Teammate.IsEmpty();
}
UPROPERTY(BlueprintReadOnly, Category="DTFlux|model", EditAnywhere)
int Bib = -1;
UPROPERTY(BlueprintReadOnly, Category="DTFlux|model", EditAnywhere)
int ContestId = -1;
UPROPERTY(BlueprintReadOnly, Category="DTFlux|model", EditAnywhere)
FString Category;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
FString Club;
@ -121,9 +130,58 @@ public:
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model", EditAnywhere)
bool bIsMassStartParticipant = false;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|model")
int LastSplitId = 0;
bool IsTeam() const;
void Dump() const;
FString GetParticipantFormatedName(bool Truncate = false, int MaxSize = 20) const;
int LastSplitId = -1;
// void Dump() const;
void AddTeammate(const FDTFluxPerson& Person);
void AddTeammate(const FString LastName, const FString FirstName, const FString Gender);
FText GetFormattedName(const int MaxChar = 15, const FString OverflowChar = FString("..."));
FText GetConcatFormattedName(const int MaxChar = 20, const FString OverflowChar = FString("..."));
private:
// --- Constructeur privé ---
explicit FDTFluxParticipant(const TSharedPtr<FJsonObject>& JsonObject);
};
protected:
UPROPERTY(Category="DTFlux|model", VisibleAnywhere)
TArray<FDTFluxPerson> Teammate;
// Méthode publique pour construire à partir d'un JSON (utilisée par la factory)
static FDTFluxParticipant CreateFromJson(const TSharedPtr<FJsonObject>& JsonObject);
int GetTeammateNum() const;
bool IsTeam();
};
/**
* @struct FDTFluxTeamListDefinition
* Struct representing the Participant List definition
* Used to exchange data between Objects in the system
*/
USTRUCT(BlueprintType)
struct DTFLUXCORE_API FDTFluxTeamListDefinition
{
GENERATED_BODY()
public:
UPROPERTY()
// ReSharper disable once IdentifierTypo
TArray<FDTFluxParticipant> Participants;
};
USTRUCT(BlueprintType)
struct FDTFluxTeamStatusUpdate
{
GENERATED_BODY()
public:
FDTFluxTeamStatusUpdate() = default;
FDTFluxTeamStatusUpdate(const int InBib, const int InStatus)
:Bib(InBib)
, Status(static_cast<EDTFluxParticipantStatusType>(InStatus)){};
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Participant")
int Bib = -1;
UPROPERTY(BlueprintReadWrite, Category="DTFlux|Participant")
EDTFluxParticipantStatusType Status = EDTFluxParticipantStatusType::Unknown;
};