Zappy GUI
C++ graphic client: renderer, camera, network
Loading...
Searching...
No Matches
EntityTooltipWidget Class Reference

#include <EntityTooltipWidget.hpp>

+ Inheritance diagram for EntityTooltipWidget:
+ Collaboration diagram for EntityTooltipWidget:

Public Member Functions

 EntityTooltipWidget ()
 
 ~EntityTooltipWidget () override=default
 
void setSelection (const SelectionFinder::Selection &sel)
 
void setWorld (const WorldState *world)
 
void setTeamColorFunc (std::function< Color(const std::string &)> func)
 
void setFollowActive (bool active)
 Tells the widget whether follow mode is currently active (affects button label/color).
 
int popFollowRequest ()
 Returns and clears the pending follow target player id. Positive id = start follow. -2 = stop follow requested. -1 = no request.
 
bool isFollowButtonHovered () const
 True when the follow button is hovered — use to block raycasts.
 
void draw (int scaledFontSize) const override
 Draws the widget.
 
bool handleInput () override
 Processes user input.
 
- Public Member Functions inherited from IWidget
virtual ~IWidget ()=default
 

Private Member Functions

void _rebuild () const
 
bool _isPlayerCase () const
 
void _positionButton () const
 

Private Attributes

const WorldState_world = nullptr
 
SelectionFinder::Selection _selection
 
std::function< Color(const std::string &)> _colorFunc
 
bool _followActive = false
 
int _pendingFollowId = -1
 
int _scaledFontSize = 18
 
TooltipWidget _tooltip
 
ButtonWidget _followBtn
 
bool _btnHovered = false
 
float _btnW = BTN_W
 

Static Private Attributes

static constexpr float BTN_W = 120.0f
 
static constexpr float BTN_H = 36.0f
 
static constexpr float BTN_MARGIN = 10.0f
 

Detailed Description

Definition at line 19 of file EntityTooltipWidget.hpp.

Constructor & Destructor Documentation

◆ EntityTooltipWidget()

◆ ~EntityTooltipWidget()

EntityTooltipWidget::~EntityTooltipWidget ( )
overridedefault

Member Function Documentation

◆ _isPlayerCase()

bool EntityTooltipWidget::_isPlayerCase ( ) const
private

Definition at line 55 of file EntityTooltipWidget.cpp.

References _selection, _world, SelectionFinder::Selection::id, SelectionFinder::Player, WorldState::playerExists(), and SelectionFinder::Selection::type.

Referenced by _rebuild(), draw(), and handleInput().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _positionButton()

void EntityTooltipWidget::_positionButton ( ) const
private

Definition at line 135 of file EntityTooltipWidget.cpp.

References _btnW, _followBtn, _scaledFontSize, _tooltip, I18n::BTN_FOLLOW, BTN_H, BTN_MARGIN, I18n::BTN_STOP_FOLLOW, BTN_W, I18n::get(), TooltipWidget::getLastBounds(), TextRenderer::measure(), ButtonWidget::setPosition(), and ButtonWidget::setSize().

Referenced by draw(), and handleInput().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _rebuild()

◆ draw()

void EntityTooltipWidget::draw ( int  scaledFontSize) const
overridevirtual

Draws the widget.

Parameters
scaledFontSizeBase font size for UI scaling.

Implements IWidget.

Definition at line 171 of file EntityTooltipWidget.cpp.

References _followBtn, _isPlayerCase(), _positionButton(), _rebuild(), _scaledFontSize, _selection, _tooltip, ButtonWidget::draw(), TooltipWidget::draw(), SelectionFinder::None, and SelectionFinder::Selection::type.

Referenced by RaylibRenderer::_render2D().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleInput()

bool EntityTooltipWidget::handleInput ( )
overridevirtual

Processes user input.

Returns
true if the widget consumed the input, false otherwise.

Implements IWidget.

Definition at line 151 of file EntityTooltipWidget.cpp.

References _btnHovered, _followActive, _followBtn, _isPlayerCase(), _pendingFollowId, _positionButton(), _selection, I18n::BTN_FOLLOW, I18n::BTN_STOP_FOLLOW, FOLLOW_HOVER, FOLLOW_NORMAL, I18n::get(), ButtonWidget::getBounds(), ButtonWidget::handleInput(), SelectionFinder::Selection::id, ButtonWidget::setLabel(), ButtonWidget::setNormalColor(), STOP_HOVER, STOP_NORMAL, and ButtonWidget::wasClicked().

Referenced by RaylibRenderer::handleInput().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isFollowButtonHovered()

bool EntityTooltipWidget::isFollowButtonHovered ( ) const

True when the follow button is hovered — use to block raycasts.

Definition at line 53 of file EntityTooltipWidget.cpp.

References _btnHovered.

Referenced by RaylibRenderer::handleInput().

+ Here is the caller graph for this function:

◆ popFollowRequest()

int EntityTooltipWidget::popFollowRequest ( )

Returns and clears the pending follow target player id. Positive id = start follow. -2 = stop follow requested. -1 = no request.

Definition at line 46 of file EntityTooltipWidget.cpp.

References _pendingFollowId.

Referenced by RaylibRenderer::handleInput().

+ Here is the caller graph for this function:

◆ setFollowActive()

void EntityTooltipWidget::setFollowActive ( bool  active)

Tells the widget whether follow mode is currently active (affects button label/color).

Definition at line 44 of file EntityTooltipWidget.cpp.

References _followActive.

Referenced by RaylibRenderer::_render2D(), and RaylibRenderer::handleInput().

+ Here is the caller graph for this function:

◆ setSelection()

void EntityTooltipWidget::setSelection ( const SelectionFinder::Selection sel)

Definition at line 38 of file EntityTooltipWidget.cpp.

References _selection.

Referenced by RaylibRenderer::_render2D(), and RaylibRenderer::handleInput().

+ Here is the caller graph for this function:

◆ setTeamColorFunc()

void EntityTooltipWidget::setTeamColorFunc ( std::function< Color(const std::string &)>  func)

Definition at line 40 of file EntityTooltipWidget.cpp.

References _colorFunc.

Referenced by RaylibRenderer::_render2D(), and RaylibRenderer::handleInput().

+ Here is the caller graph for this function:

◆ setWorld()

void EntityTooltipWidget::setWorld ( const WorldState world)

Definition at line 39 of file EntityTooltipWidget.cpp.

References _world.

Referenced by RaylibRenderer::_render2D(), and RaylibRenderer::handleInput().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _btnHovered

bool EntityTooltipWidget::_btnHovered = false
mutableprivate

Definition at line 52 of file EntityTooltipWidget.hpp.

Referenced by handleInput(), and isFollowButtonHovered().

◆ _btnW

float EntityTooltipWidget::_btnW = BTN_W
mutableprivate

Definition at line 53 of file EntityTooltipWidget.hpp.

Referenced by _positionButton(), and _rebuild().

◆ _colorFunc

std::function<Color(const std::string&)> EntityTooltipWidget::_colorFunc
private

Definition at line 44 of file EntityTooltipWidget.hpp.

Referenced by _rebuild(), and setTeamColorFunc().

◆ _followActive

bool EntityTooltipWidget::_followActive = false
private

Definition at line 45 of file EntityTooltipWidget.hpp.

Referenced by handleInput(), and setFollowActive().

◆ _followBtn

ButtonWidget EntityTooltipWidget::_followBtn
mutableprivate

Definition at line 51 of file EntityTooltipWidget.hpp.

Referenced by _positionButton(), draw(), EntityTooltipWidget(), and handleInput().

◆ _pendingFollowId

int EntityTooltipWidget::_pendingFollowId = -1
private

Definition at line 47 of file EntityTooltipWidget.hpp.

Referenced by handleInput(), and popFollowRequest().

◆ _scaledFontSize

int EntityTooltipWidget::_scaledFontSize = 18
mutableprivate

Definition at line 48 of file EntityTooltipWidget.hpp.

Referenced by _positionButton(), and draw().

◆ _selection

SelectionFinder::Selection EntityTooltipWidget::_selection
private

Definition at line 43 of file EntityTooltipWidget.hpp.

Referenced by _isPlayerCase(), _rebuild(), draw(), handleInput(), and setSelection().

◆ _tooltip

TooltipWidget EntityTooltipWidget::_tooltip
mutableprivate

Definition at line 50 of file EntityTooltipWidget.hpp.

Referenced by _positionButton(), _rebuild(), draw(), and EntityTooltipWidget().

◆ _world

const WorldState* EntityTooltipWidget::_world = nullptr
private

Definition at line 42 of file EntityTooltipWidget.hpp.

Referenced by _isPlayerCase(), _rebuild(), and setWorld().

◆ BTN_H

constexpr float EntityTooltipWidget::BTN_H = 36.0f
staticconstexprprivate

Definition at line 56 of file EntityTooltipWidget.hpp.

Referenced by _positionButton(), _rebuild(), and EntityTooltipWidget().

◆ BTN_MARGIN

constexpr float EntityTooltipWidget::BTN_MARGIN = 10.0f
staticconstexprprivate

Definition at line 57 of file EntityTooltipWidget.hpp.

Referenced by _positionButton(), and _rebuild().

◆ BTN_W

constexpr float EntityTooltipWidget::BTN_W = 120.0f
staticconstexprprivate

Definition at line 55 of file EntityTooltipWidget.hpp.

Referenced by _positionButton(), and EntityTooltipWidget().


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