mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-27 16:32:20 -07:00
[Game] Playmats (#7101)
* [Game] Playmats Took 19 seconds Took 1 minute * [Playmats] Add fixed override and configurable fallbacks to settings. Took 29 minutes Took 43 seconds * Add main to test. Took 1 minute Took 29 seconds * Move settings to own group Took 11 minutes * Some attempts to refresh macOS compositor Took 2 minutes * Try something else Took 17 minutes * Don't manipulate live list Took 11 minutes * Change things about resolution, address comments. Took 45 minutes Took 12 minutes * Comments. Took 14 minutes Took 8 seconds * Re-order settings menu location Took 2 minutes * Rename PlaymatResolution to Info and add enums Took 8 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
74a454552a
commit
9eafd90a91
52 changed files with 1931 additions and 28 deletions
|
|
@ -31,8 +31,22 @@ QRectF StackZone::boundingRect() const
|
|||
|
||||
void StackZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
|
||||
{
|
||||
QBrush brush = themeManager->getExtraBgBrush(ThemeManager::Stack, getLogic()->getPlayer()->getZoneId());
|
||||
painter->fillRect(boundingRect(), brush);
|
||||
if (playmatActive) {
|
||||
// Subtle overlay to distinguish stack zone from table zone (slightly darker)
|
||||
painter->fillRect(boundingRect(), QColor(0, 0, 0, 80));
|
||||
} else {
|
||||
QBrush brush = themeManager->getExtraBgBrush(ThemeManager::Stack, getLogic()->getPlayer()->getZoneId());
|
||||
painter->fillRect(boundingRect(), brush);
|
||||
}
|
||||
}
|
||||
|
||||
void StackZone::onPlaymatChanged(bool active)
|
||||
{
|
||||
playmatActive = active;
|
||||
// See TableZone::onPlaymatChanged for the rationale. Translucent overlay
|
||||
// over a dynamic playmat should not be held in the device cache.
|
||||
setCacheMode(active ? QGraphicsItem::NoCache : QGraphicsItem::DeviceCoordinateCache);
|
||||
update();
|
||||
}
|
||||
|
||||
void StackZone::handleDropEvent(const QList<CardDragItem *> &dragItems,
|
||||
|
|
|
|||
|
|
@ -15,9 +15,13 @@ class StackZone : public SelectZone
|
|||
Q_OBJECT
|
||||
private:
|
||||
qreal zoneHeight;
|
||||
bool playmatActive = false;
|
||||
private slots:
|
||||
void updateBg();
|
||||
|
||||
public slots:
|
||||
void onPlaymatChanged(bool active);
|
||||
|
||||
public:
|
||||
StackZone(StackZoneLogic *_logic, int _zoneHeight, QGraphicsItem *parent);
|
||||
/** @brief Resizes the stack zone height, e.g. when sharing vertical space with the command zone. */
|
||||
|
|
|
|||
|
|
@ -92,14 +92,19 @@ bool TableZone::isInverted() const
|
|||
|
||||
void TableZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
|
||||
{
|
||||
QBrush brush = themeManager->getExtraBgBrush(ThemeManager::Table, getLogic()->getPlayer()->getZoneId());
|
||||
painter->fillRect(boundingRect(), brush);
|
||||
if (playmatActive) {
|
||||
// Subtle overlay to distinguish table zone from stack zone
|
||||
painter->fillRect(boundingRect(), QColor(0, 0, 0, 60));
|
||||
} else {
|
||||
QBrush brush = themeManager->getExtraBgBrush(ThemeManager::Table, getLogic()->getPlayer()->getZoneId());
|
||||
painter->fillRect(boundingRect(), brush);
|
||||
}
|
||||
|
||||
if (active) {
|
||||
paintZoneOutline(painter);
|
||||
} else {
|
||||
// inactive player gets a darker table zone with a semi transparent black mask
|
||||
// this means if the user provides a custom background it will fade
|
||||
// this means if the user provides a custom background or playmat it will fade
|
||||
painter->fillRect(boundingRect(), FADE_MASK);
|
||||
}
|
||||
|
||||
|
|
@ -113,6 +118,17 @@ void TableZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*opti
|
|||
paintLandDivider(painter);
|
||||
}
|
||||
|
||||
void TableZone::onPlaymatChanged(bool active)
|
||||
{
|
||||
playmatActive = active;
|
||||
// While a playmat is shown the zone paints a translucent overlay over the
|
||||
// dynamic playmat behind it. Keep it out of the device cache so the cached
|
||||
// pixels are never stale relative to the playmat (and to avoid compositing
|
||||
// artifacts of cached translucent content on some platforms).
|
||||
setCacheMode(active ? QGraphicsItem::NoCache : QGraphicsItem::DeviceCoordinateCache);
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
Render a soft outline around the edge of the TableZone.
|
||||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ private:
|
|||
*/
|
||||
bool active = false;
|
||||
bool mirrored = false;
|
||||
bool playmatActive = false;
|
||||
|
||||
[[nodiscard]] bool isInverted() const;
|
||||
|
||||
|
|
@ -95,6 +96,9 @@ private slots:
|
|||
*/
|
||||
void updateBg();
|
||||
|
||||
public slots:
|
||||
void onPlaymatChanged(bool active);
|
||||
|
||||
public slots:
|
||||
/**
|
||||
Reorganizes CardItems in the TableZone
|
||||
|
|
@ -184,8 +188,17 @@ public:
|
|||
}
|
||||
void setWidth(qreal _width)
|
||||
{
|
||||
// The width is stored as an int; truncate to match the previous implicit conversion.
|
||||
const int newWidth = static_cast<int>(_width);
|
||||
if (width == newWidth) {
|
||||
return;
|
||||
}
|
||||
prepareGeometryChange();
|
||||
width = _width;
|
||||
width = newWidth;
|
||||
// The parent player item's boundingRect (which clips the playmat painting) is
|
||||
// derived from this zone's size. Without this signal the playmat is cut off at
|
||||
// the stale boundingRect edge whenever the scene is resized wider.
|
||||
emit sizeChanged();
|
||||
}
|
||||
[[nodiscard]] qreal getWidth() const
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue