#pragma once #include "CoreMinimal.h" #include "Widgets/DeclarativeSyntaxSupport.h" #include "Widgets/SCompoundWidget.h" class SDPIScaler; /** * The root of everything the UI puts into the viewport (HUD, window host, gallery). It undoes the engine's UI scale * (the project's DPI curve gives 0.67 at 720p, which would shrink the 800 x 450 layout to nothing) and applies the * UI's own: one UI unit is one viewport pixel up to 1080p, larger screens scale up (Tune::UI::UiScaleForViewport). * Children therefore lay out in UI units; `GetUiScale()` converts back to viewport pixels. * * The layer itself never takes mouse hits (SelfHitTestInvisible): its children decide. */ class THEDESCENT_API SDescentUiLayer : public SCompoundWidget { public: SLATE_BEGIN_ARGS(SDescentUiLayer) {} SLATE_DEFAULT_SLOT(FArguments, Content) SLATE_END_ARGS() void Construct(const FArguments& InArgs); virtual void Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime) override; /** Viewport pixels per UI unit as of the last tick. */ float GetUiScale() const { return UiScale; } /** Size of the layer in UI units as of the last tick. */ FVector2f GetLayoutSize() const { return LayoutSize; } private: float GetChildScale() const { return ChildScale; } TSharedPtr Scaler; float ChildScale = 1.f; float UiScale = 1.f; FVector2f LayoutSize = FVector2f(1280.f, 720.f); };