optional setting for horizonal hand display
This commit is contained in:
parent
33606f55ce
commit
e6e20cb048
19 changed files with 275 additions and 76 deletions
|
@ -20,6 +20,8 @@ HEADERS += src/counter.h \
|
||||||
src/carditem.h \
|
src/carditem.h \
|
||||||
src/tablezone.h \
|
src/tablezone.h \
|
||||||
src/handzone.h \
|
src/handzone.h \
|
||||||
|
src/handzone_vert.h \
|
||||||
|
src/handzone_horiz.h \
|
||||||
src/carddatabase.h \
|
src/carddatabase.h \
|
||||||
src/gameview.h \
|
src/gameview.h \
|
||||||
src/deck_picturecacher.h \
|
src/deck_picturecacher.h \
|
||||||
|
@ -73,6 +75,8 @@ SOURCES += src/counter.cpp \
|
||||||
src/carditem.cpp \
|
src/carditem.cpp \
|
||||||
src/tablezone.cpp \
|
src/tablezone.cpp \
|
||||||
src/handzone.cpp \
|
src/handzone.cpp \
|
||||||
|
src/handzone_vert.cpp \
|
||||||
|
src/handzone_horiz.cpp \
|
||||||
src/carddatabase.cpp \
|
src/carddatabase.cpp \
|
||||||
src/gameview.cpp \
|
src/gameview.cpp \
|
||||||
src/deck_picturecacher.cpp \
|
src/deck_picturecacher.cpp \
|
||||||
|
|
|
@ -199,6 +199,16 @@ AppearanceSettingsPage::AppearanceSettingsPage()
|
||||||
zoneBgGroupBox = new QGroupBox;
|
zoneBgGroupBox = new QGroupBox;
|
||||||
zoneBgGroupBox->setLayout(zoneBgGrid);
|
zoneBgGroupBox->setLayout(zoneBgGrid);
|
||||||
|
|
||||||
|
horizontalHandCheckBox = new QCheckBox;
|
||||||
|
horizontalHandCheckBox->setChecked(settingsCache->getHorizontalHand());
|
||||||
|
connect(horizontalHandCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setHorizontalHand(int)));
|
||||||
|
|
||||||
|
QGridLayout *handGrid = new QGridLayout;
|
||||||
|
handGrid->addWidget(horizontalHandCheckBox, 0, 0, 1, 2);
|
||||||
|
|
||||||
|
handGroupBox = new QGroupBox;
|
||||||
|
handGroupBox->setLayout(handGrid);
|
||||||
|
|
||||||
economicGridCheckBox = new QCheckBox;
|
economicGridCheckBox = new QCheckBox;
|
||||||
economicGridCheckBox->setChecked(settingsCache->getEconomicGrid());
|
economicGridCheckBox->setChecked(settingsCache->getEconomicGrid());
|
||||||
connect(economicGridCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setEconomicGrid(int)));
|
connect(economicGridCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setEconomicGrid(int)));
|
||||||
|
@ -225,6 +235,7 @@ AppearanceSettingsPage::AppearanceSettingsPage()
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addWidget(zoneBgGroupBox);
|
mainLayout->addWidget(zoneBgGroupBox);
|
||||||
|
mainLayout->addWidget(handGroupBox);
|
||||||
mainLayout->addWidget(tableGroupBox);
|
mainLayout->addWidget(tableGroupBox);
|
||||||
mainLayout->addWidget(zoneViewGroupBox);
|
mainLayout->addWidget(zoneViewGroupBox);
|
||||||
|
|
||||||
|
@ -239,6 +250,9 @@ void AppearanceSettingsPage::retranslateUi()
|
||||||
tableBgLabel->setText(tr("Path to table background:"));
|
tableBgLabel->setText(tr("Path to table background:"));
|
||||||
playerAreaBgLabel->setText(tr("Path to player info background:"));
|
playerAreaBgLabel->setText(tr("Path to player info background:"));
|
||||||
|
|
||||||
|
handGroupBox->setTitle(tr("Hand layout"));
|
||||||
|
horizontalHandCheckBox->setText(tr("Display hand horizontally (wastes space)"));
|
||||||
|
|
||||||
tableGroupBox->setTitle(tr("Table grid layout"));
|
tableGroupBox->setTitle(tr("Table grid layout"));
|
||||||
economicGridCheckBox->setText(tr("Economic layout"));
|
economicGridCheckBox->setText(tr("Economic layout"));
|
||||||
|
|
||||||
|
|
|
@ -60,8 +60,8 @@ signals:
|
||||||
private:
|
private:
|
||||||
QLabel *handBgLabel, *tableBgLabel, *playerAreaBgLabel;
|
QLabel *handBgLabel, *tableBgLabel, *playerAreaBgLabel;
|
||||||
QLineEdit *handBgEdit, *tableBgEdit, *playerAreaBgEdit;
|
QLineEdit *handBgEdit, *tableBgEdit, *playerAreaBgEdit;
|
||||||
QCheckBox *economicGridCheckBox, *zoneViewSortByNameCheckBox, *zoneViewSortByTypeCheckBox;
|
QCheckBox *horizontalHandCheckBox, *economicGridCheckBox, *zoneViewSortByNameCheckBox, *zoneViewSortByTypeCheckBox;
|
||||||
QGroupBox *zoneBgGroupBox, *tableGroupBox, *zoneViewGroupBox;
|
QGroupBox *zoneBgGroupBox, *handGroupBox, *tableGroupBox, *zoneViewGroupBox;
|
||||||
public:
|
public:
|
||||||
AppearanceSettingsPage();
|
AppearanceSettingsPage();
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
|
|
|
@ -103,3 +103,26 @@ void GameScene::closeMostRecentZoneView()
|
||||||
if (!views.isEmpty())
|
if (!views.isEmpty())
|
||||||
views.last()->close();
|
views.last()->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameScene::processViewSizeChange(const QSize &newSize)
|
||||||
|
{
|
||||||
|
qreal newRatio = ((qreal) newSize.width()) / newSize.height();
|
||||||
|
qreal minWidth = 0;
|
||||||
|
for (int i = 0; i < players.size(); ++i) {
|
||||||
|
qreal w = players[i]->getMinimumWidth();
|
||||||
|
if (w > minWidth)
|
||||||
|
minWidth = w;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal minRatio = minWidth / sceneRect().height();
|
||||||
|
if (minRatio > newRatio) {
|
||||||
|
// Aspect ratio is dominated by table width.
|
||||||
|
setSceneRect(sceneRect().x(), sceneRect().y(), minWidth, sceneRect().height());
|
||||||
|
} else {
|
||||||
|
// Aspect ratio is dominated by window dimensions.
|
||||||
|
setSceneRect(sceneRect().x(), sceneRect().y(), newRatio * sceneRect().height(), sceneRect().height());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < players.size(); ++i)
|
||||||
|
players[i]->processSceneSizeChange(sceneRect().size());
|
||||||
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ public:
|
||||||
GameScene(QObject *parent = 0);
|
GameScene(QObject *parent = 0);
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
const QRectF &getPlayersRect() const { return playersRect; }
|
const QRectF &getPlayersRect() const { return playersRect; }
|
||||||
|
void processViewSizeChange(const QSize &newSize);
|
||||||
public slots:
|
public slots:
|
||||||
void toggleZoneView(Player *player, const QString &zoneName, int numberCards);
|
void toggleZoneView(Player *player, const QString &zoneName, int numberCards);
|
||||||
void removeZoneView(ZoneViewWidget *item);
|
void removeZoneView(ZoneViewWidget *item);
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "gameview.h"
|
#include "gameview.h"
|
||||||
|
#include "gamescene.h"
|
||||||
|
#include <QResizeEvent>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
|
||||||
GameView::GameView(QGraphicsScene *scene, QWidget *parent)
|
GameView::GameView(QGraphicsScene *scene, QWidget *parent)
|
||||||
|
@ -21,6 +23,10 @@ GameView::GameView(QGraphicsScene *scene, QWidget *parent)
|
||||||
void GameView::resizeEvent(QResizeEvent *event)
|
void GameView::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
QGraphicsView::resizeEvent(event);
|
QGraphicsView::resizeEvent(event);
|
||||||
|
GameScene *s = dynamic_cast<GameScene *>(scene());
|
||||||
|
if (s) {
|
||||||
|
s->processViewSizeChange(event->size());
|
||||||
|
}
|
||||||
updateSceneRect(scene()->sceneRect());
|
updateSceneRect(scene()->sceneRect());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,13 @@
|
||||||
#include <QtGui>
|
|
||||||
#include "handzone.h"
|
#include "handzone.h"
|
||||||
#include "player.h"
|
|
||||||
#include "client.h"
|
|
||||||
#include "protocol_items.h"
|
|
||||||
#include "settingscache.h"
|
#include "settingscache.h"
|
||||||
|
#include "player.h"
|
||||||
|
#include "protocol_items.h"
|
||||||
|
|
||||||
HandZone::HandZone(Player *_p, bool _contentsKnown, int _zoneHeight, QGraphicsItem *parent)
|
HandZone::HandZone(Player *_p, bool _contentsKnown, QGraphicsItem *parent)
|
||||||
: CardZone(_p, "hand", false, false, _contentsKnown, parent), zoneHeight(_zoneHeight)
|
: CardZone(_p, "hand", false, false, _contentsKnown, parent)
|
||||||
{
|
{
|
||||||
connect(settingsCache, SIGNAL(handBgPathChanged()), this, SLOT(updateBgPixmap()));
|
connect(settingsCache, SIGNAL(handBgPathChanged()), this, SLOT(updateBgPixmap()));
|
||||||
updateBgPixmap();
|
updateBgPixmap();
|
||||||
|
|
||||||
setCacheMode(DeviceCoordinateCache);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandZone::updateBgPixmap()
|
void HandZone::updateBgPixmap()
|
||||||
|
@ -22,46 +18,6 @@ void HandZone::updateBgPixmap()
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF HandZone::boundingRect() const
|
|
||||||
{
|
|
||||||
return QRectF(0, 0, 100, zoneHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HandZone::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
|
|
||||||
{
|
|
||||||
if (bgPixmap.isNull())
|
|
||||||
painter->fillRect(boundingRect(), Qt::darkGreen);
|
|
||||||
else
|
|
||||||
painter->fillRect(boundingRect(), QBrush(bgPixmap));
|
|
||||||
}
|
|
||||||
|
|
||||||
void HandZone::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();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HandZone::addCardImpl(CardItem *card, int x, int /*y*/)
|
void HandZone::addCardImpl(CardItem *card, int x, int /*y*/)
|
||||||
{
|
{
|
||||||
if (x == -1)
|
if (x == -1)
|
||||||
|
|
|
@ -5,19 +5,17 @@
|
||||||
|
|
||||||
class HandZone : public CardZone {
|
class HandZone : public CardZone {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
protected:
|
||||||
QPixmap bgPixmap;
|
QPixmap bgPixmap;
|
||||||
int zoneHeight;
|
private slots:
|
||||||
private slots:
|
|
||||||
void updateBgPixmap();
|
void updateBgPixmap();
|
||||||
public:
|
public:
|
||||||
HandZone(Player *_p, bool _contentsKnown, int _zoneHeight, QGraphicsItem *parent = 0);
|
HandZone(Player *_p, bool _contentsKnown, QGraphicsItem *parent = 0);
|
||||||
QRectF boundingRect() const;
|
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
|
||||||
void reorganizeCards();
|
|
||||||
void handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint, bool faceDown);
|
void handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint, bool faceDown);
|
||||||
|
virtual void setWidth(qreal _width) = 0;
|
||||||
protected:
|
protected:
|
||||||
void addCardImpl(CardItem *card, int x, int y);
|
void addCardImpl(CardItem *card, int x, int y);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
52
cockatrice/src/handzone_horiz.cpp
Normal file
52
cockatrice/src/handzone_horiz.cpp
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
#include <QPainter>
|
||||||
|
#include "handzone_horiz.h"
|
||||||
|
#include "player.h"
|
||||||
|
|
||||||
|
HandZoneHoriz::HandZoneHoriz(Player *_p, bool _contentsKnown, QGraphicsItem *parent)
|
||||||
|
: HandZone(_p, _contentsKnown, parent), width(CARD_WIDTH * 10)
|
||||||
|
{
|
||||||
|
setCacheMode(DeviceCoordinateCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF HandZoneHoriz::boundingRect() const
|
||||||
|
{
|
||||||
|
return QRectF(0, 0, width, CARD_HEIGHT + 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HandZoneHoriz::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
|
||||||
|
{
|
||||||
|
if (bgPixmap.isNull())
|
||||||
|
painter->fillRect(boundingRect(), Qt::darkGreen);
|
||||||
|
else
|
||||||
|
painter->fillRect(boundingRect(), QBrush(bgPixmap));
|
||||||
|
}
|
||||||
|
|
||||||
|
void HandZoneHoriz::reorganizeCards()
|
||||||
|
{
|
||||||
|
if (!cards.isEmpty()) {
|
||||||
|
const int cardCount = cards.size();
|
||||||
|
const int xPadding = 5;
|
||||||
|
qreal totalWidth = boundingRect().width() - 2 * xPadding;
|
||||||
|
qreal cardWidth = cards.at(0)->boundingRect().width();
|
||||||
|
|
||||||
|
for (int i = 0; i < cardCount; i++) {
|
||||||
|
CardItem *c = cards.at(i);
|
||||||
|
|
||||||
|
// If the total width of the cards is smaller than the available width,
|
||||||
|
// the cards do not need to overlap and are displayed in the center of the area.
|
||||||
|
if (cardWidth * cardCount > totalWidth)
|
||||||
|
c->setPos(xPadding + ((qreal) i) * (totalWidth - cardWidth) / (cardCount - 1), 5);
|
||||||
|
else
|
||||||
|
c->setPos(xPadding + ((qreal) i) * cardWidth + (totalWidth - cardCount * cardWidth) / 2, 5);
|
||||||
|
c->setZValue(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HandZoneHoriz::setWidth(qreal _width)
|
||||||
|
{
|
||||||
|
prepareGeometryChange();
|
||||||
|
width = _width;
|
||||||
|
reorganizeCards();
|
||||||
|
}
|
18
cockatrice/src/handzone_horiz.h
Normal file
18
cockatrice/src/handzone_horiz.h
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#ifndef HANDZONE_HORIZ_H
|
||||||
|
#define HANDZONE_HORIZ_H
|
||||||
|
|
||||||
|
#include "handzone.h"
|
||||||
|
|
||||||
|
class HandZoneHoriz : public HandZone {
|
||||||
|
Q_OBJECT
|
||||||
|
private:
|
||||||
|
qreal width;
|
||||||
|
public:
|
||||||
|
HandZoneHoriz(Player *_p, bool _contentsKnown, QGraphicsItem *parent = 0);
|
||||||
|
QRectF boundingRect() const;
|
||||||
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
void reorganizeCards();
|
||||||
|
void setWidth(qreal _width);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
52
cockatrice/src/handzone_vert.cpp
Normal file
52
cockatrice/src/handzone_vert.cpp
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
#include <QtGui>
|
||||||
|
#include "handzone_vert.h"
|
||||||
|
#include "player.h"
|
||||||
|
#include "client.h"
|
||||||
|
#include "protocol_items.h"
|
||||||
|
#include "settingscache.h"
|
||||||
|
|
||||||
|
HandZoneVert::HandZoneVert(Player *_p, bool _contentsKnown, int _zoneHeight, QGraphicsItem *parent)
|
||||||
|
: HandZone(_p, _contentsKnown, parent), zoneHeight(_zoneHeight)
|
||||||
|
{
|
||||||
|
setCacheMode(DeviceCoordinateCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF HandZoneVert::boundingRect() const
|
||||||
|
{
|
||||||
|
return QRectF(0, 0, 100, zoneHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HandZoneVert::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
|
||||||
|
{
|
||||||
|
if (bgPixmap.isNull())
|
||||||
|
painter->fillRect(boundingRect(), Qt::darkGreen);
|
||||||
|
else
|
||||||
|
painter->fillRect(boundingRect(), QBrush(bgPixmap));
|
||||||
|
}
|
||||||
|
|
||||||
|
void HandZoneVert::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();
|
||||||
|
}
|
18
cockatrice/src/handzone_vert.h
Normal file
18
cockatrice/src/handzone_vert.h
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#ifndef HANDZONE_VERT_H
|
||||||
|
#define HANDZONE_VERT_H
|
||||||
|
|
||||||
|
#include "handzone.h"
|
||||||
|
|
||||||
|
class HandZoneVert : public HandZone {
|
||||||
|
Q_OBJECT
|
||||||
|
private:
|
||||||
|
int zoneHeight;
|
||||||
|
public:
|
||||||
|
HandZoneVert(Player *_p, bool _contentsKnown, int _zoneHeight, QGraphicsItem *parent = 0);
|
||||||
|
QRectF boundingRect() const;
|
||||||
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
void reorganizeCards();
|
||||||
|
void setWidth(qreal /*_width*/) { }
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -7,7 +7,8 @@
|
||||||
#include "zoneviewwidget.h"
|
#include "zoneviewwidget.h"
|
||||||
#include "pilezone.h"
|
#include "pilezone.h"
|
||||||
#include "tablezone.h"
|
#include "tablezone.h"
|
||||||
#include "handzone.h"
|
#include "handzone_vert.h"
|
||||||
|
#include "handzone_horiz.h"
|
||||||
#include "cardlist.h"
|
#include "cardlist.h"
|
||||||
#include "tab_game.h"
|
#include "tab_game.h"
|
||||||
#include "protocol_items.h"
|
#include "protocol_items.h"
|
||||||
|
@ -17,8 +18,8 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
Player::Player(const QString &_name, int _id, bool _local, Client *_client, TabGame *_parent)
|
Player::Player(const QString &_name, int _id, bool _local, bool _mirrored, Client *_client, TabGame *_parent)
|
||||||
: QObject(_parent), defaultNumberTopCards(3), name(_name), id(_id), active(false), local(_local), client(_client)
|
: QObject(_parent), defaultNumberTopCards(3), name(_name), id(_id), active(false), local(_local), mirrored(_mirrored), client(_client)
|
||||||
{
|
{
|
||||||
setCacheMode(DeviceCoordinateCache);
|
setCacheMode(DeviceCoordinateCache);
|
||||||
|
|
||||||
|
@ -43,12 +44,25 @@ Player::Player(const QString &_name, int _id, bool _local, Client *_client, TabG
|
||||||
|
|
||||||
table = new TableZone(this, this);
|
table = new TableZone(this, this);
|
||||||
connect(table, SIGNAL(sizeChanged()), this, SLOT(updateBoundingRect()));
|
connect(table, SIGNAL(sizeChanged()), this, SLOT(updateBoundingRect()));
|
||||||
hand = new HandZone(this, _local || (_parent->getSpectator() && _parent->getSpectatorsSeeEverything()), (int) table->boundingRect().height(), this);
|
|
||||||
|
|
||||||
base = QPointF(deck->boundingRect().width() + counterAreaWidth + 5, 0);
|
base = QPointF(deck->boundingRect().width() + counterAreaWidth + 5, 0);
|
||||||
hand->setPos(base);
|
|
||||||
base += QPointF(hand->boundingRect().width(), 0);
|
if (settingsCache->getHorizontalHand()) {
|
||||||
table->setPos(base);
|
hand = new HandZoneHoriz(this, _local || (_parent->getSpectator() && _parent->getSpectatorsSeeEverything()), this);
|
||||||
|
|
||||||
|
if (mirrored) {
|
||||||
|
hand->setPos(counterAreaWidth + CARD_WIDTH + 5, base.y());
|
||||||
|
table->setPos(base.x(), base.y() + hand->boundingRect().height());
|
||||||
|
} else {
|
||||||
|
table->setPos(base);
|
||||||
|
hand->setPos(counterAreaWidth + CARD_WIDTH + 5, base.y() + table->boundingRect().height());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
hand = new HandZoneVert(this, _local || (_parent->getSpectator() && _parent->getSpectatorsSeeEverything()), (int) table->boundingRect().height(), this);
|
||||||
|
hand->setPos(base);
|
||||||
|
base += QPointF(hand->boundingRect().width(), 0);
|
||||||
|
table->setPos(base);
|
||||||
|
}
|
||||||
|
|
||||||
updateBoundingRect();
|
updateBoundingRect();
|
||||||
|
|
||||||
|
@ -281,7 +295,10 @@ void Player::updateBgPixmap()
|
||||||
void Player::updateBoundingRect()
|
void Player::updateBoundingRect()
|
||||||
{
|
{
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
bRect = QRectF(0, 0, CARD_WIDTH + 5 + counterAreaWidth + hand->boundingRect().width() + table->boundingRect().width(), table->boundingRect().height());
|
if (settingsCache->getHorizontalHand())
|
||||||
|
bRect = QRectF(0, 0, CARD_WIDTH + 5 + counterAreaWidth + table->boundingRect().width(), table->boundingRect().height() + hand->boundingRect().height());
|
||||||
|
else
|
||||||
|
bRect = QRectF(0, 0, CARD_WIDTH + 5 + counterAreaWidth + hand->boundingRect().width() + table->boundingRect().width(), table->boundingRect().height());
|
||||||
emit sizeChanged();
|
emit sizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -707,17 +724,16 @@ QRectF Player::boundingRect() const
|
||||||
|
|
||||||
void Player::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
|
void Player::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
|
||||||
{
|
{
|
||||||
if (bgPixmap.isNull())
|
|
||||||
painter->fillRect(boundingRect(), QColor(200, 200, 200));
|
|
||||||
else
|
|
||||||
painter->fillRect(boundingRect(), QBrush(bgPixmap));
|
|
||||||
|
|
||||||
QString nameStr = getName();
|
QString nameStr = getName();
|
||||||
QFont font("Times");
|
QFont font("Times");
|
||||||
font.setPixelSize(20);
|
font.setPixelSize(20);
|
||||||
// font.setWeight(QFont::Bold);
|
// font.setWeight(QFont::Bold);
|
||||||
|
|
||||||
int totalWidth = CARD_WIDTH + counterAreaWidth + 5;
|
int totalWidth = CARD_WIDTH + counterAreaWidth + 5;
|
||||||
|
if (bgPixmap.isNull())
|
||||||
|
painter->fillRect(QRectF(0, 0, totalWidth, boundingRect().height()), QColor(200, 200, 200));
|
||||||
|
else
|
||||||
|
painter->fillRect(QRectF(0, 0, totalWidth, boundingRect().height()), QBrush(bgPixmap));
|
||||||
|
|
||||||
if (getActive()) {
|
if (getActive()) {
|
||||||
QFontMetrics fm(font);
|
QFontMetrics fm(font);
|
||||||
|
@ -995,3 +1011,18 @@ void Player::actMoveToExile(CardItem *card)
|
||||||
CardZone *startZone = qgraphicsitem_cast<CardZone *>(card->parentItem());
|
CardZone *startZone = qgraphicsitem_cast<CardZone *>(card->parentItem());
|
||||||
sendGameCommand(new Command_MoveCard(-1, startZone->getName(), card->getId(), "rfg", 0, 0, false));
|
sendGameCommand(new Command_MoveCard(-1, startZone->getName(), card->getId(), "rfg", 0, 0, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qreal Player::getMinimumWidth() const
|
||||||
|
{
|
||||||
|
return table->getMinimumWidth() + CARD_WIDTH + 5 + counterAreaWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::processSceneSizeChange(const QSizeF &newSize)
|
||||||
|
{
|
||||||
|
// This will need to be changed if player areas are displayed side by side (e.g. 2x2 for a 4-player game)
|
||||||
|
qreal fullPlayerWidth = newSize.width();
|
||||||
|
|
||||||
|
qreal tableWidth = fullPlayerWidth - CARD_WIDTH - 5 - counterAreaWidth;
|
||||||
|
table->setWidth(tableWidth);
|
||||||
|
hand->setWidth(tableWidth);
|
||||||
|
}
|
||||||
|
|
|
@ -112,6 +112,7 @@ private:
|
||||||
int id;
|
int id;
|
||||||
bool active;
|
bool active;
|
||||||
bool local;
|
bool local;
|
||||||
|
bool mirrored;
|
||||||
|
|
||||||
QMap<QString, CardZone *> zones;
|
QMap<QString, CardZone *> zones;
|
||||||
TableZone *table;
|
TableZone *table;
|
||||||
|
@ -164,13 +165,14 @@ public:
|
||||||
void clearArrows();
|
void clearArrows();
|
||||||
|
|
||||||
Client *client;
|
Client *client;
|
||||||
Player(const QString &_name, int _id, bool _local, Client *_client, TabGame *_parent);
|
Player(const QString &_name, int _id, bool _local, bool _mirrored, Client *_client, TabGame *_parent);
|
||||||
~Player();
|
~Player();
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
QMenu *getPlayerMenu() const { return playerMenu; }
|
QMenu *getPlayerMenu() const { return playerMenu; }
|
||||||
int getId() const { return id; }
|
int getId() const { return id; }
|
||||||
QString getName() const { return name; }
|
QString getName() const { return name; }
|
||||||
bool getLocal() const { return local; }
|
bool getLocal() const { return local; }
|
||||||
|
bool getMirrored() const { return mirrored; }
|
||||||
const QMap<QString, CardZone *> &getZones() const { return zones; }
|
const QMap<QString, CardZone *> &getZones() const { return zones; }
|
||||||
const QMap<int, ArrowItem *> &getArrows() const { return arrows; }
|
const QMap<int, ArrowItem *> &getArrows() const { return arrows; }
|
||||||
TableZone *getTable() const { return table; }
|
TableZone *getTable() const { return table; }
|
||||||
|
@ -178,6 +180,9 @@ public:
|
||||||
bool getActive() const { return active; }
|
bool getActive() const { return active; }
|
||||||
void setActive(bool _active);
|
void setActive(bool _active);
|
||||||
|
|
||||||
|
qreal getMinimumWidth() const;
|
||||||
|
void processSceneSizeChange(const QSizeF &newSize);
|
||||||
|
|
||||||
void processPlayerInfo(ServerInfo_Player *info);
|
void processPlayerInfo(ServerInfo_Player *info);
|
||||||
void processGameEvent(GameEvent *event, GameEventContext *context);
|
void processGameEvent(GameEvent *event, GameEventContext *context);
|
||||||
void sendGameCommand(GameCommand *command);
|
void sendGameCommand(GameCommand *command);
|
||||||
|
|
|
@ -17,6 +17,7 @@ SettingsCache::SettingsCache()
|
||||||
|
|
||||||
picDownload = settings->value("personal/picturedownload", false).toBool();
|
picDownload = settings->value("personal/picturedownload", false).toBool();
|
||||||
doubleClickToPlay = settings->value("interface/doubleclicktoplay", true).toBool();
|
doubleClickToPlay = settings->value("interface/doubleclicktoplay", true).toBool();
|
||||||
|
horizontalHand = settings->value("hand/horizontal", false).toBool();
|
||||||
economicGrid = settings->value("table/economic", false).toBool();
|
economicGrid = settings->value("table/economic", false).toBool();
|
||||||
|
|
||||||
zoneViewSortByName = settings->value("zoneview/sortbyname", false).toBool();
|
zoneViewSortByName = settings->value("zoneview/sortbyname", false).toBool();
|
||||||
|
@ -84,6 +85,12 @@ void SettingsCache::setDoubleClickToPlay(int _doubleClickToPlay)
|
||||||
settings->setValue("interface/doubleclicktoplay", doubleClickToPlay);
|
settings->setValue("interface/doubleclicktoplay", doubleClickToPlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsCache::setHorizontalHand(int _horizontalHand)
|
||||||
|
{
|
||||||
|
horizontalHand = _horizontalHand;
|
||||||
|
settings->setValue("hand/horizontal", horizontalHand);
|
||||||
|
}
|
||||||
|
|
||||||
void SettingsCache::setEconomicGrid(int _economicGrid)
|
void SettingsCache::setEconomicGrid(int _economicGrid)
|
||||||
{
|
{
|
||||||
economicGrid = _economicGrid;
|
economicGrid = _economicGrid;
|
||||||
|
|
|
@ -24,6 +24,7 @@ private:
|
||||||
QString handBgPath, tableBgPath, playerBgPath;
|
QString handBgPath, tableBgPath, playerBgPath;
|
||||||
bool picDownload;
|
bool picDownload;
|
||||||
bool doubleClickToPlay;
|
bool doubleClickToPlay;
|
||||||
|
bool horizontalHand;
|
||||||
bool economicGrid;
|
bool economicGrid;
|
||||||
bool zoneViewSortByName, zoneViewSortByType;
|
bool zoneViewSortByName, zoneViewSortByType;
|
||||||
public:
|
public:
|
||||||
|
@ -37,6 +38,7 @@ public:
|
||||||
QString getPlayerBgPath() const { return playerBgPath; }
|
QString getPlayerBgPath() const { return playerBgPath; }
|
||||||
bool getPicDownload() const { return picDownload; }
|
bool getPicDownload() const { return picDownload; }
|
||||||
bool getDoubleClickToPlay() const { return doubleClickToPlay; }
|
bool getDoubleClickToPlay() const { return doubleClickToPlay; }
|
||||||
|
bool getHorizontalHand() const { return horizontalHand; }
|
||||||
bool getEconomicGrid() const { return economicGrid; }
|
bool getEconomicGrid() const { return economicGrid; }
|
||||||
bool getZoneViewSortByName() const { return zoneViewSortByName; }
|
bool getZoneViewSortByName() const { return zoneViewSortByName; }
|
||||||
bool getZoneViewSortByType() const { return zoneViewSortByType; }
|
bool getZoneViewSortByType() const { return zoneViewSortByType; }
|
||||||
|
@ -50,6 +52,7 @@ public slots:
|
||||||
void setPlayerBgPath(const QString &_playerBgPath);
|
void setPlayerBgPath(const QString &_playerBgPath);
|
||||||
void setPicDownload(int _picDownload);
|
void setPicDownload(int _picDownload);
|
||||||
void setDoubleClickToPlay(int _doubleClickToPlay);
|
void setDoubleClickToPlay(int _doubleClickToPlay);
|
||||||
|
void setHorizontalHand(int _horizontalHand);
|
||||||
void setEconomicGrid(int _economicGrid);
|
void setEconomicGrid(int _economicGrid);
|
||||||
void setZoneViewSortByName(int _zoneViewSortByName);
|
void setZoneViewSortByName(int _zoneViewSortByName);
|
||||||
void setZoneViewSortByType(int _zoneViewSortByType);
|
void setZoneViewSortByType(int _zoneViewSortByType);
|
||||||
|
|
|
@ -208,7 +208,8 @@ void TabGame::actRemoveLocalArrows()
|
||||||
|
|
||||||
Player *TabGame::addPlayer(int playerId, const QString &playerName)
|
Player *TabGame::addPlayer(int playerId, const QString &playerName)
|
||||||
{
|
{
|
||||||
Player *newPlayer = new Player(playerName, playerId, playerId == localPlayerId, client, this);
|
// XXX Find a different criterion for the 'mirrored' flag. When spectating, both players are not local, but only one should be mirrored.
|
||||||
|
Player *newPlayer = new Player(playerName, playerId, playerId == localPlayerId, playerId != localPlayerId, client, this);
|
||||||
scene->addPlayer(newPlayer);
|
scene->addPlayer(newPlayer);
|
||||||
|
|
||||||
connect(newPlayer, SIGNAL(newCardAdded(AbstractCardItem *)), this, SLOT(newCardAdded(AbstractCardItem *)));
|
connect(newPlayer, SIGNAL(newCardAdded(AbstractCardItem *)), this, SLOT(newCardAdded(AbstractCardItem *)));
|
||||||
|
|
|
@ -17,6 +17,7 @@ TableZone::TableZone(Player *_p, QGraphicsItem *parent)
|
||||||
else
|
else
|
||||||
height = 4 * CARD_HEIGHT + 3 * paddingY;
|
height = 4 * CARD_HEIGHT + 3 * paddingY;
|
||||||
width = minWidth + 2 * marginX;
|
width = minWidth + 2 * marginX;
|
||||||
|
currentMinimumWidth = minWidth;
|
||||||
|
|
||||||
setCacheMode(DeviceCoordinateCache);
|
setCacheMode(DeviceCoordinateCache);
|
||||||
setAcceptsHoverEvents(true);
|
setAcceptsHoverEvents(true);
|
||||||
|
@ -43,7 +44,7 @@ void TableZone::paint(QPainter *painter, const QStyleOptionGraphicsItem */*optio
|
||||||
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) - paddingY / 2;
|
qreal separatorY = 3 * (CARD_HEIGHT + paddingY) - paddingY / 2;
|
||||||
if (!player->getLocal())
|
if (player->getMirrored())
|
||||||
separatorY = height - separatorY;
|
separatorY = height - separatorY;
|
||||||
painter->drawLine(QPointF(0, separatorY), QPointF(width, separatorY));
|
painter->drawLine(QPointF(0, separatorY), QPointF(width, separatorY));
|
||||||
}
|
}
|
||||||
|
@ -120,10 +121,10 @@ void TableZone::resizeToContents()
|
||||||
xMax += 2 * CARD_WIDTH;
|
xMax += 2 * CARD_WIDTH;
|
||||||
if (xMax < minWidth)
|
if (xMax < minWidth)
|
||||||
xMax = minWidth;
|
xMax = minWidth;
|
||||||
int newWidth = xMax + 2 * marginX;
|
currentMinimumWidth = xMax + 2 * marginX;
|
||||||
if (newWidth != width) {
|
if (currentMinimumWidth > width) {
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
width = newWidth;
|
width = currentMinimumWidth;
|
||||||
emit sizeChanged();
|
emit sizeChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,3 +207,9 @@ QPointF TableZone::closestGridPoint(const QPointF &point)
|
||||||
{
|
{
|
||||||
return mapFromGrid(mapToGrid(point + QPoint(CARD_WIDTH / 2, CARD_HEIGHT / 2)));
|
return mapFromGrid(mapToGrid(point + QPoint(CARD_WIDTH / 2, CARD_HEIGHT / 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TableZone::setWidth(qreal _width)
|
||||||
|
{
|
||||||
|
prepareGeometryChange();
|
||||||
|
width = _width;
|
||||||
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ signals:
|
||||||
void sizeChanged();
|
void sizeChanged();
|
||||||
private:
|
private:
|
||||||
int width, height;
|
int width, height;
|
||||||
|
int currentMinimumWidth;
|
||||||
QPixmap bgPixmap;
|
QPixmap bgPixmap;
|
||||||
private slots:
|
private slots:
|
||||||
void updateBgPixmap();
|
void updateBgPixmap();
|
||||||
|
@ -32,6 +33,8 @@ public:
|
||||||
QPointF closestGridPoint(const QPointF &point);
|
QPointF closestGridPoint(const QPointF &point);
|
||||||
CardItem *takeCard(int position, int cardId, const QString &cardName, bool canResize = true);
|
CardItem *takeCard(int position, int cardId, const QString &cardName, bool canResize = true);
|
||||||
void resizeToContents();
|
void resizeToContents();
|
||||||
|
int getMinimumWidth() const { return currentMinimumWidth; }
|
||||||
|
void setWidth(qreal _width);
|
||||||
protected:
|
protected:
|
||||||
void addCardImpl(CardItem *card, int x, int y);
|
void addCardImpl(CardItem *card, int x, int y);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue