Make it easier to create look-at widgets

This commit is contained in:
2025-04-15 15:48:33 -04:00
parent 3423c01807
commit c0160bdd19
8 changed files with 83 additions and 59 deletions

View File

@@ -31,7 +31,7 @@ class INTEGRATION_API UlxLookAtWidget : public UUserWidget
public:
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "Luprex|Look-At Detection")
void ReadLuaConfiguration(AActor *Place, UlxLuaValues *Config);
void ReadLuaConfiguration(UlxLuaValues *Config);
};
/**
@@ -79,24 +79,33 @@ public:
UFUNCTION(BlueprintPure, meta = (WorldContext = "Context"),Category = "Luprex|Look-At Detection")
static FVector2D GetLookAtPixel(const UObject *Context);
UFUNCTION(BlueprintPure, meta = (WorldContext = "Context"),Category = "Luprex|Look-At Detection")
static const FHitResult &GetPreviousLookAt(const UObject *Context) { return FromContext(Context)->PreviousLookAt; }
UFUNCTION(BlueprintPure, meta = (WorldContext = "Context"),Category = "Luprex|Look-At Detection")
static const AActor *GetPreviousLookAtActor(const UObject *Context) { return FromContext(Context)->PreviousLookAt.GetActor(); }
UFUNCTION(BlueprintPure, meta = (WorldContext = "Context"),Category = "Luprex|Look-At Detection")
static FVector2D GetPreviousLookAtPixel(const UObject *Context);
UFUNCTION(BlueprintPure, meta = (WorldContext = "Context"),Category = "Luprex|Look-At Detection")
static bool IsLookAtChanged(const UObject *Context);
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context"), Category = "Luprex|Look-At Detection")
static void SetLookAtWidget(const UObject *Context, UlxLookAtWidget *Widget);
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context"), Category = "Luprex|Look-At Detection")
static UlxLookAtWidget *GetLookAtWidget(const UObject *Context) { return FromContext(Context)->LookAtWidget; }
// Create a new Look-At Widget, given the blueprint's name.
//
// The prefix WB_ is added to the blueprint name, and the blueprint is
// searched for in the folder "Widgets".
//
// * If the specified blueprint is not found, execution continues
// on the "Not Found" pin.
//
// * If the flag "Error if Not Found" is true, and the widget blueprint
// is not found, logs an error.
//
// * If the flag "Add to Viewport" is true, the new widget is added
// to the viewport.
//
// * If the flag "Set Look at Widget" is true, the new widget is stored
// as the current look-at widget.
//
UFUNCTION(BlueprintCallable, meta = (ExpandEnumAsExecs = "Result", WorldContext = "Context"), Category = "Luprex|Look-At Detection")
static UlxLookAtWidget *CreateLookAtWidgetByName(UObject *Context, const FString &BlueprintName,
ElxFoundOrNotFound &Result, bool ErrorIfNotFound = true, bool AddToViewport = true, bool SetLookAtWidget = true);
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context"), Category = "Luprex|Look-At Detection")
static void ClearLookAtWidget(const UObject *Context);
@@ -168,14 +177,12 @@ public:
UPROPERTY()
UlxTangibleManager *TangibleManager;
// The actor that the player was looking at, previous frame.
UPROPERTY()
FHitResult PreviousLookAt;
// The actor that the player is looking at, current frame.
UPROPERTY()
FHitResult CurrentLookAt;
bool MustCallLookAtChanged;
UPROPERTY()
UlxLookAtWidget *LookAtWidget;