diff --git a/Content/Testing/BP_BerryBush.uasset b/Content/Testing/BP_BerryBush.uasset new file mode 100644 index 0000000..229d68c Binary files /dev/null and b/Content/Testing/BP_BerryBush.uasset differ diff --git a/Content/Testing/BP_Campfire.uasset b/Content/Testing/BP_Campfire.uasset index 33862bd..cb62416 100644 Binary files a/Content/Testing/BP_Campfire.uasset and b/Content/Testing/BP_Campfire.uasset differ diff --git a/Content/ThirdPerson/Blueprints/BP_ThirdPersonCharacter.uasset b/Content/ThirdPerson/Blueprints/BP_ThirdPersonCharacter.uasset index 6623a9b..67623f4 100644 Binary files a/Content/ThirdPerson/Blueprints/BP_ThirdPersonCharacter.uasset and b/Content/ThirdPerson/Blueprints/BP_ThirdPersonCharacter.uasset differ diff --git a/Content/UI/WBP_InteractionContextMenu.uasset b/Content/UI/WBP_InteractionContextMenu.uasset index 0d0362f..1cc374f 100644 Binary files a/Content/UI/WBP_InteractionContextMenu.uasset and b/Content/UI/WBP_InteractionContextMenu.uasset differ diff --git a/Source/KingshearthLegacy/Interaction/Interactable.h b/Source/KingshearthLegacy/Interaction/Interactable.h index 887a4a0..3500241 100644 --- a/Source/KingshearthLegacy/Interaction/Interactable.h +++ b/Source/KingshearthLegacy/Interaction/Interactable.h @@ -31,6 +31,10 @@ public: UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Interaction") TArray 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). */ UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Interaction") void ExecuteInteraction(AActor* Interactor, FName ActionID); diff --git a/Source/KingshearthLegacy/UI/InteractionContextMenuWidget.cpp b/Source/KingshearthLegacy/UI/InteractionContextMenuWidget.cpp index d515f73..dc353dc 100644 --- a/Source/KingshearthLegacy/UI/InteractionContextMenuWidget.cpp +++ b/Source/KingshearthLegacy/UI/InteractionContextMenuWidget.cpp @@ -2,6 +2,7 @@ #include "InteractionContextMenuWidget.h" #include "Interaction/InteractionComponent.h" +#include "Interaction/Interactable.h" #include "Components/VerticalBox.h" #include "Components/TextBlock.h" #include "Blueprint/WidgetTree.h" @@ -50,15 +51,32 @@ void UInteractionContextMenuWidget::HandleFocusedInteractableChanged(AActor* Foc return; } - if (FocusedActor && Options.Num() > 0) - { - PromptText->SetText(Options[0].DisplayName); - PromptText->SetVisibility(ESlateVisibility::HitTestInvisible); - } - else + if (!FocusedActor || Options.Num() == 0) { 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& Options, int32 HighlightedIndex)