File size: 6,926 Bytes
7fd553e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | // Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Components/SceneComponent.h"
#include "Types/SlateEnums.h"
#include "IndicatorDescriptor.generated.h"
#define UE_API LYRAGAME_API
class SWidget;
class UIndicatorDescriptor;
class ULyraIndicatorManagerComponent;
class UUserWidget;
struct FFrame;
struct FSceneViewProjectionData;
struct FIndicatorProjection
{
bool Project(const UIndicatorDescriptor& IndicatorDescriptor, const FSceneViewProjectionData& InProjectionData, const FVector2f& ScreenSize, FVector& ScreenPositionWithDepth);
};
UENUM(BlueprintType)
enum class EActorCanvasProjectionMode : uint8
{
ComponentPoint,
ComponentBoundingBox,
ComponentScreenBoundingBox,
ActorBoundingBox,
ActorScreenBoundingBox
};
/**
* Describes and controls an active indicator. It is highly recommended that your widget implements
* IActorIndicatorWidget so that it can 'bind' to the associated data.
*/
UCLASS(MinimalAPI, BlueprintType)
class UIndicatorDescriptor : public UObject
{
GENERATED_BODY()
public:
UIndicatorDescriptor() { }
public:
UFUNCTION(BlueprintCallable)
UObject* GetDataObject() const { return DataObject; }
UFUNCTION(BlueprintCallable)
void SetDataObject(UObject* InDataObject) { DataObject = InDataObject; }
UFUNCTION(BlueprintCallable)
USceneComponent* GetSceneComponent() const { return Component; }
UFUNCTION(BlueprintCallable)
void SetSceneComponent(USceneComponent* InComponent) { Component = InComponent; }
UFUNCTION(BlueprintCallable)
FName GetComponentSocketName() const { return ComponentSocketName; }
UFUNCTION(BlueprintCallable)
void SetComponentSocketName(FName SocketName) { ComponentSocketName = SocketName; }
UFUNCTION(BlueprintCallable)
TSoftClassPtr<UUserWidget> GetIndicatorClass() const { return IndicatorWidgetClass; }
UFUNCTION(BlueprintCallable)
void SetIndicatorClass(TSoftClassPtr<UUserWidget> InIndicatorWidgetClass)
{
IndicatorWidgetClass = InIndicatorWidgetClass;
}
public:
// TODO Organize this better.
TWeakObjectPtr<UUserWidget> IndicatorWidget;
public:
UFUNCTION(BlueprintCallable)
void SetAutoRemoveWhenIndicatorComponentIsNull(bool CanAutomaticallyRemove)
{
bAutoRemoveWhenIndicatorComponentIsNull = CanAutomaticallyRemove;
}
UFUNCTION(BlueprintCallable)
bool GetAutoRemoveWhenIndicatorComponentIsNull() const { return bAutoRemoveWhenIndicatorComponentIsNull; }
bool CanAutomaticallyRemove() const
{
return bAutoRemoveWhenIndicatorComponentIsNull && !IsValid(GetSceneComponent());
}
public:
// Layout Properties
//=======================
UFUNCTION(BlueprintCallable)
bool GetIsVisible() const { return IsValid(GetSceneComponent()) && bVisible; }
UFUNCTION(BlueprintCallable)
void SetDesiredVisibility(bool InVisible)
{
bVisible = InVisible;
}
UFUNCTION(BlueprintCallable)
EActorCanvasProjectionMode GetProjectionMode() const { return ProjectionMode; }
UFUNCTION(BlueprintCallable)
void SetProjectionMode(EActorCanvasProjectionMode InProjectionMode)
{
ProjectionMode = InProjectionMode;
}
// Horizontal alignment to the point in space to place the indicator at.
UFUNCTION(BlueprintCallable)
EHorizontalAlignment GetHAlign() const { return HAlignment; }
UFUNCTION(BlueprintCallable)
void SetHAlign(EHorizontalAlignment InHAlignment)
{
HAlignment = InHAlignment;
}
// Vertical alignment to the point in space to place the indicator at.
UFUNCTION(BlueprintCallable)
EVerticalAlignment GetVAlign() const { return VAlignment; }
UFUNCTION(BlueprintCallable)
void SetVAlign(EVerticalAlignment InVAlignment)
{
VAlignment = InVAlignment;
}
// Clamp the indicator to the edge of the screen?
UFUNCTION(BlueprintCallable)
bool GetClampToScreen() const { return bClampToScreen; }
UFUNCTION(BlueprintCallable)
void SetClampToScreen(bool bValue)
{
bClampToScreen = bValue;
}
// Show the arrow if clamping to the edge of the screen?
UFUNCTION(BlueprintCallable)
bool GetShowClampToScreenArrow() const { return bShowClampToScreenArrow; }
UFUNCTION(BlueprintCallable)
void SetShowClampToScreenArrow(bool bValue)
{
bShowClampToScreenArrow = bValue;
}
// The position offset for the indicator in world space.
UFUNCTION(BlueprintCallable)
FVector GetWorldPositionOffset() const { return WorldPositionOffset; }
UFUNCTION(BlueprintCallable)
void SetWorldPositionOffset(FVector Offset)
{
WorldPositionOffset = Offset;
}
// The position offset for the indicator in screen space.
UFUNCTION(BlueprintCallable)
FVector2D GetScreenSpaceOffset() const { return ScreenSpaceOffset; }
UFUNCTION(BlueprintCallable)
void SetScreenSpaceOffset(FVector2D Offset)
{
ScreenSpaceOffset = Offset;
}
UFUNCTION(BlueprintCallable)
FVector GetBoundingBoxAnchor() const { return BoundingBoxAnchor; }
UFUNCTION(BlueprintCallable)
void SetBoundingBoxAnchor(FVector InBoundingBoxAnchor)
{
BoundingBoxAnchor = InBoundingBoxAnchor;
}
public:
// Sorting Properties
//=======================
// Allows sorting the indicators (after they are sorted by depth), to allow some group of indicators
// to always be in front of others.
UFUNCTION(BlueprintCallable)
int32 GetPriority() const { return Priority; }
UFUNCTION(BlueprintCallable)
void SetPriority(int32 InPriority)
{
Priority = InPriority;
}
public:
ULyraIndicatorManagerComponent* GetIndicatorManagerComponent() { return ManagerPtr.Get(); }
UE_API void SetIndicatorManagerComponent(ULyraIndicatorManagerComponent* InManager);
UFUNCTION(BlueprintCallable)
UE_API void UnregisterIndicator();
private:
UPROPERTY()
bool bVisible = true;
UPROPERTY()
bool bClampToScreen = false;
UPROPERTY()
bool bShowClampToScreenArrow = false;
UPROPERTY()
bool bOverrideScreenPosition = false;
UPROPERTY()
bool bAutoRemoveWhenIndicatorComponentIsNull = false;
UPROPERTY()
EActorCanvasProjectionMode ProjectionMode = EActorCanvasProjectionMode::ComponentPoint;
UPROPERTY()
TEnumAsByte<EHorizontalAlignment> HAlignment = HAlign_Center;
UPROPERTY()
TEnumAsByte<EVerticalAlignment> VAlignment = VAlign_Center;
UPROPERTY()
int32 Priority = 0;
UPROPERTY()
FVector BoundingBoxAnchor = FVector(0.5, 0.5, 0.5);
UPROPERTY()
FVector2D ScreenSpaceOffset = FVector2D(0, 0);
UPROPERTY()
FVector WorldPositionOffset = FVector(0, 0, 0);
private:
friend class SActorCanvas;
UPROPERTY()
TObjectPtr<UObject> DataObject;
UPROPERTY()
TObjectPtr<USceneComponent> Component;
UPROPERTY()
FName ComponentSocketName = NAME_None;
UPROPERTY()
TSoftClassPtr<UUserWidget> IndicatorWidgetClass;
UPROPERTY()
TWeakObjectPtr<ULyraIndicatorManagerComponent> ManagerPtr;
TWeakPtr<SWidget> Content;
TWeakPtr<SWidget> CanvasHost;
};
#undef UE_API
|