mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-30 18:43:55 -07:00
set p/t, set annotation, multiple counters per card
This commit is contained in:
parent
7553251baf
commit
df7bcf179d
25 changed files with 891 additions and 385 deletions
|
|
@ -1,33 +1,45 @@
|
|||
#include "abstractgraphicsitem.h"
|
||||
#include <QPainter>
|
||||
|
||||
void AbstractGraphicsItem::paintNumberEllipse(int number, QPainter *painter)
|
||||
void AbstractGraphicsItem::paintNumberEllipse(int number, int fontSize, const QColor &color, int position, QPainter *painter)
|
||||
{
|
||||
painter->save();
|
||||
|
||||
QString numStr = QString::number(number);
|
||||
QFont font("Serif");
|
||||
font.setPixelSize(32);
|
||||
font.setPixelSize(fontSize);
|
||||
font.setWeight(QFont::Bold);
|
||||
|
||||
QFontMetrics fm(font);
|
||||
double w = fm.width(numStr) * 1.5;
|
||||
double h = fm.height() * 1.5;
|
||||
double w = fm.width(numStr) * 1.3;
|
||||
double h = fm.height() * 1.3;
|
||||
if (w < h)
|
||||
w = h;
|
||||
|
||||
painter->setPen(QColor(255, 255, 255, 0));
|
||||
QRadialGradient grad(QPointF(0.5, 0.5), 0.5);
|
||||
grad.setCoordinateMode(QGradient::ObjectBoundingMode);
|
||||
grad.setColorAt(0, QColor(255, 255, 255, 200));
|
||||
grad.setColorAt(0.7, QColor(255, 255, 255, 200));
|
||||
grad.setColorAt(1, QColor(255, 255, 255, 0));
|
||||
QColor color1(color), color2(color);
|
||||
color1.setAlpha(255);
|
||||
color2.setAlpha(0);
|
||||
grad.setColorAt(0, color1);
|
||||
grad.setColorAt(0.8, color1);
|
||||
grad.setColorAt(1, color2);
|
||||
painter->setBrush(QBrush(grad));
|
||||
painter->drawEllipse(QRectF((boundingRect().width() - w) / 2.0, (boundingRect().height() - h) / 2.0, w, h));
|
||||
|
||||
QRectF textRect;
|
||||
if (position == -1)
|
||||
textRect = QRectF((boundingRect().width() - w) / 2.0, (boundingRect().height() - h) / 2.0, w, h);
|
||||
else {
|
||||
qreal offset = boundingRect().width() / 20.0;
|
||||
textRect = QRectF(offset, offset * (position + 1) + h * position, w, h);
|
||||
}
|
||||
|
||||
painter->drawEllipse(textRect);
|
||||
|
||||
painter->setPen(Qt::black);
|
||||
painter->setFont(font);
|
||||
painter->drawText(boundingRect(), Qt::AlignCenter, numStr);
|
||||
painter->drawText(textRect, Qt::AlignCenter, numStr);
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
class AbstractGraphicsItem : public QGraphicsItem {
|
||||
protected:
|
||||
void paintNumberEllipse(int number, QPainter *painter);
|
||||
void paintNumberEllipse(int number, int radius, const QColor &color, int position, QPainter *painter);
|
||||
public:
|
||||
AbstractGraphicsItem(QGraphicsItem *parent = 0) : QGraphicsItem(parent) { }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#include "settingscache.h"
|
||||
|
||||
CardItem::CardItem(Player *_owner, const QString &_name, int _cardid, QGraphicsItem *parent)
|
||||
: AbstractCardItem(_name, parent), owner(_owner), id(_cardid), attacking(false), facedown(false), counters(0), doesntUntap(false), beingPointedAt(false), dragItem(NULL)
|
||||
: AbstractCardItem(_name, parent), owner(_owner), id(_cardid), attacking(false), facedown(false), doesntUntap(false), beingPointedAt(false), dragItem(NULL)
|
||||
{
|
||||
owner->addCard(this);
|
||||
}
|
||||
|
|
@ -26,8 +26,29 @@ void CardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||
{
|
||||
painter->save();
|
||||
AbstractCardItem::paint(painter, option, widget);
|
||||
if (counters)
|
||||
paintNumberEllipse(counters, painter);
|
||||
|
||||
int i = 0;
|
||||
QMapIterator<int, int> counterIterator(counters);
|
||||
while (counterIterator.hasNext()) {
|
||||
counterIterator.next();
|
||||
QColor color;
|
||||
color.setHsv(counterIterator.key() * 60, 150, 255);
|
||||
|
||||
paintNumberEllipse(counterIterator.value(), 14, color, i, painter);
|
||||
++i;
|
||||
}
|
||||
if (!pt.isEmpty()) {
|
||||
QFont font("Serif");
|
||||
font.setPixelSize(16);
|
||||
painter->setFont(font);
|
||||
QPen pen(Qt::white);
|
||||
QBrush brush(Qt::black);
|
||||
painter->setBackground(brush);
|
||||
painter->setBackgroundMode(Qt::OpaqueMode);
|
||||
painter->setPen(pen);
|
||||
|
||||
painter->drawText(QRectF(0, 0, boundingRect().width() - 5, boundingRect().height() - 5), Qt::AlignRight | Qt::AlignBottom, pt);
|
||||
}
|
||||
if (beingPointedAt)
|
||||
painter->fillRect(boundingRect(), QBrush(QColor(255, 0, 0, 100)));
|
||||
painter->restore();
|
||||
|
|
@ -47,15 +68,19 @@ void CardItem::setFaceDown(bool _facedown)
|
|||
update();
|
||||
}
|
||||
|
||||
void CardItem::setCounters(int _counters)
|
||||
void CardItem::setCounter(int _id, int _value)
|
||||
{
|
||||
counters = _counters;
|
||||
if (_value)
|
||||
counters.insert(_id, _value);
|
||||
else
|
||||
counters.remove(_id);
|
||||
update();
|
||||
}
|
||||
|
||||
void CardItem::setAnnotation(const QString &_annotation)
|
||||
{
|
||||
annotation = _annotation;
|
||||
setToolTip(annotation);
|
||||
update();
|
||||
}
|
||||
|
||||
|
|
@ -64,6 +89,12 @@ void CardItem::setDoesntUntap(bool _doesntUntap)
|
|||
doesntUntap = _doesntUntap;
|
||||
}
|
||||
|
||||
void CardItem::setPT(const QString &_pt)
|
||||
{
|
||||
pt = _pt;
|
||||
update();
|
||||
}
|
||||
|
||||
void CardItem::setBeingPointedAt(bool _beingPointedAt)
|
||||
{
|
||||
beingPointedAt = _beingPointedAt;
|
||||
|
|
@ -74,8 +105,9 @@ void CardItem::resetState()
|
|||
{
|
||||
attacking = false;
|
||||
facedown = false;
|
||||
counters = 0;
|
||||
annotation = QString();
|
||||
counters.clear();
|
||||
pt.clear();
|
||||
annotation.clear();
|
||||
setTapped(false);
|
||||
setDoesntUntap(false);
|
||||
update();
|
||||
|
|
@ -83,10 +115,15 @@ void CardItem::resetState()
|
|||
|
||||
void CardItem::processCardInfo(ServerInfo_Card *info)
|
||||
{
|
||||
counters.clear();
|
||||
const QList<ServerInfo_CardCounter *> &_counterList = info->getCounters();
|
||||
for (int i = 0; i < _counterList.size(); ++i)
|
||||
counters.insert(_counterList[i]->getId(), _counterList[i]->getValue());
|
||||
|
||||
setId(info->getId());
|
||||
setName(info->getName());
|
||||
setAttacking(info->getAttacking());
|
||||
setCounters(info->getCounters());
|
||||
setPT(info->getPT());
|
||||
setAnnotation(info->getAnnotation());
|
||||
setTapped(info->getTapped());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,8 +18,9 @@ private:
|
|||
int id;
|
||||
bool attacking;
|
||||
bool facedown;
|
||||
int counters;
|
||||
QMap<int, int> counters;
|
||||
QString annotation;
|
||||
QString pt;
|
||||
bool doesntUntap;
|
||||
QPoint gridPoint;
|
||||
bool beingPointedAt;
|
||||
|
|
@ -42,12 +43,14 @@ public:
|
|||
void setAttacking(bool _attacking);
|
||||
bool getFaceDown() const { return facedown; }
|
||||
void setFaceDown(bool _facedown);
|
||||
int getCounters() const { return counters; }
|
||||
void setCounters(int _counters);
|
||||
const QMap<int, int> &getCounters() const { return counters; }
|
||||
void setCounter(int _id, int _value);
|
||||
QString getAnnotation() const { return annotation; }
|
||||
void setAnnotation(const QString &_annotation);
|
||||
bool getDoesntUntap() const { return doesntUntap; }
|
||||
void setDoesntUntap(bool _doesntUntap);
|
||||
QString getPT() const { return pt; }
|
||||
void setPT(const QString &_pt);
|
||||
void setBeingPointedAt(bool _beingPointedAt);
|
||||
void resetState();
|
||||
void processCardInfo(ServerInfo_Card *info);
|
||||
|
|
|
|||
|
|
@ -34,5 +34,5 @@ QRectF HandCounter::boundingRect() const
|
|||
void HandCounter::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
|
||||
{
|
||||
painter->drawPixmap(handImage->rect(), *handImage, handImage->rect());
|
||||
paintNumberEllipse(number, painter);
|
||||
paintNumberEllipse(number, 24, Qt::white, -1, painter);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -218,14 +218,24 @@ void MessageLogWidget::logCreateArrow(Player *player, Player *startPlayer, QStri
|
|||
);
|
||||
}
|
||||
|
||||
void MessageLogWidget::logSetCardCounters(Player *player, QString cardName, int value, int oldValue)
|
||||
void MessageLogWidget::logSetCardCounter(Player *player, QString cardName, int counterId, int value, int oldValue)
|
||||
{
|
||||
QString finalStr;
|
||||
QString finalStr, colorStr;
|
||||
|
||||
int delta = abs(oldValue - value);
|
||||
if (value > oldValue)
|
||||
finalStr = tr("%1 places %2 counters on %3 (now %4).");
|
||||
finalStr = tr("%1 places %n counter(s) (%2) on %3 (now %4).", "", delta);
|
||||
else
|
||||
finalStr = tr("%1 removes %2 counters from %3 (now %4).");
|
||||
append(finalStr.arg(sanitizeHtml(player->getName())).arg(abs(oldValue - value)).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(cardName))).arg(value));
|
||||
finalStr = tr("%1 removes %n counter(s) (%2) from %3 (now %4).", "", delta);
|
||||
|
||||
switch (counterId) {
|
||||
case 0: colorStr = tr("red"); break;
|
||||
case 1: colorStr = tr("yellow"); break;
|
||||
case 2: colorStr = tr("green"); break;
|
||||
default: ;
|
||||
}
|
||||
|
||||
append(finalStr.arg(sanitizeHtml(player->getName())).arg(colorStr).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(cardName))).arg(value));
|
||||
}
|
||||
|
||||
void MessageLogWidget::logSetTapped(Player *player, QString cardName, bool tapped)
|
||||
|
|
@ -240,7 +250,7 @@ void MessageLogWidget::logSetTapped(Player *player, QString cardName, bool tappe
|
|||
|
||||
void MessageLogWidget::logSetCounter(Player *player, QString counterName, int value, int oldValue)
|
||||
{
|
||||
append(tr("%1 sets counter \"%2\" to %3 (%4%5).").arg(sanitizeHtml(player->getName())).arg(counterName).arg(value).arg(value > oldValue ? "+" : "").arg(value - oldValue));
|
||||
append(tr("%1 sets counter %2 to %3 (%4%5).").arg(sanitizeHtml(player->getName())).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(counterName))).arg(QString("<font color=\"blue\">%1</font>").arg(value)).arg(value > oldValue ? "+" : "").arg(value - oldValue));
|
||||
}
|
||||
|
||||
void MessageLogWidget::logSetDoesntUntap(Player *player, QString cardName, bool doesntUntap)
|
||||
|
|
@ -253,6 +263,16 @@ void MessageLogWidget::logSetDoesntUntap(Player *player, QString cardName, bool
|
|||
append(finalStr.arg(sanitizeHtml(player->getName())).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(cardName))));
|
||||
}
|
||||
|
||||
void MessageLogWidget::logSetPT(Player *player, QString cardName, QString newPT)
|
||||
{
|
||||
append(tr("%1 sets PT of %2 to %3.").arg(sanitizeHtml(player->getName())).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(cardName))).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(newPT))));
|
||||
}
|
||||
|
||||
void MessageLogWidget::logSetAnnotation(Player *player, QString cardName, QString newAnnotation)
|
||||
{
|
||||
append(tr("%1 sets annotation of %2 to %3.").arg(sanitizeHtml(player->getName())).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(cardName))).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(newAnnotation))));
|
||||
}
|
||||
|
||||
void MessageLogWidget::logDumpZone(Player *player, CardZone *zone, int numberCards)
|
||||
{
|
||||
if (numberCards != -1)
|
||||
|
|
@ -301,9 +321,11 @@ void MessageLogWidget::connectToPlayer(Player *player)
|
|||
connect(player, SIGNAL(logCreateArrow(Player *, Player *, QString, Player *, QString)), this, SLOT(logCreateArrow(Player *, Player *, QString, Player *, QString)));
|
||||
connect(player, SIGNAL(logCreateToken(Player *, QString)), this, SLOT(logCreateToken(Player *, QString)));
|
||||
connect(player, SIGNAL(logSetCounter(Player *, QString, int, int)), this, SLOT(logSetCounter(Player *, QString, int, int)));
|
||||
connect(player, SIGNAL(logSetCardCounters(Player *, QString, int, int)), this, SLOT(logSetCardCounters(Player *, QString, int, int)));
|
||||
connect(player, SIGNAL(logSetCardCounter(Player *, QString, int, int, int)), this, SLOT(logSetCardCounter(Player *, QString, int, int, int)));
|
||||
connect(player, SIGNAL(logSetTapped(Player *, QString, bool)), this, SLOT(logSetTapped(Player *, QString, bool)));
|
||||
connect(player, SIGNAL(logSetDoesntUntap(Player *, QString, bool)), this, SLOT(logSetDoesntUntap(Player *, QString, bool)));
|
||||
connect(player, SIGNAL(logSetPT(Player *, QString, QString)), this, SLOT(logSetPT(Player *, QString, QString)));
|
||||
connect(player, SIGNAL(logSetAnnotation(Player *, QString, QString)), this, SLOT(logSetAnnotation(Player *, QString, QString)));
|
||||
connect(player, SIGNAL(logMoveCard(Player *, QString, CardZone *, int, CardZone *, int)), this, SLOT(logMoveCard(Player *, QString, CardZone *, int, CardZone *, int)));
|
||||
connect(player, SIGNAL(logDumpZone(Player *, CardZone *, int)), this, SLOT(logDumpZone(Player *, CardZone *, int)));
|
||||
connect(player, SIGNAL(logStopDumpZone(Player *, CardZone *)), this, SLOT(logStopDumpZone(Player *, CardZone *)));
|
||||
|
|
|
|||
|
|
@ -41,10 +41,12 @@ public slots:
|
|||
void logMoveCard(Player *player, QString cardName, CardZone *startZone, int oldX, CardZone *targetZone, int newX);
|
||||
void logCreateToken(Player *player, QString cardName);
|
||||
void logCreateArrow(Player *player, Player *startPlayer, QString startCard, Player *targetPlayer, QString targetCard);
|
||||
void logSetCardCounters(Player *player, QString cardName, int value, int oldValue);
|
||||
void logSetCardCounter(Player *player, QString cardName, int counterId, int value, int oldValue);
|
||||
void logSetTapped(Player *player, QString cardName, bool tapped);
|
||||
void logSetCounter(Player *player, QString counterName, int value, int oldValue);
|
||||
void logSetDoesntUntap(Player *player, QString cardName, bool doesntUntap);
|
||||
void logSetPT(Player *player, QString cardName, QString newPT);
|
||||
void logSetAnnotation(Player *player, QString cardName, QString newAnnotation);
|
||||
void logDumpZone(Player *player, CardZone *zone, int numberCards);
|
||||
void logStopDumpZone(Player *player, CardZone *zone);
|
||||
void logSetActivePlayer(Player *player);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ void PileZone::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||
painter->restore();
|
||||
}
|
||||
|
||||
paintNumberEllipse(cards.size(), painter);
|
||||
paintNumberEllipse(cards.size(), 32, Qt::white, -1, painter);
|
||||
painter->drawRect(QRectF(0.5, 0.5, CARD_WIDTH - 1, CARD_HEIGHT - 1));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -198,26 +198,43 @@ Player::Player(const QString &_name, int _id, bool _local, Client *_client, TabG
|
|||
aTap = new QAction(this);
|
||||
aUntap = new QAction(this);
|
||||
aDoesntUntap = new QAction(this);
|
||||
aSetPT = new QAction(this);
|
||||
connect(aSetPT, SIGNAL(triggered()), this, SLOT(actSetPT()));
|
||||
aSetAnnotation = new QAction(this);
|
||||
connect(aSetAnnotation, SIGNAL(triggered()), this, SLOT(actSetAnnotation()));
|
||||
aFlip = new QAction(this);
|
||||
aAddCounter = new QAction(this);
|
||||
aRemoveCounter = new QAction(this);
|
||||
aSetCounters = new QAction(this);
|
||||
connect(aSetCounters, SIGNAL(triggered()), this, SLOT(actSetCounters()));
|
||||
aMoveToTopLibrary = new QAction(this);
|
||||
aMoveToBottomLibrary = new QAction(this);
|
||||
aMoveToGraveyard = new QAction(this);
|
||||
aMoveToExile = new QAction(this);
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
QMenu *menu = new QMenu;
|
||||
QAction *tempAddCounter = new QAction(this);
|
||||
QAction *tempRemoveCounter = new QAction(this);
|
||||
QAction *tempSetCounter = new QAction(this);
|
||||
menu->addAction(tempAddCounter);
|
||||
menu->addAction(tempRemoveCounter);
|
||||
menu->addAction(tempSetCounter);
|
||||
aAddCounter.append(tempAddCounter);
|
||||
aRemoveCounter.append(tempRemoveCounter);
|
||||
aSetCounter.append(tempSetCounter);
|
||||
connect(menu, SIGNAL(triggered(QAction *)), this, SLOT(actCardCounterTrigger(QAction *)));
|
||||
cardCounterMenus.append(menu);
|
||||
}
|
||||
|
||||
cardMenu = new QMenu;
|
||||
cardMenu->addAction(aTap);
|
||||
cardMenu->addAction(aUntap);
|
||||
cardMenu->addAction(aDoesntUntap);
|
||||
cardMenu->addSeparator();
|
||||
cardMenu->addAction(aSetPT);
|
||||
cardMenu->addAction(aSetAnnotation);
|
||||
cardMenu->addSeparator();
|
||||
cardMenu->addAction(aFlip);
|
||||
cardMenu->addSeparator();
|
||||
cardMenu->addAction(aAddCounter);
|
||||
cardMenu->addAction(aRemoveCounter);
|
||||
cardMenu->addAction(aSetCounters);
|
||||
for (int i = 0; i < cardCounterMenus.size(); ++i)
|
||||
cardMenu->addMenu(cardCounterMenus[i]);
|
||||
cardMenu->addSeparator();
|
||||
moveMenu = cardMenu->addMenu(QString());
|
||||
|
||||
|
|
@ -233,8 +250,6 @@ Player::Player(const QString &_name, int _id, bool _local, Client *_client, TabG
|
|||
cardMenuHandlers.insert(aUntap, &Player::actUntap);
|
||||
cardMenuHandlers.insert(aDoesntUntap, &Player::actDoesntUntap);
|
||||
cardMenuHandlers.insert(aFlip, &Player::actFlip);
|
||||
cardMenuHandlers.insert(aAddCounter, &Player::actAddCounter);
|
||||
cardMenuHandlers.insert(aRemoveCounter, &Player::actRemoveCounter);
|
||||
cardMenuHandlers.insert(aMoveToTopLibrary, &Player::actMoveToTopLibrary);
|
||||
cardMenuHandlers.insert(aMoveToBottomLibrary, &Player::actMoveToBottomLibrary);
|
||||
cardMenuHandlers.insert(aMoveToGraveyard, &Player::actMoveToGraveyard);
|
||||
|
|
@ -371,10 +386,18 @@ void Player::retranslateUi()
|
|||
aTap->setText(tr("&Tap"));
|
||||
aUntap->setText(tr("&Untap"));
|
||||
aDoesntUntap->setText(tr("Toggle &normal untapping"));
|
||||
aSetPT->setText(tr("Set &P/T..."));
|
||||
aSetAnnotation->setText(tr("&Set annotation..."));
|
||||
aFlip->setText(tr("&Flip"));
|
||||
aAddCounter->setText(tr("&Add counter"));
|
||||
aRemoveCounter->setText(tr("&Remove counter"));
|
||||
aSetCounters->setText(tr("&Set counters..."));
|
||||
cardCounterMenus[0]->setTitle(tr("Counters (red)"));
|
||||
cardCounterMenus[1]->setTitle(tr("Counters (yellow)"));
|
||||
cardCounterMenus[2]->setTitle(tr("Counters (green)"));
|
||||
for (int i = 0; i < aAddCounter.size(); ++i)
|
||||
aAddCounter[i]->setText(tr("&Add counter"));
|
||||
for (int i = 0; i < aRemoveCounter.size(); ++i)
|
||||
aRemoveCounter[i]->setText(tr("&Remove counter"));
|
||||
for (int i = 0; i < aSetCounter.size(); ++i)
|
||||
aSetCounter[i]->setText(tr("&Set counters..."));
|
||||
aMoveToTopLibrary->setText(tr("&top of library"));
|
||||
aMoveToBottomLibrary->setText(tr("&bottom of library"));
|
||||
aMoveToGraveyard->setText(tr("&graveyard"));
|
||||
|
|
@ -492,16 +515,16 @@ void Player::setCardAttrHelper(CardItem *card, const QString &aname, const QStri
|
|||
card->setAttacking(avalue == "1");
|
||||
else if (aname == "facedown")
|
||||
card->setFaceDown(avalue == "1");
|
||||
else if (aname == "counters") {
|
||||
int value = avalue.toInt();
|
||||
emit logSetCardCounters(this, card->getName(), value, card->getCounters());
|
||||
card->setCounters(value);
|
||||
} else if (aname == "annotation")
|
||||
else if (aname == "annotation") {
|
||||
emit logSetAnnotation(this, card->getName(), avalue);
|
||||
card->setAnnotation(avalue);
|
||||
else if (aname == "doesnt_untap") {
|
||||
} else if (aname == "doesnt_untap") {
|
||||
bool value = (avalue == "1");
|
||||
emit logSetDoesntUntap(this, card->getName(), value);
|
||||
card->setDoesntUntap(value);
|
||||
} else if (aname == "pt") {
|
||||
emit logSetPT(this, card->getName(), avalue);
|
||||
card->setPT(avalue);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -571,6 +594,21 @@ void Player::eventSetCardAttr(Event_SetCardAttr *event)
|
|||
}
|
||||
}
|
||||
|
||||
void Player::eventSetCardCounter(Event_SetCardCounter *event)
|
||||
{
|
||||
CardZone *zone = zones.value(event->getZone(), 0);
|
||||
if (!zone)
|
||||
return;
|
||||
|
||||
CardItem *card = zone->getCard(event->getCardId(), QString());
|
||||
if (!card)
|
||||
return;
|
||||
|
||||
int oldValue = card->getCounters().value(event->getCounterId(), 0);
|
||||
card->setCounter(event->getCounterId(), event->getCounterValue());
|
||||
emit logSetCardCounter(this, card->getName(), event->getCounterId(), event->getCounterValue(), oldValue);
|
||||
}
|
||||
|
||||
void Player::eventCreateCounters(Event_CreateCounters *event)
|
||||
{
|
||||
const QList<ServerInfo_Counter *> &eventCounterList = event->getCounterList();
|
||||
|
|
@ -696,6 +734,7 @@ void Player::processGameEvent(GameEvent *event, GameEventContext *context)
|
|||
case ItemId_Event_DeleteArrow: eventDeleteArrow(qobject_cast<Event_DeleteArrow *>(event)); break;
|
||||
case ItemId_Event_CreateToken: eventCreateToken(qobject_cast<Event_CreateToken *>(event)); break;
|
||||
case ItemId_Event_SetCardAttr: eventSetCardAttr(qobject_cast<Event_SetCardAttr *>(event)); break;
|
||||
case ItemId_Event_SetCardCounter: eventSetCardCounter(qobject_cast<Event_SetCardCounter *>(event)); break;
|
||||
case ItemId_Event_CreateCounters: eventCreateCounters(qobject_cast<Event_CreateCounters *>(event)); break;
|
||||
case ItemId_Event_SetCounter: eventSetCounter(qobject_cast<Event_SetCounter *>(event)); break;
|
||||
case ItemId_Event_DelCounter: eventDelCounter(qobject_cast<Event_DelCounter *>(event)); break;
|
||||
|
|
@ -944,35 +983,85 @@ void Player::actDoesntUntap(CardItem *card)
|
|||
sendGameCommand(new Command_SetCardAttr(-1, qgraphicsitem_cast<CardZone *>(card->parentItem())->getName(), card->getId(), "doesnt_untap", QString::number(!card->getDoesntUntap())));
|
||||
}
|
||||
|
||||
void Player::actSetPT()
|
||||
{
|
||||
QString oldPT;
|
||||
QListIterator<QGraphicsItem *> i(scene()->selectedItems());
|
||||
while (i.hasNext()) {
|
||||
CardItem *card = static_cast<CardItem *>(i.next());
|
||||
if (!card->getPT().isEmpty())
|
||||
oldPT = card->getPT();
|
||||
}
|
||||
bool ok;
|
||||
QString pt = QInputDialog::getText(0, tr("Set power/toughness"), tr("Please enter the new PT:"), QLineEdit::Normal, oldPT, &ok);
|
||||
if (!ok)
|
||||
return;
|
||||
|
||||
i.toFront();
|
||||
while (i.hasNext()) {
|
||||
CardItem *card = static_cast<CardItem *>(i.next());
|
||||
sendGameCommand(new Command_SetCardAttr(-1, qgraphicsitem_cast<CardZone *>(card->parentItem())->getName(), card->getId(), "pt", pt));
|
||||
}
|
||||
}
|
||||
|
||||
void Player::actSetAnnotation()
|
||||
{
|
||||
QString oldAnnotation;
|
||||
QListIterator<QGraphicsItem *> i(scene()->selectedItems());
|
||||
while (i.hasNext()) {
|
||||
CardItem *card = static_cast<CardItem *>(i.next());
|
||||
if (!card->getAnnotation().isEmpty())
|
||||
oldAnnotation = card->getAnnotation();
|
||||
}
|
||||
|
||||
bool ok;
|
||||
QString annotation = QInputDialog::getText(0, tr("Set annotation"), tr("Please enter the new annotation:"), QLineEdit::Normal, oldAnnotation, &ok);
|
||||
if (!ok)
|
||||
return;
|
||||
|
||||
i.toFront();
|
||||
while (i.hasNext()) {
|
||||
CardItem *card = static_cast<CardItem *>(i.next());
|
||||
sendGameCommand(new Command_SetCardAttr(-1, qgraphicsitem_cast<CardZone *>(card->parentItem())->getName(), card->getId(), "annotation", annotation));
|
||||
}
|
||||
}
|
||||
|
||||
void Player::actFlip(CardItem *card)
|
||||
{
|
||||
QString zone = qgraphicsitem_cast<CardZone *>(card->parentItem())->getName();
|
||||
sendGameCommand(new Command_MoveCard(-1, zone, card->getId(), zone, card->getGridPoint().x(), card->getGridPoint().y(), !card->getFaceDown()));
|
||||
}
|
||||
|
||||
void Player::actAddCounter(CardItem *card)
|
||||
void Player::actCardCounterTrigger(QAction *a)
|
||||
{
|
||||
if (card->getCounters() < MAX_COUNTERS_ON_CARD)
|
||||
sendGameCommand(new Command_SetCardAttr(-1, qgraphicsitem_cast<CardZone *>(card->parentItem())->getName(), card->getId(), "counters", QString::number(card->getCounters() + 1)));
|
||||
}
|
||||
|
||||
void Player::actRemoveCounter(CardItem *card)
|
||||
{
|
||||
if (card->getCounters())
|
||||
sendGameCommand(new Command_SetCardAttr(-1, qgraphicsitem_cast<CardZone *>(card->parentItem())->getName(), card->getId(), "counters", QString::number(card->getCounters() - 1)));
|
||||
}
|
||||
|
||||
void Player::actSetCounters()
|
||||
{
|
||||
bool ok;
|
||||
int number = QInputDialog::getInteger(0, tr("Set counters"), tr("Number:"), 0, 0, MAX_COUNTERS_ON_CARD, 1, &ok);
|
||||
if (!ok)
|
||||
return;
|
||||
|
||||
QListIterator<QGraphicsItem *> i(scene()->selectedItems());
|
||||
while (i.hasNext()) {
|
||||
CardItem *temp = (CardItem *) i.next();
|
||||
sendGameCommand(new Command_SetCardAttr(-1, qgraphicsitem_cast<CardZone *>(temp->parentItem())->getName(), temp->getId(), "counters", QString::number(number)));
|
||||
QMenu *menu = static_cast<QMenu *>(sender());
|
||||
int counterId = cardCounterMenus.indexOf(menu);
|
||||
|
||||
if (aAddCounter.contains(a)) {
|
||||
QListIterator<QGraphicsItem *> i(scene()->selectedItems());
|
||||
while (i.hasNext()) {
|
||||
CardItem *card = static_cast<CardItem *>(i.next());
|
||||
if (card->getCounters().value(counterId, 0) < MAX_COUNTERS_ON_CARD)
|
||||
sendGameCommand(new Command_SetCardCounter(-1, qgraphicsitem_cast<CardZone *>(card->parentItem())->getName(), card->getId(), counterId, card->getCounters().value(counterId, 0) + 1));
|
||||
}
|
||||
} else if (aRemoveCounter.contains(a)) {
|
||||
QListIterator<QGraphicsItem *> i(scene()->selectedItems());
|
||||
while (i.hasNext()) {
|
||||
CardItem *card = static_cast<CardItem *>(i.next());
|
||||
if (card->getCounters().value(counterId, 0))
|
||||
sendGameCommand(new Command_SetCardCounter(-1, qgraphicsitem_cast<CardZone *>(card->parentItem())->getName(), card->getId(), counterId, card->getCounters().value(counterId, 0) - 1));
|
||||
}
|
||||
} else if (aSetCounter.contains(a)) {
|
||||
bool ok;
|
||||
int number = QInputDialog::getInteger(0, tr("Set counters"), tr("Number:"), 0, 0, MAX_COUNTERS_ON_CARD, 1, &ok);
|
||||
if (!ok)
|
||||
return;
|
||||
|
||||
QListIterator<QGraphicsItem *> i(scene()->selectedItems());
|
||||
while (i.hasNext()) {
|
||||
CardItem *card = static_cast<CardItem *>(i.next());
|
||||
sendGameCommand(new Command_SetCardCounter(-1, qgraphicsitem_cast<CardZone *>(card->parentItem())->getName(), card->getId(), counterId, number));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ class Event_CreateArrows;
|
|||
class Event_DeleteArrow;
|
||||
class Event_CreateToken;
|
||||
class Event_SetCardAttr;
|
||||
class Event_SetCardCounter;
|
||||
class Event_CreateCounters;
|
||||
class Event_SetCounter;
|
||||
class Event_DelCounter;
|
||||
|
|
@ -51,10 +52,12 @@ signals:
|
|||
void logCreateToken(Player *player, QString cardName);
|
||||
void logDrawCards(Player *player, int number);
|
||||
void logMoveCard(Player *player, QString cardName, CardZone *startZone, int oldX, CardZone *targetZone, int newX);
|
||||
void logSetCardCounters(Player *player, QString cardName, int value, int oldValue);
|
||||
void logSetCardCounter(Player *player, QString cardName, int counterId, int value, int oldValue);
|
||||
void logSetTapped(Player *player, QString cardName, bool tapped);
|
||||
void logSetCounter(Player *player, QString counterName, int value, int oldValue);
|
||||
void logSetDoesntUntap(Player *player, QString cardName, bool doesntUntap);
|
||||
void logSetPT(Player *player, QString cardName, QString newPT);
|
||||
void logSetAnnotation(Player *player, QString cardName, QString newAnnotation);
|
||||
void logDumpZone(Player *player, CardZone *zone, int numberCards);
|
||||
void logStopDumpZone(Player *player, CardZone *zone);
|
||||
|
||||
|
|
@ -76,12 +79,17 @@ public slots:
|
|||
|
||||
void actSayMessage();
|
||||
private slots:
|
||||
void actSetPT();
|
||||
void actSetAnnotation();
|
||||
|
||||
void updateBgPixmap();
|
||||
void updateBoundingRect();
|
||||
void cardMenuAction();
|
||||
void actSetCounters();
|
||||
void actCardCounterTrigger(QAction *a);
|
||||
void rearrangeZones();
|
||||
private:
|
||||
QList<QMenu *> cardCounterMenus;
|
||||
QList<QAction *> aAddCounter, aSetCounter, aRemoveCounter;
|
||||
QMenu *playerMenu, *handMenu, *graveMenu, *rfgMenu, *libraryMenu, *sbMenu, *countersMenu, *sayMenu;
|
||||
QAction *aMoveHandToTopLibrary, *aMoveHandToBottomLibrary, *aMoveHandToGrave, *aMoveHandToRfg,
|
||||
*aMoveGraveToTopLibrary, *aMoveGraveToBottomLibrary, *aMoveGraveToHand, *aMoveGraveToRfg,
|
||||
|
|
@ -94,15 +102,13 @@ private:
|
|||
QHash<QAction *, CardMenuHandler> cardMenuHandlers;
|
||||
|
||||
QMenu *cardMenu, *moveMenu;
|
||||
QAction *aTap, *aUntap, *aDoesntUntap, *aFlip, *aAddCounter, *aRemoveCounter, *aSetCounters,
|
||||
QAction *aTap, *aUntap, *aDoesntUntap, *aSetPT, *aSetAnnotation, *aFlip,
|
||||
*aMoveToTopLibrary, *aMoveToBottomLibrary, *aMoveToGraveyard, *aMoveToExile;
|
||||
|
||||
void actTap(CardItem *card);
|
||||
void actUntap(CardItem *card);
|
||||
void actDoesntUntap(CardItem *card);
|
||||
void actFlip(CardItem *card);
|
||||
void actAddCounter(CardItem *card);
|
||||
void actRemoveCounter(CardItem *card);
|
||||
void actMoveToTopLibrary(CardItem *card);
|
||||
void actMoveToBottomLibrary(CardItem *card);
|
||||
void actMoveToGraveyard(CardItem *card);
|
||||
|
|
@ -137,6 +143,7 @@ private:
|
|||
void eventDeleteArrow(Event_DeleteArrow *event);
|
||||
void eventCreateToken(Event_CreateToken *event);
|
||||
void eventSetCardAttr(Event_SetCardAttr *event);
|
||||
void eventSetCardCounter(Event_SetCardCounter *event);
|
||||
void eventCreateCounters(Event_CreateCounters *event);
|
||||
void eventSetCounter(Event_SetCounter *event);
|
||||
void eventDelCounter(Event_DelCounter *event);
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ WndDeckEditor::WndDeckEditor(QWidget *parent)
|
|||
aLoadDeckFromClipboard = new QAction(tr("Load deck from cl&ipboard..."), this);
|
||||
connect(aLoadDeckFromClipboard, SIGNAL(triggered()), this, SLOT(actLoadDeckFromClipboard()));
|
||||
aLoadDeckFromClipboard->setShortcuts(QKeySequence::Paste);
|
||||
aSaveDeckToClipboard = new QAction(tr("Save deck to cl&ipboard"), this);
|
||||
aSaveDeckToClipboard = new QAction(tr("Save deck to clip&board"), this);
|
||||
connect(aSaveDeckToClipboard, SIGNAL(triggered()), this, SLOT(actSaveDeckToClipboard()));
|
||||
aSaveDeckToClipboard->setShortcuts(QKeySequence::Copy);
|
||||
aPrintDeck = new QAction(tr("&Print deck..."), this);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue