2022-05-23 18:41:30 +00:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-09-13 07:18:28 +00:00
|
|
|
#include "Containers/Array.h"
|
|
|
|
#include "HAL/Platform.h"
|
|
|
|
#include "Math/Vector2D.h"
|
|
|
|
#include "Misc/Attribute.h"
|
|
|
|
#include "Rendering/SlateRenderTransform.h"
|
|
|
|
#include "Styling/CoreStyle.h"
|
|
|
|
#include "Styling/ISlateStyle.h"
|
|
|
|
#include "Styling/SlateColor.h"
|
2022-05-23 18:41:30 +00:00
|
|
|
#include "Widgets/DeclarativeSyntaxSupport.h"
|
|
|
|
#include "Widgets/SLeafWidget.h"
|
2022-09-13 07:18:28 +00:00
|
|
|
|
2022-05-23 18:41:30 +00:00
|
|
|
#include "SCircumferenceMarkerWidget.generated.h"
|
|
|
|
|
2022-09-13 07:18:28 +00:00
|
|
|
class FPaintArgs;
|
|
|
|
class FSlateRect;
|
|
|
|
class FSlateWindowElementList;
|
|
|
|
class FWidgetStyle;
|
|
|
|
struct FGeometry;
|
|
|
|
struct FSlateBrush;
|
|
|
|
|
2022-05-23 18:41:30 +00:00
|
|
|
USTRUCT(BlueprintType)
|
|
|
|
struct FCircumferenceMarkerEntry
|
|
|
|
{
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
// The angle to place this marker around the circle (in degrees)
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(ForceUnits=deg))
|
|
|
|
float PositionAngle = 0.0f;
|
|
|
|
|
|
|
|
// The angle to rotate the marker image (in degrees)
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(ForceUnits=deg))
|
|
|
|
float ImageRotationAngle = 0.0f;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SCircumferenceMarkerWidget : public SLeafWidget
|
|
|
|
{
|
|
|
|
SLATE_BEGIN_ARGS(SCircumferenceMarkerWidget)
|
|
|
|
: _MarkerBrush(FCoreStyle::Get().GetBrush("Throbber.CircleChunk"))
|
|
|
|
, _Radius(48.0f)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
/** What each marker on the circumference looks like */
|
|
|
|
SLATE_ARGUMENT(const FSlateBrush*, MarkerBrush)
|
|
|
|
/** At which angles should a marker be drawn */
|
|
|
|
SLATE_ARGUMENT(TArray<FCircumferenceMarkerEntry>, MarkerList)
|
|
|
|
/** The radius of the circle */
|
|
|
|
SLATE_ATTRIBUTE(float, Radius)
|
|
|
|
/** The color and opacity of the marker */
|
|
|
|
SLATE_ATTRIBUTE(FSlateColor, ColorAndOpacity)
|
|
|
|
SLATE_END_ARGS()
|
|
|
|
|
|
|
|
public:
|
|
|
|
void Construct(const FArguments& InArgs);
|
|
|
|
|
|
|
|
SCircumferenceMarkerWidget();
|
|
|
|
|
|
|
|
//~SWidget interface
|
|
|
|
virtual int32 OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override;
|
|
|
|
virtual FVector2D ComputeDesiredSize(float) const override;
|
|
|
|
virtual bool ComputeVolatility() const override { return true; }
|
|
|
|
//~End of SWidget interface
|
|
|
|
|
|
|
|
void SetRadius(float NewRadius);
|
|
|
|
void SetMarkerList(TArray<FCircumferenceMarkerEntry>& NewMarkerList);
|
|
|
|
|
|
|
|
private:
|
|
|
|
FSlateRenderTransform GetMarkerRenderTransform(const FCircumferenceMarkerEntry& Marker, const float BaseRadius, const float HUDScale) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
/** What each marker on the circumference looks like */
|
|
|
|
const FSlateBrush* MarkerBrush;
|
|
|
|
|
|
|
|
/** Angles around the reticle center to place ReticleCornerImage icons */
|
|
|
|
TArray<FCircumferenceMarkerEntry> MarkerList;
|
|
|
|
|
|
|
|
/** The radius of the circle */
|
|
|
|
TAttribute<float> Radius;
|
|
|
|
|
|
|
|
/** Color and opacity of the markers */
|
|
|
|
TAttribute<FSlateColor> ColorAndOpacity;
|
|
|
|
bool bColorAndOpacitySet;
|
|
|
|
|
|
|
|
/** Whether reticle corner images are placed outside the spread radius */
|
|
|
|
//@TODO: Make this a 0-1 float alignment instead (e.g., inside/on/outside the radius)?
|
|
|
|
uint8 bReticleCornerOutsideSpreadRadius : 1;
|
|
|
|
};
|