The in-game HUD is created with a mixture of Canvas drawing and Slate widgets.
In the top-left corner, a game timer counts down the warm-up time for the game, using the function
GetGameTime in the class
SStrategySlateHUDWidget. After the game begins, this countdown disappears,
and the display for the number of lives left (1) is revealed. The properties for the "lives left" display are set in the
DrawLives function of the
AStrategyHUD class; the initial number of lives
is set in the PlayerBaseUpgrades subgraph in the TowerDefenseMap Level Blueprint.
The current gold resources are displayed in the top-center of the screen (2). Both the game timer and the resource display are defined using basic widgets in the
SStrategySlateHUDWidget. The same class
is used to create all top level widgets, but not all of these widgets are displayed by default.
The mini-map is in the bottom-left corner of the HUD (3). It is built from an invisible Slate widget overlay which handles the input and the actual map image, which is drawn using Canvas.
is responsible for moving the camera when the button is clicked or held on the mini-map area.
When a building slot is clicked on, the
SStrategyActionGrid menu appears. There is only one instance of this widget; its location is determined by the active building slot. Calculating the screen
position of the menu is done in the
DrawHUD method, which projects the selected Actor location to 2D coordinates. The look and event mapping of the action buttons for this menu are defined in the
AStrategyBuilding class in either the
ShowActionMenu method or the
ShowCustomAction method. The
Button widget is defined in the
SStrategyButtonWidget class, and any additional information
bound to the action buttons is stored in the
FActionButton information structure.
The health bars of Pawns and buildings are drawn on the canvas using the
DrawActorsHealth method. Each team has a different healthbar texture.
In the bottom-right corner of the HUD, there is a
PauseButton (4) which toggles pausing the game and the in-game menu visibility.
After the game time is up, or one of the bases is destroyed, the game will pause and "Victory" or "Defeat" text will be animated from the center of the screen. The animation changes the font size over time.
This text is created using a simple
STextBlock widget with delegates for Visibility, Font, and Text.