Revert "Feature/continuumatrice product migration"

This commit is contained in:
Christian Daniel Jensen 2026-11-03 18:51:23 -07:00 • committed by GitHub
parent 533d2f04c1
commit e49d053838
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
150 changed files with 2599 additions and 5304 deletions

View file

@ -1,186 +0,0 @@
#include "essence_pool_item.h"
#include "../../interface/pixel_map_generator.h"
#include <QFont>
#include <QGraphicsSceneHoverEvent>
#include <QGraphicsSceneMouseEvent>
#include <QInputDialog>
#include <QPainter>
#include <QPen>
#include <QRectF>
#include <QSize>
#include <QWidget>
#include <libcockatrice/game/board/counter_state.h>
#include <libcockatrice/game/player/player_actions.h>
#include <libcockatrice/game/player/player_info.h>
#include <libcockatrice/game/player/player_logic.h>
#include <libcockatrice/utility/essence_counter.h>
#include <limits>
EssencePoolItem::EssencePoolItem(PlayerLogic *_player, QGraphicsItem *parent)
: QGraphicsObject(parent), player(_player)
{
setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton);
setAcceptHoverEvents(true);
setZValue(5);
connect(player, &PlayerLogic::counterAdded, this, &EssencePoolItem::attachCounter);
connect(player, &PlayerLogic::counterRemoved, this, &EssencePoolItem::detachCounter);
// Reconnect and late view construction must paint the full snapshot,
// even when the counterAdded events happened before this item existed.
for (CounterState *state : player->getCounters()) {
attachCounter(state);
}
setToolTip(tr("Essence pool — left click +1, right click -1, Shift+left to set"));
}
QRectF EssencePoolItem::boundingRect() const
{
return QRectF(0, 0, Width, Height);
}
void EssencePoolItem::attachCounter(CounterState *state)
{
if (!state) {
return;
}
const QChar code = EssenceCounter::codeFromName(state->getName());
if (code.isNull()) {
return;
}
counters.insert(code, state);
connect(state, &CounterState::valueChanged, this, [this](int, int, bool) { update(); });
update();
}
void EssencePoolItem::detachCounter(int id)
{
for (auto it = counters.begin(); it != counters.end();) {
if (it.value() && it.value()->getId() == id) {
it = counters.erase(it);
} else {
++it;
}
}
update();
}
CounterState *EssencePoolItem::stateFor(QChar code) const
{
return counters.value(code).data();
}
QChar EssencePoolItem::codeAt(const QPointF &position) const
{
const qreal x = position.x() - Padding;
const qreal y = position.y() - HeaderHeight;
if (x < 0 || y < 0 || x >= Columns * CellWidth || y >= 4 * CellHeight) {
return QChar();
}
const int col = static_cast<int>(x) / CellWidth;
const int row = static_cast<int>(y) / CellHeight;
const int index = row * Columns + col;
const QString &codes = EssenceCounter::symbols();
return index >= 0 && index < codes.size() ? codes.at(index) : QChar();
}
void EssencePoolItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
painter->save();
painter->setRenderHint(QPainter::Antialiasing, true);
painter->setPen(QPen(QColor(118, 125, 158), 1));
painter->setBrush(QColor(16, 19, 31, 232));
painter->drawRoundedRect(boundingRect().adjusted(0.5, 0.5, -0.5, -0.5), 7, 7);
QFont titleFont = painter->font();
titleFont.setBold(true);
titleFont.setPixelSize(15);
painter->setFont(titleFont);
painter->setPen(QColor(236, 238, 248));
painter->drawText(QRectF(8, 3, Width - 16, 24), Qt::AlignCenter, tr("ESSENCE POOL"));
QFont countFont = painter->font();
countFont.setBold(true);
countFont.setPixelSize(14);
painter->setFont(countFont);
const QString &codes = EssenceCounter::symbols();
for (int i = 0; i < codes.size(); ++i) {
const QChar code = codes.at(i);
const int col = i % Columns;
const int row = i / Columns;
const qreal x = Padding + col * CellWidth;
const qreal y = HeaderHeight + row * CellHeight;
const QRectF tile(x, y, CellWidth - 3, CellHeight - 3);
painter->setPen(QPen(QColor(85, 91, 119), 1));
painter->setBrush(QColor(43, 47, 67, 228));
painter->drawRoundedRect(tile, 5, 5);
const QPixmap icon = ManaSymbolPixmapGenerator::generatePixmap(QString(code), QSize(32, 32));
if (!icon.isNull()) {
painter->drawPixmap(QPointF(x + 9, y + 2), icon);
} else {
painter->setPen(Qt::white);
painter->drawText(QRectF(x, y + 2, CellWidth - 3, 30), Qt::AlignCenter, QString(code));
}
CounterState *state = stateFor(code);
const int count = state ? state->getValue() : 0;
painter->setPen(count > 0 ? QColor(255, 244, 191) : QColor(178, 182, 200));
painter->drawText(QRectF(x, y + 33, CellWidth - 3, 18),
Qt::AlignCenter, QString::number(count));
}
painter->restore();
}
void EssencePoolItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
const QChar code = codeAt(event->pos());
CounterState *state = stateFor(code);
if (!state || !player->getPlayerInfo()->getLocalOrJudge()) {
event->ignore();
return;
}
PlayerActions *actions = player->getPlayerActions();
if (event->button() == Qt::LeftButton && (event->modifiers() & Qt::ShiftModifier)) {
const QString label = code == QChar('N') ? tr("Colorless (N)") :
code == QChar('J') ? tr("Jasper (J)") : tr("Essence %1").arg(code);
bool accepted = false;
QWidget *parent = event->widget() ? event->widget()->window() : nullptr;
const int value = QInputDialog::getInt(parent, tr("Set Essence"),
tr("Available %1:").arg(label),
state->getValue(), 0, std::numeric_limits<int>::max(), 1, &accepted);
if (accepted) {
actions->actSetCounter(state->getId(), value);
}
} else if (event->button() == Qt::LeftButton) {
actions->actIncrementCounter(state->getId(), 1);
} else if (event->button() == Qt::RightButton) {
if (state->getValue() > 0) {
actions->actIncrementCounter(state->getId(), -1);
}
} else {
event->ignore();
return;
}
event->accept();
}
void EssencePoolItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
const QChar code = codeAt(event->pos());
CounterState *state = stateFor(code);
if (!state) {
setToolTip(tr("Essence pool — all types start at zero"));
return;
}
const QString name = code == QChar('N') ? tr("Colorless Essence") :
code == QChar('J') ? tr("Jasper Essence") : tr("Essence %1").arg(code);
setToolTip(tr("%1: %2 available\nLeft +1 | Right -1 | Shift+Left: Set")
.arg(name).arg(state->getValue()));
}

View file

@ -1,57 +0,0 @@
#ifndef CONTINUUMATRICE_ESSENCE_POOL_ITEM_H
#define CONTINUUMATRICE_ESSENCE_POOL_ITEM_H
#include <QGraphicsObject>
#include <QHash>
#include <QPointer>
class CounterState;
class PlayerLogic;
class QGraphicsSceneMouseEvent;
class QGraphicsSceneHoverEvent;
class QPainter;
class QStyleOptionGraphicsItem;
class QWidget;
/**
* An interactive, sixteen-type Essence resource pool attached to a player
* battlefield. All values are read from the existing server-owned CounterState
* objects; this graphics item does NOT own mutable match resource balances.
*
* Left click +1, right click -1, Shift+left to set an exact nonnegative amount.
* Only the owning player or a game judge can modify the pool.
*/
class EssencePoolItem final : public QGraphicsObject
{
Q_OBJECT
public:
static constexpr int Width = 224;
static constexpr int Height = 258;
explicit EssencePoolItem(PlayerLogic *player, QGraphicsItem *parent = nullptr);
QRectF boundingRect() const override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override;
private:
static constexpr int Columns = 4;
static constexpr int Padding = 8;
static constexpr int CellWidth = 52;
static constexpr int CellHeight = 54;
static constexpr int HeaderHeight = 29;
[[nodiscard]] QChar codeAt(const QPointF &position) const;
[[nodiscard]] CounterState *stateFor(QChar code) const;
void attachCounter(CounterState *state);
void detachCounter(int id);
PlayerLogic *player;
QHash<QChar, QPointer<CounterState>> counters;
};
#endif // CONTINUUMATRICE_ESSENCE_POOL_ITEM_H

View file

@ -20,7 +20,6 @@
#include "libcockatrice/utility/card_ref.h"
#include "menu/player_menu.h"
#include "player_area.h"
#include "essence_pool_item.h"
#include "player_dialogs.h"
#include "player_target.h"
@ -41,7 +40,6 @@
#include <libcockatrice/game/player/player_actions.h>
#include <libcockatrice/game/player/player_info.h>
#include <libcockatrice/game/player/player_logic.h>
#include <libcockatrice/utility/essence_counter.h>
#include <libcockatrice/game/zones/card_zone_logic.h>
#include <libcockatrice/game/zones/hand_zone_logic.h>
#include <libcockatrice/game/zones/pile_zone_logic.h>
@ -53,10 +51,7 @@
namespace
{
// Reserve a third, compact column for the synchronized 4x4 Essence pool.
// This keeps the 16 resource balances visible without obscuring the table.
constexpr qreal EXTRA_PILE_COLUMN_WIDTH =
CardDimensions::HEIGHT_F + 24 + EssencePoolItem::Width + 16;
constexpr qreal EXTRA_PILE_COLUMN_WIDTH = CardDimensions::HEIGHT_F + 24;
} // namespace
PlayerGraphicsItem::PlayerGraphicsItem(PlayerLogic *_player) : player(_player)
@ -108,13 +103,6 @@ PlayerGraphicsItem::PlayerGraphicsItem(PlayerLogic *_player) : player(_player)
initializeZones();
// Board-owned renderer only. All Essence balances live in player runtime
// CounterState and are sent/validated by the server.
essencePool = new EssencePoolItem(player, this);
const qreal essenceLeft = CardDimensions::HEIGHT_F + counterAreaWidth + 15 + 8 +
CardDimensions::HEIGHT_F + 14;
essencePool->setPos(essenceLeft, 14);
connect(player, &PlayerLogic::addViewCustomZoneActionToCustomZoneMenu, this,
&PlayerGraphicsItem::onCustomZoneAdded);
@ -322,11 +310,6 @@ void PlayerGraphicsItem::setMirrored(bool _mirrored)
void PlayerGraphicsItem::onCounterAdded(CounterState *state)
{
// The Essence pool owns its own compact 4x4 display. Never add sixteen
// full-size generic counters down the narrow life-counter column.
if (EssenceCounter::isEssenceCounter(state->getName())) {
return;
}
AbstractCounter *widget;
if (state->getName() == "life") {
widget = playerTarget->addCounter(state);

View file

@ -31,7 +31,6 @@ class TableZone;
class AbstractCounter;
class CardZone;
class CounterState;
class EssencePoolItem;
class PlayerArea;
class PlayerLogic;
struct CardRef;
@ -161,7 +160,6 @@ private:
PlayerDialogs *playerDialogs;
PlayerArea *playerArea;
PlayerTarget *playerTarget;
EssencePoolItem *essencePool = nullptr;
QMap<int, AbstractCounter *> counterWidgets;
QMap<QString, CardZone *> zoneGraphicsItems;
PileZone *deckZoneGraphicsItem;

View file

@ -251,11 +251,9 @@ void TableZone::paintBattlefieldRows(QPainter *painter)
*/
void TableZone::reloadBattlefieldAppearance()
{
// Canonical default battlefield palette. Theme battlefield.ini can override
// these with #RRGGBB (opaque) or #AARRGGBB (alpha) values.
frontZoneColor = QColor(QStringLiteral("#dc143c"));
supportZoneColor = QColor(QStringLiteral("#c3b091"));
commandZoneColor = QColor(QStringLiteral("#0a0e3f"));
frontZoneColor = QColor(142, 52, 61, 128);
supportZoneColor = QColor(40, 105, 129, 128);
commandZoneColor = QColor(94, 66, 140, 128);
const QString themePath = themeManager->getCurrentThemePath();
if (!themePath.isEmpty()) {