Interaktionslogik und UI-Aufforderungen verbessert
Neue Funktion `GetInteractableDisplayName` in `Interactable.h` hinzugefügt, um benutzerfreundliche Objektnamen für Interaktionsaufforderungen bereitzustellen. Die Logik in `InteractionContextMenuWidget.cpp` wurde überarbeitet: - Aufforderungen werden ausgeblendet, wenn keine Optionen verfügbar sind. - Objektnamen werden in die Aufforderungen integriert. - Zusätzliche Hinweise für sekundäre Interaktionen und Kontextmenüs hinzugefügt. Binärdateien (`BP_BerryBush.uasset`, `BP_Campfire.uasset`, `BP_ThirdPersonCharacter.uasset`, `WBP_InteractionContextMenu.uasset`) aktualisiert.
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -31,6 +31,10 @@ public:
|
|||||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Interaction")
|
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Interaction")
|
||||||
TArray<FInteractionOption> GetInteractionOptions(AActor* Interactor);
|
TArray<FInteractionOption> GetInteractionOptions(AActor* Interactor);
|
||||||
|
|
||||||
|
/** Friendly object name for prompts, e.g. "Berry Bush", "Wooden Chest", "Workbench". Optional - an empty default just drops the "with X" part of the prompt. */
|
||||||
|
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Interaction")
|
||||||
|
FText GetInteractableDisplayName();
|
||||||
|
|
||||||
/** Runs the interaction identified by ActionID (one of the ActionIDs previously returned by GetInteractionOptions). */
|
/** Runs the interaction identified by ActionID (one of the ActionIDs previously returned by GetInteractionOptions). */
|
||||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Interaction")
|
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Interaction")
|
||||||
void ExecuteInteraction(AActor* Interactor, FName ActionID);
|
void ExecuteInteraction(AActor* Interactor, FName ActionID);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "InteractionContextMenuWidget.h"
|
#include "InteractionContextMenuWidget.h"
|
||||||
#include "Interaction/InteractionComponent.h"
|
#include "Interaction/InteractionComponent.h"
|
||||||
|
#include "Interaction/Interactable.h"
|
||||||
#include "Components/VerticalBox.h"
|
#include "Components/VerticalBox.h"
|
||||||
#include "Components/TextBlock.h"
|
#include "Components/TextBlock.h"
|
||||||
#include "Blueprint/WidgetTree.h"
|
#include "Blueprint/WidgetTree.h"
|
||||||
@@ -50,15 +51,32 @@ void UInteractionContextMenuWidget::HandleFocusedInteractableChanged(AActor* Foc
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FocusedActor && Options.Num() > 0)
|
if (!FocusedActor || Options.Num() == 0)
|
||||||
{
|
|
||||||
PromptText->SetText(Options[0].DisplayName);
|
|
||||||
PromptText->SetVisibility(ESlateVisibility::HitTestInvisible);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
PromptText->SetVisibility(ESlateVisibility::Collapsed);
|
PromptText->SetVisibility(ESlateVisibility::Collapsed);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// "{Verb} with {ObjectName}" on line one, "Press E" always, then a hint for the
|
||||||
|
// hold behaviour only when there is one (2 options = secondary, 3+ = Context Menu).
|
||||||
|
const FText ObjectName = IInteractable::Execute_GetInteractableDisplayName(FocusedActor);
|
||||||
|
FString Prompt = ObjectName.IsEmpty()
|
||||||
|
? Options[0].DisplayName.ToString()
|
||||||
|
: FString::Printf(TEXT("%s with %s"), *Options[0].DisplayName.ToString(), *ObjectName.ToString());
|
||||||
|
|
||||||
|
Prompt += TEXT("\nPress E");
|
||||||
|
|
||||||
|
if (Options.Num() == 2)
|
||||||
|
{
|
||||||
|
Prompt += TEXT("\nHold E for secondary interaction");
|
||||||
|
}
|
||||||
|
else if (Options.Num() >= 3)
|
||||||
|
{
|
||||||
|
Prompt += TEXT("\nHold E for Context Menu");
|
||||||
|
}
|
||||||
|
|
||||||
|
PromptText->SetText(FText::FromString(Prompt));
|
||||||
|
PromptText->SetVisibility(ESlateVisibility::HitTestInvisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UInteractionContextMenuWidget::RefreshOptions(const TArray<FInteractionOption>& Options, int32 HighlightedIndex)
|
void UInteractionContextMenuWidget::RefreshOptions(const TArray<FInteractionOption>& Options, int32 HighlightedIndex)
|
||||||
|
|||||||
Reference in New Issue
Block a user