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

Widget displaying players and allowing selection. More...

#include <PlayerPanel.hpp>

+ Inheritance diagram for PlayerPanel:
+ Collaboration diagram for PlayerPanel:

Public Member Functions

 PlayerPanel ()=default
 
 ~PlayerPanel () override=default
 
void setWorld (const WorldState *world)
 Sets the world state pointer.
 
void draw (int scaledFontSize) const override
 Draws the panel and player list.
 
bool handleInput () override
 Processes mouse clicks on player rows.
 
std::optional< SelectionFinder::SelectiongetPendingSelection ()
 Gets and clears any pending selection made by the user.
 
bool isOpen () const
 Checks if panel is currently open.
 
void setTeamColorFunc (std::function< Color(const std::string &)> func)
 Sets the team color resolution function.
 
- Public Member Functions inherited from IWidget
virtual ~IWidget ()=default
 

Private Attributes

const WorldState_world = nullptr
 
bool _isOpen = false
 
std::optional< SelectionFinder::Selection_pendingSelection = std::nullopt
 
std::function< Color(const std::string &)> _colorFunc
 
TooltipWidget _background
 
std::vector< ButtonWidget_playerButtons
 

Static Private Attributes

static constexpr int PANEL_WIDTH = 400
 
static constexpr int ROW_HEIGHT = 36
 

Detailed Description

Widget displaying players and allowing selection.

Definition at line 18 of file PlayerPanel.hpp.

Constructor & Destructor Documentation

◆ PlayerPanel()

PlayerPanel::PlayerPanel ( )
default

◆ ~PlayerPanel()

PlayerPanel::~PlayerPanel ( )
overridedefault

Member Function Documentation

◆ draw()

void PlayerPanel::draw ( int  scaledFontSize) const
overridevirtual

Draws the panel and player list.

Parameters
scaledFontSizeBase font size for UI scaling.

Implements IWidget.

Definition at line 78 of file PlayerPanel.cpp.

References _background, _isOpen, _playerButtons, _world, and TooltipWidget::draw().

Referenced by RaylibRenderer::_render2D().

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

◆ getPendingSelection()

std::optional< SelectionFinder::Selection > PlayerPanel::getPendingSelection ( )

Gets and clears any pending selection made by the user.

Returns
The pending selection, or nullopt if none.

Definition at line 71 of file PlayerPanel.cpp.

References _pendingSelection.

Referenced by RaylibRenderer::handleInput().

+ Here is the caller graph for this function:

◆ handleInput()

bool PlayerPanel::handleInput ( )
overridevirtual

Processes mouse clicks on player rows.

Returns
true if the widget consumed the input.

Implements IWidget.

Definition at line 9 of file PlayerPanel.cpp.

References _background, _colorFunc, _isOpen, _pendingSelection, _playerButtons, _world, TooltipWidget::addLine(), TooltipWidget::Center, TooltipWidget::clearLines(), I18n::get(), TooltipWidget::getLastBounds(), I18n::PANEL_LVL, I18n::PANEL_PLAYER_LIST, PANEL_WIDTH, SelectionFinder::Player, WorldState::players, ROW_HEIGHT, TooltipWidget::setAnchor(), ButtonWidget::setBorderThickness(), TooltipWidget::setExtraBottomPadding(), ButtonWidget::setLabel(), TooltipWidget::setMinWidth(), ButtonWidget::setOnClick(), ButtonWidget::setPosition(), ButtonWidget::setRoundness(), ButtonWidget::setSize(), and TooltipWidget::setTextAlign().

Referenced by RaylibRenderer::handleInput().

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

◆ isOpen()

bool PlayerPanel::isOpen ( ) const
inline

Checks if panel is currently open.

Returns
true if open.

Definition at line 41 of file PlayerPanel.hpp.

References _isOpen.

Referenced by RaylibRenderer::handleInput().

+ Here is the caller graph for this function:

◆ setTeamColorFunc()

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

Sets the team color resolution function.

Definition at line 44 of file PlayerPanel.hpp.

References _colorFunc.

Referenced by RaylibRenderer::_render2D().

+ Here is the caller graph for this function:

◆ setWorld()

void PlayerPanel::setWorld ( const WorldState world)

Sets the world state pointer.

Parameters
worldPointer to the current world state.

Definition at line 7 of file PlayerPanel.cpp.

References _world.

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

+ Here is the caller graph for this function:

Member Data Documentation

◆ _background

TooltipWidget PlayerPanel::_background
mutableprivate

Definition at line 55 of file PlayerPanel.hpp.

Referenced by draw(), and handleInput().

◆ _colorFunc

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

Definition at line 53 of file PlayerPanel.hpp.

Referenced by handleInput(), and setTeamColorFunc().

◆ _isOpen

bool PlayerPanel::_isOpen = false
private

Definition at line 51 of file PlayerPanel.hpp.

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

◆ _pendingSelection

std::optional<SelectionFinder::Selection> PlayerPanel::_pendingSelection = std::nullopt
private

Definition at line 52 of file PlayerPanel.hpp.

Referenced by getPendingSelection(), and handleInput().

◆ _playerButtons

std::vector<ButtonWidget> PlayerPanel::_playerButtons
mutableprivate

Definition at line 56 of file PlayerPanel.hpp.

Referenced by draw(), and handleInput().

◆ _world

const WorldState* PlayerPanel::_world = nullptr
private

Definition at line 50 of file PlayerPanel.hpp.

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

◆ PANEL_WIDTH

constexpr int PlayerPanel::PANEL_WIDTH = 400
staticconstexprprivate

Definition at line 58 of file PlayerPanel.hpp.

Referenced by handleInput().

◆ ROW_HEIGHT

constexpr int PlayerPanel::ROW_HEIGHT = 36
staticconstexprprivate

Definition at line 59 of file PlayerPanel.hpp.

Referenced by handleInput().


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