// // This class implements the layout calculatations for a radial // menu. // #pragma once #include "CoreMinimal.h" #include "RadialMenu.generated.h" USTRUCT(BlueprintType) struct FRadialMenuItem { GENERATED_BODY() FVector2D Point1 = {0,0}; FVector2D Point2 = {0,0}; FVector2D Point3 = {0,0}; bool RightSide = false; }; UCLASS(BlueprintType) class URadialMenu : public UObject { GENERATED_BODY() public: UFUNCTION(BlueprintCallable) void Configure(int32 NItems, float ItemHeight, float InnerRadius, float MinSpoke, float Spread); UFUNCTION(BlueprintCallable) int32 NumItems() const { return Items.Num(); } UFUNCTION(BlueprintCallable) const TArray GetItems() const { return Items; } TArray Items; private: using View = TArrayView; void CalculateSide(View V); void FlipHorizontal(View V); // The half-circle is divided into pie slices. Returns a direction vector // which aims directly down the center of the pie slice. FVector2D PieSliceToVector(double Slice, double Slices); int32 CNItems = 0; float CItemHeight = 0; float CInnerRadius = 0; float CMinSpoke = 0; float CSpread = 0; int32 CNumLeft = 0; int32 CNumRight = 0; View LeftItems; View RightItems; };