mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-15 11:38:49 -07:00
Click to hide revealed cards; MultiMove function
This commit is contained in:
parent
f07bb38e4a
commit
9c527fb5aa
28 changed files with 424 additions and 284 deletions
|
|
@ -72,17 +72,18 @@ void CardDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
QPointF sp = pos();
|
||||
sc->removeItem(this);
|
||||
|
||||
QList<CardDragItem *> dragItemList;
|
||||
CardZone *startZone = static_cast<CardItem *>(item)->getZone();
|
||||
if (currentZone && !(static_cast<CardItem *>(item)->getAttachedTo() && (startZone == currentZone))) {
|
||||
if (!occupied)
|
||||
currentZone->handleDropEvent(this, startZone, (sp - currentZone->scenePos()).toPoint(), faceDown);
|
||||
dragItemList.append(this);
|
||||
for (int i = 0; i < childDrags.size(); i++) {
|
||||
CardDragItem *c = static_cast<CardDragItem *>(childDrags[i]);
|
||||
if (!(static_cast<CardItem *>(c->item)->getAttachedTo() && (startZone == currentZone)) && !c->occupied)
|
||||
currentZone->handleDropEvent(static_cast<CardDragItem *>(c), startZone, (sp - currentZone->scenePos() + c->getHotSpot()).toPoint(), faceDown);
|
||||
dragItemList.append(c);
|
||||
sc->removeItem(c);
|
||||
}
|
||||
}
|
||||
currentZone->handleDropEvent(dragItemList, startZone, (sp - currentZone->scenePos()).toPoint(), faceDown);
|
||||
|
||||
event->accept();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@
|
|||
#include "settingscache.h"
|
||||
#include "tab_game.h"
|
||||
|
||||
CardItem::CardItem(Player *_owner, const QString &_name, int _cardid, QGraphicsItem *parent)
|
||||
: AbstractCardItem(_name, _owner, parent), zone(0), id(_cardid), attacking(false), facedown(false), destroyOnZoneChange(false), doesntUntap(false), dragItem(0), attachedTo(0)
|
||||
CardItem::CardItem(Player *_owner, const QString &_name, int _cardid, bool _revealedCard, QGraphicsItem *parent)
|
||||
: AbstractCardItem(_name, _owner, parent), zone(0), id(_cardid), revealedCard(_revealedCard), attacking(false), facedown(false), destroyOnZoneChange(false), doesntUntap(false), dragItem(0), attachedTo(0)
|
||||
{
|
||||
owner->addCard(this);
|
||||
|
||||
|
|
@ -59,6 +59,8 @@ CardItem::CardItem(Player *_owner, const QString &_name, int _cardid, QGraphicsI
|
|||
|
||||
aPlay = new QAction(this);
|
||||
connect(aPlay, SIGNAL(triggered()), this, SLOT(actPlay()));
|
||||
aHide = new QAction(this);
|
||||
connect(aHide, SIGNAL(triggered()), this, SLOT(actHide()));
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
QAction *tempAddCounter = new QAction(this);
|
||||
|
|
@ -128,7 +130,9 @@ void CardItem::updateCardMenu()
|
|||
{
|
||||
cardMenu->clear();
|
||||
|
||||
if (owner->getLocal()) {
|
||||
if (revealedCard)
|
||||
cardMenu->addAction(aHide);
|
||||
else if (owner->getLocal()) {
|
||||
if (zone) {
|
||||
if (zone->getName() == "table") {
|
||||
cardMenu->addAction(aTap);
|
||||
|
|
@ -169,6 +173,7 @@ void CardItem::updateCardMenu()
|
|||
void CardItem::retranslateUi()
|
||||
{
|
||||
aPlay->setText(tr("&Play"));
|
||||
aHide->setText(tr("&Hide"));
|
||||
|
||||
aTap->setText(tr("&Tap"));
|
||||
aUntap->setText(tr("&Untap"));
|
||||
|
|
@ -426,7 +431,10 @@ void CardItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
cardMenu->exec(event->screenPos());
|
||||
} else if ((event->button() == Qt::LeftButton) && !settingsCache->getDoubleClickToPlay()) {
|
||||
setCursor(Qt::OpenHandCursor);
|
||||
playCard(event->modifiers().testFlag(Qt::ShiftModifier));
|
||||
if (revealedCard)
|
||||
actHide();
|
||||
else
|
||||
playCard(event->modifiers().testFlag(Qt::ShiftModifier));
|
||||
}
|
||||
|
||||
AbstractCardItem::mouseReleaseEvent(event);
|
||||
|
|
@ -434,8 +442,12 @@ void CardItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
|
||||
void CardItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (settingsCache->getDoubleClickToPlay())
|
||||
playCard(event->modifiers().testFlag(Qt::ShiftModifier));
|
||||
if (settingsCache->getDoubleClickToPlay()) {
|
||||
if (revealedCard)
|
||||
actHide();
|
||||
else
|
||||
playCard(event->modifiers().testFlag(Qt::ShiftModifier));
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
|
||||
|
|
@ -483,4 +495,9 @@ void CardItem::actCardCounterTrigger()
|
|||
void CardItem::actPlay()
|
||||
{
|
||||
playCard(false);
|
||||
}
|
||||
|
||||
void CardItem::actHide()
|
||||
{
|
||||
zone->removeCard(this);
|
||||
}
|
||||
|
|
@ -17,6 +17,7 @@ class CardItem : public AbstractCardItem {
|
|||
private:
|
||||
CardZone *zone;
|
||||
int id;
|
||||
bool revealedCard;
|
||||
bool attacking;
|
||||
bool facedown;
|
||||
QMap<int, int> counters;
|
||||
|
|
@ -31,6 +32,7 @@ private:
|
|||
|
||||
QList<QAction *> aAddCounter, aSetCounter, aRemoveCounter;
|
||||
QAction *aPlay,
|
||||
*aHide,
|
||||
*aTap, *aUntap, *aDoesntUntap, *aAttach, *aUnattach, *aSetPT, *aSetAnnotation, *aFlip, *aClone,
|
||||
*aMoveToTopLibrary, *aMoveToBottomLibrary, *aMoveToGraveyard, *aMoveToExile;
|
||||
QMenu *cardMenu, *moveMenu;
|
||||
|
|
@ -45,12 +47,13 @@ private slots:
|
|||
void actSetPT();
|
||||
void actSetAnnotation();
|
||||
void actPlay();
|
||||
void actHide();
|
||||
public slots:
|
||||
void deleteLater();
|
||||
public:
|
||||
enum { Type = typeCard };
|
||||
int type() const { return Type; }
|
||||
CardItem(Player *_owner, const QString &_name = QString(), int _cardid = -1, QGraphicsItem *parent = 0);
|
||||
CardItem(Player *_owner, const QString &_name = QString(), int _cardid = -1, bool revealedCard = false, QGraphicsItem *parent = 0);
|
||||
~CardItem();
|
||||
void retranslateUi();
|
||||
CardZone *getZone() const { return zone; }
|
||||
|
|
|
|||
|
|
@ -157,16 +157,25 @@ CardItem *CardZone::takeCard(int position, int cardId, bool /*canResize*/)
|
|||
return c;
|
||||
}
|
||||
|
||||
void CardZone::removeCard(CardItem *card)
|
||||
{
|
||||
cards.removeAt(cards.indexOf(card));
|
||||
reorganizeCards();
|
||||
emit cardCountChanged();
|
||||
player->deleteCard(card);
|
||||
}
|
||||
|
||||
void CardZone::moveAllToZone()
|
||||
{
|
||||
QList<QVariant> data = static_cast<QAction *>(sender())->data().toList();
|
||||
QString targetZone = data[0].toString();
|
||||
int targetX = data[1].toInt();
|
||||
|
||||
// Cards need to be moved in reverse order so that the other
|
||||
// cards' list index doesn't change
|
||||
for (int i = cards.size() - 1; i >= 0; i--)
|
||||
player->sendGameCommand(new Command_MoveCard(-1, getName(), cards.at(i)->getId(), player->getId(), targetZone, targetX));
|
||||
QList<CardId *> idList;
|
||||
for (int i = 0; i < cards.size(); ++i)
|
||||
idList.append(new CardId(cards[i]->getId()));
|
||||
|
||||
player->sendGameCommand(new Command_MoveCard(-1, getName(), idList, player->getId(), targetZone, targetX));
|
||||
}
|
||||
|
||||
QPointF CardZone::closestGridPoint(const QPointF &point)
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public slots:
|
|||
public:
|
||||
enum { Type = typeZone };
|
||||
int type() const { return Type; }
|
||||
virtual void handleDropEvent(CardDragItem *dragItem, CardZone *startZone, const QPoint &dropPoint, bool faceDown) = 0;
|
||||
virtual void handleDropEvent(const QList<CardDragItem *> &dragItem, CardZone *startZone, const QPoint &dropPoint, bool faceDown) = 0;
|
||||
CardZone(Player *_player, const QString &_name, bool _hasCardAttr, bool _isShufflable, bool _contentsKnown, QGraphicsItem *parent = 0, bool isView = false);
|
||||
~CardZone();
|
||||
void retranslateUi();
|
||||
|
|
@ -54,6 +54,7 @@ public:
|
|||
CardItem *getCard(int cardId, const QString &cardName);
|
||||
// takeCard() finds a card by position and removes it from the zone and from all of its views.
|
||||
virtual CardItem *takeCard(int position, int cardId, bool canResize = true);
|
||||
void removeCard(CardItem *card);
|
||||
ZoneViewZone *getView() const { return view; }
|
||||
void setView(ZoneViewZone *_view) { view = _view; }
|
||||
virtual void reorganizeCards() = 0;
|
||||
|
|
|
|||
|
|
@ -37,9 +37,13 @@ void HandZone::addCardImpl(CardItem *card, int x, int /*y*/)
|
|||
card->update();
|
||||
}
|
||||
|
||||
void HandZone::handleDropEvent(CardDragItem *dragItem, CardZone *startZone, const QPoint &/*dropPoint*/, bool /*faceDown*/)
|
||||
void HandZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &/*dropPoint*/, bool /*faceDown*/)
|
||||
{
|
||||
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), dragItem->getId(), player->getId(), getName(), cards.size(), -1, false));
|
||||
QList<CardId *> idList;
|
||||
for (int i = 0; i < dragItems.size(); ++i)
|
||||
idList.append(new CardId(dragItems[i]->getId()));
|
||||
|
||||
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), cards.size(), -1, false));
|
||||
}
|
||||
|
||||
QRectF HandZone::boundingRect() const
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public slots:
|
|||
void updateOrientation();
|
||||
public:
|
||||
HandZone(Player *_p, bool _contentsKnown, int _zoneHeight, QGraphicsItem *parent = 0);
|
||||
void handleDropEvent(CardDragItem *dragItem, CardZone *startZone, const QPoint &dropPoint, bool faceDown);
|
||||
void handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &dropPoint, bool faceDown);
|
||||
QRectF boundingRect() const;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
void reorganizeCards();
|
||||
|
|
|
|||
|
|
@ -48,9 +48,13 @@ void PileZone::addCardImpl(CardItem *card, int x, int /*y*/)
|
|||
card->setParentItem(this);
|
||||
}
|
||||
|
||||
void PileZone::handleDropEvent(CardDragItem *dragItem, CardZone *startZone, const QPoint &/*dropPoint*/, bool /*faceDown*/)
|
||||
void PileZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &/*dropPoint*/, bool /*faceDown*/)
|
||||
{
|
||||
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), dragItem->getId(), player->getId(), getName(), 0, 0, false));
|
||||
QList<CardId *> idList;
|
||||
for (int i = 0; i < dragItems.size(); ++i)
|
||||
idList.append(new CardId(dragItems[i]->getId()));
|
||||
|
||||
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), 0, 0, false));
|
||||
}
|
||||
|
||||
void PileZone::reorganizeCards()
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ public:
|
|||
QRectF boundingRect() const;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
void reorganizeCards();
|
||||
void handleDropEvent(CardDragItem *dragItem, CardZone *startZone, const QPoint &dropPoint, bool faceDown);
|
||||
void handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &dropPoint, bool faceDown);
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||||
|
|
|
|||
|
|
@ -563,9 +563,10 @@ void Player::actMoveTopCardsToGrave()
|
|||
const int maxCards = zones.value("deck")->getCards().size();
|
||||
if (number > maxCards)
|
||||
number = maxCards;
|
||||
QList<CardId *> idList;
|
||||
for (int i = 0; i < number; ++i)
|
||||
commandList.append(new Command_MoveCard(-1, "deck", 0, getId(), "grave", 0, 0, false));
|
||||
sendCommandContainer(new CommandContainer(commandList));
|
||||
idList.append(new CardId(i));
|
||||
sendGameCommand(new Command_MoveCard(-1, "deck", idList, getId(), "grave", 0, 0, false));
|
||||
}
|
||||
|
||||
void Player::actMoveTopCardsToExile()
|
||||
|
|
@ -578,14 +579,15 @@ void Player::actMoveTopCardsToExile()
|
|||
const int maxCards = zones.value("deck")->getCards().size();
|
||||
if (number > maxCards)
|
||||
number = maxCards;
|
||||
QList<CardId *> idList;
|
||||
for (int i = 0; i < number; ++i)
|
||||
commandList.append(new Command_MoveCard(-1, "deck", 0, getId(), "rfg", 0, 0, false));
|
||||
sendCommandContainer(new CommandContainer(commandList));
|
||||
idList.append(new CardId(i));
|
||||
sendGameCommand(new Command_MoveCard(-1, "deck", idList, getId(), "rfg", 0, 0, false));
|
||||
}
|
||||
|
||||
void Player::actMoveTopCardToBottom()
|
||||
{
|
||||
sendGameCommand(new Command_MoveCard(-1, "deck", 0, getId(), "deck", -1, 0, false));
|
||||
sendGameCommand(new Command_MoveCard(-1, "deck", QList<CardId *>() << new CardId(0), getId(), "deck", -1, 0, false));
|
||||
}
|
||||
|
||||
void Player::actUntapAll()
|
||||
|
|
@ -1088,10 +1090,10 @@ void Player::playCard(CardItem *c, bool faceDown, bool tapped)
|
|||
{
|
||||
CardInfo *ci = c->getInfo();
|
||||
if (ci->getTableRow() == 3)
|
||||
sendGameCommand(new Command_MoveCard(-1, c->getZone()->getName(), c->getId(), getId(), "stack", 0, 0, false));
|
||||
sendGameCommand(new Command_MoveCard(-1, c->getZone()->getName(), QList<CardId *>() << new CardId(c->getId()), getId(), "stack", 0, 0, false));
|
||||
else {
|
||||
QPoint gridPoint = QPoint(-1, 2 - ci->getTableRow());
|
||||
sendGameCommand(new Command_MoveCard(-1, c->getZone()->getName(), c->getId(), getId(), "table", gridPoint.x(), gridPoint.y(), faceDown, tapped));
|
||||
sendGameCommand(new Command_MoveCard(-1, c->getZone()->getName(), QList<CardId *>() << new CardId(c->getId()), getId(), "table", gridPoint.x(), gridPoint.y(), faceDown, tapped));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1276,42 +1278,54 @@ bool Player::clearCardsToDelete()
|
|||
void Player::cardMenuAction(QAction *a)
|
||||
{
|
||||
QList<QGraphicsItem *> sel = scene()->selectedItems();
|
||||
QList<CardItem *> cardList;
|
||||
while (!sel.isEmpty())
|
||||
cardList.append(qgraphicsitem_cast<CardItem *>(sel.takeFirst()));
|
||||
|
||||
QList<Command *> commandList;
|
||||
while (!sel.isEmpty()) {
|
||||
unsigned int i = (unsigned int) (((double) sel.size()) * qrand() / (RAND_MAX + 1.0));
|
||||
CardItem *card = qgraphicsitem_cast<CardItem *>(sel.takeAt(i));
|
||||
|
||||
switch (a->data().toInt()) {
|
||||
case 0:
|
||||
if (!card->getTapped())
|
||||
commandList.append(new Command_SetCardAttr(-1, card->getZone()->getName(), card->getId(), "tapped", "1"));
|
||||
break;
|
||||
case 1:
|
||||
if (card->getTapped())
|
||||
commandList.append(new Command_SetCardAttr(-1, card->getZone()->getName(), card->getId(), "tapped", "0"));
|
||||
break;
|
||||
case 2:
|
||||
commandList.append(new Command_SetCardAttr(-1, card->getZone()->getName(), card->getId(), "doesnt_untap", QString::number(!card->getDoesntUntap())));
|
||||
break;
|
||||
case 3: {
|
||||
QString zone = card->getZone()->getName();
|
||||
commandList.append(new Command_FlipCard(-1, zone, card->getId(), !card->getFaceDown()));
|
||||
break;
|
||||
if (a->data().toInt() <= 4)
|
||||
for (int i = 0; i < cardList.size(); ++i) {
|
||||
CardItem *card = cardList[i];
|
||||
switch (a->data().toInt()) {
|
||||
case 0:
|
||||
if (!card->getTapped())
|
||||
commandList.append(new Command_SetCardAttr(-1, card->getZone()->getName(), card->getId(), "tapped", "1"));
|
||||
break;
|
||||
case 1:
|
||||
if (card->getTapped())
|
||||
commandList.append(new Command_SetCardAttr(-1, card->getZone()->getName(), card->getId(), "tapped", "0"));
|
||||
break;
|
||||
case 2:
|
||||
commandList.append(new Command_SetCardAttr(-1, card->getZone()->getName(), card->getId(), "doesnt_untap", QString::number(!card->getDoesntUntap())));
|
||||
break;
|
||||
case 3: {
|
||||
QString zone = card->getZone()->getName();
|
||||
commandList.append(new Command_FlipCard(-1, zone, card->getId(), !card->getFaceDown()));
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
commandList.append(new Command_CreateToken(-1, card->getZone()->getName(), card->getName(), card->getColor(), card->getPT(), card->getAnnotation(), true, -1, card->getGridPoint().y()));
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
commandList.append(new Command_CreateToken(-1, card->getZone()->getName(), card->getName(), card->getColor(), card->getPT(), card->getAnnotation(), true, -1, card->getGridPoint().y()));
|
||||
break;
|
||||
}
|
||||
else {
|
||||
QList<CardId *> idList;
|
||||
for (int i = 0; i < cardList.size(); ++i)
|
||||
idList.append(new CardId(cardList[i]->getId()));
|
||||
QString startZone = cardList[0]->getZone()->getName();
|
||||
|
||||
switch (a->data().toInt()) {
|
||||
case 5:
|
||||
commandList.append(new Command_MoveCard(-1, card->getZone()->getName(), card->getId(), getId(), "deck", 0, 0, false));
|
||||
commandList.append(new Command_MoveCard(-1, startZone, idList, getId(), "deck", 0, 0, false));
|
||||
break;
|
||||
case 6:
|
||||
commandList.append(new Command_MoveCard(-1, card->getZone()->getName(), card->getId(), getId(), "deck", -1, 0, false));
|
||||
commandList.append(new Command_MoveCard(-1, startZone, idList, getId(), "deck", -1, 0, false));
|
||||
break;
|
||||
case 7:
|
||||
commandList.append(new Command_MoveCard(-1, card->getZone()->getName(), card->getId(), getId(), "grave", 0, 0, false));
|
||||
commandList.append(new Command_MoveCard(-1, startZone, idList, getId(), "grave", 0, 0, false));
|
||||
break;
|
||||
case 8:
|
||||
commandList.append(new Command_MoveCard(-1, card->getZone()->getName(), card->getId(), getId(), "rfg", 0, 0, false));
|
||||
commandList.append(new Command_MoveCard(-1, startZone, idList, getId(), "rfg", 0, 0, false));
|
||||
break;
|
||||
default: ;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,11 +52,16 @@ void StackZone::paint(QPainter *painter, const QStyleOptionGraphicsItem */*optio
|
|||
painter->fillRect(boundingRect(), QBrush(bgPixmap));
|
||||
}
|
||||
|
||||
void StackZone::handleDropEvent(CardDragItem *dragItem, CardZone *startZone, const QPoint &/*dropPoint*/, bool /*faceDown*/)
|
||||
void StackZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &/*dropPoint*/, bool /*faceDown*/)
|
||||
{
|
||||
if (startZone == this)
|
||||
return;
|
||||
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), dragItem->getId(), player->getId(), getName(), 0, 0, false));
|
||||
|
||||
QList<CardId *> idList;
|
||||
for (int i = 0; i < dragItems.size(); ++i)
|
||||
idList.append(new CardId(dragItems[i]->getId()));
|
||||
|
||||
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), 0, 0, false));
|
||||
}
|
||||
|
||||
void StackZone::reorganizeCards()
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ private slots:
|
|||
void updateBgPixmap();
|
||||
public:
|
||||
StackZone(Player *_p, int _zoneHeight, QGraphicsItem *parent = 0);
|
||||
void handleDropEvent(CardDragItem *dragItem, CardZone *startZone, const QPoint &dropPoint, bool faceDown);
|
||||
void handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &dropPoint, bool faceDown);
|
||||
QRectF boundingRect() const;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
void reorganizeCards();
|
||||
|
|
|
|||
|
|
@ -85,14 +85,18 @@ void TableZone::addCardImpl(CardItem *card, int _x, int _y)
|
|||
card->update();
|
||||
}
|
||||
|
||||
void TableZone::handleDropEvent(CardDragItem *dragItem, CardZone *startZone, const QPoint &dropPoint, bool faceDown)
|
||||
void TableZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &dropPoint, bool faceDown)
|
||||
{
|
||||
handleDropEventByGrid(dragItem, startZone, mapToGrid(dropPoint), faceDown);
|
||||
handleDropEventByGrid(dragItems, startZone, mapToGrid(dropPoint), faceDown);
|
||||
}
|
||||
|
||||
void TableZone::handleDropEventByGrid(CardDragItem *dragItem, CardZone *startZone, const QPoint &gridPoint, bool faceDown, bool tapped)
|
||||
void TableZone::handleDropEventByGrid(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &gridPoint, bool faceDown, bool tapped)
|
||||
{
|
||||
static_cast<CardItem *>(dragItem->getItem())->getZone()->getPlayer()->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), dragItem->getId(), player->getId(), getName(), gridPoint.x(), gridPoint.y(), faceDown, tapped));
|
||||
QList<CardId *> idList;
|
||||
for (int i = 0; i < dragItems.size(); ++i)
|
||||
idList.append(new CardId(dragItems[i]->getId()));
|
||||
|
||||
startZone->getPlayer()->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), gridPoint.x(), gridPoint.y(), faceDown, tapped));
|
||||
}
|
||||
|
||||
void TableZone::reorganizeCards()
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ public:
|
|||
QRectF boundingRect() const;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
void toggleTapped();
|
||||
void handleDropEvent(CardDragItem *dragItem, CardZone *startZone, const QPoint &dropPoint, bool faceDown = false);
|
||||
void handleDropEventByGrid(CardDragItem *dragItem, CardZone *startZone, const QPoint &gridPoint, bool faceDown = false, bool tapped = false);
|
||||
void handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &dropPoint, bool faceDown = false);
|
||||
void handleDropEventByGrid(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &gridPoint, bool faceDown = false, bool tapped = false);
|
||||
CardItem *getCardFromGrid(const QPoint &gridPoint) const;
|
||||
CardItem *getCardFromCoords(const QPointF &point) const;
|
||||
QPointF mapFromGrid(QPoint gridPoint) const;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ void ZoneViewZone::initializeCards(const QList<ServerInfo_Card *> &cardList)
|
|||
{
|
||||
if (!cardList.isEmpty()) {
|
||||
for (int i = 0; i < cardList.size(); ++i)
|
||||
addCard(new CardItem(player, cardList[i]->getName(), cardList[i]->getId(), this), false, i);
|
||||
addCard(new CardItem(player, cardList[i]->getName(), cardList[i]->getId(), revealZone, this), false, i);
|
||||
reorganizeCards();
|
||||
} else if (!origZone->contentsKnown()) {
|
||||
Command_DumpZone *command = new Command_DumpZone(-1, player->getId(), name, numberCards);
|
||||
|
|
@ -44,7 +44,7 @@ void ZoneViewZone::initializeCards(const QList<ServerInfo_Card *> &cardList)
|
|||
int number = numberCards == -1 ? c.size() : (numberCards < c.size() ? numberCards : c.size());
|
||||
for (int i = 0; i < number; i++) {
|
||||
CardItem *card = c.at(i);
|
||||
addCard(new CardItem(player, card->getName(), card->getId(), this), false, i);
|
||||
addCard(new CardItem(player, card->getName(), card->getId(), revealZone, this), false, i);
|
||||
}
|
||||
reorganizeCards();
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ void ZoneViewZone::zoneDumpReceived(ProtocolResponse *r)
|
|||
|
||||
const QList<ServerInfo_Card *> &respCardList = resp->getZone()->getCardList();
|
||||
for (int i = 0; i < respCardList.size(); i++) {
|
||||
CardItem *card = new CardItem(player, respCardList[i]->getName(), respCardList[i]->getId(), this);
|
||||
CardItem *card = new CardItem(player, respCardList[i]->getName(), respCardList[i]->getId(), revealZone, this);
|
||||
addCard(card, false, i);
|
||||
}
|
||||
|
||||
|
|
@ -87,7 +87,6 @@ void ZoneViewZone::reorganizeCards()
|
|||
cols = 2;
|
||||
|
||||
qDebug() << "reorganizeCards: rows=" << rows << "cols=" << cols;
|
||||
qDebug() << "SORT BY NAME:" << sortByName << "SORT BY TYPE:" << sortByType;
|
||||
|
||||
CardList cardsToDisplay(cards);
|
||||
if (sortByName || sortByType)
|
||||
|
|
@ -125,9 +124,13 @@ void ZoneViewZone::addCardImpl(CardItem *card, int x, int /*y*/)
|
|||
card->update();
|
||||
}
|
||||
|
||||
void ZoneViewZone::handleDropEvent(CardDragItem *dragItem, CardZone *startZone, const QPoint &/*dropPoint*/, bool /*faceDown*/)
|
||||
void ZoneViewZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &/*dropPoint*/, bool /*faceDown*/)
|
||||
{
|
||||
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), dragItem->getId(), player->getId(), getName(), 0, 0, false));
|
||||
QList<CardId *> idList;
|
||||
for (int i = 0; i < dragItems.size(); ++i)
|
||||
idList.append(new CardId(dragItems[i]->getId()));
|
||||
|
||||
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), 0, 0, false));
|
||||
}
|
||||
|
||||
void ZoneViewZone::removeCard(int position)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class ZoneViewZone : public SelectZone, public QGraphicsLayoutItem {
|
|||
private:
|
||||
QRectF bRect, optimumRect;
|
||||
int minRows, numberCards;
|
||||
void handleDropEvent(CardDragItem *dragItem, CardZone *startZone, const QPoint &dropPoint, bool faceDown);
|
||||
void handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &dropPoint, bool faceDown);
|
||||
CardZone *origZone;
|
||||
bool revealZone;
|
||||
bool sortByName, sortByType;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue