Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
Loading...
Searching...
No Matches
Engine::Components::WidgetComponent Class Reference

Runtime ImGui widget that can be rendered into a world-space UI texture. More...

#include <WidgetComponent.h>

Inheritance diagram for Engine::Components::WidgetComponent:
Collaboration diagram for Engine::Components::WidgetComponent:

Classes

struct  Resolution
 Requested render-target size for the widget texture. More...
struct  WorldUiWindowStyle

Public Member Functions

 WidgetComponent (Entities::Scene *scene)
 Creates a widget component attached to a scene.
void beginPlay () override
 Called when the component is added to the scene or the game starts.
void endPlay () override
 Called when the component is removed or the game ends.
std::string getComponentName () const override
 Gets the component type name for debugging/UI.
Resolution getRequestedResolution () const
 Returns the requested offscreen render target resolution.
void setRequestedResolution (uint32_t width, uint32_t height)
 Sets the requested offscreen render target resolution.
void setPixelsPerMeter (float pixelsPerMeter)
 Sets the density used to map widget pixels onto a 1m x 1m plane.
glm::vec3 getPlaneScale () const
 Returns the scale for a unit XZ plane at the requested resolution and pixel density.
bool isWorldUiActive () const
 Returns whether this widget should be rendered into world UI.
void setWorldUiActive (bool active)
 Enables or disables world UI rendering for this widget.
uint32_t getWorldUiDescriptorIndex () const
 Returns the texture descriptor index assigned to this widget.
void setWorldUiDescriptorIndex (uint32_t descriptorIndex)
 Stores the texture descriptor index assigned by the world UI renderer.
void clearWorldUiDescriptorIndex ()
 Clears the assigned world UI texture descriptor index.
void setWorldUiWindowStyle (WorldUiWindowStyle style)
const std::optional< WorldUiWindowStyle > & getWorldUiWindowStyle () const
virtual void drawRuntimeImGui ()
 Draws this widget's runtime ImGui content into the active ImGui context.
void requestWorldUiTexture (Assets::Texture2DHandle handle)
 Makes a loaded engine texture available to this widget's ImGui draw calls.
uint64_t getWorldUiTextureId (Assets::Texture2DHandle handle) const
 Returns the ImGui texture ID assigned by the world UI renderer, or zero while loading.
const std::vector< Assets::Texture2DHandle > & getRequestedWorldUiTextures () const
void setWorldUiTextureId (Assets::Texture2DHandle handle, uint64_t textureId)
void selectNextUpgrade ()
 Selects the next upgrade entry in the demo widget state.
void selectPreviousUpgrade ()
 Selects the previous upgrade entry in the demo widget state.
void buySelectedUpgrade ()
 Attempts to purchase the currently selected demo upgrade.
Public Member Functions inherited from Engine::Components::Logic
 Logic (Entities::Scene *owningScene)
 Constructs a logic component owned by a scene.
 Logic (const Entities::SpawnContext &context)
 Constructs a logic component from spawn context data.
virtual ~Logic ()=default
 Destroys the logic component.
virtual bool drawImGui ()
 Draws component-specific ImGui inspector controls.
virtual bool drawImGuiName ()
 Used to alter the name of the entity in the outliner.
virtual void tick (double deltaTime)
 Called every frame if ticking is enabled.
bool hasBegunPlay () const
 Checks whether beginPlay() has been called without a matching endPlay().
bool canTick () const
 Checks if the component is currently set to tick.
void setCanTick (bool enable)
 Enables or disables ticking for this component.
Entities::Entity * getOwningEntity () const
 Gets the entity this component belongs to.

Static Public Attributes

static constexpr bool IsUnique = false
 Widget components are allowed to have multiple instances per entity.
Static Public Attributes inherited from Engine::Components::Logic
static constexpr bool IsUnique = false
 Defines whether multiple instances of this component can exist on the same entity. Defaults to false (multiple allowed). Override in derived classes with static constexpr bool IsUnique = true; if needed.
static constexpr const char * ComponentName = "Logic"
 Fallback component type name. Derived classes may override getComponentName() for custom labels.

Private Attributes

Resolution resolution_ {}
float pixelsPerMeter_ = 750.0f
bool active_ = true
uint32_t descriptorIndex_ = std::numeric_limits<uint32_t>::max()
std::optional< WorldUiWindowStyle > worldUiWindowStyle_
std::vector< Assets::Texture2DHandle > requestedTextures_
std::unordered_map< uint32_t, uint64_t > worldUiTextureIds_
int selectedUpgrade_ = 0
int credits_ = 120
int purchaseCount_ = 0

Additional Inherited Members

Protected Member Functions inherited from Engine::Components::Logic
Entities::Scene * getScene () const
 Gets the scene this component belongs to.
Core::SceneManager * getSceneManager () const
 Helper to get the SceneManager from the owning scene.

Detailed Description

Runtime ImGui widget that can be rendered into a world-space UI texture.

Interaction is driven by gameplay or physical button code mutating this state.

Definition at line 22 of file WidgetComponent.h.

Constructor & Destructor Documentation

◆ WidgetComponent()

Engine::Components::WidgetComponent::WidgetComponent ( Entities::Scene * scene)
explicit

Creates a widget component attached to a scene.

Member Function Documentation

◆ beginPlay()

void Engine::Components::WidgetComponent::beginPlay ( )
overridevirtual

Called when the component is added to the scene or the game starts.

Reimplemented from Engine::Components::Logic.

◆ buySelectedUpgrade()

void Engine::Components::WidgetComponent::buySelectedUpgrade ( )

Attempts to purchase the currently selected demo upgrade.

◆ clearWorldUiDescriptorIndex()

void Engine::Components::WidgetComponent::clearWorldUiDescriptorIndex ( )

Clears the assigned world UI texture descriptor index.

◆ drawRuntimeImGui()

virtual void Engine::Components::WidgetComponent::drawRuntimeImGui ( )
virtual

Draws this widget's runtime ImGui content into the active ImGui context.

◆ endPlay()

void Engine::Components::WidgetComponent::endPlay ( )
overridevirtual

Called when the component is removed or the game ends.

Reimplemented from Engine::Components::Logic.

◆ getComponentName()

std::string Engine::Components::WidgetComponent::getComponentName ( ) const
nodiscardoverridevirtual

Gets the component type name for debugging/UI.

Returns
The component display name.

Reimplemented from Engine::Components::Logic.

◆ getPlaneScale()

glm::vec3 Engine::Components::WidgetComponent::getPlaneScale ( ) const
nodiscard

Returns the scale for a unit XZ plane at the requested resolution and pixel density.

◆ getRequestedResolution()

Resolution Engine::Components::WidgetComponent::getRequestedResolution ( ) const
nodiscard

Returns the requested offscreen render target resolution.

◆ getRequestedWorldUiTextures()

const std::vector< Assets::Texture2DHandle > & Engine::Components::WidgetComponent::getRequestedWorldUiTextures ( ) const
nodiscard

◆ getWorldUiDescriptorIndex()

uint32_t Engine::Components::WidgetComponent::getWorldUiDescriptorIndex ( ) const
nodiscard

Returns the texture descriptor index assigned to this widget.

◆ getWorldUiTextureId()

uint64_t Engine::Components::WidgetComponent::getWorldUiTextureId ( Assets::Texture2DHandle handle) const
nodiscard

Returns the ImGui texture ID assigned by the world UI renderer, or zero while loading.

◆ getWorldUiWindowStyle()

const std::optional< WorldUiWindowStyle > & Engine::Components::WidgetComponent::getWorldUiWindowStyle ( ) const
nodiscard

◆ isWorldUiActive()

bool Engine::Components::WidgetComponent::isWorldUiActive ( ) const
nodiscard

Returns whether this widget should be rendered into world UI.

◆ requestWorldUiTexture()

void Engine::Components::WidgetComponent::requestWorldUiTexture ( Assets::Texture2DHandle handle)

Makes a loaded engine texture available to this widget's ImGui draw calls.

◆ selectNextUpgrade()

void Engine::Components::WidgetComponent::selectNextUpgrade ( )

Selects the next upgrade entry in the demo widget state.

◆ selectPreviousUpgrade()

void Engine::Components::WidgetComponent::selectPreviousUpgrade ( )

Selects the previous upgrade entry in the demo widget state.

◆ setPixelsPerMeter()

void Engine::Components::WidgetComponent::setPixelsPerMeter ( float pixelsPerMeter)

Sets the density used to map widget pixels onto a 1m x 1m plane.

◆ setRequestedResolution()

void Engine::Components::WidgetComponent::setRequestedResolution ( uint32_t width,
uint32_t height )

Sets the requested offscreen render target resolution.

◆ setWorldUiActive()

void Engine::Components::WidgetComponent::setWorldUiActive ( bool active)

Enables or disables world UI rendering for this widget.

◆ setWorldUiDescriptorIndex()

void Engine::Components::WidgetComponent::setWorldUiDescriptorIndex ( uint32_t descriptorIndex)

Stores the texture descriptor index assigned by the world UI renderer.

◆ setWorldUiTextureId()

void Engine::Components::WidgetComponent::setWorldUiTextureId ( Assets::Texture2DHandle handle,
uint64_t textureId )

◆ setWorldUiWindowStyle()

void Engine::Components::WidgetComponent::setWorldUiWindowStyle ( WorldUiWindowStyle style)

Member Data Documentation

◆ active_

bool Engine::Components::WidgetComponent::active_ = true
private

Definition at line 138 of file WidgetComponent.h.

◆ credits_

int Engine::Components::WidgetComponent::credits_ = 120
private

Definition at line 145 of file WidgetComponent.h.

◆ descriptorIndex_

uint32_t Engine::Components::WidgetComponent::descriptorIndex_ = std::numeric_limits<uint32_t>::max()
private

Definition at line 139 of file WidgetComponent.h.

◆ IsUnique

bool Engine::Components::WidgetComponent::IsUnique = false
staticconstexpr

Widget components are allowed to have multiple instances per entity.

Definition at line 42 of file WidgetComponent.h.

◆ pixelsPerMeter_

float Engine::Components::WidgetComponent::pixelsPerMeter_ = 750.0f
private

Definition at line 137 of file WidgetComponent.h.

◆ purchaseCount_

int Engine::Components::WidgetComponent::purchaseCount_ = 0
private

Definition at line 146 of file WidgetComponent.h.

◆ requestedTextures_

std::vector<Assets::Texture2DHandle> Engine::Components::WidgetComponent::requestedTextures_
private

Definition at line 141 of file WidgetComponent.h.

◆ resolution_

Resolution Engine::Components::WidgetComponent::resolution_ {}
private

Definition at line 136 of file WidgetComponent.h.

◆ selectedUpgrade_

int Engine::Components::WidgetComponent::selectedUpgrade_ = 0
private

Definition at line 144 of file WidgetComponent.h.

◆ worldUiTextureIds_

std::unordered_map<uint32_t, uint64_t> Engine::Components::WidgetComponent::worldUiTextureIds_
private

Definition at line 142 of file WidgetComponent.h.

◆ worldUiWindowStyle_

std::optional<WorldUiWindowStyle> Engine::Components::WidgetComponent::worldUiWindowStyle_
private

Definition at line 140 of file WidgetComponent.h.


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