mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
- CardText's unset fallback is qApp->font() again: only the three counter painters (paintNumberEllipse, GeneralCounter, PlayerCounter) were Serif before the role existed, and they now ask for it through ThemeManager::cardTextFont(). Card names, player names, counters, the overlay, the Archidekt and EDHREC labels and the completer delegate keep the app font they used before. - Use setPixelSize for the EDHREC card name (20px) and commander name (28px) and details (16px) sizes: the stylesheets said px, and setPointSize made them about a third larger.
53 lines
1.6 KiB
C++
53 lines
1.6 KiB
C++
#include "counter_general.h"
|
|
|
|
#include "../../interface/pixel_map_generator.h"
|
|
#include "../../interface/theme_manager.h"
|
|
#include "abstract_graphics_item.h"
|
|
|
|
#include <QFont>
|
|
#include <QPainter>
|
|
#include <QPixmap>
|
|
#include <QPoint>
|
|
#include <QRectF>
|
|
#include <QSizeF>
|
|
#include <QString>
|
|
#include <QTransform>
|
|
#include <QtGlobal>
|
|
#include <qnamespace.h>
|
|
|
|
class CounterState;
|
|
class PlayerLogic;
|
|
class QGraphicsItem;
|
|
|
|
GeneralCounter::GeneralCounter(CounterState *state, PlayerLogic *player, bool useNameForShortcut, QGraphicsItem *parent)
|
|
: AbstractCounter(state, player, true, useNameForShortcut, parent)
|
|
{
|
|
setCacheMode(DeviceCoordinateCache);
|
|
}
|
|
|
|
QRectF GeneralCounter::boundingRect() const
|
|
{
|
|
return QRectF(0, 0, radius * 2, radius * 2);
|
|
}
|
|
|
|
void GeneralCounter::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
|
|
{
|
|
QRectF mapRect = painter->combinedTransform().mapRect(boundingRect());
|
|
int translatedHeight = mapRect.size().height();
|
|
qreal scaleFactor = translatedHeight / boundingRect().height();
|
|
QPixmap pixmap = CounterPixmapGenerator::generatePixmap(translatedHeight, name, hovered);
|
|
|
|
painter->save();
|
|
resetPainterTransform(painter);
|
|
painter->drawPixmap(QPoint(0, 0), pixmap);
|
|
|
|
if (value) {
|
|
QFont f = themeManager->cardTextFont();
|
|
f.setPixelSize(qMax((int)(radius * scaleFactor), 10));
|
|
f.setWeight(QFont::Bold);
|
|
painter->setPen(Qt::black);
|
|
painter->setFont(f);
|
|
painter->drawText(mapRect, Qt::AlignCenter, QString::number(value));
|
|
}
|
|
painter->restore();
|
|
}
|