mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 08:34:52 -07:00
removed some unneeded code, counter appearance changed
This commit is contained in:
parent
a543c9b90c
commit
29699418d2
20 changed files with 293 additions and 242 deletions
|
|
@ -3,14 +3,16 @@
|
|||
#include "client.h"
|
||||
#include <QtGui>
|
||||
|
||||
Counter::Counter(Player *_player, const QString &_name, QColor _color, int _value, QGraphicsItem *parent)
|
||||
: QGraphicsItem(parent), name(_name), color(_color), value(_value), player(_player)
|
||||
Counter::Counter(Player *_player, int _id, const QString &_name, QColor _color, int _radius, int _value, QGraphicsItem *parent)
|
||||
: QGraphicsItem(parent), id(_id), name(_name), color(_color), radius(_radius), value(_value), player(_player)
|
||||
{
|
||||
if (radius > Player::counterAreaWidth / 2)
|
||||
radius = Player::counterAreaWidth / 2;
|
||||
}
|
||||
|
||||
QRectF Counter::boundingRect() const
|
||||
{
|
||||
return QRectF(0, 0, 40, 40);
|
||||
return QRectF(0, 0, radius * 2, radius * 2);
|
||||
}
|
||||
|
||||
void Counter::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
|
||||
|
|
@ -18,8 +20,8 @@ void Counter::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*
|
|||
painter->setBrush(QBrush(color));
|
||||
painter->drawEllipse(boundingRect());
|
||||
if (value) {
|
||||
QFont f("Times");
|
||||
f.setPixelSize(20);
|
||||
QFont f("Serif");
|
||||
f.setPixelSize(radius * 0.8);
|
||||
f.setWeight(QFont::Bold);
|
||||
painter->setFont(f);
|
||||
painter->drawText(boundingRect(), Qt::AlignCenter, QString::number(value));
|
||||
|
|
@ -35,7 +37,7 @@ void Counter::setValue(int _value)
|
|||
void Counter::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton)
|
||||
player->client->incCounter(name, 1);
|
||||
player->client->incCounter(id, 1);
|
||||
else if (event->button() == Qt::RightButton)
|
||||
player->client->incCounter(name, -1);
|
||||
player->client->incCounter(id, -1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue