Cockatrice 2026-09-01-Development-3.1.0-beta.10
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
PlayerCounter Class Reference

#include <player_target.h>

Inheritance diagram for PlayerCounter:
[legend]
Collaboration diagram for PlayerCounter:
[legend]

Public Member Functions

 PlayerCounter (CounterState *state, PlayerLogic *player, QGraphicsItem *parent)
QRectF boundingRect () const override
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
bool animationEvent () override
 Advances the item's animation by one timer tick.
Public Member Functions inherited from AbstractCounter
 AbstractCounter (CounterState *state, PlayerLogic *player, bool shownInCounterArea, bool useNameForShortcut=false, QGraphicsItem *parent=nullptr)
 ~AbstractCounter () override
void retranslateUi () override
 Retranslate all user-visible strings. Called on language change.
void setShortcutsActive () override
 Bind keyboard shortcuts. Called when this player gains focus.
void setShortcutsInactive () override
 Unbind keyboard shortcuts. Called when this player loses focus.
void delCounter ()
QMenu * getMenu () const
int getId () const
QString getName () const
QColor getColor () const
int getRadius () const
int getValue () const
bool getShownInCounterArea () const
Public Member Functions inherited from AbstractPlayerComponent
virtual ~AbstractPlayerComponent ()=default
Public Member Functions inherited from IAnimatedItem
virtual ~IAnimatedItem ()=default

Protected Member Functions

void onValueChanged (int oldValue, int newValue) override
 Hook for subclasses that need per-value-change feedback (e.g. life-total flash).
Protected Member Functions inherited from AbstractCounter
void mousePressEvent (QGraphicsSceneMouseEvent *event) override
void hoverEnterEvent (QGraphicsSceneHoverEvent *event) override
void hoverLeaveEvent (QGraphicsSceneHoverEvent *event) override

Private Attributes

QElapsedTimer flashClock
qreal flashAlpha = 0.0
int flashDelta = 0

Static Private Attributes

static constexpr qreal flashDurationMs = 450.0

Additional Inherited Members

Protected Attributes inherited from AbstractCounter
PlayerLogicplayer
int id
QString name
int value
QColor color
int radius
bool hovered = false
bool useNameForShortcut

Constructor & Destructor Documentation

◆ PlayerCounter()

PlayerCounter::PlayerCounter ( CounterState * state,
PlayerLogic * player,
QGraphicsItem * parent )
Here is the call graph for this function:

Member Function Documentation

◆ animationEvent()

bool PlayerCounter::animationEvent ( )
overridevirtual

Advances the item's animation by one timer tick.

Returns
true while the animation is still running, false once it has finished.

Implements IAnimatedItem.

◆ boundingRect()

QRectF PlayerCounter::boundingRect ( ) const
override

◆ onValueChanged()

void PlayerCounter::onValueChanged ( int oldValue,
int newValue )
overrideprotectedvirtual

Hook for subclasses that need per-value-change feedback (e.g. life-total flash).

Called whenever the counter's value changes, before the item repaints.

Reimplemented from AbstractCounter.

Here is the call graph for this function:

◆ paint()

void PlayerCounter::paint ( QPainter * painter,
const QStyleOptionGraphicsItem * option,
QWidget * widget )
override

Member Data Documentation

◆ flashAlpha

qreal PlayerCounter::flashAlpha = 0.0
private

◆ flashClock

QElapsedTimer PlayerCounter::flashClock
private

◆ flashDelta

int PlayerCounter::flashDelta = 0
private

◆ flashDurationMs

qreal PlayerCounter::flashDurationMs = 450.0
staticconstexprprivate

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