diff --git a/cockatrice/cockatrice.qrc b/cockatrice/cockatrice.qrc index 9baff49d..1391fc83 100644 --- a/cockatrice/cockatrice.qrc +++ b/cockatrice/cockatrice.qrc @@ -62,7 +62,9 @@ resources/countries/jp.svg resources/countries/mx.svg resources/countries/nl.svg + resources/countries/no.svg resources/countries/pl.svg + resources/countries/pt.svg resources/countries/ru.svg resources/countries/se.svg resources/countries/tr.svg diff --git a/cockatrice/resources/countries/no.svg b/cockatrice/resources/countries/no.svg new file mode 100644 index 00000000..ec2bd8de --- /dev/null +++ b/cockatrice/resources/countries/no.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/cockatrice/resources/countries/pt.svg b/cockatrice/resources/countries/pt.svg new file mode 100644 index 00000000..1286a1bf --- /dev/null +++ b/cockatrice/resources/countries/pt.svg @@ -0,0 +1,859 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cockatrice/src/abstractcarditem.cpp b/cockatrice/src/abstractcarditem.cpp index 22e0dade..ca7e22db 100644 --- a/cockatrice/src/abstractcarditem.cpp +++ b/cockatrice/src/abstractcarditem.cpp @@ -176,6 +176,8 @@ void AbstractCardItem::setHovered(bool _hovered) if (isHovered == _hovered) return; + if (_hovered) + processHoverEvent(); isHovered = _hovered; setZValue(_hovered ? 2000000004 : realZValue); update(); @@ -226,19 +228,6 @@ void AbstractCardItem::processHoverEvent() emit hovered(this); } -void AbstractCardItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) -{ - processHoverEvent(); - isHovered = true; - QGraphicsItem::hoverEnterEvent(event); -} - -void AbstractCardItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - isHovered = false; - QGraphicsItem::hoverLeaveEvent(event); -} - QVariant AbstractCardItem::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) { if (change == ItemSelectedHasChanged) { diff --git a/cockatrice/src/abstractcarditem.h b/cockatrice/src/abstractcarditem.h index e1ca65c8..0f592d31 100644 --- a/cockatrice/src/abstractcarditem.h +++ b/cockatrice/src/abstractcarditem.h @@ -55,8 +55,6 @@ protected: void transformPainter(QPainter *painter, const QSizeF &translatedSize, int angle); void mousePressEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - void hoverEnterEvent(QGraphicsSceneHoverEvent *event); - void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value); }; diff --git a/cockatrice/src/carditem.cpp b/cockatrice/src/carditem.cpp index d571f400..c3da70d8 100644 --- a/cockatrice/src/carditem.cpp +++ b/cockatrice/src/carditem.cpp @@ -106,19 +106,37 @@ CardItem::CardItem(Player *_owner, const QString &_name, int _cardid, QGraphicsI CardItem::~CardItem() { - if (owner->getCardMenu() == cardMenu) - owner->setCardMenu(0); + prepareDelete(); + delete cardMenu; + cardMenu = 0; + + deleteDragItem(); +} + +void CardItem::prepareDelete() +{ + if (owner) { + if (owner->getCardMenu() == cardMenu) + owner->setCardMenu(0); + owner = 0; + } while (!attachedCards.isEmpty()) { attachedCards.first()->setZone(0); // so that it won't try to call reorganizeCards() attachedCards.first()->setAttachedTo(0); } - if (attachedTo) + if (attachedTo) { attachedTo->removeAttachedCard(this); + attachedTo = 0; + } +} - deleteDragItem(); +void CardItem::deleteLater() +{ + prepareDelete(); + AbstractCardItem::deleteLater(); } void CardItem::retranslateUi() @@ -236,10 +254,12 @@ void CardItem::setAttachedTo(CardItem *_attachedTo) gridPoint.setX(-1); attachedTo = _attachedTo; if (attachedTo) { + setParentItem(attachedTo->getZone()); attachedTo->addAttachedCard(this); if (zone != attachedTo->getZone()) attachedTo->getZone()->reorganizeCards(); - } + } else + setParentItem(zone); if (zone) zone->reorganizeCards(); diff --git a/cockatrice/src/carditem.h b/cockatrice/src/carditem.h index 586d2147..52642abb 100644 --- a/cockatrice/src/carditem.h +++ b/cockatrice/src/carditem.h @@ -35,6 +35,9 @@ private: QMenu *cardMenu, *moveMenu; void playCard(QGraphicsSceneMouseEvent *event); + void prepareDelete(); +public slots: + void deleteLater(); public: enum { Type = typeCard }; int type() const { return Type; } diff --git a/cockatrice/src/gamescene.cpp b/cockatrice/src/gamescene.cpp index 55b7079c..e92fb820 100644 --- a/cockatrice/src/gamescene.cpp +++ b/cockatrice/src/gamescene.cpp @@ -170,8 +170,12 @@ bool GameScene::event(QEvent *event) CardItem *card = qgraphicsitem_cast(itemList[i]); if (!card) continue; - if (card->getZone() != zone) + if (card->getAttachedTo()) { + if (card->getAttachedTo()->getZone() != zone) + continue; + } else if (card->getZone() != zone) continue; + if (card->getRealZValue() > maxZ) { maxZ = card->getRealZValue(); maxZCard = card; diff --git a/cockatrice/src/player.cpp b/cockatrice/src/player.cpp index 7872c17a..c13c13bf 100644 --- a/cockatrice/src/player.cpp +++ b/cockatrice/src/player.cpp @@ -252,7 +252,7 @@ Player::Player(ServerInfo_User *info, int _id, bool _local, TabGame *_parent) Player::~Player() { - qDebug("Player destructor"); + qDebug() << "Player destructor:" << getName(); static_cast(scene())->removePlayer(this); @@ -889,10 +889,6 @@ void Player::eventAttachCard(Event_AttachCard *event) CardItem *oldParent = startCard->getAttachedTo(); - if (targetZone) - startCard->setParentItem(targetZone); - else - startCard->setParentItem(startZone); startCard->setAttachedTo(targetCard); startZone->reorganizeCards(); diff --git a/cockatrice/src/settingscache.cpp b/cockatrice/src/settingscache.cpp index 604766cd..3023d911 100644 --- a/cockatrice/src/settingscache.cpp +++ b/cockatrice/src/settingscache.cpp @@ -80,7 +80,7 @@ void SettingsCache::setTableBgPath(const QString &_tableBgPath) void SettingsCache::setPlayerBgPath(const QString &_playerBgPath) { playerBgPath = _playerBgPath; - settings->setValue("zonebg/player", playerBgPath); + settings->setValue("zonebg/playerarea", playerBgPath); emit playerBgPathChanged(); } diff --git a/common/server_card.cpp b/common/server_card.cpp index 6c332b93..792ec0db 100644 --- a/common/server_card.cpp +++ b/common/server_card.cpp @@ -37,15 +37,11 @@ Server_Card::~Server_Card() void Server_Card::resetState() { - setCoords(0, 0); counters.clear(); setTapped(false); setAttacking(false); - setFaceDown(false); - setColor(QString()); setPT(QString()); setAnnotation(QString()); - setDestroyOnZoneChange(false); setDoesntUntap(false); } diff --git a/common/server_protocolhandler.cpp b/common/server_protocolhandler.cpp index bfa61080..18c80565 100644 --- a/common/server_protocolhandler.cpp +++ b/common/server_protocolhandler.cpp @@ -623,6 +623,8 @@ ResponseCode Server_ProtocolHandler::moveCard(Server_Game *game, Server_Player * y = 0; if (x == -1) x = targetzone->cards.size(); + + card->resetState(); } else if (x == -1) x = targetzone->getFreeGridColumn(y); @@ -680,7 +682,7 @@ ResponseCode Server_ProtocolHandler::moveCard(Server_Game *game, Server_Player * if (tapped) setCardAttrHelper(cont, game, player, targetzone->getName(), card->getId(), "tapped", "1"); - + return RespOk; } @@ -943,6 +945,7 @@ ResponseCode Server_ProtocolHandler::setCardAttrHelper(CommandContainer *cont, S } cont->enqueueGameEventPrivate(new Event_SetCardAttr(player->getPlayerId(), zone->getName(), cardId, attrName, attrValue), game->getGameId()); cont->enqueueGameEventPublic(new Event_SetCardAttr(player->getPlayerId(), zone->getName(), cardId, attrName, attrValue), game->getGameId()); + cont->enqueueGameEventOmniscient(new Event_SetCardAttr(player->getPlayerId(), zone->getName(), cardId, attrName, attrValue), game->getGameId()); return RespOk; } @@ -1197,11 +1200,12 @@ ResponseCode Server_ProtocolHandler::cmdRevealCards(Command_RevealCards *cmd, Co for (int i = 0; i < cardsToReveal.size(); ++i) { Server_Card *card = cardsToReveal[i]; - QList cardCounterList; + QList cardCounterListPrivate, cardCounterListOmniscient; QMapIterator cardCounterIterator(card->getCounters()); while (cardCounterIterator.hasNext()) { cardCounterIterator.next(); - cardCounterList.append(new ServerInfo_CardCounter(cardCounterIterator.key(), cardCounterIterator.value())); + cardCounterListPrivate.append(new ServerInfo_CardCounter(cardCounterIterator.key(), cardCounterIterator.value())); + cardCounterListOmniscient.append(new ServerInfo_CardCounter(cardCounterIterator.key(), cardCounterIterator.value())); } int attachPlayerId = -1; @@ -1214,8 +1218,8 @@ ResponseCode Server_ProtocolHandler::cmdRevealCards(Command_RevealCards *cmd, Co } if (cmd->getPlayerId() != -1) - respCardListPrivate.append(new ServerInfo_Card(card->getId(), card->getName(), card->getX(), card->getY(), card->getTapped(), card->getAttacking(), card->getColor(), card->getPT(), card->getAnnotation(), card->getDestroyOnZoneChange(), cardCounterList, attachPlayerId, attachZone, attachCardId)); - respCardListOmniscient.append(new ServerInfo_Card(card->getId(), card->getName(), card->getX(), card->getY(), card->getTapped(), card->getAttacking(), card->getColor(), card->getPT(), card->getAnnotation(), card->getDestroyOnZoneChange(), cardCounterList, attachPlayerId, attachZone, attachCardId)); + respCardListPrivate.append(new ServerInfo_Card(card->getId(), card->getName(), card->getX(), card->getY(), card->getTapped(), card->getAttacking(), card->getColor(), card->getPT(), card->getAnnotation(), card->getDestroyOnZoneChange(), cardCounterListPrivate, attachPlayerId, attachZone, attachCardId)); + respCardListOmniscient.append(new ServerInfo_Card(card->getId(), card->getName(), card->getX(), card->getY(), card->getTapped(), card->getAttacking(), card->getColor(), card->getPT(), card->getAnnotation(), card->getDestroyOnZoneChange(), cardCounterListOmniscient, attachPlayerId, attachZone, attachCardId)); } if (cmd->getPlayerId() == -1)