Files
gig-line/Game/GigLine/Source/GigLine/GigLineHUD.h
T

73 lines
2.4 KiB
C++

#pragma once
#include "CoreMinimal.h"
#include "GameFramework/HUD.h"
#include "GigLineHUD.generated.h"
/**
* On-screen text overlay: control legend (bottom-right) and the optional
* performance/state readout (top-left).
*
* Plain AHUD::DrawText is used deliberately: no UMG widget asset is needed, so
* the overlay cannot be accidentally dropped from a cook by a missing widget
* reference.
*/
UCLASS()
class GIGLINE_API AGigLineHUD : public AHUD
{
GENERATED_BODY()
public:
virtual void DrawHUD() override;
/**
* Control legend, shown bottom-right so the 0.1.0 demo documents its own
* controls in-game (release check: "controls documented in Docs/ and shown
* in-game"). Keep in sync with Docs/controls.md.
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Controls")
FString ControlsLine = TEXT("WASD move \u00B7 Mouse look \u00B7 Space jump \u00B7 V view \u00B7 R reset \u00B7 Esc pause");
/**
* Performance and state readout, top-left, off by default.
*
* Toggle in game with **F3**, or start with it on by passing `-perf` (the
* performance capture does). The built demo ships with it hidden so a player
* does not see an FPS counter over Hollywood Boulevard.
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Debug")
bool bShowDebug = false;
/** Smoothed FPS and a rolling frame-time window, refreshed every frame. */
void UpdateFrameStats(float DeltaSeconds);
/** Screen-space margin in pixels. */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HUD")
float MarginPx = 18.0f;
/** Text scale relative to the default canvas font. */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HUD")
float TextScale = 1.45f;
private:
/** Exponential moving average of frame time, in milliseconds. */
float SmoothedFrameMs = 16.7f;
/** Worst frame in the rolling window, so a hitch is visible without a log. */
float WorstFrameMs = 0.0f;
/** Seconds until the rolling worst-frame window resets. */
float WorstWindowSeconds = 0.0f;
/** Frames drawn, so the overlay can show that the counter is live. */
int64 FramesDrawn = 0;
/**
* Seconds left in the warm-up window. The first frames of a session include
* shader and streaming hitches of several hundred milliseconds; without this
* the "worst" figure read 400 ms for the whole first two seconds and made a
* healthy run look broken.
*/
float WarmupSeconds = 2.0f;
};