Space Plunder
Loading...
Searching...
No Matches
SHitMarkerConfirmationWidget Class Reference

#include <SHitMarkerConfirmationWidget.h>

Inheritance diagram for SHitMarkerConfirmationWidget:

Public Member Functions

void Construct (const FArguments &InArgs, const FLocalPlayerContext &InContext, const TMap< FGameplayTag, FSlateBrush > &ZoneOverrideImages)
 
 SHitMarkerConfirmationWidget ()
 
virtual int32 OnPaint (const FPaintArgs &Args, const FGeometry &AllottedGeometry, const FSlateRect &MyCullingRect, FSlateWindowElementList &OutDrawElements, int32 LayerId, const FWidgetStyle &InWidgetStyle, bool bParentEnabled) const override
 
virtual void Tick (const FGeometry &AllottedGeometry, const double InCurrentTime, const float InDeltaTime) override
 
virtual FVector2D ComputeDesiredSize (float) const override
 
virtual bool ComputeVolatility () const override
 
void HitMarker (const AActor *Actor, float Damage, FName HitBone, FVector HitLocation)
 

Private Member Functions

 SLATE_BEGIN_ARGS (SHitMarkerConfirmationWidget)
 

Private Attributes

const FSlateBrush * PerHitMarkerImage = nullptr
 
TMap< FGameplayTag, FSlateBrush > PerHitMarkerZoneOverrideImages
 
const FSlateBrush * AnyHitsMarkerImage = nullptr
 
float HitNotifyOpacity = 1.0f
 
float LastHitTime = 0.0f
 
float HitNotifyDuration = 0.4f
 
TAttribute< FSlateColor > ColorAndOpacity
 
bool bColorAndOpacitySet
 
FLocalPlayerContext MyContext
 

Constructor & Destructor Documentation

◆ SHitMarkerConfirmationWidget()

SHitMarkerConfirmationWidget::SHitMarkerConfirmationWidget ( )
10{
11
12}

Member Function Documentation

◆ ComputeDesiredSize()

FVector2D SHitMarkerConfirmationWidget::ComputeDesiredSize ( float ) const
overridevirtual
50{
51 return FVector2D(100.0f, 100.0f);
52}

◆ ComputeVolatility()

virtual bool SHitMarkerConfirmationWidget::ComputeVolatility ( ) const
inlineoverridevirtual
48{ return true; }

◆ Construct()

void SHitMarkerConfirmationWidget::Construct ( const FArguments & InArgs,
const FLocalPlayerContext & InContext,
const TMap< FGameplayTag, FSlateBrush > & ZoneOverrideImages )

The marker image to draw for individual hit markers. The marker image to draw if there are any hits at all. The duration (in seconds) to display hit notifies (they fade to transparent over this time)
The color and opacity of the marker

15{
16 PerHitMarkerImage = InArgs._PerHitMarkerImage;
17 PerHitMarkerZoneOverrideImages = ZoneOverrideImages;
18 AnyHitsMarkerImage = InArgs._AnyHitsMarkerImage;
19 bColorAndOpacitySet = InArgs._ColorAndOpacity.IsSet();
20 ColorAndOpacity = InArgs._ColorAndOpacity;
21
22 MyContext = InContext;
23}
FLocalPlayerContext MyContext
Definition SHitMarkerConfirmationWidget.h:78
bool bColorAndOpacitySet
Definition SHitMarkerConfirmationWidget.h:75
const FSlateBrush * PerHitMarkerImage
Definition SHitMarkerConfirmationWidget.h:56
TMap< FGameplayTag, FSlateBrush > PerHitMarkerZoneOverrideImages
Definition SHitMarkerConfirmationWidget.h:59
TAttribute< FSlateColor > ColorAndOpacity
Definition SHitMarkerConfirmationWidget.h:74
const FSlateBrush * AnyHitsMarkerImage
Definition SHitMarkerConfirmationWidget.h:62

◆ HitMarker()

void SHitMarkerConfirmationWidget::HitMarker ( const AActor * Actor,
float Damage,
FName HitBone,
FVector HitLocation )
55{
56 LastHitTime = 0.0f;
57}
float LastHitTime
Definition SHitMarkerConfirmationWidget.h:68

◆ OnPaint()

int32 SHitMarkerConfirmationWidget::OnPaint ( const FPaintArgs & Args,
const FGeometry & AllottedGeometry,
const FSlateRect & MyCullingRect,
FSlateWindowElementList & OutDrawElements,
int32 LayerId,
const FWidgetStyle & InWidgetStyle,
bool bParentEnabled ) const
overridevirtual
26{
27 const bool bIsEnabled = ShouldBeEnabled(bParentEnabled);
28 const ESlateDrawEffect DrawEffects = bIsEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect;
29 const FVector2D LocalCenter = AllottedGeometry.GetLocalPositionAtCoordinates(FVector2D(0.5f, 0.5f));
30
31 const bool bDrawMarkers = (HitNotifyOpacity > KINDA_SMALL_NUMBER);
32 if (bDrawMarkers)
33 {
34 if (AnyHitsMarkerImage != nullptr)
35 {
36 FLinearColor MarkerColor = bColorAndOpacitySet ?
37 ColorAndOpacity.Get().GetColor(InWidgetStyle) :
38 (InWidgetStyle.GetColorAndOpacityTint() * AnyHitsMarkerImage->GetTint(InWidgetStyle));
39 MarkerColor.A *= HitNotifyOpacity;
40
41 // Otherwise show the hit notify in the center of the reticle
42 const FPaintGeometry Geometry(AllottedGeometry.ToPaintGeometry(AnyHitsMarkerImage->ImageSize, FSlateLayoutTransform(LocalCenter - (AnyHitsMarkerImage->ImageSize * 0.5f))));
43 FSlateDrawElement::MakeBox(OutDrawElements, LayerId, Geometry, AnyHitsMarkerImage, DrawEffects, MarkerColor);
44 }
45 }
46 return LayerId;
47}
float HitNotifyOpacity
Definition SHitMarkerConfirmationWidget.h:65

◆ SLATE_BEGIN_ARGS()

SHitMarkerConfirmationWidget::SLATE_BEGIN_ARGS ( SHitMarkerConfirmationWidget )
inlineprivate
24 : _PerHitMarkerImage(FCoreStyle::Get().GetBrush("Throbber.CircleChunk"))
25 , _AnyHitsMarkerImage(nullptr)
26 , _HitNotifyDuration(0.4f)
27 {
28 }

◆ Tick()

void SHitMarkerConfirmationWidget::Tick ( const FGeometry & AllottedGeometry,
const double InCurrentTime,
const float InDeltaTime )
overridevirtual
60{
61 HitNotifyOpacity = 0.0f;
62 const double TimeSinceLastHitNotification = LastHitTime;
63 if (TimeSinceLastHitNotification < HitNotifyDuration)
64 {
65 HitNotifyOpacity = FMath::Clamp(1.0f - (float)(TimeSinceLastHitNotification / HitNotifyDuration), 0.0f, 1.0f);
66 }
67 LastHitTime += 0.01f;
68}
float HitNotifyDuration
Definition SHitMarkerConfirmationWidget.h:71

Member Data Documentation

◆ AnyHitsMarkerImage

const FSlateBrush* SHitMarkerConfirmationWidget::AnyHitsMarkerImage = nullptr
private

The marker image to draw if there are any hits at all.

◆ bColorAndOpacitySet

bool SHitMarkerConfirmationWidget::bColorAndOpacitySet
private

◆ ColorAndOpacity

TAttribute<FSlateColor> SHitMarkerConfirmationWidget::ColorAndOpacity
private

Color and opacity of the markers

◆ HitNotifyDuration

float SHitMarkerConfirmationWidget::HitNotifyDuration = 0.4f
private

The duration (in seconds) to display hit notifies (they fade to transparent over this time)

◆ HitNotifyOpacity

float SHitMarkerConfirmationWidget::HitNotifyOpacity = 1.0f
private

The opacity for the hit markers

◆ LastHitTime

float SHitMarkerConfirmationWidget::LastHitTime = 0.0f
private

◆ MyContext

FLocalPlayerContext SHitMarkerConfirmationWidget::MyContext
private

Player context for the owning HUD

◆ PerHitMarkerImage

const FSlateBrush* SHitMarkerConfirmationWidget::PerHitMarkerImage = nullptr
private

The marker image to draw for individual hit markers.

◆ PerHitMarkerZoneOverrideImages

TMap<FGameplayTag, FSlateBrush> SHitMarkerConfirmationWidget::PerHitMarkerZoneOverrideImages
private

Map from zone tag (e.g., weak spot) to override marker images.


The documentation for this class was generated from the following files: