Introduced stack zone, shrunk table to have higher zoom factor
This commit is contained in:
parent
1cd76c2641
commit
df5791d318
16 changed files with 186 additions and 23 deletions
|
@ -35,6 +35,7 @@ HEADERS += src/counter.h \
|
||||||
src/zoneviewzone.h \
|
src/zoneviewzone.h \
|
||||||
src/zoneviewwidget.h \
|
src/zoneviewwidget.h \
|
||||||
src/pilezone.h \
|
src/pilezone.h \
|
||||||
|
src/stackzone.h \
|
||||||
src/carddragitem.h \
|
src/carddragitem.h \
|
||||||
src/carddatabasemodel.h \
|
src/carddatabasemodel.h \
|
||||||
src/window_deckeditor.h \
|
src/window_deckeditor.h \
|
||||||
|
@ -111,6 +112,7 @@ SOURCES += src/counter.cpp \
|
||||||
src/zoneviewzone.cpp \
|
src/zoneviewzone.cpp \
|
||||||
src/zoneviewwidget.cpp \
|
src/zoneviewwidget.cpp \
|
||||||
src/pilezone.cpp \
|
src/pilezone.cpp \
|
||||||
|
src/stackzone.cpp \
|
||||||
src/carddragitem.cpp \
|
src/carddragitem.cpp \
|
||||||
src/carddatabasemodel.cpp \
|
src/carddatabasemodel.cpp \
|
||||||
src/window_deckeditor.cpp \
|
src/window_deckeditor.cpp \
|
||||||
|
|
|
@ -188,11 +188,6 @@ void AbstractCardItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractCardItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|
||||||
{
|
|
||||||
emit deleteCardInfoPopup();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AbstractCardItem::processHoverEvent()
|
void AbstractCardItem::processHoverEvent()
|
||||||
{
|
{
|
||||||
emit hovered(this);
|
emit hovered(this);
|
||||||
|
|
|
@ -48,7 +48,6 @@ protected:
|
||||||
QSizeF getTranslatedSize(QPainter *painter) const;
|
QSizeF getTranslatedSize(QPainter *painter) const;
|
||||||
void transformPainter(QPainter *painter, const QSizeF &translatedSize);
|
void transformPainter(QPainter *painter, const QSizeF &translatedSize);
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
|
||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||||
QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value);
|
QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value);
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
|
#include <QMouseEvent>
|
||||||
#include "cardinfowidget.h"
|
#include "cardinfowidget.h"
|
||||||
#include "carditem.h"
|
#include "carditem.h"
|
||||||
#include "carddatabase.h"
|
#include "carddatabase.h"
|
||||||
|
@ -157,3 +158,9 @@ void CardInfoWidget::resizeEvent(QResizeEvent * /*event*/)
|
||||||
updatePixmap();
|
updatePixmap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CardInfoWidget::mouseReleaseEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if ((event->button() == Qt::MidButton) && (mode == ModePopUp))
|
||||||
|
emit mouseReleased();
|
||||||
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ class QPushButton;
|
||||||
class AbstractCardItem;
|
class AbstractCardItem;
|
||||||
class CardInfo;
|
class CardInfo;
|
||||||
class QResizeEvent;
|
class QResizeEvent;
|
||||||
|
class QMouseEvent;
|
||||||
|
|
||||||
class CardInfoWidget : public QFrame {
|
class CardInfoWidget : public QFrame {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -40,8 +41,11 @@ public slots:
|
||||||
private slots:
|
private slots:
|
||||||
void updatePixmap();
|
void updatePixmap();
|
||||||
void minimizeClicked();
|
void minimizeClicked();
|
||||||
|
signals:
|
||||||
|
void mouseReleased();
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
|
void mouseReleaseEvent(QMouseEvent *event);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -369,9 +369,7 @@ void CardItem::playCard(QGraphicsSceneMouseEvent *event)
|
||||||
bool faceDown = event->modifiers().testFlag(Qt::ShiftModifier);
|
bool faceDown = event->modifiers().testFlag(Qt::ShiftModifier);
|
||||||
bool tapped = info->getCipt();
|
bool tapped = info->getCipt();
|
||||||
|
|
||||||
TableZone *table = zone->getPlayer()->getTable();
|
zone->getPlayer()->playCard(this, faceDown, tapped);
|
||||||
QPoint gridPoint = QPoint(-1, 3 - info->getTableRow());
|
|
||||||
table->handleDropEventByGrid(id, zone, gridPoint, faceDown, tapped);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,6 +172,8 @@ void MessageLogWidget::logMoveCard(Player *player, QString cardName, CardZone *s
|
||||||
fromStr = tr(" from library");
|
fromStr = tr(" from library");
|
||||||
} else if (startName == "sb")
|
} else if (startName == "sb")
|
||||||
fromStr = tr(" from sideboard");
|
fromStr = tr(" from sideboard");
|
||||||
|
else if (startName == "stack")
|
||||||
|
fromStr = tr(" from the stack");
|
||||||
|
|
||||||
QString finalStr;
|
QString finalStr;
|
||||||
if (targetName == "table")
|
if (targetName == "table")
|
||||||
|
@ -193,6 +195,8 @@ void MessageLogWidget::logMoveCard(Player *player, QString cardName, CardZone *s
|
||||||
finalStr = tr("%1 puts %2%3 into his library at position %4.");
|
finalStr = tr("%1 puts %2%3 into his library at position %4.");
|
||||||
} else if (targetName == "sb")
|
} else if (targetName == "sb")
|
||||||
finalStr = tr("%1 moves %2%3 to sideboard.");
|
finalStr = tr("%1 moves %2%3 to sideboard.");
|
||||||
|
else if (targetName == "stack")
|
||||||
|
finalStr = tr("%1 plays %2%3.");
|
||||||
|
|
||||||
QString cardStr;
|
QString cardStr;
|
||||||
if (cardNameContainsStartZone)
|
if (cardNameContainsStartZone)
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "zoneviewzone.h"
|
#include "zoneviewzone.h"
|
||||||
#include "zoneviewwidget.h"
|
#include "zoneviewwidget.h"
|
||||||
#include "pilezone.h"
|
#include "pilezone.h"
|
||||||
|
#include "stackzone.h"
|
||||||
#include "tablezone.h"
|
#include "tablezone.h"
|
||||||
#include "handzone.h"
|
#include "handzone.h"
|
||||||
#include "handcounter.h"
|
#include "handcounter.h"
|
||||||
|
@ -15,6 +16,7 @@
|
||||||
#include "gamescene.h"
|
#include "gamescene.h"
|
||||||
#include "settingscache.h"
|
#include "settingscache.h"
|
||||||
#include "dlg_create_token.h"
|
#include "dlg_create_token.h"
|
||||||
|
#include "carddatabase.h"
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
@ -54,6 +56,8 @@ Player::Player(ServerInfo_User *info, int _id, bool _local, TabGame *_parent)
|
||||||
table = new TableZone(this, this);
|
table = new TableZone(this, this);
|
||||||
connect(table, SIGNAL(sizeChanged()), this, SLOT(updateBoundingRect()));
|
connect(table, SIGNAL(sizeChanged()), this, SLOT(updateBoundingRect()));
|
||||||
|
|
||||||
|
stack = new StackZone(this, (int) table->boundingRect().height(), this);
|
||||||
|
|
||||||
hand = new HandZone(this, _local || (_parent->getSpectator() && _parent->getSpectatorsSeeEverything()), (int) table->boundingRect().height(), this);
|
hand = new HandZone(this, _local || (_parent->getSpectator() && _parent->getSpectatorsSeeEverything()), (int) table->boundingRect().height(), this);
|
||||||
connect(hand, SIGNAL(cardCountChanged()), handCounter, SLOT(updateNumber()));
|
connect(hand, SIGNAL(cardCountChanged()), handCounter, SLOT(updateNumber()));
|
||||||
|
|
||||||
|
@ -295,16 +299,29 @@ void Player::rearrangeZones()
|
||||||
|
|
||||||
if (settingsCache->getHorizontalHand()) {
|
if (settingsCache->getHorizontalHand()) {
|
||||||
if (mirrored) {
|
if (mirrored) {
|
||||||
hand->setPos(counterAreaWidth + CARD_WIDTH + 5, base.y());
|
hand->setPos(base);
|
||||||
table->setPos(base.x(), base.y() + hand->boundingRect().height());
|
base += QPointF(0, hand->boundingRect().height());
|
||||||
} else {
|
|
||||||
|
stack->setPos(base);
|
||||||
|
base += QPointF(stack->boundingRect().width(), 0);
|
||||||
|
|
||||||
table->setPos(base);
|
table->setPos(base);
|
||||||
hand->setPos(counterAreaWidth + CARD_WIDTH + 5, base.y() + table->boundingRect().height());
|
} else {
|
||||||
|
stack->setPos(base);
|
||||||
|
|
||||||
|
table->setPos(base.x() + stack->boundingRect().width(), 0);
|
||||||
|
base += QPointF(0, table->boundingRect().height());
|
||||||
|
|
||||||
|
hand->setPos(base);
|
||||||
}
|
}
|
||||||
hand->setWidth(table->getWidth());
|
hand->setWidth(table->getWidth() + stack->boundingRect().width());
|
||||||
} else {
|
} else {
|
||||||
hand->setPos(base);
|
hand->setPos(base);
|
||||||
base += QPointF(hand->boundingRect().width(), 0);
|
base += QPointF(hand->boundingRect().width(), 0);
|
||||||
|
|
||||||
|
stack->setPos(base);
|
||||||
|
base += QPointF(stack->boundingRect().width(), 0);
|
||||||
|
|
||||||
table->setPos(base);
|
table->setPos(base);
|
||||||
}
|
}
|
||||||
hand->updateOrientation();
|
hand->updateOrientation();
|
||||||
|
@ -326,10 +343,11 @@ void Player::updateBgPixmap()
|
||||||
void Player::updateBoundingRect()
|
void Player::updateBoundingRect()
|
||||||
{
|
{
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
qreal width = CARD_WIDTH + 5 + counterAreaWidth + stack->boundingRect().width();
|
||||||
if (settingsCache->getHorizontalHand())
|
if (settingsCache->getHorizontalHand())
|
||||||
bRect = QRectF(0, 0, CARD_WIDTH + 5 + counterAreaWidth + table->boundingRect().width(), table->boundingRect().height() + hand->boundingRect().height());
|
bRect = QRectF(0, 0, width + table->boundingRect().width(), table->boundingRect().height() + hand->boundingRect().height());
|
||||||
else
|
else
|
||||||
bRect = QRectF(0, 0, CARD_WIDTH + 5 + counterAreaWidth + hand->boundingRect().width() + table->boundingRect().width(), table->boundingRect().height());
|
bRect = QRectF(0, 0, width + hand->boundingRect().width() + table->boundingRect().width(), table->boundingRect().height());
|
||||||
emit sizeChanged();
|
emit sizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -993,6 +1011,17 @@ void Player::processCardAttachment(ServerInfo_Player *info)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::playCard(CardItem *c, bool faceDown, bool tapped)
|
||||||
|
{
|
||||||
|
CardInfo *ci = c->getInfo();
|
||||||
|
if (ci->getTableRow() == 3)
|
||||||
|
stack->handleDropEvent(c->getId(), c->getZone(), QPoint(), false);
|
||||||
|
else {
|
||||||
|
QPoint gridPoint = QPoint(-1, 2 - ci->getTableRow());
|
||||||
|
table->handleDropEventByGrid(c->getId(), c->getZone(), gridPoint, faceDown, tapped);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Player::addCard(CardItem *c)
|
void Player::addCard(CardItem *c)
|
||||||
{
|
{
|
||||||
emit newCardAdded(c);
|
emit newCardAdded(c);
|
||||||
|
|
|
@ -14,6 +14,7 @@ class TabGame;
|
||||||
class Counter;
|
class Counter;
|
||||||
class ArrowItem;
|
class ArrowItem;
|
||||||
class CardZone;
|
class CardZone;
|
||||||
|
class StackZone;
|
||||||
class TableZone;
|
class TableZone;
|
||||||
class HandZone;
|
class HandZone;
|
||||||
class PlayerTarget;
|
class PlayerTarget;
|
||||||
|
@ -133,6 +134,7 @@ private:
|
||||||
QList<CardItem *> cardsToDelete;
|
QList<CardItem *> cardsToDelete;
|
||||||
|
|
||||||
QMap<QString, CardZone *> zones;
|
QMap<QString, CardZone *> zones;
|
||||||
|
StackZone *stack;
|
||||||
TableZone *table;
|
TableZone *table;
|
||||||
HandZone *hand;
|
HandZone *hand;
|
||||||
PlayerTarget *playerTarget;
|
PlayerTarget *playerTarget;
|
||||||
|
@ -174,6 +176,7 @@ public:
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
|
||||||
|
void playCard(CardItem *c, bool faceDown, bool tapped);
|
||||||
void addCard(CardItem *c);
|
void addCard(CardItem *c);
|
||||||
void deleteCard(CardItem *c);
|
void deleteCard(CardItem *c);
|
||||||
void addZone(CardZone *z);
|
void addZone(CardZone *z);
|
||||||
|
|
|
@ -12,6 +12,7 @@ SettingsCache::SettingsCache()
|
||||||
cardDatabasePath = settings->value("paths/carddatabase").toString();
|
cardDatabasePath = settings->value("paths/carddatabase").toString();
|
||||||
|
|
||||||
handBgPath = settings->value("zonebg/hand").toString();
|
handBgPath = settings->value("zonebg/hand").toString();
|
||||||
|
stackBgPath = settings->value("zonebg/stack").toString();
|
||||||
tableBgPath = settings->value("zonebg/table").toString();
|
tableBgPath = settings->value("zonebg/table").toString();
|
||||||
playerBgPath = settings->value("zonebg/playerarea").toString();
|
playerBgPath = settings->value("zonebg/playerarea").toString();
|
||||||
cardBackPicturePath = settings->value("paths/cardbackpicture").toString();
|
cardBackPicturePath = settings->value("paths/cardbackpicture").toString();
|
||||||
|
@ -62,6 +63,13 @@ void SettingsCache::setHandBgPath(const QString &_handBgPath)
|
||||||
emit handBgPathChanged();
|
emit handBgPathChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsCache::setStackBgPath(const QString &_stackBgPath)
|
||||||
|
{
|
||||||
|
stackBgPath = _stackBgPath;
|
||||||
|
settings->setValue("zonebg/stack", stackBgPath);
|
||||||
|
emit stackBgPathChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void SettingsCache::setTableBgPath(const QString &_tableBgPath)
|
void SettingsCache::setTableBgPath(const QString &_tableBgPath)
|
||||||
{
|
{
|
||||||
tableBgPath = _tableBgPath;
|
tableBgPath = _tableBgPath;
|
||||||
|
|
|
@ -12,6 +12,7 @@ signals:
|
||||||
void picsPathChanged();
|
void picsPathChanged();
|
||||||
void cardDatabasePathChanged();
|
void cardDatabasePathChanged();
|
||||||
void handBgPathChanged();
|
void handBgPathChanged();
|
||||||
|
void stackBgPathChanged();
|
||||||
void tableBgPathChanged();
|
void tableBgPathChanged();
|
||||||
void playerBgPathChanged();
|
void playerBgPathChanged();
|
||||||
void cardBackPicturePathChanged();
|
void cardBackPicturePathChanged();
|
||||||
|
@ -24,7 +25,7 @@ private:
|
||||||
|
|
||||||
QString lang;
|
QString lang;
|
||||||
QString deckPath, picsPath, cardDatabasePath;
|
QString deckPath, picsPath, cardDatabasePath;
|
||||||
QString handBgPath, tableBgPath, playerBgPath, cardBackPicturePath;
|
QString handBgPath, stackBgPath, tableBgPath, playerBgPath, cardBackPicturePath;
|
||||||
bool picDownload;
|
bool picDownload;
|
||||||
bool doubleClickToPlay;
|
bool doubleClickToPlay;
|
||||||
bool cardInfoMinimized;
|
bool cardInfoMinimized;
|
||||||
|
@ -40,6 +41,7 @@ public:
|
||||||
QString getPicsPath() const { return picsPath; }
|
QString getPicsPath() const { return picsPath; }
|
||||||
QString getCardDatabasePath() const { return cardDatabasePath; }
|
QString getCardDatabasePath() const { return cardDatabasePath; }
|
||||||
QString getHandBgPath() const { return handBgPath; }
|
QString getHandBgPath() const { return handBgPath; }
|
||||||
|
QString getStackBgPath() const { return stackBgPath; }
|
||||||
QString getTableBgPath() const { return tableBgPath; }
|
QString getTableBgPath() const { return tableBgPath; }
|
||||||
QString getPlayerBgPath() const { return playerBgPath; }
|
QString getPlayerBgPath() const { return playerBgPath; }
|
||||||
QString getCardBackPicturePath() const { return cardBackPicturePath; }
|
QString getCardBackPicturePath() const { return cardBackPicturePath; }
|
||||||
|
@ -58,6 +60,7 @@ public slots:
|
||||||
void setPicsPath(const QString &_picsPath);
|
void setPicsPath(const QString &_picsPath);
|
||||||
void setCardDatabasePath(const QString &_cardDatabasePath);
|
void setCardDatabasePath(const QString &_cardDatabasePath);
|
||||||
void setHandBgPath(const QString &_handBgPath);
|
void setHandBgPath(const QString &_handBgPath);
|
||||||
|
void setStackBgPath(const QString &_stackBgPath);
|
||||||
void setTableBgPath(const QString &_tableBgPath);
|
void setTableBgPath(const QString &_tableBgPath);
|
||||||
void setPlayerBgPath(const QString &_playerBgPath);
|
void setPlayerBgPath(const QString &_playerBgPath);
|
||||||
void setCardBackPicturePath(const QString &_cardBackPicturePath);
|
void setCardBackPicturePath(const QString &_cardBackPicturePath);
|
||||||
|
|
84
cockatrice/src/stackzone.cpp
Normal file
84
cockatrice/src/stackzone.cpp
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
#include <QPainter>
|
||||||
|
#include "stackzone.h"
|
||||||
|
#include "settingscache.h"
|
||||||
|
#include "player.h"
|
||||||
|
#include "protocol_items.h"
|
||||||
|
|
||||||
|
StackZone::StackZone(Player *_p, int _zoneHeight, QGraphicsItem *parent)
|
||||||
|
: CardZone(_p, "stack", false, false, true, parent), zoneHeight(_zoneHeight)
|
||||||
|
{
|
||||||
|
connect(settingsCache, SIGNAL(stackBgPathChanged()), this, SLOT(updateBgPixmap()));
|
||||||
|
updateBgPixmap();
|
||||||
|
setCacheMode(DeviceCoordinateCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
void StackZone::updateBgPixmap()
|
||||||
|
{
|
||||||
|
QString bgPath = settingsCache->getStackBgPath();
|
||||||
|
if (!bgPath.isEmpty())
|
||||||
|
bgPixmap.load(bgPath);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void StackZone::addCardImpl(CardItem *card, int x, int /*y*/)
|
||||||
|
{
|
||||||
|
if (x == -1)
|
||||||
|
x = cards.size();
|
||||||
|
cards.insert(x, card);
|
||||||
|
|
||||||
|
if (!cards.getContentsKnown()) {
|
||||||
|
card->setId(-1);
|
||||||
|
card->setName();
|
||||||
|
}
|
||||||
|
card->setParentItem(this);
|
||||||
|
card->resetState();
|
||||||
|
card->setVisible(true);
|
||||||
|
card->update();
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF StackZone::boundingRect() const
|
||||||
|
{
|
||||||
|
return QRectF(0, 0, 100, zoneHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
void StackZone::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
|
||||||
|
{
|
||||||
|
if (bgPixmap.isNull())
|
||||||
|
painter->fillRect(boundingRect(), Qt::darkBlue);
|
||||||
|
else
|
||||||
|
painter->fillRect(boundingRect(), QBrush(bgPixmap));
|
||||||
|
}
|
||||||
|
|
||||||
|
void StackZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint &/*dropPoint*/, bool /*faceDown*/)
|
||||||
|
{
|
||||||
|
if (startZone == this)
|
||||||
|
return;
|
||||||
|
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), cardId, getName(), 0, 0, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
void StackZone::reorganizeCards()
|
||||||
|
{
|
||||||
|
if (!cards.isEmpty()) {
|
||||||
|
const int cardCount = cards.size();
|
||||||
|
qreal totalWidth = boundingRect().width();
|
||||||
|
qreal totalHeight = boundingRect().height();
|
||||||
|
qreal cardWidth = cards.at(0)->boundingRect().width();
|
||||||
|
qreal cardHeight = cards.at(0)->boundingRect().height();
|
||||||
|
qreal xspace = 5;
|
||||||
|
qreal x1 = xspace;
|
||||||
|
qreal x2 = totalWidth - xspace - cardWidth;
|
||||||
|
|
||||||
|
for (int i = 0; i < cardCount; i++) {
|
||||||
|
CardItem *c = cards.at(i);
|
||||||
|
qreal x = i % 2 ? x2 : x1;
|
||||||
|
// If the total height of the cards is smaller than the available height,
|
||||||
|
// the cards do not need to overlap and are displayed in the center of the area.
|
||||||
|
if (cardHeight * cardCount > totalHeight)
|
||||||
|
c->setPos(x, ((qreal) i) * (totalHeight - cardHeight) / (cardCount - 1));
|
||||||
|
else
|
||||||
|
c->setPos(x, ((qreal) i) * cardHeight + (totalHeight - cardCount * cardHeight) / 2);
|
||||||
|
c->setZValue(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
update();
|
||||||
|
}
|
24
cockatrice/src/stackzone.h
Normal file
24
cockatrice/src/stackzone.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#ifndef STACKZONE_H
|
||||||
|
#define STACKZONE_H
|
||||||
|
|
||||||
|
#include "cardzone.h"
|
||||||
|
|
||||||
|
class StackZone : public CardZone {
|
||||||
|
Q_OBJECT
|
||||||
|
private:
|
||||||
|
qreal zoneHeight;
|
||||||
|
QPixmap bgPixmap;
|
||||||
|
private slots:
|
||||||
|
void updateBgPixmap();
|
||||||
|
public:
|
||||||
|
StackZone(Player *_p, int _zoneHeight, QGraphicsItem *parent = 0);
|
||||||
|
void handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint, bool faceDown);
|
||||||
|
QRectF boundingRect() const;
|
||||||
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
void reorganizeCards();
|
||||||
|
protected:
|
||||||
|
void addCardImpl(CardItem *card, int x, int y);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -693,6 +693,7 @@ Player *TabGame::getActiveLocalPlayer() const
|
||||||
void TabGame::showCardInfoPopup(const QPoint &pos, const QString &cardName)
|
void TabGame::showCardInfoPopup(const QPoint &pos, const QString &cardName)
|
||||||
{
|
{
|
||||||
infoPopup = new CardInfoWidget(CardInfoWidget::ModePopUp, 0, Qt::Widget | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint | Qt::WindowStaysOnTopHint);
|
infoPopup = new CardInfoWidget(CardInfoWidget::ModePopUp, 0, Qt::Widget | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint | Qt::WindowStaysOnTopHint);
|
||||||
|
connect(infoPopup, SIGNAL(mouseReleased()), this, SLOT(deleteCardInfoPopup()));
|
||||||
infoPopup->setCard(cardName);
|
infoPopup->setCard(cardName);
|
||||||
QRect screenRect = qApp->desktop()->screenGeometry(this);
|
QRect screenRect = qApp->desktop()->screenGeometry(this);
|
||||||
infoPopup->move(
|
infoPopup->move(
|
||||||
|
@ -700,6 +701,7 @@ void TabGame::showCardInfoPopup(const QPoint &pos, const QString &cardName)
|
||||||
qMax(screenRect.top(), qMin(pos.y() - infoPopup->height() / 2, screenRect.top() + screenRect.height() - infoPopup->height()))
|
qMax(screenRect.top(), qMin(pos.y() - infoPopup->height() / 2, screenRect.top() + screenRect.height() - infoPopup->height()))
|
||||||
);
|
);
|
||||||
infoPopup->show();
|
infoPopup->show();
|
||||||
|
infoPopup->grabMouse();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabGame::deleteCardInfoPopup()
|
void TabGame::deleteCardInfoPopup()
|
||||||
|
|
|
@ -17,9 +17,9 @@ TableZone::TableZone(Player *_p, QGraphicsItem *parent)
|
||||||
updateBgPixmap();
|
updateBgPixmap();
|
||||||
|
|
||||||
if (settingsCache->getEconomicalGrid())
|
if (settingsCache->getEconomicalGrid())
|
||||||
height = 2 * boxLineWidth + (int) (14.0 / 3 * CARD_HEIGHT + 3 * paddingY);
|
height = 2 * boxLineWidth + (int) (11.0 / 3 * CARD_HEIGHT + 2 * paddingY);
|
||||||
else
|
else
|
||||||
height = 2 * boxLineWidth + 4 * CARD_HEIGHT + 3 * paddingY;
|
height = 2 * boxLineWidth + 3 * CARD_HEIGHT + 2 * paddingY;
|
||||||
width = minWidth + 2 * marginX + 2 * boxLineWidth;
|
width = minWidth + 2 * marginX + 2 * boxLineWidth;
|
||||||
currentMinimumWidth = minWidth;
|
currentMinimumWidth = minWidth;
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ void TableZone::paint(QPainter *painter, const QStyleOptionGraphicsItem */*optio
|
||||||
else
|
else
|
||||||
painter->fillRect(boundingRect(), QBrush(bgPixmap));
|
painter->fillRect(boundingRect(), QBrush(bgPixmap));
|
||||||
painter->setPen(QColor(255, 255, 255, 40));
|
painter->setPen(QColor(255, 255, 255, 40));
|
||||||
qreal separatorY = 3 * (CARD_HEIGHT + paddingY) + boxLineWidth - paddingY / 2;
|
qreal separatorY = 2 * (CARD_HEIGHT + paddingY) + boxLineWidth - paddingY / 2;
|
||||||
if (isInverted())
|
if (isInverted())
|
||||||
separatorY = height - separatorY;
|
separatorY = height - separatorY;
|
||||||
painter->drawLine(QPointF(0, separatorY), QPointF(width, separatorY));
|
painter->drawLine(QPointF(0, separatorY), QPointF(width, separatorY));
|
||||||
|
@ -216,7 +216,7 @@ CardItem *TableZone::getCardFromCoords(const QPointF &point) const
|
||||||
QPointF TableZone::mapFromGrid(const QPoint &gridPoint) const
|
QPointF TableZone::mapFromGrid(const QPoint &gridPoint) const
|
||||||
{
|
{
|
||||||
qreal x, y;
|
qreal x, y;
|
||||||
if ((gridPoint.y() == 3) && (settingsCache->getEconomicalGrid())) {
|
if ((gridPoint.y() == 2) && (settingsCache->getEconomicalGrid())) {
|
||||||
x = marginX + (CARD_WIDTH * gridPoint.x() + CARD_WIDTH * (gridPoint.x() / 3)) / 2;
|
x = marginX + (CARD_WIDTH * gridPoint.x() + CARD_WIDTH * (gridPoint.x() / 3)) / 2;
|
||||||
y = boxLineWidth + (CARD_HEIGHT + paddingY) * gridPoint.y() + (gridPoint.x() % 3 * CARD_HEIGHT) / 3;
|
y = boxLineWidth + (CARD_HEIGHT + paddingY) * gridPoint.y() + (gridPoint.x() % 3 * CARD_HEIGHT) / 3;
|
||||||
} else {
|
} else {
|
||||||
|
@ -251,10 +251,10 @@ QPoint TableZone::mapToGrid(const QPointF &mapPoint) const
|
||||||
|
|
||||||
int resultY = (int) (y / (CARD_HEIGHT + paddingY));
|
int resultY = (int) (y / (CARD_HEIGHT + paddingY));
|
||||||
|
|
||||||
if ((resultY == 3) && (settingsCache->getEconomicalGrid()))
|
if ((resultY == 2) && (settingsCache->getEconomicalGrid()))
|
||||||
return QPoint(
|
return QPoint(
|
||||||
(int) (x * 2 / CARD_WIDTH - floor(x / (2 * CARD_WIDTH))),
|
(int) (x * 2 / CARD_WIDTH - floor(x / (2 * CARD_WIDTH))),
|
||||||
3
|
2
|
||||||
);
|
);
|
||||||
else {
|
else {
|
||||||
int resultX = -1;
|
int resultX = -1;
|
||||||
|
|
|
@ -64,6 +64,7 @@ void Server_Player::setupZones()
|
||||||
addZone(sbZone);
|
addZone(sbZone);
|
||||||
addZone(new Server_CardZone(this, "table", true, PublicZone));
|
addZone(new Server_CardZone(this, "table", true, PublicZone));
|
||||||
addZone(new Server_CardZone(this, "hand", false, PrivateZone));
|
addZone(new Server_CardZone(this, "hand", false, PrivateZone));
|
||||||
|
addZone(new Server_CardZone(this, "stack", false, PublicZone));
|
||||||
addZone(new Server_CardZone(this, "grave", false, PublicZone));
|
addZone(new Server_CardZone(this, "grave", false, PublicZone));
|
||||||
addZone(new Server_CardZone(this, "rfg", false, PublicZone));
|
addZone(new Server_CardZone(this, "rfg", false, PublicZone));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue