|
|
|
|
| #pragma once
|
|
|
| #include "CommonUserWidget.h"
|
| #include "Fonts/SlateFontInfo.h"
|
|
|
| #include "CommonPlayerInputKey.generated.h"
|
|
|
| #define UE_API COMMONGAME_API
|
|
|
| enum class ECommonInputType : uint8;
|
|
|
| class APlayerController;
|
| class FPaintArgs;
|
| class FSlateRect;
|
| class FSlateWindowElementList;
|
| class FWidgetStyle;
|
| class UCommonLocalPlayer;
|
| class UMaterialInstanceDynamic;
|
| class UObject;
|
| struct FFrame;
|
| struct FGeometry;
|
|
|
| UENUM(BlueprintType)
|
| enum class ECommonKeybindForcedHoldStatus : uint8
|
| {
|
| NoForcedHold,
|
| ForcedHold,
|
| NeverShowHold
|
| };
|
|
|
| USTRUCT()
|
| struct FMeasuredText
|
| {
|
| GENERATED_BODY()
|
|
|
| public:
|
| FText GetText() const { return CachedText; }
|
| void SetText(const FText& InText);
|
|
|
| FVector2D GetTextSize() const { return CachedTextSize; }
|
| FVector2D UpdateTextSize(const FSlateFontInfo &InFontInfo, float FontScale = 1.0f) const;
|
|
|
| private:
|
|
|
| FText CachedText;
|
| mutable FVector2D CachedTextSize;
|
| mutable bool bTextDirty = true;
|
| };
|
|
|
| UCLASS(MinimalAPI, Abstract, BlueprintType, Blueprintable, meta = (DisableNativeTick))
|
| class UCommonPlayerInputKey : public UCommonUserWidget
|
| {
|
| GENERATED_BODY()
|
|
|
| public:
|
| UE_API UCommonPlayerInputKey(const FObjectInitializer& ObjectInitializer);
|
|
|
|
|
| UFUNCTION(BlueprintCallable, Category = "Keybind Widget")
|
| UE_API void UpdateKeybindWidget();
|
|
|
|
|
| UFUNCTION(BlueprintCallable, Category = "Keybind Widget")
|
| UE_API void SetBoundKey(FKey NewBoundAction);
|
|
|
|
|
| UFUNCTION(BlueprintCallable, Category = "Keybind Widget")
|
| UE_API void SetBoundAction(FName NewBoundAction);
|
|
|
|
|
| UFUNCTION(BlueprintCallable, Category = "Keybind Widget")
|
| UE_API void SetForcedHoldKeybindStatus(ECommonKeybindForcedHoldStatus InForcedHoldKeybindStatus);
|
|
|
|
|
| UFUNCTION(BlueprintCallable, Category = "Keybind Widget")
|
| UE_API void SetShowProgressCountDown(bool bShow);
|
|
|
|
|
| UFUNCTION(BlueprintCallable, Category = "Keybind Widget")
|
| void SetAxisScale(const float NewValue) { AxisScale = NewValue; }
|
|
|
|
|
| UFUNCTION(BlueprintCallable, Category = "Keybind Widget")
|
| void SetPresetNameOverride(const FName NewValue) { PresetNameOverride = NewValue; }
|
|
|
|
|
| UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Keybind Widget")
|
| FName BoundAction;
|
|
|
|
|
| UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Keybind Widget")
|
| float AxisScale;
|
|
|
|
|
| UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Keybind Widget")
|
| FKey BoundKeyFallback;
|
|
|
|
|
| UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Keybind Widget")
|
| ECommonInputType InputTypeOverride;
|
|
|
|
|
| UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Keybind Widget")
|
| FName PresetNameOverride;
|
|
|
|
|
| UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Keybind Widget")
|
| ECommonKeybindForcedHoldStatus ForcedHoldKeybindStatus;
|
|
|
|
|
| UFUNCTION()
|
| UE_API void StartHoldProgress(FName HoldActionName, float HoldDuration);
|
|
|
|
|
| UFUNCTION()
|
| UE_API void StopHoldProgress(FName HoldActionName, bool bCompletedSuccessfully);
|
|
|
|
|
| UFUNCTION(BlueprintCallable, Category = "Keybind Widget")
|
| bool IsHoldKeybind() const { return bIsHoldKeybind; }
|
|
|
| UFUNCTION()
|
| bool IsBoundKeyValid() const { return BoundKey.IsValid(); }
|
|
|
| protected:
|
| UE_API virtual void NativePreConstruct() override;
|
| UE_API virtual void NativeConstruct() override;
|
| UE_API virtual int32 NativePaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override;
|
| UE_API void RecalculateDesiredSize();
|
|
|
|
|
| UE_API virtual void NativeDestruct() override;
|
|
|
|
|
| UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Keybind Widget", meta=(ScriptName = "IsHoldKeybindValue"))
|
| bool bIsHoldKeybind;
|
|
|
|
|
| UPROPERTY(Transient)
|
| bool bShowKeybindBorder;
|
|
|
| UPROPERTY(Transient)
|
| FVector2D FrameSize;
|
|
|
| UPROPERTY(BlueprintReadOnly, Category = "Keybind Widget")
|
| bool bShowTimeCountDown;
|
|
|
|
|
| UPROPERTY(BlueprintReadOnly, Category = "Keybind Widget")
|
| FKey BoundKey;
|
|
|
|
|
| UPROPERTY(EditDefaultsOnly, Category = "Keybind Widget")
|
| FSlateBrush HoldProgressBrush;
|
|
|
|
|
| UPROPERTY(EditDefaultsOnly, Category = "Keybind Widget")
|
| FSlateBrush KeyBindTextBorder;
|
|
|
|
|
| UPROPERTY(EditAnywhere, Category = "Keybind Widget")
|
| bool bShowUnboundStatus = false;
|
|
|
|
|
| UPROPERTY(EditDefaultsOnly, Category = "Font")
|
| FSlateFontInfo KeyBindTextFont;
|
|
|
|
|
| UPROPERTY(EditDefaultsOnly, Category = "Font")
|
| FSlateFontInfo CountdownTextFont;
|
|
|
| UPROPERTY(Transient)
|
| FMeasuredText CountdownText;
|
|
|
| UPROPERTY(Transient)
|
| FMeasuredText KeybindText;
|
|
|
| UPROPERTY(Transient)
|
| FMargin KeybindTextPadding;
|
|
|
| UPROPERTY(Transient)
|
| FVector2D KeybindFrameMinimumSize;
|
|
|
|
|
| UPROPERTY(EditDefaultsOnly, Category = "Keybind Widget")
|
| FName PercentageMaterialParameterName;
|
|
|
|
|
| UPROPERTY(Transient)
|
| TObjectPtr<UMaterialInstanceDynamic> ProgressPercentageMID;
|
|
|
| UE_API virtual void NativeOnInitialized() override;
|
|
|
| private:
|
| |
| |
| |
|
|
| UE_API void SyncHoldProgress();
|
|
|
|
|
| UE_API void UpdateHoldProgress();
|
|
|
|
|
| UE_API void SetupHoldKeybind();
|
|
|
| UE_API void ShowHoldBackPlate();
|
|
|
| UE_API void HandlePlayerControllerSet(UCommonLocalPlayer* LocalPlayer, APlayerController* PlayerController);
|
|
|
|
|
| float HoldKeybindStartTime = 0;
|
|
|
|
|
| float HoldKeybindDuration = 0;
|
|
|
| bool bDrawProgress = false;
|
| bool bDrawBrushForKey = false;
|
| bool bDrawCountdownText = false;
|
| bool bWaitingForPlayerController = false;
|
|
|
| UPROPERTY(Transient)
|
| FSlateBrush CachedKeyBrush;
|
| };
|
|
|
| #undef UE_API
|
|
|