mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-03 03:53:56 -07:00
full reveal card support
This commit is contained in:
parent
1cd76c2641
commit
e1380f199e
16 changed files with 1556 additions and 675 deletions
|
|
@ -63,6 +63,7 @@ HEADERS += src/counter.h \
|
|||
src/localserver.h \
|
||||
src/localserverinterface.h \
|
||||
src/localclient.h \
|
||||
src/translation.h \
|
||||
../common/color.h \
|
||||
../common/serializable_item.h \
|
||||
../common/decklist.h \
|
||||
|
|
|
|||
|
|
@ -48,33 +48,33 @@ QString CardZone::getTranslatedName(bool hisOwn, GrammaticalCase gc) const
|
|||
QString ownerName = player->getName();
|
||||
if (name == "hand")
|
||||
switch (gc) {
|
||||
case CaseNominative: return hisOwn ? tr("his hand") : tr("%1's hand").arg(ownerName);
|
||||
case CaseGenitive: return hisOwn ? tr("of his hand") : tr("of %1's hand").arg(ownerName);
|
||||
case CaseAccusative: return hisOwn ? tr("his hand") : tr("%1's hand").arg(ownerName);
|
||||
case CaseNominative: return hisOwn ? tr("his hand", "nominative") : tr("%1's hand", "nominative").arg(ownerName);
|
||||
case CaseGenitive: return hisOwn ? tr("of his hand", "genitive") : tr("of %1's hand", "genitive").arg(ownerName);
|
||||
case CaseAccusative: return hisOwn ? tr("his hand", "accusative") : tr("%1's hand", "accusative").arg(ownerName);
|
||||
}
|
||||
else if (name == "deck")
|
||||
switch (gc) {
|
||||
case CaseNominative: return hisOwn ? tr("his library") : tr("%1's library").arg(ownerName);
|
||||
case CaseGenitive: return hisOwn ? tr("of his library") : tr("of %1's library").arg(ownerName);
|
||||
case CaseAccusative: return hisOwn ? tr("his library") : tr("%1's library").arg(ownerName);
|
||||
case CaseNominative: return hisOwn ? tr("his library", "nominative") : tr("%1's library", "nominative").arg(ownerName);
|
||||
case CaseGenitive: return hisOwn ? tr("of his library", "genitive") : tr("of %1's library", "genitive").arg(ownerName);
|
||||
case CaseAccusative: return hisOwn ? tr("his library", "accusative") : tr("%1's library", "accusative").arg(ownerName);
|
||||
}
|
||||
else if (name == "grave")
|
||||
switch (gc) {
|
||||
case CaseNominative: return hisOwn ? tr("his graveyard") : tr("%1's graveyard").arg(ownerName);
|
||||
case CaseGenitive: return hisOwn ? tr("of his graveyard") : tr("of %1's graveyard").arg(ownerName);
|
||||
case CaseAccusative: return hisOwn ? tr("his graveyard") : tr("%1's graveyard").arg(ownerName);
|
||||
case CaseNominative: return hisOwn ? tr("his graveyard", "nominative") : tr("%1's graveyard", "nominative").arg(ownerName);
|
||||
case CaseGenitive: return hisOwn ? tr("of his graveyard", "genitive") : tr("of %1's graveyard", "genitive").arg(ownerName);
|
||||
case CaseAccusative: return hisOwn ? tr("his graveyard", "accusative") : tr("%1's graveyard", "accusative").arg(ownerName);
|
||||
}
|
||||
else if (name == "rfg")
|
||||
switch (gc) {
|
||||
case CaseNominative: return hisOwn ? tr("his exile") : tr("%1's exile").arg(ownerName);
|
||||
case CaseGenitive: return hisOwn ? tr("of his exile") : tr("of %1's exile").arg(ownerName);
|
||||
case CaseAccusative: return hisOwn ? tr("his exile") : tr("%1's exile").arg(ownerName);
|
||||
case CaseNominative: return hisOwn ? tr("his exile", "nominative") : tr("%1's exile", "nominative").arg(ownerName);
|
||||
case CaseGenitive: return hisOwn ? tr("of his exile", "genitive") : tr("of %1's exile", "genitive").arg(ownerName);
|
||||
case CaseAccusative: return hisOwn ? tr("his exile", "accusative") : tr("%1's exile", "accusative").arg(ownerName);
|
||||
}
|
||||
else if (name == "sb")
|
||||
switch (gc) {
|
||||
case CaseNominative: return hisOwn ? tr("his sideboard") : tr("%1's sideboard").arg(ownerName);
|
||||
case CaseGenitive: return hisOwn ? tr("of his sideboard") : tr("of %1's sideboard").arg(ownerName);
|
||||
case CaseAccusative: return hisOwn ? tr("his sideboard") : tr("%1's sideboard").arg(ownerName);
|
||||
case CaseNominative: return hisOwn ? tr("his sideboard", "nominative") : tr("%1's sideboard", "nominative").arg(ownerName);
|
||||
case CaseGenitive: return hisOwn ? tr("of his sideboard", "genitive") : tr("of %1's sideboard", "genitive").arg(ownerName);
|
||||
case CaseAccusative: return hisOwn ? tr("his sideboard", "accusative") : tr("%1's sideboard", "accusative").arg(ownerName);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,6 +89,15 @@ void GameScene::toggleZoneView(Player *player, const QString &zoneName, int numb
|
|||
item->setPos(100, 100);
|
||||
}
|
||||
|
||||
void GameScene::addRevealedZoneView(Player *player, CardZone *zone, const QList<ServerInfo_Card *> &cardList)
|
||||
{
|
||||
ZoneViewWidget *item = new ZoneViewWidget(player, zone, -2, cardList);
|
||||
views.append(item);
|
||||
connect(item, SIGNAL(closePressed(ZoneViewWidget *)), this, SLOT(removeZoneView(ZoneViewWidget *)));
|
||||
addItem(item);
|
||||
item->setPos(100, 100);
|
||||
}
|
||||
|
||||
void GameScene::removeZoneView(ZoneViewWidget *item)
|
||||
{
|
||||
views.removeAt(views.indexOf(item));
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
class Player;
|
||||
class ZoneViewWidget;
|
||||
class CardZone;
|
||||
class ServerInfo_Card;
|
||||
|
||||
class GameScene : public QGraphicsScene {
|
||||
Q_OBJECT
|
||||
|
|
@ -23,6 +25,7 @@ public:
|
|||
void processViewSizeChange(const QSize &newSize);
|
||||
public slots:
|
||||
void toggleZoneView(Player *player, const QString &zoneName, int numberCards);
|
||||
void addRevealedZoneView(Player *player, CardZone *zone, const QList<ServerInfo_Card *> &cardList);
|
||||
void removeZoneView(ZoneViewWidget *item);
|
||||
void addPlayer(Player *player);
|
||||
void removePlayer(Player *player);
|
||||
|
|
|
|||
|
|
@ -138,14 +138,11 @@ void MessageLogWidget::logDrawCards(Player *player, int number)
|
|||
append(tr("%1 draws %2 cards.").arg(sanitizeHtml(player->getName())).arg(number));
|
||||
}
|
||||
|
||||
void MessageLogWidget::logMoveCard(Player *player, QString cardName, CardZone *startZone, int oldX, CardZone *targetZone, int newX)
|
||||
QPair<QString, QString> MessageLogWidget::getFromStr(CardZone *zone, QString cardName, int position) const
|
||||
{
|
||||
QString startName = startZone->getName();
|
||||
QString targetName = targetZone->getName();
|
||||
if (((startName == "table") && (targetName == "table")) || ((startName == "hand") && (targetName == "hand")))
|
||||
return;
|
||||
QString fromStr;
|
||||
bool cardNameContainsStartZone = false;
|
||||
QString fromStr;
|
||||
QString startName = zone->getName();
|
||||
|
||||
if (startName == "table")
|
||||
fromStr = tr(" from table");
|
||||
|
|
@ -156,13 +153,13 @@ void MessageLogWidget::logMoveCard(Player *player, QString cardName, CardZone *s
|
|||
else if (startName == "hand")
|
||||
fromStr = tr(" from hand");
|
||||
else if (startName == "deck") {
|
||||
if (oldX == startZone->getCards().size() - 1) {
|
||||
if (position == zone->getCards().size() - 1) {
|
||||
if (cardName.isEmpty()) {
|
||||
cardName = tr("the bottom card of his library");
|
||||
cardNameContainsStartZone = true;
|
||||
} else
|
||||
fromStr = tr(" from the bottom of his library");
|
||||
} else if (oldX == 0) {
|
||||
} else if (position == 0) {
|
||||
if (cardName.isEmpty()) {
|
||||
cardName = tr("the top card of his library");
|
||||
cardNameContainsStartZone = true;
|
||||
|
|
@ -172,6 +169,25 @@ void MessageLogWidget::logMoveCard(Player *player, QString cardName, CardZone *s
|
|||
fromStr = tr(" from library");
|
||||
} else if (startName == "sb")
|
||||
fromStr = tr(" from sideboard");
|
||||
|
||||
if (!cardNameContainsStartZone)
|
||||
cardName.clear();
|
||||
return QPair<QString, QString>(cardName, fromStr);
|
||||
}
|
||||
|
||||
void MessageLogWidget::logMoveCard(Player *player, QString cardName, CardZone *startZone, int oldX, CardZone *targetZone, int newX)
|
||||
{
|
||||
QString startName = startZone->getName();
|
||||
QString targetName = targetZone->getName();
|
||||
if (((startName == "table") && (targetName == "table")) || ((startName == "hand") && (targetName == "hand")))
|
||||
return;
|
||||
QPair<QString, QString> temp = getFromStr(startZone, cardName, oldX);
|
||||
bool cardNameContainsStartZone = false;
|
||||
if (!temp.first.isEmpty()) {
|
||||
cardNameContainsStartZone = true;
|
||||
cardName = temp.first;
|
||||
}
|
||||
QString fromStr = temp.second;
|
||||
|
||||
QString finalStr;
|
||||
if (targetName == "table")
|
||||
|
|
@ -321,6 +337,42 @@ void MessageLogWidget::logStopDumpZone(Player *player, CardZone *zone)
|
|||
append(tr("%1 stops looking at %2.").arg(sanitizeHtml(player->getName())).arg(zoneName));
|
||||
}
|
||||
|
||||
void MessageLogWidget::logRevealCards(Player *player, CardZone *zone, int cardId, QString cardName, Player *otherPlayer)
|
||||
{
|
||||
QPair<QString, QString> temp = getFromStr(zone, cardName, cardId);
|
||||
bool cardNameContainsStartZone = false;
|
||||
if (!temp.first.isEmpty()) {
|
||||
cardNameContainsStartZone = true;
|
||||
cardName = temp.first;
|
||||
}
|
||||
QString fromStr = temp.second;
|
||||
|
||||
QString cardStr;
|
||||
if (cardNameContainsStartZone)
|
||||
cardStr = cardName;
|
||||
else if (cardName.isEmpty())
|
||||
cardStr = tr("a card");
|
||||
else
|
||||
cardStr = QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(cardName));
|
||||
|
||||
if (cardId == -1) {
|
||||
if (otherPlayer)
|
||||
append(tr("%1 reveals %2 to %3.").arg(sanitizeHtml(player->getName())).arg(zone->getTranslatedName(true, CaseAccusative)).arg(sanitizeHtml(otherPlayer->getName())));
|
||||
else
|
||||
append(tr("%1 reveals %2.").arg(sanitizeHtml(player->getName())).arg(zone->getTranslatedName(true, CaseAccusative)));
|
||||
} else if (cardId == -2) {
|
||||
if (otherPlayer)
|
||||
append(tr("%1 randomly reveals %2%3 to %4.").arg(sanitizeHtml(player->getName())).arg(cardStr).arg(fromStr).arg(sanitizeHtml(otherPlayer->getName())));
|
||||
else
|
||||
append(tr("%1 randomly reveals %2%3.").arg(sanitizeHtml(player->getName())).arg(cardStr).arg(fromStr));
|
||||
} else {
|
||||
if (otherPlayer)
|
||||
append(tr("%1 reveals %2%3 to %4.").arg(sanitizeHtml(player->getName())).arg(cardStr).arg(fromStr).arg(sanitizeHtml(otherPlayer->getName())));
|
||||
else
|
||||
append(tr("%1 reveals %2%3.").arg(sanitizeHtml(player->getName())).arg(cardStr).arg(fromStr));
|
||||
}
|
||||
}
|
||||
|
||||
void MessageLogWidget::logSetActivePlayer(Player *player)
|
||||
{
|
||||
append("---");
|
||||
|
|
@ -368,6 +420,7 @@ void MessageLogWidget::connectToPlayer(Player *player)
|
|||
connect(player, SIGNAL(logDumpZone(Player *, CardZone *, int)), this, SLOT(logDumpZone(Player *, CardZone *, int)));
|
||||
connect(player, SIGNAL(logStopDumpZone(Player *, CardZone *)), this, SLOT(logStopDumpZone(Player *, CardZone *)));
|
||||
connect(player, SIGNAL(logDrawCards(Player *, int)), this, SLOT(logDrawCards(Player *, int)));
|
||||
connect(player, SIGNAL(logRevealCards(Player *, CardZone *, int, QString, Player *)), this, SLOT(logRevealCards(Player *, CardZone *, int, QString, Player *)));
|
||||
}
|
||||
|
||||
MessageLogWidget::MessageLogWidget(QWidget *parent)
|
||||
|
|
@ -379,12 +432,12 @@ MessageLogWidget::MessageLogWidget(QWidget *parent)
|
|||
setFont(f);
|
||||
}
|
||||
|
||||
void MessageLogWidget::enterEvent(QEvent *event)
|
||||
void MessageLogWidget::enterEvent(QEvent * /*event*/)
|
||||
{
|
||||
setMouseTracking(true);
|
||||
}
|
||||
|
||||
void MessageLogWidget::leaveEvent(QEvent *event)
|
||||
void MessageLogWidget::leaveEvent(QEvent * /*event*/)
|
||||
{
|
||||
setMouseTracking(false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class MessageLogWidget : public QTextEdit {
|
|||
private:
|
||||
CardInfoWidget *infoWidget;
|
||||
QString sanitizeHtml(QString dirty) const;
|
||||
QString trZoneName(CardZone *zone, Player *player, bool hisOwn, GrammaticalCase gc) const;
|
||||
QPair<QString, QString> getFromStr(CardZone *zone, QString cardName, int position) const;
|
||||
QString getCardNameUnderMouse(const QPoint &pos) const;
|
||||
signals:
|
||||
void cardNameHovered(QString cardName);
|
||||
|
|
@ -62,6 +62,7 @@ public slots:
|
|||
void logSetAnnotation(Player *player, QString cardName, QString newAnnotation);
|
||||
void logDumpZone(Player *player, CardZone *zone, int numberCards);
|
||||
void logStopDumpZone(Player *player, CardZone *zone);
|
||||
void logRevealCards(Player *player, CardZone *zone, int cardId, QString cardName, Player *otherPlayer);
|
||||
void logSetActivePlayer(Player *player);
|
||||
void logSetActivePhase(int phase);
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -223,6 +223,15 @@ Player::Player(ServerInfo_User *info, int _id, bool _local, TabGame *_parent)
|
|||
aCardMenu = new QAction(this);
|
||||
playerMenu->addSeparator();
|
||||
playerMenu->addAction(aCardMenu);
|
||||
|
||||
for (int i = 0; i < playerLists.size(); ++i) {
|
||||
QAction *newAction = playerLists[i]->addAction(QString());
|
||||
newAction->setData(-1);
|
||||
connect(newAction, SIGNAL(triggered()), this, SLOT(playerListActionTriggered()));
|
||||
allPlayersActions.append(newAction);
|
||||
playerLists[i]->addSeparator();
|
||||
}
|
||||
|
||||
} else {
|
||||
countersMenu = 0;
|
||||
sbMenu = 0;
|
||||
|
|
@ -286,6 +295,12 @@ void Player::playerListActionTriggered()
|
|||
|
||||
if (menu == mRevealLibrary) {
|
||||
sendGameCommand(new Command_RevealCards(-1, "deck", -1, otherPlayerId));
|
||||
} else if (menu == mRevealTopCard) {
|
||||
sendGameCommand(new Command_RevealCards(-1, "deck", 0, otherPlayerId));
|
||||
} else if (menu == mRevealHand) {
|
||||
sendGameCommand(new Command_RevealCards(-1, "hand", -1, otherPlayerId));
|
||||
} else if (menu == mRevealRandomHandCard) {
|
||||
sendGameCommand(new Command_RevealCards(-1, "hand", -2, otherPlayerId));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -384,6 +399,9 @@ void Player::retranslateUi()
|
|||
counterIterator.next().value()->retranslateUi();
|
||||
|
||||
aCardMenu->setText(tr("C&ard"));
|
||||
|
||||
for (int i = 0; i < allPlayersActions.size(); ++i)
|
||||
allPlayersActions[i]->setText(tr("&All players"));
|
||||
}
|
||||
|
||||
QMapIterator<QString, CardZone *> zoneIterator(zones);
|
||||
|
|
@ -880,6 +898,28 @@ void Player::eventDrawCards(Event_DrawCards *event)
|
|||
emit logDrawCards(this, event->getNumberCards());
|
||||
}
|
||||
|
||||
void Player::eventRevealCards(Event_RevealCards *event)
|
||||
{
|
||||
CardZone *zone = zones.value(event->getZoneName());
|
||||
if (!zone)
|
||||
return;
|
||||
Player *otherPlayer = 0;
|
||||
if (event->getOtherPlayerId() != -1) {
|
||||
otherPlayer = static_cast<TabGame *>(parent())->getPlayers().value(event->getOtherPlayerId());
|
||||
if (!otherPlayer)
|
||||
return;
|
||||
}
|
||||
|
||||
QList<ServerInfo_Card *> cardList = event->getCardList();
|
||||
if (!cardList.isEmpty())
|
||||
static_cast<GameScene *>(scene())->addRevealedZoneView(this, zone, cardList);
|
||||
|
||||
QString cardName;
|
||||
if (cardList.size() == 1)
|
||||
cardName = cardList.first()->getName();
|
||||
emit logRevealCards(this, zone, event->getCardId(), cardName, otherPlayer);
|
||||
}
|
||||
|
||||
void Player::processGameEvent(GameEvent *event, GameEventContext *context)
|
||||
{
|
||||
qDebug() << "player event: id=" << event->getItemId();
|
||||
|
|
@ -902,6 +942,7 @@ void Player::processGameEvent(GameEvent *event, GameEventContext *context)
|
|||
case ItemId_Event_DestroyCard: eventDestroyCard(qobject_cast<Event_DestroyCard *>(event)); break;
|
||||
case ItemId_Event_AttachCard: eventAttachCard(qobject_cast<Event_AttachCard *>(event)); break;
|
||||
case ItemId_Event_DrawCards: eventDrawCards(qobject_cast<Event_DrawCards *>(event)); break;
|
||||
case ItemId_Event_RevealCards: eventRevealCards(qobject_cast<Event_RevealCards *>(event)); break;
|
||||
default: {
|
||||
qDebug() << "unhandled game event";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ class Event_FlipCard;
|
|||
class Event_DestroyCard;
|
||||
class Event_AttachCard;
|
||||
class Event_DrawCards;
|
||||
class Event_RevealCards;
|
||||
|
||||
class Player : public QObject, public QGraphicsItem {
|
||||
Q_OBJECT
|
||||
|
|
@ -68,6 +69,7 @@ signals:
|
|||
void logSetAnnotation(Player *player, QString cardName, QString newAnnotation);
|
||||
void logDumpZone(Player *player, CardZone *zone, int numberCards);
|
||||
void logStopDumpZone(Player *player, CardZone *zone);
|
||||
void logRevealCards(Player *player, CardZone *zone, int cardId, QString cardName, Player *otherPlayer);
|
||||
|
||||
void sizeChanged();
|
||||
public slots:
|
||||
|
|
@ -109,6 +111,7 @@ private:
|
|||
QMenu *playerMenu, *handMenu, *graveMenu, *rfgMenu, *libraryMenu, *sbMenu, *countersMenu, *sayMenu,
|
||||
*mRevealLibrary, *mRevealTopCard, *mRevealHand, *mRevealRandomHandCard;
|
||||
QList<QMenu *> playerLists;
|
||||
QList<QAction *> allPlayersActions;
|
||||
QAction *aMoveHandToTopLibrary, *aMoveHandToBottomLibrary, *aMoveHandToGrave, *aMoveHandToRfg,
|
||||
*aMoveGraveToTopLibrary, *aMoveGraveToBottomLibrary, *aMoveGraveToHand, *aMoveGraveToRfg,
|
||||
*aMoveRfgToTopLibrary, *aMoveRfgToBottomLibrary, *aMoveRfgToHand, *aMoveRfgToGrave,
|
||||
|
|
@ -166,6 +169,7 @@ private:
|
|||
void eventDestroyCard(Event_DestroyCard *event);
|
||||
void eventAttachCard(Event_AttachCard *event);
|
||||
void eventDrawCards(Event_DrawCards *event);
|
||||
void eventRevealCards(Event_RevealCards *event);
|
||||
public:
|
||||
static const int counterAreaWidth = 65;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include "protocol_items.h"
|
||||
#include "settingscache.h"
|
||||
|
||||
ZoneViewWidget::ZoneViewWidget(Player *_player, CardZone *_origZone, int numberCards)
|
||||
ZoneViewWidget::ZoneViewWidget(Player *_player, CardZone *_origZone, int numberCards, const QList<ServerInfo_Card *> &cardList)
|
||||
: QGraphicsWidget(0, Qt::Tool | Qt::CustomizeWindowHint | Qt::WindowSystemMenuHint | Qt::WindowTitleHint/* | Qt::WindowCloseButtonHint*/), player(_player)
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
|
@ -21,7 +21,7 @@ ZoneViewWidget::ZoneViewWidget(Player *_player, CardZone *_origZone, int numberC
|
|||
|
||||
QGraphicsLinearLayout *vbox = new QGraphicsLinearLayout(Qt::Vertical);
|
||||
|
||||
if (numberCards == -1) {
|
||||
if (numberCards < 0) {
|
||||
sortByNameCheckBox = new QCheckBox;
|
||||
QGraphicsProxyWidget *sortByNameProxy = new QGraphicsProxyWidget;
|
||||
sortByNameProxy->setWidget(sortByNameCheckBox);
|
||||
|
|
@ -52,7 +52,7 @@ ZoneViewWidget::ZoneViewWidget(Player *_player, CardZone *_origZone, int numberC
|
|||
connect(zone, SIGNAL(optimumRectChanged()), this, SLOT(resizeToZoneContents()));
|
||||
connect(zone, SIGNAL(beingDeleted()), this, SLOT(zoneDeleted()));
|
||||
vbox->addItem(zone);
|
||||
zone->initializeCards();
|
||||
zone->initializeCards(cardList);
|
||||
|
||||
if (sortByNameCheckBox) {
|
||||
connect(sortByNameCheckBox, SIGNAL(stateChanged(int)), zone, SLOT(setSortByName(int)));
|
||||
|
|
@ -89,7 +89,8 @@ void ZoneViewWidget::resizeToZoneContents()
|
|||
void ZoneViewWidget::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
disconnect(zone, SIGNAL(beingDeleted()), this, 0);
|
||||
player->sendGameCommand(new Command_StopDumpZone(-1, player->getId(), zone->getName()));
|
||||
if (zone->getNumberCards() != -2)
|
||||
player->sendGameCommand(new Command_StopDumpZone(-1, player->getId(), zone->getName()));
|
||||
if (shuffleCheckBox)
|
||||
if (shuffleCheckBox->isChecked())
|
||||
player->sendGameCommand(new Command_Shuffle);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ class CardDatabase;
|
|||
class QScrollBar;
|
||||
class QCheckBox;
|
||||
class GameScene;
|
||||
class ServerInfo_Card;
|
||||
|
||||
class ZoneViewWidget : public QGraphicsWidget {
|
||||
Q_OBJECT
|
||||
|
|
@ -29,7 +30,7 @@ private slots:
|
|||
void resizeToZoneContents();
|
||||
void zoneDeleted();
|
||||
public:
|
||||
ZoneViewWidget(Player *_player, CardZone *_origZone, int numberCards = 0);
|
||||
ZoneViewWidget(Player *_player, CardZone *_origZone, int numberCards = 0, const QList<ServerInfo_Card *> &cardList = QList<ServerInfo_Card *>());
|
||||
ZoneViewZone *getZone() const { return zone; }
|
||||
void retranslateUi();
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -26,9 +26,13 @@ void ZoneViewZone::paint(QPainter */*painter*/, const QStyleOptionGraphicsItem *
|
|||
{
|
||||
}
|
||||
|
||||
void ZoneViewZone::initializeCards()
|
||||
void ZoneViewZone::initializeCards(const QList<ServerInfo_Card *> &cardList)
|
||||
{
|
||||
if (!origZone->contentsKnown()) {
|
||||
if (!cardList.isEmpty()) {
|
||||
for (int i = 0; i < cardList.size(); ++i)
|
||||
addCard(new CardItem(player, cardList[i]->getName(), cardList[i]->getId(), this), false, i);
|
||||
reorganizeCards();
|
||||
} else if (!origZone->contentsKnown()) {
|
||||
Command_DumpZone *command = new Command_DumpZone(-1, player->getId(), name, numberCards);
|
||||
connect(command, SIGNAL(finished(ProtocolResponse *)), this, SLOT(zoneDumpReceived(ProtocolResponse *)));
|
||||
player->sendGameCommand(command);
|
||||
|
|
@ -80,6 +84,7 @@ 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)
|
||||
|
|
@ -119,7 +124,6 @@ void ZoneViewZone::addCardImpl(CardItem *card, int x, int /*y*/)
|
|||
|
||||
void ZoneViewZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint &/*dropPoint*/, bool /*faceDown*/)
|
||||
{
|
||||
qDebug(QString("handleDropEvent id=%1").arg(cardId).toLatin1());
|
||||
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), cardId, getName(), 0, 0, false));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
class ZoneViewWidget;
|
||||
class ProtocolResponse;
|
||||
class ServerInfo_Card;
|
||||
|
||||
class ZoneViewZone : public CardZone, public QGraphicsLayoutItem {
|
||||
Q_OBJECT
|
||||
|
|
@ -21,7 +22,7 @@ public:
|
|||
QRectF boundingRect() const;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
void reorganizeCards();
|
||||
void initializeCards();
|
||||
void initializeCards(const QList<ServerInfo_Card *> &cardList = QList<ServerInfo_Card *>());
|
||||
void removeCard(int position);
|
||||
int getNumberCards() const { return numberCards; }
|
||||
void setGeometry(const QRectF &rect);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue