mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-10 20:13:24 -08:00
[Banner] Keep horizontal user banner crops inside the artwork (#7742)
This commit is contained in:
parent
d944273335
commit
e558c0dffa
7 changed files with 139 additions and 32 deletions
|
|
@ -12,7 +12,6 @@
|
|||
#include <QChar>
|
||||
#include <QMetaObject>
|
||||
#include <QPointer>
|
||||
#include <QRect>
|
||||
#include <QSize>
|
||||
#include <QStringList>
|
||||
#include <libcockatrice/card/database/card_database_manager.h>
|
||||
|
|
@ -66,27 +65,6 @@ void UserCardArtProvider::requestCardArt(const QString &userName, const QString
|
|||
processQueue();
|
||||
}
|
||||
|
||||
QPixmap UserCardArtProvider::cropCardArt(const QPixmap &fullRes, const ExactCard &card)
|
||||
{
|
||||
QPixmap source = fullRes;
|
||||
|
||||
// Sideways-layout cards (plane, siege/battle, split) store their landscape
|
||||
// artwork rotated 90° inside a portrait frame. Rotate it upright first so
|
||||
// the crop below lands on the horizontal art, mirroring the way
|
||||
// CardInfoPictureWidget displays these cards.
|
||||
const bool landscape = card.getInfo().getUiAttributes().landscapeOrientation;
|
||||
source = CardArtUtils::rotateSidewaysLayoutArt(source, card);
|
||||
|
||||
const QSize sz = source.size();
|
||||
const int marginX = sz.width() * 0.07;
|
||||
const int topMargin = landscape ? sz.height() * 0.05 : sz.height() * 0.11;
|
||||
const int bottomMargin = landscape ? sz.height() * 0.42 : sz.height() * 0.45;
|
||||
|
||||
const QRect artRect(marginX, topMargin, sz.width() - 2 * marginX, sz.height() - topMargin - bottomMargin);
|
||||
|
||||
return source.copy(artRect.intersected(source.rect()));
|
||||
}
|
||||
|
||||
void UserCardArtProvider::insertIntoCache(const QString &key, const QPixmap &pixmap)
|
||||
{
|
||||
if (pixmap.isNull()) {
|
||||
|
|
@ -134,7 +112,7 @@ void UserCardArtProvider::processQueue()
|
|||
|
||||
// Synchronous hit (already loaded/on disk)
|
||||
if (!fullRes.isNull()) {
|
||||
insertIntoCache(key, cropCardArt(fullRes, card));
|
||||
insertIntoCache(key, CardArtUtils::cropCardArt(fullRes, card));
|
||||
pending.remove(key);
|
||||
|
||||
emit cardArtUpdated(userName);
|
||||
|
|
@ -158,7 +136,7 @@ void UserCardArtProvider::processQueue()
|
|||
CardPictureLoader::getPixmap(fullRes, card, QSize(745, 1040));
|
||||
|
||||
if (!fullRes.isNull()) {
|
||||
self->insertIntoCache(key, self->cropCardArt(fullRes, card));
|
||||
self->insertIntoCache(key, CardArtUtils::cropCardArt(fullRes, card));
|
||||
}
|
||||
|
||||
self->pending.remove(key);
|
||||
|
|
@ -172,4 +150,4 @@ void UserCardArtProvider::processQueue()
|
|||
// Stop here. We'll continue when the async load finishes.
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@
|
|||
#include <QString>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
class ExactCard;
|
||||
|
||||
class UserCardArtProvider : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -21,7 +19,6 @@ public:
|
|||
|
||||
void requestCardArt(const QString &userName, const QString &cardName, const QString &providerId);
|
||||
const QMap<QString, QPixmap> &cache() const;
|
||||
static QPixmap cropCardArt(const QPixmap &fullRes, const ExactCard &card);
|
||||
|
||||
signals:
|
||||
void cardArtUpdated(const QString &userName);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "../../../card_picture_loader/card_picture_loader.h"
|
||||
#include "../../cards/art_crop_attribution.h"
|
||||
#include "../../cards/card_art_utils.h"
|
||||
#include "../../utility/completer_utils.h"
|
||||
#include "card_database_display_model.h"
|
||||
#include "card_database_model.h"
|
||||
|
|
@ -10,7 +11,6 @@
|
|||
#include "libcockatrice/card/printing/exact_card.h"
|
||||
#include "libcockatrice/card/printing/printing_info.h"
|
||||
#include "libcockatrice/card/set/card_set.h"
|
||||
#include "user_card_art_provider.h"
|
||||
#include "user_list_painter.h"
|
||||
|
||||
#include <QBrush>
|
||||
|
|
@ -580,7 +580,7 @@ void UserCardArtSettingsDialog::reloadPreview()
|
|||
return;
|
||||
}
|
||||
|
||||
currentPixmap = UserCardArtProvider::cropCardArt(fullRes, card);
|
||||
currentPixmap = CardArtUtils::cropCardArt(fullRes, card);
|
||||
preview->setPixmap(currentPixmap);
|
||||
preview->setParams(currentParams);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue