Initial work on prompt widget
This commit is contained in:
67
Source/Integration/PromptWidget.h
Normal file
67
Source/Integration/PromptWidget.h
Normal file
@@ -0,0 +1,67 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Common.h"
|
||||
#include "Components/Widget.h"
|
||||
#include "InputCoreTypes.h"
|
||||
#include "Widgets/Layout/SScaleBox.h"
|
||||
#include "PromptWidget.generated.h"
|
||||
|
||||
|
||||
UCLASS(BlueprintType, Blueprintable)
|
||||
class INTEGRATION_API UlxPromptWidget : public UWidget
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, Category="Prompt")
|
||||
TObjectPtr<UTexture2D> ButtonAtlas;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Prompt")
|
||||
void SetKeys(FKey InGamepadKey, FKey InKeyboardKey);
|
||||
|
||||
UPROPERTY(EditAnywhere, Setter, Category="Prompt")
|
||||
FVector2D Size = FVector2D(64, 64);
|
||||
|
||||
UPROPERTY(EditAnywhere, Setter, Category="Prompt")
|
||||
FMargin GlyphMargins = FMargin(0.0f, 0.1f, 0.0f, 0.1f);
|
||||
|
||||
UPROPERTY(EditAnywhere, Setter, Category="Prompt")
|
||||
FLinearColor GlyphColor = FLinearColor::White;
|
||||
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Prompt")
|
||||
void SetGlyphMargins(FMargin InMargins);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Prompt")
|
||||
void SetGlyphColor(FLinearColor InColor);
|
||||
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Prompt")
|
||||
void SetSize(FVector2D InSize);
|
||||
|
||||
protected:
|
||||
virtual TSharedRef<SWidget> RebuildWidget() override;
|
||||
virtual void SynchronizeProperties() override;
|
||||
virtual void ReleaseSlateResources(bool bReleaseChildren) override;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="Prompt")
|
||||
FKey GamepadKey = EKeys::Gamepad_FaceButton_Left;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category="Prompt")
|
||||
FKey KeyboardKey = EKeys::Z;
|
||||
|
||||
private:
|
||||
FSlateBrush MyBrush;
|
||||
TSharedPtr<SOverlay> MyOverlay;
|
||||
TSharedPtr<SImage> MyImage;
|
||||
TSharedPtr<SScaleBox> MyScaleBox;
|
||||
TSharedPtr<STextBlock> MyGlyph;
|
||||
SOverlay::FOverlaySlot* MyGlyphSlot = nullptr;
|
||||
|
||||
FBox2f GetIconUVs(int32 IconIndex);
|
||||
FMargin GetScaledMargins() const;
|
||||
void CalcAppearance(int32& OutIcon, FString& OutGlyph) const;
|
||||
void CalcKeyboardAppearance(int32& OutIcon, FString& OutGlyph) const;
|
||||
void CalcGamepadAppearance(ElxInputMode Mode, int32& OutIcon, FString& OutGlyph) const;
|
||||
};
|
||||
Reference in New Issue
Block a user