#pragma once #include "CoreMinimal.h" #include "InputCoreTypes.h" #include "UI/DescentUiSubsystem.h" #include "Widgets/DeclarativeSyntaxSupport.h" #include "Widgets/SCompoundWidget.h" class SDPIScaler; class SBox; namespace Descent::Ui { /** The body of a window for its current tab, drawn from the subsystem's view-models. Called again whenever the window, the tab or a view-model changes. */ TSharedRef BuildPage(UDescentUiSubsystem& Ui, EDescentWindow Window, FName Tab); /** Tabs of a window as (id, label). The PDA has four; the fabricator one per recipe category; the rest none. */ /** Which keys close which window: Esc closes every window but the title card; Tab and M close the PDA; E closes a station (not the PDA, the pause window or the end card). */ THEDESCENT_API bool KeyClosesWindow(EDescentWindow Window, const FKey& Key); void GetWindowTabs(const UDescentUiSubsystem& Ui, EDescentWindow Window, TArray& OutIds, TArray& OutLabels); } /** * Full-viewport host of the windows: a dark scrim (an opaque backdrop for the title card), the SNeuWindow frame centred and * scaled down uniformly when the viewport is smaller than the window's design size, and the keyboard (Esc, Tab, M, E close). * It follows the subsystem: when the open window, the tab or the revision changes, it rebuilds its page on the next tick. */ class THEDESCENT_API SDescentWindowHost : public SCompoundWidget { public: SLATE_BEGIN_ARGS(SDescentWindowHost) {} SLATE_ARGUMENT(TWeakObjectPtr, Ui) SLATE_END_ARGS() void Construct(const FArguments& InArgs); virtual void Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime) override; virtual bool SupportsKeyboardFocus() const override { return true; } virtual FReply OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent) override; /** Rebuilds the frame and page for what the subsystem has open now. */ void Rebuild(); /** Where the frame is, in the host's own layout units, as of the last tick. */ Descent::Ui::FWindowFit GetFit() const { return Fit; } FVector2f GetLayoutSize() const { return LayoutSize; } private: float GetFitScale() const { return Fit.Scale; } TWeakObjectPtr Ui; TSharedPtr FrameBox; TSharedPtr Scaler; TSharedPtr Backdrop; EDescentWindow BuiltWindow = EDescentWindow::None; FName BuiltTab; int32 BuiltRevision = -1; FVector2f LayoutSize = FVector2f(1280.f, 720.f); Descent::Ui::FWindowFit Fit; };