HUD Surfaces
Last Update: 24/03/2024 17:44:14
Author: TT
Loading...
# Introduction
HUD surfaces is a feature that allows script developers modify client's HUDs to display shapes, images and texts on
[TT 4.8 Update 1 (r8912)](/Downloads/#rev-8912) and newer versions.
## Surfaces
Surfaces are containers for all the visual elements that are created on the screen. It is possible to set a texture to a surface, to display this texture
on each element contained by the surface. Elements can change the texture's color and UV individually, without affecting other elements that use the
texture.
Surfaces do not use a standard coordinate system, and instead uses the render resolution sent by the player as the coordinate system. Developers will
have to calculate the correct position and size of elements based on the player's resolution.
## Elements
These surfaces are capable of handling 4 different element types: Lines, Rectangles, Outlines and Texts.
### Lines
This element draws lines on the screen with adjustable size, color and thickness.
### Rectangles
This element draws filled rectangles on the screen with adjustable size and color.
### Outlines
This element draws outlined rectangles on the screen with adjustable size, color and thickness.
### Texts
This element draws texts on the screen with adjustable font, size and color. There are 6 different fonts with different styles and sizes available
for use.
# Usage
*Note for regular users: This section is for developers, and details how to use HUD surfaces.*
HUD surfaces require an existing client's ID (whether or not they are in-game, so they can be created during connection requests) to work, and surfaces
are automatically deleted when the owning client leaves the game, **after player leave event hooks**. Surfaces also reset automatically on every level
unload. (Game Over event)
## Engine Functions
HUD surfaces are created, controlled and deleted by calling engine functions.
### Create_HUD_Surface(int target)
This function creates a HUD surface for the specified client, and returns the surface instance.
### Find_HUD_Surface(int id)
This function finds a surface by it's ID. Returns `nullptr` if a surface was not found.
### Show_HUD_Surface(HUDSurfaceClass* surface)
This function signals the owning client to show this surface.
### Hide_HUD_Surface(HUDSurfaceClass* surface)
This function signals the owning client to hide this surface.
### Delete_HUD_Surface(HUDSurfaceClass* surface)
This function deletes the surface.
## Surface/Element Functions
Please refer to the header file `HUDSurfaceClass.h` for available functions for surfaces and elements.
## Samples
The [Voting](https://github.com/TheUnstoppable/Essentials/blob/master/Essentials/EssentialsVoteStatusPlayerObserverClass.cpp) feature of
[Essentials](https://github.com/TheUnstoppable/Essentials) project by Unstoppable contains an implementation that makes use of HUD surfaces.