From fd09e174594d2ce4e1cec8cc9cedcfdc1d7ba99d Mon Sep 17 00:00:00 2001 From: axiomlogicnexus Date: Fri, 1 May 2026 23:29:23 +0200 Subject: [PATCH] Bridge imported generated selectors into launch config --- .../HyperTwistTrainingCatalogLibrary.cpp | 59 +++++++++++++++++++ .../HyperTwistTrainingRuntimeLibrary.cpp | 14 +++++ .../HyperTwistTrainingSubsystem.cpp | 12 ++++ .../HyperTwistTrainingCatalogLibrary.h | 8 +++ .../HyperTwistTrainingRuntimeLibrary.h | 6 ++ .../HyperTwistTrainingSubsystem.h | 5 ++ .../HyperTwistTrainingTypes.h | 51 ++++++++++++++++ 7 files changed, 155 insertions(+) diff --git a/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistTraining/HyperTwistTrainingCatalogLibrary.cpp b/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistTraining/HyperTwistTrainingCatalogLibrary.cpp index d0af91e..7f69dd0 100644 --- a/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistTraining/HyperTwistTrainingCatalogLibrary.cpp +++ b/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistTraining/HyperTwistTrainingCatalogLibrary.cpp @@ -2801,6 +2801,65 @@ bool UHyperTwistTrainingCatalogLibrary::TryGetImportedRuntimeSelectorOptionCaseF return OutCase.IsStructurallyValid(); } +bool UHyperTwistTrainingCatalogLibrary::TryBuildImportedGeneratedModeLaunchConfig( + const FHyperTwistTrainingDeck& Deck, + const FHyperTwistTrainingImportedRuntimeSelectionState& ImportedRuntimeSelectionState, + const FHyperTwistTrainingSession& Session, + FHyperTwistTrainingImportedGeneratedModeLaunchConfig& OutLaunchConfig +) +{ + OutLaunchConfig = FHyperTwistTrainingImportedGeneratedModeLaunchConfig(); + if (!Deck.IsStructurallyValid() + || !Session.IsStructurallyValid() + || !Deck.ImportedRuntimeSurface.IsStructurallyValid() + || !ImportedRuntimeSelectionState.IsStructurallyValid() + || !Deck.ImportedRuntimeSurface.SurfaceKind.Equals(TEXT("generated-mode"), ESearchCase::IgnoreCase) + || ImportedRuntimeSelectionState.SurfaceId != Deck.ImportedRuntimeSurface.SurfaceId) + { + return false; + } + + for (const FHyperTwistTrainingImportedRuntimeSelector& Selector : Deck.ImportedRuntimeSurface.Selectors) + { + const FHyperTwistTrainingImportedRuntimeSelectorChoice* MatchingChoice = + ImportedRuntimeSelectionState.SelectorChoices.FindByPredicate( + [&Selector](const FHyperTwistTrainingImportedRuntimeSelectorChoice& Candidate) + { + return Candidate.SelectorId == Selector.SelectorId && Candidate.IsStructurallyValid(); + } + ); + if (MatchingChoice == nullptr) + { + return false; + } + } + + OutLaunchConfig.DeckId = Deck.DeckId; + OutLaunchConfig.UserId = Session.UserId; + OutLaunchConfig.TrainingSessionId = Session.TrainingSessionId; + OutLaunchConfig.DeliveryMode = Session.Mode; + OutLaunchConfig.SurfaceId = Deck.ImportedRuntimeSurface.SurfaceId; + OutLaunchConfig.SurfaceLabel = Deck.ImportedRuntimeSurface.SurfaceLabel; + OutLaunchConfig.RuntimeModeId = Deck.ImportedRuntimeSurface.RuntimeModeId; + OutLaunchConfig.GeneratorType = Deck.ImportedRuntimeSurface.GeneratorType; + OutLaunchConfig.OriginPaths = Deck.ImportedRuntimeSurface.OriginPaths; + OutLaunchConfig.Notes = Deck.ImportedRuntimeSurface.Notes; + OutLaunchConfig.SelectorChoices = ImportedRuntimeSelectionState.SelectorChoices; + + const FHyperTwistTrainingCase* SeedCase = Deck.Cases.FindByPredicate( + [](const FHyperTwistTrainingCase& Candidate) + { + return Candidate.IsStructurallyValid(); + } + ); + if (SeedCase != nullptr) + { + OutLaunchConfig.PuzzleId = SeedCase->PuzzleId; + } + + return OutLaunchConfig.IsStructurallyValid(); +} + FHyperTwistTrainingMethodDescriptor UHyperTwistTrainingCatalogLibrary::DescribeTrainingDeckMethod( const FHyperTwistTrainingDeck& Deck ) diff --git a/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.cpp b/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.cpp index 6a761a6..9599bc8 100644 --- a/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.cpp +++ b/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.cpp @@ -116,6 +116,20 @@ bool UHyperTwistTrainingRuntimeLibrary::TryGetActiveImportedRuntimeSelectionStat return false; } +bool UHyperTwistTrainingRuntimeLibrary::TryGetActiveImportedGeneratedModeLaunchConfig( + UObject* WorldContextObject, + FHyperTwistTrainingImportedGeneratedModeLaunchConfig& OutLaunchConfig +) +{ + if (UHyperTwistTrainingSubsystem* TrainingSubsystem = GetTrainingSubsystem(WorldContextObject)) + { + return TrainingSubsystem->TryGetActiveImportedGeneratedModeLaunchConfig(OutLaunchConfig); + } + + OutLaunchConfig = FHyperTwistTrainingImportedGeneratedModeLaunchConfig(); + return false; +} + FHyperTwistTrainingRunState UHyperTwistTrainingRuntimeLibrary::ApplyActiveImportedRuntimeSelectorOption( UObject* WorldContextObject, const FString& SelectorId, diff --git a/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistTraining/HyperTwistTrainingSubsystem.cpp b/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistTraining/HyperTwistTrainingSubsystem.cpp index 22aec8e..83326ca 100644 --- a/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistTraining/HyperTwistTrainingSubsystem.cpp +++ b/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistTraining/HyperTwistTrainingSubsystem.cpp @@ -759,6 +759,18 @@ bool UHyperTwistTrainingSubsystem::TryGetActiveImportedRuntimeSelectionState( return OutSelectionState.IsStructurallyValid(); } +bool UHyperTwistTrainingSubsystem::TryGetActiveImportedGeneratedModeLaunchConfig( + FHyperTwistTrainingImportedGeneratedModeLaunchConfig& OutLaunchConfig +) const +{ + return UHyperTwistTrainingCatalogLibrary::TryBuildImportedGeneratedModeLaunchConfig( + ActiveRunState.ActiveDeck, + ActiveRunState.ImportedRuntimeSelectionState, + ActiveRunState.Session, + OutLaunchConfig + ); +} + FHyperTwistTrainingRunState UHyperTwistTrainingSubsystem::ApplyActiveImportedRuntimeSelectorOption( const FString& SelectorId, const FString& OptionId diff --git a/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistTraining/HyperTwistTrainingCatalogLibrary.h b/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistTraining/HyperTwistTrainingCatalogLibrary.h index 683b3db..ca57fbc 100644 --- a/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistTraining/HyperTwistTrainingCatalogLibrary.h +++ b/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistTraining/HyperTwistTrainingCatalogLibrary.h @@ -162,6 +162,14 @@ public: FHyperTwistTrainingCase& OutCase ); + UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training|Catalog") + static bool TryBuildImportedGeneratedModeLaunchConfig( + const FHyperTwistTrainingDeck& Deck, + const FHyperTwistTrainingImportedRuntimeSelectionState& ImportedRuntimeSelectionState, + const FHyperTwistTrainingSession& Session, + FHyperTwistTrainingImportedGeneratedModeLaunchConfig& OutLaunchConfig + ); + UFUNCTION(BlueprintPure, Category = "HyperTwist|Training|Catalog") static FHyperTwistTrainingMethodDescriptor DescribeTrainingDeckMethod( const FHyperTwistTrainingDeck& Deck diff --git a/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h b/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h index d42d29f..e1a947d 100644 --- a/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h +++ b/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h @@ -54,6 +54,12 @@ public: FHyperTwistTrainingImportedRuntimeSelectionState& OutSelectionState ); + UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training", meta = (WorldContext = "WorldContextObject")) + static bool TryGetActiveImportedGeneratedModeLaunchConfig( + UObject* WorldContextObject, + FHyperTwistTrainingImportedGeneratedModeLaunchConfig& OutLaunchConfig + ); + UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training", meta = (WorldContext = "WorldContextObject")) static FHyperTwistTrainingRunState ApplyActiveImportedRuntimeSelectorOption( UObject* WorldContextObject, diff --git a/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistTraining/HyperTwistTrainingSubsystem.h b/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistTraining/HyperTwistTrainingSubsystem.h index 013a52a..9417e80 100644 --- a/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistTraining/HyperTwistTrainingSubsystem.h +++ b/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistTraining/HyperTwistTrainingSubsystem.h @@ -43,6 +43,11 @@ public: FHyperTwistTrainingImportedRuntimeSelectionState& OutSelectionState ) const; + UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training") + bool TryGetActiveImportedGeneratedModeLaunchConfig( + FHyperTwistTrainingImportedGeneratedModeLaunchConfig& OutLaunchConfig + ) const; + UFUNCTION(BlueprintCallable, Category = "HyperTwist|Training") FHyperTwistTrainingRunState ApplyActiveImportedRuntimeSelectorOption( const FString& SelectorId, diff --git a/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistTraining/HyperTwistTrainingTypes.h b/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistTraining/HyperTwistTrainingTypes.h index ec0d36e..7b045df 100644 --- a/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistTraining/HyperTwistTrainingTypes.h +++ b/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistTraining/HyperTwistTrainingTypes.h @@ -493,6 +493,57 @@ struct FHyperTwistTrainingImportedRuntimeSelectionState } }; +USTRUCT(BlueprintType) +struct FHyperTwistTrainingImportedGeneratedModeLaunchConfig +{ + GENERATED_BODY() + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString DeckId; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString UserId; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString TrainingSessionId; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + EHyperTwistTrainingDeliveryMode DeliveryMode = EHyperTwistTrainingDeliveryMode::Timer; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString PuzzleId; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString SurfaceId; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString SurfaceLabel; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString RuntimeModeId; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString GeneratorType; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + TArray SelectorChoices; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + TArray OriginPaths; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString Notes; + + bool IsStructurallyValid() const + { + return !DeckId.IsEmpty() + && !TrainingSessionId.IsEmpty() + && !SurfaceId.IsEmpty() + && !RuntimeModeId.IsEmpty() + && SelectorChoices.Num() > 0; + } +}; + USTRUCT(BlueprintType) struct FHyperTwistTrainingDeck {