[Game][Counters] Split counters into AbstractCounter (graphics) and CounterState (logic) (#6917)

* [Counters] Split counters into graphics and logic states

Took 22 minutes

* Don't have widget hold pointer to state -> Copy what we need and subscribe to changes.

Took 12 minutes

Took 5 seconds

* Sync value too.

Took 3 minutes

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2026-05-21 20:16:28 +02:00 committed by GitHub
parent 0549892092
commit bddf9bd818
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 273 additions and 199 deletions

View file

@ -19,7 +19,7 @@ class PlayerCounter : public AbstractCounter
{
Q_OBJECT
public:
PlayerCounter(PlayerLogic *_player, int _id, const QString &_name, int _value, QGraphicsItem *parent = nullptr);
PlayerCounter(CounterState *state, PlayerLogic *player, QGraphicsItem *parent);
QRectF boundingRect() const override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
};
@ -48,7 +48,7 @@ public:
QRectF boundingRect() const override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
AbstractCounter *addCounter(int _counterId, const QString &_name, int _value);
AbstractCounter *addCounter(CounterState *state);
};
#endif