mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-10 20:33:58 -07:00
[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:
parent
0549892092
commit
bddf9bd818
17 changed files with 273 additions and 199 deletions
51
cockatrice/src/game/board/counter_state.h
Normal file
51
cockatrice/src/game/board/counter_state.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#ifndef COCKATRICE_COUNTER_STATE_H
|
||||
#define COCKATRICE_COUNTER_STATE_H
|
||||
|
||||
#include <QColor>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <libcockatrice/protocol/pb/serverinfo_counter.pb.h>
|
||||
|
||||
class CounterState : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CounterState(int id, const QString &name, const QColor &color, int radius, int value, QObject *parent = nullptr);
|
||||
|
||||
static CounterState *fromProto(const ServerInfo_Counter &counter, QObject *parent = nullptr);
|
||||
|
||||
int getId() const
|
||||
{
|
||||
return id;
|
||||
}
|
||||
QString getName() const
|
||||
{
|
||||
return name;
|
||||
}
|
||||
QColor getColor() const
|
||||
{
|
||||
return color;
|
||||
}
|
||||
int getRadius() const
|
||||
{
|
||||
return radius;
|
||||
}
|
||||
int getValue() const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
void setValue(int newValue);
|
||||
|
||||
signals:
|
||||
void valueChanged(int oldValue, int newValue);
|
||||
|
||||
private:
|
||||
int id;
|
||||
QString name;
|
||||
QColor color;
|
||||
int radius;
|
||||
int value;
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_COUNTER_STATE_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue