51 lines
2.0 KiB
C
51 lines
2.0 KiB
C
|
|
#pragma once
|
||
|
|
|
||
|
|
#include "CoreMinimal.h"
|
||
|
|
#include "Blueprint/UserWidget.h"
|
||
|
|
#include "EnhancedInputComponent.h"
|
||
|
|
#include "LuprexUserWidget.generated.h"
|
||
|
|
|
||
|
|
UCLASS(BlueprintType, Blueprintable)
|
||
|
|
class INTEGRATION_API UlxUserWidget : public UUserWidget
|
||
|
|
{
|
||
|
|
GENERATED_BODY()
|
||
|
|
|
||
|
|
public:
|
||
|
|
using EventBinding = TUniquePtr<FEnhancedInputActionEventBinding>;
|
||
|
|
|
||
|
|
UlxUserWidget(const FObjectInitializer& ObjectInitializer);
|
||
|
|
|
||
|
|
virtual void NativeOnInitialized() override;
|
||
|
|
|
||
|
|
// Clone every enhanced-input action binding currently on InputComponent
|
||
|
|
// into SavedEnhancedActionEventBindings, so bindings can later be removed
|
||
|
|
// from the component and reinstated without losing their delegates.
|
||
|
|
void BackupInputComponent();
|
||
|
|
|
||
|
|
// Remove every live event binding whose action is InputAction.
|
||
|
|
// No-op if there are none, or if InputComponent isn't enhanced.
|
||
|
|
UFUNCTION(BlueprintCallable, Category="Luprex|Widget Enhanced Input")
|
||
|
|
void DisableEventBinding(const UInputAction* InputAction);
|
||
|
|
|
||
|
|
// Replace any live bindings for InputAction with fresh clones of every
|
||
|
|
// saved binding for that action. Leaves the backup array intact so this
|
||
|
|
// can be called repeatedly.
|
||
|
|
UFUNCTION(BlueprintCallable, Category="Luprex|Widget Enhanced Input")
|
||
|
|
void RestoreInputBinding(const UInputAction* InputAction);
|
||
|
|
|
||
|
|
// Install live bindings on From that, when fired, dispatch through a
|
||
|
|
// clone of each saved binding for To. Clears any pre-existing live
|
||
|
|
// bindings on From first. Backup array is untouched.
|
||
|
|
UFUNCTION(BlueprintCallable, Category="Luprex|Widget Enhanced Input")
|
||
|
|
void RedirectInputAction(const UInputAction* From, const UInputAction* To);
|
||
|
|
|
||
|
|
// Cloned bindings captured from InputComponent after construction.
|
||
|
|
TArray<EventBinding> SavedEnhancedActionEventBindings;
|
||
|
|
|
||
|
|
private:
|
||
|
|
// Strip the synthetic const off UEnhancedInputComponent::GetActionEventBindings
|
||
|
|
// to get direct mutable access to the protected array. Well-defined because
|
||
|
|
// the underlying object is not const; only the getter's return type is.
|
||
|
|
static TArray<EventBinding>& GetMutableActionEventBindings(UEnhancedInputComponent* EIC);
|
||
|
|
};
|