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

#include <WheelMenu.h>

Inheritance diagram for UWheelMenu:
IRadialMenu

Public Member Functions

 UWheelMenu (const FObjectInitializer &ObjectInitializer)
 
virtual void SetWheelData (const FRadialMenuData &Data) override
 
virtual bool GetCurrentIndex (int32 &Value) const override
 
virtual void StartUpdateInput () override
 
virtual void CenterMousePosition () override
 
FVector2D GetJoystickDirection (const bool bLeft) const
 

Protected Member Functions

virtual bool Initialize () override
 
virtual void NativePreConstruct () override
 
virtual void NativeConstruct () override
 
virtual void UpdateInput ()
 
void SetIndex (const int32 Value)
 
FVector2D FixInputRotation (const FVector2D &Input) const
 
void SetInDeadZone (const bool bValue)
 
FVector2D GetScreenCenter () const
 
float GetSectionDegreeSize () const
 
float GetSectionDegreeSizeUp () const
 
FVector GetSegmentDirection (const int32 SegmentIndex) const
 
void UpdateChildPositions () const
 
void SetBackgroundRotation () const
 
void UpdateDirectionWithMouseCursor ()
 
void UpdateDirectionWithJoystick ()
 
void SetInputDirection (const FVector2D Direction)
 

Protected Attributes

class UOverlay * RootOverlay = nullptr
 
class UImage * RadialBackground = nullptr
 
class UImage * RadialDebug = nullptr
 
class UTextBlock * TitleTextBlock = nullptr
 
class UTextBlock * DescriptionTextBlock = nullptr
 
class USizeBox * SizeBox = nullptr
 
float UpdateSpeed = 1.0f
 
bool bNormalize = false
 
float ItemOffsetRadius = 180.0f
 
bool bAutoRotateForUp = true
 
bool bUseCustomInput = false
 
float MouseDeadZone = 0.2f
 
float JoystickDeadZone = 0.3f
 
UMaterialInterface * MaterialBase = nullptr
 
FName MaterialParamSegments = FName("Segments")
 
FName MaterialParamIndex = FName("Index")
 
FName MaterialParamDeadZone = FName("Deadzone")
 
FName MaterialParamRadialTexture = FName("RadialTexture")
 
bool bUseCustomTexture = false
 
UTexture2D * RadialTexture = nullptr
 
bool bUseCustomColors = false
 
FName MaterialParamOuterRingColor = FName("OuterRingColor")
 
FName MaterialParamInnerRingColor = FName("InnerRingColor")
 
FName MaterialParamRingMainColor = FName("RingMainColor")
 
FName MaterialParamUnhighlightColor = FName("UnhighlightColor")
 
FLinearColor OuterRingColorDefault = FLinearColor(0.0f,0.25641f, 1.0f)
 
FLinearColor InnerRingColorDefault = FLinearColor(0.369792f,0.369792f, 0.369792f)
 
FLinearColor RingMainColorDefault = FLinearColor(1.0f,1.0f, 1.0f)
 
FLinearColor UnhighlightColorDefault = FLinearColor(0.291667f, 0.291667f, 0.291667f)
 
FVector2D MenuSizeDefault = FVector2D(512.0f, 512.0f)
 
bool bUseDeadZoneEvents = false
 
float IndexRaw = 0.0f
 
int32 Index = -1
 
int32 Segments = 2
 
bool bInDeadZone = false
 
FVector2D CurrentInput = FVector2D::ZeroVector
 
UMaterialInstanceDynamic * DynamicMaterial = nullptr
 
FRadialMenuData MenuData
 

Private Member Functions

virtual bool GetCurrentSegmentData (FRadialSegmentData &Data) const
 
void SetDescriptionText (const FRadialSegmentData &SegmentData) const
 
void SetCancelText () const
 
void ClearDescriptionText () const
 
void SetColors (const FLinearColor &OuterRing, const FLinearColor &InnerRing, const FLinearColor &RingMain, const FLinearColor &UnHighlight)
 
void SetColorsToDefault ()
 
void SetMenuSize () const
 
void CreateMaterial ()
 
void UpdateMaterials () const
 
void UpdateMaterialVisuals () const
 
void SetMaterialSegments () const
 
void Setup ()
 
void SetSegmentData (const TArray< FRadialSegmentData > &Selections, const bool bShowDescription) const
 

Private Attributes

FTimerHandle UpdateSpeedTimer
 
TSubclassOf< UUserWidget > RadialSegmentClass
 
FLinearColor OuterRingColor = FLinearColor(0.0f,0.25641f, 1.0f)
 
FLinearColor InnerRingColor = FLinearColor(0.369792f,0.369792f, 0.369792f)
 
FLinearColor RingMainColor = FLinearColor(1.0f,1.0f, 1.0f)
 
FLinearColor UnhighlightColor = FLinearColor(0.291667f, 0.291667f, 0.291667f)
 

Constructor & Destructor Documentation

◆ UWheelMenu()

UWheelMenu::UWheelMenu ( const FObjectInitializer & ObjectInitializer)
explicit
18 : Super(ObjectInitializer)
19{
20 const ConstructorHelpers::FClassFinder<UWheelSegment> RadialWheelWidget(TEXT("/BaseHelpers/Widgets/WBP_WheelSegment"));
21 if (!ensure(RadialWheelWidget.Class != nullptr)) return;
22 RadialSegmentClass = RadialWheelWidget.Class;
23}
TSubclassOf< UUserWidget > RadialSegmentClass
Definition WheelMenu.h:197

Member Function Documentation

◆ CenterMousePosition()

void UWheelMenu::CenterMousePosition ( )
overridevirtual

Implements IRadialMenu.

188{
189 GetOwningPlayer()->SetMouseLocation(GetScreenCenter().X, GetScreenCenter().Y);
191}
FVector2D CurrentInput
Definition WheelMenu.h:165
FVector2D GetScreenCenter() const
Definition WheelMenu.cpp:193

◆ ClearDescriptionText()

void UWheelMenu::ClearDescriptionText ( ) const
private
410{
411 if(TitleTextBlock == nullptr || DescriptionTextBlock == nullptr){return;}
412 TitleTextBlock->SetText(FText::FromString(""));
413 DescriptionTextBlock->SetText(FText::FromString(""));
414}
class UTextBlock * TitleTextBlock
Definition WheelMenu.h:81
class UTextBlock * DescriptionTextBlock
Definition WheelMenu.h:83

◆ CreateMaterial()

void UWheelMenu::CreateMaterial ( )
private
70{
71 DynamicMaterial = UKismetMaterialLibrary::CreateDynamicMaterialInstance(GetOwningPlayer(), MaterialBase);
72}
UMaterialInstanceDynamic * DynamicMaterial
Definition WheelMenu.h:167
UMaterialInterface * MaterialBase
Definition WheelMenu.h:112

◆ FixInputRotation()

FVector2D UWheelMenu::FixInputRotation ( const FVector2D & Input) const
protected
163{
165 {
166 const FVector Direction = UKismetMathLibrary::RotateAngleAxis(FVector(Input, 0.0f), (GetSectionDegreeSizeUp() * -1.0f), FVector(0.0f,0.0f,1.0f));
167 return FVector2D(Direction);
168 }
169 return Input;
170}
float GetSectionDegreeSizeUp() const
Definition WheelMenu.cpp:85
bool bAutoRotateForUp
Definition WheelMenu.h:102

◆ GetCurrentIndex()

bool UWheelMenu::GetCurrentIndex ( int32 & Value) const
overridevirtual

Implements IRadialMenu.

268{
269 Value = Index;
270 if(Index >= 0 && RootOverlay->GetAllChildren().IsValidIndex(Index))
271 {
272 return true;
273 }
274 return false;
275}
class UOverlay * RootOverlay
Definition WheelMenu.h:75
int32 Index
Definition WheelMenu.h:159

◆ GetCurrentSegmentData()

bool UWheelMenu::GetCurrentSegmentData ( FRadialSegmentData & Data) const
privatevirtual
371{
372 FRadialSegmentData SegmentData;
373 if(MenuData.Selections.IsValidIndex(Index) == false){return false;}
374 Data = MenuData.Selections[Index];
375 return true;
376}
FRadialMenuData MenuData
Definition WheelMenu.h:169
TArray< FRadialSegmentData > Selections
Definition RadialWheelData.h:106
Definition RadialWheelData.h:72

◆ GetJoystickDirection()

FVector2D UWheelMenu::GetJoystickDirection ( const bool bLeft) const
145{
146 FVector2D Direction;
147 if(GetOwningPlayer() == nullptr){return Direction;}
148 const IPlayerControllerInterface* PlayerControllerInterface = Cast<IPlayerControllerInterface>(GetOwningPlayer());
149 if(PlayerControllerInterface == nullptr){return Direction;}
150 if(bLeft)
151 {
152 Direction = PlayerControllerInterface->GetMoveAxis();
153 Direction.Y *= -1.0f;
154 }
155 else
156 {
157 Direction = PlayerControllerInterface->GetLookAxis();
158 }
159 return Direction;
160}
Definition PlayerControllerInterface.h:21
virtual FVector2D GetLookAxis() const =0
virtual FVector2D GetMoveAxis() const =0

◆ GetScreenCenter()

FVector2D UWheelMenu::GetScreenCenter ( ) const
protected
194{
195 if(GetOwningPlayer() == nullptr){return FVector2D::ZeroVector;}
196 const FVector2D ViewportSize = UWidgetLayoutLibrary::GetViewportSize(GetOwningPlayer());
197 const int32 HalfWidth = UKismetMathLibrary::FTrunc(ViewportSize.X / 2.0f);
198 const int32 HalfHeight = UKismetMathLibrary::FTrunc(ViewportSize.Y / 2.0f);
199 return FVector2D(HalfWidth, HalfHeight);
200}

◆ GetSectionDegreeSize()

float UWheelMenu::GetSectionDegreeSize ( ) const
protected
81{
82 return 360.0f / static_cast<float>(Segments);
83}
int32 Segments
Definition WheelMenu.h:161

◆ GetSectionDegreeSizeUp()

float UWheelMenu::GetSectionDegreeSizeUp ( ) const
protected
86{
87 return (GetSectionDegreeSize() / 2.0f * -1.0f);
88}
float GetSectionDegreeSize() const
Definition WheelMenu.cpp:80

◆ GetSegmentDirection()

FVector UWheelMenu::GetSegmentDirection ( const int32 SegmentIndex) const
protected
91{
92 const float Center = (static_cast<float>(SegmentIndex) + 0.5f);
93 const float Angle = Center * GetSectionDegreeSize();
94 FVector Direction = UKismetMathLibrary::RotateAngleAxis(FVector(0.0f, -1.0f, 0.0f), Angle, FVector(0.0f,0.0f,1.0f));
96 {
97 const float UpAngle = GetSectionDegreeSizeUp();
98 Direction = UKismetMathLibrary::RotateAngleAxis(Direction, UpAngle, FVector(0.0f, 0.0f, 1.0f));
99 }
100 return Direction;
101}

◆ Initialize()

bool UWheelMenu::Initialize ( )
overrideprotectedvirtual
27{
28 const bool Success = Super::Initialize();
29 if(!Success) return false;
30 if (!ensure(RadialDebug != nullptr)) return false;
31 if (!ensure(RadialBackground != nullptr)) return false;
32 if (!ensure(RootOverlay != nullptr)) return false;
33 if (!ensure(RadialSegmentClass != nullptr)) return false;
34 if (!ensure(TitleTextBlock != nullptr)) return false;
35 if (!ensure(DescriptionTextBlock != nullptr)) return false;
36 if (!ensure(SizeBox != nullptr)) return false;
37 return true;
38}
class UImage * RadialDebug
Definition WheelMenu.h:79
class UImage * RadialBackground
Definition WheelMenu.h:77
class USizeBox * SizeBox
Definition WheelMenu.h:85

◆ NativeConstruct()

void UWheelMenu::NativeConstruct ( )
overrideprotectedvirtual
51{
52 Super::NativeConstruct();
53 Setup();
54}
void Setup()
Definition WheelMenu.cpp:56

◆ NativePreConstruct()

void UWheelMenu::NativePreConstruct ( )
overrideprotectedvirtual
41{
42 Super::NativePreConstruct();
43 if(RadialDebug != nullptr)
44 {
45 RadialDebug->SetRenderTranslation(FVector2D(0.0f, ItemOffsetRadius));
46 }
47 Setup();
48}
float ItemOffsetRadius
Definition WheelMenu.h:99

◆ SetBackgroundRotation()

void UWheelMenu::SetBackgroundRotation ( ) const
protected
115{
116 float Angle = 0.0f;
118 {
119 Angle = GetSectionDegreeSizeUp();
120 }
121 RadialBackground->SetRenderTransformAngle(Angle);
122}

◆ SetCancelText()

void UWheelMenu::SetCancelText ( ) const
private
404{
405 TitleTextBlock->SetText(FText::FromString("Cancel"));
406 DescriptionTextBlock->SetText(FText::FromString(""));
407}

◆ SetColors()

void UWheelMenu::SetColors ( const FLinearColor & OuterRing,
const FLinearColor & InnerRing,
const FLinearColor & RingMain,
const FLinearColor & UnHighlight )
private
417{
418 OuterRingColor = OuterRing;
419 InnerRingColor = InnerRing;
420 RingMainColor = RingMain;
421 UnhighlightColor = UnHighlight;
422}
FLinearColor RingMainColor
Definition WheelMenu.h:204
FLinearColor InnerRingColor
Definition WheelMenu.h:202
FLinearColor UnhighlightColor
Definition WheelMenu.h:206
FLinearColor OuterRingColor
Definition WheelMenu.h:200

◆ SetColorsToDefault()

void UWheelMenu::SetColorsToDefault ( )
private
425{
427}
FLinearColor InnerRingColorDefault
Definition WheelMenu.h:139
FLinearColor OuterRingColorDefault
Definition WheelMenu.h:137
FLinearColor RingMainColorDefault
Definition WheelMenu.h:141
void SetColors(const FLinearColor &OuterRing, const FLinearColor &InnerRing, const FLinearColor &RingMain, const FLinearColor &UnHighlight)
Definition WheelMenu.cpp:416
FLinearColor UnhighlightColorDefault
Definition WheelMenu.h:143

◆ SetDescriptionText()

void UWheelMenu::SetDescriptionText ( const FRadialSegmentData & SegmentData) const
private
379{
380 if(TitleTextBlock == nullptr || DescriptionTextBlock == nullptr){return;}
381 if(SegmentData.IsValid() == false){SetCancelText();return;}
382 if(SegmentData.Name.IsEmpty())
383 {
384 TitleTextBlock->SetVisibility(ESlateVisibility::Collapsed);
385 }
386 else
387 {
388 TitleTextBlock->SetVisibility(ESlateVisibility::Visible);
389 }
390 if(SegmentData.Description.IsEmpty())
391
392 {
393 DescriptionTextBlock->SetVisibility(ESlateVisibility::Collapsed);
394 }
395 else
396 {
397 DescriptionTextBlock->SetVisibility(ESlateVisibility::Visible);
398 }
399 TitleTextBlock->SetText(FText::FromString(SegmentData.Name));
400 DescriptionTextBlock->SetText(FText::FromString(SegmentData.Description));
401}
void SetCancelText() const
Definition WheelMenu.cpp:403
bool IsValid() const
Definition RadialWheelData.h:84
FString Description
Definition RadialWheelData.h:80
FString Name
Definition RadialWheelData.h:78

◆ SetInDeadZone()

void UWheelMenu::SetInDeadZone ( const bool bValue)
protected
252{
253 if(bInDeadZone == bValue){return;}
254 bInDeadZone = bValue;
255 if(bInDeadZone)
256 {
257 SetIndex(-1);
258 }
260 {
261 // OnDeadZoneChanged(const bool bValue);
262
263 }
265}
void UpdateMaterials() const
Definition WheelMenu.cpp:298
void SetIndex(const int32 Value)
Definition WheelMenu.cpp:218
bool bUseDeadZoneEvents
Definition WheelMenu.h:151
bool bInDeadZone
Definition WheelMenu.h:163

◆ SetIndex()

void UWheelMenu::SetIndex ( const int32 Value)
protected
219{
220 if(Index == Value){return;}
221 Index = Value;
222 if(RootOverlay->GetAllChildren().IsValidIndex(Index))
223 {
224 UWheelSegment* LastSelection = Cast<UWheelSegment>(RootOverlay->GetAllChildren()[Index]);
225 if(LastSelection != nullptr)
226 {
227 LastSelection->SetSelected(false);
228 }
229 }
230 FRadialSegmentData SelectedSegmentData;
231 if(RootOverlay->GetAllChildren().IsValidIndex(Index))
232 {
233 UWheelSegment* NextSelection = Cast<UWheelSegment>(RootOverlay->GetAllChildren()[Index]);
234 if(NextSelection != nullptr)
235 {
236 NextSelection->SetSelected(true);
237 SelectedSegmentData = NextSelection->GetSegmentData();
238 }
239 }
241 {
242 SetDescriptionText(SelectedSegmentData);
243 }
244 else
245 {
247 }
248 //Call OnSelectionChanged(const int32 NewSelection, const int32 PreviousSelection);
249}
void SetDescriptionText(const FRadialSegmentData &SegmentData) const
Definition WheelMenu.cpp:378
void ClearDescriptionText() const
Definition WheelMenu.cpp:409
Definition WheelSegment.h:15
void SetSelected(const bool bValue)
Definition WheelSegment.cpp:64
FRadialSegmentData GetSegmentData() const
Definition WheelSegment.h:21
bool bCenterDescription
Definition RadialWheelData.h:110

◆ SetInputDirection()

void UWheelMenu::SetInputDirection ( const FVector2D Direction)
protected
174{
175 CurrentInput = FixInputRotation(Direction);
176 FVector2D Input = CurrentInput;
177 UKismetMathLibrary::Normalize2D(Input);
178 const float Degrees = UKismetMathLibrary::DegAtan2(Input.X * -1.0f, Input.Y);
179 const float DegreesWithOffset = Degrees + 180.0f; //Offset the input so 0 index is on the top right.
180 IndexRaw = DegreesWithOffset / GetSectionDegreeSize();
181 const int32 IndexToSet = UKismetMathLibrary::FTrunc(IndexRaw);
182 SetIndex(IndexToSet);
184}
float IndexRaw
Definition WheelMenu.h:156
FVector2D FixInputRotation(const FVector2D &Input) const
Definition WheelMenu.cpp:162

◆ SetMaterialSegments()

void UWheelMenu::SetMaterialSegments ( ) const
private
75{
76 if(DynamicMaterial == nullptr){return;}
77 DynamicMaterial->SetScalarParameterValue(MaterialParamSegments, static_cast<float>(Segments));
78}
FName MaterialParamSegments
Definition WheelMenu.h:114

◆ SetMenuSize()

void UWheelMenu::SetMenuSize ( ) const
private
430{
431 if(SizeBox != nullptr)
432 {
434 {
435 SizeBox->SetWidthOverride(MenuData.MenuSize.X);
436 SizeBox->SetHeightOverride(MenuData.MenuSize.Y);
437 return;
438 }
439 SizeBox->SetWidthOverride(MenuSizeDefault.X);
440 SizeBox->SetHeightOverride(MenuSizeDefault.Y);
441 }
442}
FVector2D MenuSizeDefault
Definition WheelMenu.h:145
FVector2D MenuSize
Definition RadialWheelData.h:129
bool bUseCustomSize
Definition RadialWheelData.h:127

◆ SetSegmentData()

void UWheelMenu::SetSegmentData ( const TArray< FRadialSegmentData > & Selections,
const bool bShowDescription ) const
private
349{
350 for(int i = 0; i < Selections.Num(); ++i)
351 {
352 UWheelSegment* WheelSegment = CreateWidget<UWheelSegment>(GetOwningPlayer(), RadialSegmentClass);
353 WheelSegment->SetShowDescription(bShowDescription);
354 WheelSegment->SetSegmentData(Selections[i]);
355 WheelSegment->SetIndex(i);
356 UPanelSlot* Panel = RootOverlay->AddChild(WheelSegment);
357 if(Panel != nullptr)
358 {
359 UOverlaySlot* OverlaySlot = Cast<UOverlaySlot>(Panel);
360 if(OverlaySlot != nullptr)
361 {
362 OverlaySlot->SetVerticalAlignment(VAlign_Center);
363 OverlaySlot->SetHorizontalAlignment(HAlign_Center);
364 WheelSegment->SetRenderTransformPivot(FVector2D(0.5f, 0.5f));
365 }
366 }
367 }
368}
void SetIndex(const int32 Value)
Definition WheelSegment.h:25
void SetSegmentData(const FRadialSegmentData &Data)
Definition WheelSegment.cpp:34
void SetShowDescription(const bool bValue)
Definition WheelSegment.cpp:52

◆ Setup()

void UWheelMenu::Setup ( )
private
57{
59 if(DynamicMaterial != nullptr && RadialBackground != nullptr)
60 {
61 RadialBackground->SetBrushFromMaterial(DynamicMaterial);
65 }
67}
void SetBackgroundRotation() const
Definition WheelMenu.cpp:114
void CreateMaterial()
Definition WheelMenu.cpp:69
void UpdateMaterialVisuals() const
Definition WheelMenu.cpp:305
void SetMenuSize() const
Definition WheelMenu.cpp:429
void SetMaterialSegments() const
Definition WheelMenu.cpp:74

◆ SetWheelData()

void UWheelMenu::SetWheelData ( const FRadialMenuData & Data)
overridevirtual

Implements IRadialMenu.

322{
323 MenuData = Data;
324 Segments = 0;
325 SetIndex(-1);
326 RootOverlay->ClearChildren();
331 {
333 }
334 else
335 {
337 }
339 Segments = RootOverlay->GetChildrenCount();
345 SetMenuSize();
346}
bool bUseCustomColors
Definition WheelMenu.h:126
void UpdateChildPositions() const
Definition WheelMenu.cpp:103
void SetSegmentData(const TArray< FRadialSegmentData > &Selections, const bool bShowDescription) const
Definition WheelMenu.cpp:348
void SetColorsToDefault()
Definition WheelMenu.cpp:424
FLinearColor RingMainColor
Definition RadialWheelData.h:122
FLinearColor UnhighlightColor
Definition RadialWheelData.h:124
bool bShowSegmentDescription
Definition RadialWheelData.h:108
FLinearColor InnerRingColor
Definition RadialWheelData.h:120
bool bUseCustomColors
Definition RadialWheelData.h:116
FLinearColor OuterRingColor
Definition RadialWheelData.h:118

◆ StartUpdateInput()

void UWheelMenu::StartUpdateInput ( )
overridevirtual

Implements IRadialMenu.

278{
279 GetWorld()->GetTimerManager().SetTimer(UpdateSpeedTimer, this, &UWheelMenu::UpdateInput, UpdateSpeed, true);
280}
float UpdateSpeed
Definition WheelMenu.h:88
FTimerHandle UpdateSpeedTimer
Definition WheelMenu.h:194
virtual void UpdateInput()
Definition WheelMenu.cpp:282

◆ UpdateChildPositions()

void UWheelMenu::UpdateChildPositions ( ) const
protected
104{
105 TArray<UWidget*> AllSegments = RootOverlay->GetAllChildren();
106 for (int i = 0; i < RootOverlay->GetChildrenCount(); ++i)
107 {
108 if(AllSegments.IsValidIndex(i) == false){continue;}
109 const FVector Direction = (GetSegmentDirection(i) * ItemOffsetRadius);
110 AllSegments[i]->SetRenderTranslation(FVector2D(Direction));
111 }
112}
FVector GetSegmentDirection(const int32 SegmentIndex) const
Definition WheelMenu.cpp:90

◆ UpdateDirectionWithJoystick()

void UWheelMenu::UpdateDirectionWithJoystick ( )
protected
204{
205 if(GetOwningPlayer() == nullptr){return;}
206 const FVector2D Direction = GetJoystickDirection(MenuData.bLeftJoystick);
207 if(UKismetMathLibrary::VSize2D(Direction) <= JoystickDeadZone)
208 {
209 CurrentInput = FVector2D::ZeroVector;
210 }
211 else
212 {
213 SetInputDirection(Direction);
214 }
215}
float JoystickDeadZone
Definition WheelMenu.h:109
FVector2D GetJoystickDirection(const bool bLeft) const
Definition WheelMenu.cpp:144
void SetInputDirection(const FVector2D Direction)
Definition WheelMenu.cpp:173
bool bLeftJoystick
Definition RadialWheelData.h:113

◆ UpdateDirectionWithMouseCursor()

void UWheelMenu::UpdateDirectionWithMouseCursor ( )
protected
125{
126 const FVector2D MousePosition = UWidgetLayoutLibrary::GetMousePositionOnViewport(GetOwningPlayer());
127 const float ViewportScale = UWidgetLayoutLibrary::GetViewportScale(GetOwningPlayer());
128 const FVector2D ScaledMousePosition = (MousePosition * ViewportScale) - (GetScreenCenter());
129 FVector2D ModifiedMousePosition = FVector2D(ScaledMousePosition.X, ScaledMousePosition.Y);
130 if(ModifiedMousePosition.Length() <= (ViewportScale * MouseDeadZone))
131 {
132 CurrentInput = FVector2D::ZeroVector;
133 return;
134 }
135 if(bNormalize)
136 {
137 UKismetMathLibrary::Normalize2D(ModifiedMousePosition);
138 }
139 RadialDebug->SetRenderTranslation(ModifiedMousePosition);
140 // @ Should this be somewhere else?
141 SetInputDirection(ModifiedMousePosition);
142}
float MouseDeadZone
Definition WheelMenu.h:106
bool bNormalize
Definition WheelMenu.h:93

◆ UpdateInput()

void UWheelMenu::UpdateInput ( )
protectedvirtual
283{
285 {
286 //UpdateDirectionWithCustomInput
287 }
289 if(UKismetMathLibrary::VSize2D(CurrentInput) <= JoystickDeadZone)
290 {
293 return;
294 }
295 SetInDeadZone(false);
296}
void SetInDeadZone(const bool bValue)
Definition WheelMenu.cpp:251
bool bUseCustomInput
Definition WheelMenu.h:104
void UpdateDirectionWithMouseCursor()
Definition WheelMenu.cpp:124
void UpdateDirectionWithJoystick()
Definition WheelMenu.cpp:203

◆ UpdateMaterials()

void UWheelMenu::UpdateMaterials ( ) const
private
299{
300 if(DynamicMaterial == nullptr){return;}
301 DynamicMaterial->SetScalarParameterValue(MaterialParamIndex, IndexRaw);
302 DynamicMaterial->SetScalarParameterValue(MaterialParamDeadZone, bInDeadZone);
303}
FName MaterialParamIndex
Definition WheelMenu.h:116
FName MaterialParamDeadZone
Definition WheelMenu.h:118

◆ UpdateMaterialVisuals()

void UWheelMenu::UpdateMaterialVisuals ( ) const
private
306{
307 if(DynamicMaterial == nullptr){return;}
308 if(bUseCustomTexture && RadialTexture != nullptr)
309 {
310 DynamicMaterial->SetTextureParameterValue(MaterialParamRadialTexture, RadialTexture);
311 }
313 {
318 }
319}
FName MaterialParamInnerRingColor
Definition WheelMenu.h:131
FName MaterialParamOuterRingColor
Definition WheelMenu.h:129
UTexture2D * RadialTexture
Definition WheelMenu.h:124
bool bUseCustomTexture
Definition WheelMenu.h:122
FName MaterialParamRingMainColor
Definition WheelMenu.h:133
FName MaterialParamUnhighlightColor
Definition WheelMenu.h:135
FName MaterialParamRadialTexture
Definition WheelMenu.h:120

Member Data Documentation

◆ bAutoRotateForUp

bool UWheelMenu::bAutoRotateForUp = true
protected

Have a main Slice at the top

◆ bInDeadZone

bool UWheelMenu::bInDeadZone = false
protected

◆ bNormalize

bool UWheelMenu::bNormalize = false
protected

◆ bUseCustomColors

bool UWheelMenu::bUseCustomColors = false
protected

◆ bUseCustomInput

bool UWheelMenu::bUseCustomInput = false
protected

◆ bUseCustomTexture

bool UWheelMenu::bUseCustomTexture = false
protected

◆ bUseDeadZoneEvents

bool UWheelMenu::bUseDeadZoneEvents = false
protected

◆ CurrentInput

FVector2D UWheelMenu::CurrentInput = FVector2D::ZeroVector
protected

◆ DescriptionTextBlock

class UTextBlock* UWheelMenu::DescriptionTextBlock = nullptr
protected

◆ DynamicMaterial

UMaterialInstanceDynamic* UWheelMenu::DynamicMaterial = nullptr
protected

◆ Index

int32 UWheelMenu::Index = -1
protected

The current truncated index of the user's selection

◆ IndexRaw

float UWheelMenu::IndexRaw = 0.0f
protected

Raw index is useful for converting back to a direction and getting in between values.

◆ InnerRingColor

FLinearColor UWheelMenu::InnerRingColor = FLinearColor(0.369792f,0.369792f, 0.369792f)
private

◆ InnerRingColorDefault

FLinearColor UWheelMenu::InnerRingColorDefault = FLinearColor(0.369792f,0.369792f, 0.369792f)
protected

◆ ItemOffsetRadius

float UWheelMenu::ItemOffsetRadius = 180.0f
protected

How far from the center should the widgets be placed? NOTE: The square seen in the viewport is there to debug this,

◆ JoystickDeadZone

float UWheelMenu::JoystickDeadZone = 0.3f
protected

How far should the stick be pressed before being used as input.

◆ MaterialBase

UMaterialInterface* UWheelMenu::MaterialBase = nullptr
protected

◆ MaterialParamDeadZone

FName UWheelMenu::MaterialParamDeadZone = FName("Deadzone")
protected

◆ MaterialParamIndex

FName UWheelMenu::MaterialParamIndex = FName("Index")
protected

◆ MaterialParamInnerRingColor

FName UWheelMenu::MaterialParamInnerRingColor = FName("InnerRingColor")
protected

◆ MaterialParamOuterRingColor

FName UWheelMenu::MaterialParamOuterRingColor = FName("OuterRingColor")
protected

◆ MaterialParamRadialTexture

FName UWheelMenu::MaterialParamRadialTexture = FName("RadialTexture")
protected

◆ MaterialParamRingMainColor

FName UWheelMenu::MaterialParamRingMainColor = FName("RingMainColor")
protected

◆ MaterialParamSegments

FName UWheelMenu::MaterialParamSegments = FName("Segments")
protected

◆ MaterialParamUnhighlightColor

FName UWheelMenu::MaterialParamUnhighlightColor = FName("UnhighlightColor")
protected

◆ MenuData

FRadialMenuData UWheelMenu::MenuData
protected

◆ MenuSizeDefault

FVector2D UWheelMenu::MenuSizeDefault = FVector2D(512.0f, 512.0f)
protected

◆ MouseDeadZone

float UWheelMenu::MouseDeadZone = 0.2f
protected

◆ OuterRingColor

FLinearColor UWheelMenu::OuterRingColor = FLinearColor(0.0f,0.25641f, 1.0f)
private

◆ OuterRingColorDefault

FLinearColor UWheelMenu::OuterRingColorDefault = FLinearColor(0.0f,0.25641f, 1.0f)
protected

◆ RadialBackground

class UImage* UWheelMenu::RadialBackground = nullptr
protected

◆ RadialDebug

class UImage* UWheelMenu::RadialDebug = nullptr
protected

◆ RadialSegmentClass

TSubclassOf<UUserWidget> UWheelMenu::RadialSegmentClass
private

◆ RadialTexture

UTexture2D* UWheelMenu::RadialTexture = nullptr
protected

◆ RingMainColor

FLinearColor UWheelMenu::RingMainColor = FLinearColor(1.0f,1.0f, 1.0f)
private

◆ RingMainColorDefault

FLinearColor UWheelMenu::RingMainColorDefault = FLinearColor(1.0f,1.0f, 1.0f)
protected

◆ RootOverlay

class UOverlay* UWheelMenu::RootOverlay = nullptr
protected

◆ Segments

int32 UWheelMenu::Segments = 2
protected

◆ SizeBox

class USizeBox* UWheelMenu::SizeBox = nullptr
protected

◆ TitleTextBlock

class UTextBlock* UWheelMenu::TitleTextBlock = nullptr
protected

◆ UnhighlightColor

FLinearColor UWheelMenu::UnhighlightColor = FLinearColor(0.291667f, 0.291667f, 0.291667f)
private

◆ UnhighlightColorDefault

FLinearColor UWheelMenu::UnhighlightColorDefault = FLinearColor(0.291667f, 0.291667f, 0.291667f)
protected

◆ UpdateSpeed

float UWheelMenu::UpdateSpeed = 1.0f
protected

◆ UpdateSpeedTimer

FTimerHandle UWheelMenu::UpdateSpeedTimer
private

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