Clutter Engine 0.0.1
Loading...
Searching...
No Matches
clt::HUDComponent Class Reference

Component responsible for managing UI widgets (panels) for the HUD. More...

#include <HUDComponent.h>

Inheritance diagram for clt::HUDComponent:
clt::Component DoomHUD MainMenuHUD

Public Member Functions

 HUDComponent ()
 Constructs a HUDComponent.
 
 ~HUDComponent ()
 Destructor. Cleans up all widgets.
 
virtual void SetOwner (Actor *pOwner) override
 Sets the owner actor for this component.
 
template<typename T , typename ... Args>
T * CreateWidget (std::string pName, Args &&...args)
 Creates a new widget of type T and adds it to the HUD.
 
template<typename T >
T * GetWidget (const std::string pName)
 Retrieves a widget of type T by name.
 
void ShowWidget (const std::string pName)
 Sets the widget with the given name as the current widget and displays it.
 
void RemoveWidget (const std::string &pName)
 Removes the widget with the given name from the HUD.
 
UIPanelGetCurrentWidget () const
 Gets the currently active widget.
 
virtual void Update () override
 Updates the HUD component and its widgets.
 
- Public Member Functions inherited from clt::Component
 Component (int pUpdateOrder=0)
 Constructor for Component.
 
virtual ~Component ()=default
 Virtual destructor for Component.
 
virtual void Start ()
 Called when the component is started.
 
virtual void Destroy ()
 Called to destroy the component.
 
void SetActive (bool pActive)
 Enables or disables the component.
 
void OnDestroy ()
 Called when the component is destroyed.
 
bool IsActive () const
 Checks if the component is enabled.
 
int GetUpdateOrder () const
 Gets the update order of the component.
 
void SetRelativeLocation (const Vector3 &loc)
 Sets the relative location of the component.
 
void SetRelativeLocation (const Vector2 &loc)
 Sets the relative location of the component.
 
void SetWorldLocation (const Vector3 &loc)
 Sets the world location of the component.
 
void SetRelativeScale (const Vector3 &scale)
 Sets the relative scale of the component.
 
void SetRelativeScale (const Vector2 &scale)
 Sets the relative scale of the component.
 
void SetRelativeRotation (Quaternion rot)
 Sets the relative rotation of the component.
 
void SetRelativeRotation (Vector3 rot)
 Sets the relative rotation of the component.
 
void SetWorldRotation (const Quaternion &rot)
 Sets the world rotation of the component.
 
void SetWorldRotation (const Vector3 &rot)
 Sets the world rotation of the component.
 
void AddRelativeRotation (Vector3 rot)
 Adds a rotation to the current relative rotation.
 
void SetRelativeRotation (float rot)
 Sets the relative rotation of the component.
 
void SetRelativeTransform (Transform &transform)
 Sets the relative transform of the component.
 
Vector3 GetRelativeLocation () const
 Gets the relative location of the component.
 
Vector3 GetRelativeScale () const
 Gets the relative scale of the component.
 
Quaternion GetRelativeRotation () const
 Gets the relative rotation of the component.
 
Vector3 GetRelativeRotationEuler () const
 Gets the relative rotation of the component as Euler angles.
 
Transform GetRelativeTransform () const
 Gets the relative transform of the component.
 
Vector3 GetWorldLocation () const
 Gets the world location of the component.
 
Vector3 GetWorldScale () const
 Gets the world scale of the component.
 
Quaternion GetWorldRotation () const
 Gets the world rotation of the component.
 
virtual Transform GetWorldTransform () const
 Gets the world transform of the component.
 
ActorGetOwner () const
 Gets the owner actor of this component.
 

Additional Inherited Members

- Public Attributes inherited from clt::Component
friend Actor
 
- Protected Member Functions inherited from clt::Component
bool LineTrace (Vector3 start, Vector3 direction, float maxDistance, raycastHit &hit, bool debugPersistant=false)
 Performs a line trace (raycast) using the owning actor.
 
- Protected Attributes inherited from clt::Component
bool mIsActive = true
 Indicates if the component is active.
 
int mUpdateOrder = 0
 The order in which the component is updated.
 
ActormOwner
 The actor that owns this component.
 
Transform mRelativeTransform
 The relative transform of the component to its owner.
 

Detailed Description

Component responsible for managing UI widgets (panels) for the HUD.

HUDComponent allows creation, retrieval, display, and removal of UI widgets. It keeps track of the currently active widget and provides update functionality.

Member Function Documentation

◆ CreateWidget()

template<typename T , typename ... Args>
T * clt::HUDComponent::CreateWidget ( std::string pName,
Args &&... args )
inline

Creates a new widget of type T and adds it to the HUD.

Template implementation for creating a widget of type T.

Template Parameters
TType of the widget, must derive from UIPanel.
ArgsConstructor argument types.
Parameters
pNameName to associate with the widget.
argsArguments to forward to the widget's constructor.
Returns
Pointer to the created widget, or nullptr if a widget with the same name exists.

◆ GetCurrentWidget()

UIPanel * clt::HUDComponent::GetCurrentWidget ( ) const
inline

Gets the currently active widget.

Returns
Pointer to the current UIPanel widget.

◆ GetWidget()

template<typename T >
T * clt::HUDComponent::GetWidget ( const std::string pName)
inline

Retrieves a widget of type T by name.

Template implementation for retrieving a widget of type T by name.

Template Parameters
TType of the widget, must derive from UIPanel.
Parameters
pNameName of the widget.
Returns
Pointer to the widget if found and of type T, nullptr otherwise.

◆ RemoveWidget()

void HUDComponent::RemoveWidget ( const std::string & pName)

Removes the widget with the given name from the HUD.

Parameters
pNameName of the widget to remove.

◆ SetOwner()

void HUDComponent::SetOwner ( Actor * pOwner)
overridevirtual

Sets the owner actor for this component.

Parameters
pOwnerPointer to the owning Actor.

Reimplemented from clt::Component.

◆ ShowWidget()

void HUDComponent::ShowWidget ( const std::string pName)

Sets the widget with the given name as the current widget and displays it.

Parameters
pNameName of the widget to show.

◆ Update()

void HUDComponent::Update ( )
overridevirtual

Updates the HUD component and its widgets.

Reimplemented from clt::Component.

Reimplemented in DoomHUD, and MainMenuHUD.


The documentation for this class was generated from the following files: