mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-12 00:54:53 -07:00
nice ellipses :)
This commit is contained in:
parent
7e13352a95
commit
175512a2ad
13 changed files with 144 additions and 101 deletions
|
|
@ -45,7 +45,7 @@ void CardZone::addCard(CardItem *card, bool reorganize, int x, int y)
|
|||
view->addCard(new CardItem(player->getDb(), card->getName(), card->getId()), reorganize, x, y);
|
||||
|
||||
addCardImpl(card, x, y);
|
||||
|
||||
|
||||
if (reorganize)
|
||||
reorganizeCards();
|
||||
}
|
||||
|
|
@ -67,9 +67,9 @@ CardItem *CardZone::takeCard(int position, int cardId, const QString &cardName)
|
|||
{
|
||||
if (position >= cards->size())
|
||||
return NULL;
|
||||
|
||||
|
||||
CardItem *c = cards->takeAt(position);
|
||||
|
||||
|
||||
if (view)
|
||||
view->removeCard(position);
|
||||
|
||||
|
|
@ -103,3 +103,26 @@ void CardZone::moveAllToZone(const QString &targetZone, int targetX)
|
|||
for (int i = cards->size() - 1; i >= 0; i--)
|
||||
player->client->moveCard(cards->at(i)->getId(), getName(), targetZone, targetX);
|
||||
}
|
||||
|
||||
void CardZone::paintCardNumberEllipse(QPainter *painter)
|
||||
{
|
||||
painter->save();
|
||||
|
||||
QString numStr = QString::number(cards->size());
|
||||
QFont font("Times", 32, QFont::Bold);
|
||||
QFontMetrics fm(font);
|
||||
QRect br = fm.boundingRect(numStr);
|
||||
double w = br.width() * 1.42;
|
||||
double h = br.height() * 1.42;
|
||||
if (w < h)
|
||||
w = h;
|
||||
|
||||
painter->setPen(QPen(QColor("black")));
|
||||
painter->setBrush(QColor(255, 255, 255, 150));
|
||||
painter->drawEllipse(QRectF((boundingRect().width() - w) / 2.0, (boundingRect().height() - h) / 2.0, w, h));
|
||||
|
||||
painter->setFont(font);
|
||||
painter->drawText(boundingRect(), Qt::AlignCenter, numStr);
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue