card tap/untap animation; misc fixes
This commit is contained in:
parent
28a77f10e4
commit
db2c2d1b15
9 changed files with 98 additions and 38 deletions
|
@ -3,13 +3,16 @@
|
||||||
#include <QCursor>
|
#include <QCursor>
|
||||||
#include <QStyleOptionGraphicsItem>
|
#include <QStyleOptionGraphicsItem>
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
|
#include <math.h>
|
||||||
#include "carddatabase.h"
|
#include "carddatabase.h"
|
||||||
#include "abstractcarditem.h"
|
#include "abstractcarditem.h"
|
||||||
|
#include "settingscache.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
AbstractCardItem::AbstractCardItem(const QString &_name, Player *_owner, QGraphicsItem *parent)
|
AbstractCardItem::AbstractCardItem(const QString &_name, Player *_owner, QGraphicsItem *parent)
|
||||||
: ArrowTarget(_owner, parent), info(db->getCard(_name)), name(_name), tapped(false)
|
: ArrowTarget(_owner, parent), info(db->getCard(_name)), name(_name), tapped(false), tapAngle(0)
|
||||||
{
|
{
|
||||||
setCursor(Qt::OpenHandCursor);
|
setCursor(Qt::OpenHandCursor);
|
||||||
setFlag(ItemIsSelectable);
|
setFlag(ItemIsSelectable);
|
||||||
|
@ -17,6 +20,10 @@ AbstractCardItem::AbstractCardItem(const QString &_name, Player *_owner, QGraphi
|
||||||
setCacheMode(DeviceCoordinateCache);
|
setCacheMode(DeviceCoordinateCache);
|
||||||
|
|
||||||
connect(info, SIGNAL(pixmapUpdated()), this, SLOT(pixmapUpdated()));
|
connect(info, SIGNAL(pixmapUpdated()), this, SLOT(pixmapUpdated()));
|
||||||
|
|
||||||
|
animationTimer = new QTimer(this);
|
||||||
|
animationTimer->setSingleShot(false);
|
||||||
|
connect(animationTimer, SIGNAL(timeout()), this, SLOT(animationEvent()));
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractCardItem::~AbstractCardItem()
|
AbstractCardItem::~AbstractCardItem()
|
||||||
|
@ -37,19 +44,22 @@ void AbstractCardItem::pixmapUpdated()
|
||||||
void AbstractCardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
|
void AbstractCardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
QSizeF translatedSize = painter->combinedTransform().mapRect(boundingRect()).size();
|
qreal w = painter->combinedTransform().map(QLineF(0, 0, boundingRect().width(), 0)).length();
|
||||||
if (tapped)
|
qreal h = painter->combinedTransform().map(QLineF(0, 0, 0, boundingRect().height())).length();
|
||||||
translatedSize.transpose();
|
QSizeF translatedSize(w, h);
|
||||||
|
QRectF totalBoundingRect = painter->combinedTransform().mapRect(boundingRect());
|
||||||
QPixmap *translatedPixmap = info->getPixmap(translatedSize.toSize());
|
QPixmap *translatedPixmap = info->getPixmap(translatedSize.toSize());
|
||||||
painter->save();
|
painter->save();
|
||||||
if (translatedPixmap) {
|
if (translatedPixmap) {
|
||||||
painter->resetTransform();
|
painter->resetTransform();
|
||||||
if (tapped) {
|
QTransform pixmapTransform;
|
||||||
painter->translate(((qreal) translatedSize.height()) / 2, ((qreal) translatedSize.width()) / 2);
|
pixmapTransform.translate(totalBoundingRect.width() / 2, totalBoundingRect.height() / 2);
|
||||||
painter->rotate(90);
|
pixmapTransform.rotate(tapAngle);
|
||||||
painter->translate(-((qreal) translatedSize.width()) / 2, -((qreal) translatedSize.height()) / 2);
|
QPointF transPoint = QPointF(-w / 2, -h / 2);
|
||||||
}
|
pixmapTransform.translate(transPoint.x(), transPoint.y());
|
||||||
painter->drawPixmap(translatedPixmap->rect(), *translatedPixmap, translatedPixmap->rect());
|
painter->setTransform(pixmapTransform);
|
||||||
|
|
||||||
|
painter->drawPixmap(QPointF(0, 0), *translatedPixmap);
|
||||||
} else {
|
} else {
|
||||||
QFont f("Times");
|
QFont f("Times");
|
||||||
f.setStyleHint(QFont::Serif);
|
f.setStyleHint(QFont::Serif);
|
||||||
|
@ -105,6 +115,21 @@ void AbstractCardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AbstractCardItem::animationEvent()
|
||||||
|
{
|
||||||
|
int delta = 10;
|
||||||
|
if (!tapped)
|
||||||
|
delta *= -1;
|
||||||
|
|
||||||
|
tapAngle += delta;
|
||||||
|
|
||||||
|
setTransform(QTransform().translate((float) CARD_WIDTH / 2, (float) CARD_HEIGHT / 2).rotate(tapAngle).translate((float) -CARD_WIDTH / 2, (float) -CARD_HEIGHT / 2));
|
||||||
|
update();
|
||||||
|
|
||||||
|
if ((tapped && (tapAngle >= 90)) || (!tapped && (tapAngle <= 0)))
|
||||||
|
animationTimer->stop();
|
||||||
|
}
|
||||||
|
|
||||||
void AbstractCardItem::setName(const QString &_name)
|
void AbstractCardItem::setName(const QString &_name)
|
||||||
{
|
{
|
||||||
disconnect(info, 0, this, 0);
|
disconnect(info, 0, this, 0);
|
||||||
|
@ -120,14 +145,19 @@ void AbstractCardItem::setColor(const QString &_color)
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractCardItem::setTapped(bool _tapped)
|
void AbstractCardItem::setTapped(bool _tapped, bool canAnimate)
|
||||||
{
|
{
|
||||||
|
if (tapped == _tapped)
|
||||||
|
return;
|
||||||
|
|
||||||
tapped = _tapped;
|
tapped = _tapped;
|
||||||
if (tapped)
|
if (settingsCache->getTapAnimation() && canAnimate)
|
||||||
setTransform(QTransform().translate((float) CARD_WIDTH / 2, (float) CARD_HEIGHT / 2).rotate(90).translate((float) -CARD_WIDTH / 2, (float) -CARD_HEIGHT / 2));
|
animationTimer->start(25);
|
||||||
else
|
else {
|
||||||
setTransform(QTransform());
|
tapAngle = tapped ? 90 : 0;
|
||||||
|
setTransform(QTransform().translate((float) CARD_WIDTH / 2, (float) CARD_HEIGHT / 2).rotate(tapAngle).translate((float) -CARD_WIDTH / 2, (float) -CARD_HEIGHT / 2));
|
||||||
update();
|
update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractCardItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void AbstractCardItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
class CardInfo;
|
class CardInfo;
|
||||||
class Player;
|
class Player;
|
||||||
|
class QTimer;
|
||||||
|
|
||||||
const int CARD_WIDTH = 72;
|
const int CARD_WIDTH = 72;
|
||||||
const int CARD_HEIGHT = 102;
|
const int CARD_HEIGHT = 102;
|
||||||
|
@ -15,8 +16,12 @@ protected:
|
||||||
CardInfo *info;
|
CardInfo *info;
|
||||||
QString name;
|
QString name;
|
||||||
bool tapped;
|
bool tapped;
|
||||||
|
int tapAngle;
|
||||||
QString color;
|
QString color;
|
||||||
|
private:
|
||||||
|
QTimer *animationTimer;
|
||||||
private slots:
|
private slots:
|
||||||
|
void animationEvent();
|
||||||
void pixmapUpdated();
|
void pixmapUpdated();
|
||||||
signals:
|
signals:
|
||||||
void hovered(AbstractCardItem *card);
|
void hovered(AbstractCardItem *card);
|
||||||
|
@ -33,7 +38,7 @@ public:
|
||||||
QString getColor() const { return color; }
|
QString getColor() const { return color; }
|
||||||
void setColor(const QString &_color);
|
void setColor(const QString &_color);
|
||||||
bool getTapped() const { return tapped; }
|
bool getTapped() const { return tapped; }
|
||||||
void setTapped(bool _tapped);
|
void setTapped(bool _tapped, bool canAnimate = false);
|
||||||
void processHoverEvent();
|
void processHoverEvent();
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
|
@ -252,6 +252,7 @@ CardDatabase::CardDatabase(QObject *parent)
|
||||||
CardDatabase::~CardDatabase()
|
CardDatabase::~CardDatabase()
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
delete noCard;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardDatabase::clear()
|
void CardDatabase::clear()
|
||||||
|
|
|
@ -202,12 +202,12 @@ AppearanceSettingsPage::AppearanceSettingsPage()
|
||||||
handGroupBox = new QGroupBox;
|
handGroupBox = new QGroupBox;
|
||||||
handGroupBox->setLayout(handGrid);
|
handGroupBox->setLayout(handGrid);
|
||||||
|
|
||||||
economicGridCheckBox = new QCheckBox;
|
economicalGridCheckBox = new QCheckBox;
|
||||||
economicGridCheckBox->setChecked(settingsCache->getEconomicGrid());
|
economicalGridCheckBox->setChecked(settingsCache->getEconomicalGrid());
|
||||||
connect(economicGridCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setEconomicGrid(int)));
|
connect(economicalGridCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setEconomicalGrid(int)));
|
||||||
|
|
||||||
QGridLayout *tableGrid = new QGridLayout;
|
QGridLayout *tableGrid = new QGridLayout;
|
||||||
tableGrid->addWidget(economicGridCheckBox, 0, 0, 1, 2);
|
tableGrid->addWidget(economicalGridCheckBox, 0, 0, 1, 2);
|
||||||
|
|
||||||
tableGroupBox = new QGroupBox;
|
tableGroupBox = new QGroupBox;
|
||||||
tableGroupBox->setLayout(tableGrid);
|
tableGroupBox->setLayout(tableGrid);
|
||||||
|
@ -248,7 +248,7 @@ void AppearanceSettingsPage::retranslateUi()
|
||||||
horizontalHandCheckBox->setText(tr("Display hand horizontally (wastes space)"));
|
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"));
|
economicalGridCheckBox->setText(tr("Economical layout"));
|
||||||
|
|
||||||
zoneViewGroupBox->setTitle(tr("Zone view layout"));
|
zoneViewGroupBox->setTitle(tr("Zone view layout"));
|
||||||
zoneViewSortByNameCheckBox->setText(tr("Sort by name"));
|
zoneViewSortByNameCheckBox->setText(tr("Sort by name"));
|
||||||
|
@ -307,8 +307,19 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
||||||
generalGroupBox = new QGroupBox;
|
generalGroupBox = new QGroupBox;
|
||||||
generalGroupBox->setLayout(generalGrid);
|
generalGroupBox->setLayout(generalGrid);
|
||||||
|
|
||||||
|
tapAnimationCheckBox = new QCheckBox;
|
||||||
|
tapAnimationCheckBox->setChecked(settingsCache->getTapAnimation());
|
||||||
|
connect(tapAnimationCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setTapAnimation(int)));
|
||||||
|
|
||||||
|
QGridLayout *animationGrid = new QGridLayout;
|
||||||
|
animationGrid->addWidget(tapAnimationCheckBox, 0, 0);
|
||||||
|
|
||||||
|
animationGroupBox = new QGroupBox;
|
||||||
|
animationGroupBox->setLayout(animationGrid);
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addWidget(generalGroupBox);
|
mainLayout->addWidget(generalGroupBox);
|
||||||
|
mainLayout->addWidget(animationGroupBox);
|
||||||
|
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
}
|
}
|
||||||
|
@ -317,6 +328,8 @@ void UserInterfaceSettingsPage::retranslateUi()
|
||||||
{
|
{
|
||||||
generalGroupBox->setTitle(tr("General interface settings"));
|
generalGroupBox->setTitle(tr("General interface settings"));
|
||||||
doubleClickToPlayCheckBox->setText(tr("&Double-click cards to play them (instead of single-click)"));
|
doubleClickToPlayCheckBox->setText(tr("&Double-click cards to play them (instead of single-click)"));
|
||||||
|
animationGroupBox->setTitle(tr("Animation settings"));
|
||||||
|
tapAnimationCheckBox->setText(tr("&Tap/untap animation"));
|
||||||
}
|
}
|
||||||
|
|
||||||
MessagesSettingsPage::MessagesSettingsPage()
|
MessagesSettingsPage::MessagesSettingsPage()
|
||||||
|
|
|
@ -60,7 +60,7 @@ signals:
|
||||||
private:
|
private:
|
||||||
QLabel *handBgLabel, *tableBgLabel, *playerAreaBgLabel, *cardBackPicturePathLabel;
|
QLabel *handBgLabel, *tableBgLabel, *playerAreaBgLabel, *cardBackPicturePathLabel;
|
||||||
QLineEdit *handBgEdit, *tableBgEdit, *playerAreaBgEdit, *cardBackPicturePathEdit;
|
QLineEdit *handBgEdit, *tableBgEdit, *playerAreaBgEdit, *cardBackPicturePathEdit;
|
||||||
QCheckBox *horizontalHandCheckBox, *economicGridCheckBox, *zoneViewSortByNameCheckBox, *zoneViewSortByTypeCheckBox;
|
QCheckBox *horizontalHandCheckBox, *economicalGridCheckBox, *zoneViewSortByNameCheckBox, *zoneViewSortByTypeCheckBox;
|
||||||
QGroupBox *zoneBgGroupBox, *handGroupBox, *tableGroupBox, *zoneViewGroupBox;
|
QGroupBox *zoneBgGroupBox, *handGroupBox, *tableGroupBox, *zoneViewGroupBox;
|
||||||
public:
|
public:
|
||||||
AppearanceSettingsPage();
|
AppearanceSettingsPage();
|
||||||
|
@ -71,7 +71,8 @@ class UserInterfaceSettingsPage : public AbstractSettingsPage {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
QCheckBox *doubleClickToPlayCheckBox;
|
QCheckBox *doubleClickToPlayCheckBox;
|
||||||
QGroupBox *generalGroupBox;
|
QCheckBox *tapAnimationCheckBox;
|
||||||
|
QGroupBox *generalGroupBox, *animationGroupBox;
|
||||||
public:
|
public:
|
||||||
UserInterfaceSettingsPage();
|
UserInterfaceSettingsPage();
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
|
|
|
@ -526,7 +526,7 @@ void Player::setCardAttrHelper(CardItem *card, const QString &aname, const QStri
|
||||||
if (!(!tapped && card->getDoesntUntap() && allCards)) {
|
if (!(!tapped && card->getDoesntUntap() && allCards)) {
|
||||||
if (!allCards)
|
if (!allCards)
|
||||||
emit logSetTapped(this, card->getName(), tapped);
|
emit logSetTapped(this, card->getName(), tapped);
|
||||||
card->setTapped(tapped);
|
card->setTapped(tapped, true);
|
||||||
}
|
}
|
||||||
} else if (aname == "attacking")
|
} else if (aname == "attacking")
|
||||||
card->setAttacking(avalue == "1");
|
card->setAttacking(avalue == "1");
|
||||||
|
|
|
@ -19,7 +19,8 @@ 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();
|
horizontalHand = settings->value("hand/horizontal", false).toBool();
|
||||||
economicGrid = settings->value("table/economic", false).toBool();
|
economicalGrid = settings->value("table/economic", false).toBool();
|
||||||
|
tapAnimation = settings->value("cards/tapanimation", true).toBool();
|
||||||
|
|
||||||
zoneViewSortByName = settings->value("zoneview/sortbyname", false).toBool();
|
zoneViewSortByName = settings->value("zoneview/sortbyname", false).toBool();
|
||||||
zoneViewSortByType = settings->value("zoneview/sortbytype", false).toBool();
|
zoneViewSortByType = settings->value("zoneview/sortbytype", false).toBool();
|
||||||
|
@ -100,11 +101,17 @@ void SettingsCache::setHorizontalHand(int _horizontalHand)
|
||||||
emit horizontalHandChanged();
|
emit horizontalHandChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsCache::setEconomicGrid(int _economicGrid)
|
void SettingsCache::setEconomicalGrid(int _economicalGrid)
|
||||||
{
|
{
|
||||||
economicGrid = _economicGrid;
|
economicalGrid = _economicalGrid;
|
||||||
settings->setValue("table/economic", economicGrid);
|
settings->setValue("table/economic", economicalGrid);
|
||||||
emit economicGridChanged();
|
emit economicalGridChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsCache::setTapAnimation(int _tapAnimation)
|
||||||
|
{
|
||||||
|
tapAnimation = _tapAnimation;
|
||||||
|
settings->setValue("cards/tapanimation", tapAnimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsCache::setZoneViewSortByName(int _zoneViewSortByName)
|
void SettingsCache::setZoneViewSortByName(int _zoneViewSortByName)
|
||||||
|
|
|
@ -17,7 +17,7 @@ signals:
|
||||||
void cardBackPicturePathChanged();
|
void cardBackPicturePathChanged();
|
||||||
void picDownloadChanged();
|
void picDownloadChanged();
|
||||||
void horizontalHandChanged();
|
void horizontalHandChanged();
|
||||||
void economicGridChanged();
|
void economicalGridChanged();
|
||||||
private:
|
private:
|
||||||
QSettings *settings;
|
QSettings *settings;
|
||||||
|
|
||||||
|
@ -27,7 +27,8 @@ private:
|
||||||
bool picDownload;
|
bool picDownload;
|
||||||
bool doubleClickToPlay;
|
bool doubleClickToPlay;
|
||||||
bool horizontalHand;
|
bool horizontalHand;
|
||||||
bool economicGrid;
|
bool economicalGrid;
|
||||||
|
bool tapAnimation;
|
||||||
bool zoneViewSortByName, zoneViewSortByType;
|
bool zoneViewSortByName, zoneViewSortByType;
|
||||||
public:
|
public:
|
||||||
SettingsCache();
|
SettingsCache();
|
||||||
|
@ -42,7 +43,8 @@ public:
|
||||||
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 getHorizontalHand() const { return horizontalHand; }
|
||||||
bool getEconomicGrid() const { return economicGrid; }
|
bool getEconomicalGrid() const { return economicalGrid; }
|
||||||
|
bool getTapAnimation() const { return tapAnimation; }
|
||||||
bool getZoneViewSortByName() const { return zoneViewSortByName; }
|
bool getZoneViewSortByName() const { return zoneViewSortByName; }
|
||||||
bool getZoneViewSortByType() const { return zoneViewSortByType; }
|
bool getZoneViewSortByType() const { return zoneViewSortByType; }
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -57,7 +59,8 @@ public slots:
|
||||||
void setPicDownload(int _picDownload);
|
void setPicDownload(int _picDownload);
|
||||||
void setDoubleClickToPlay(int _doubleClickToPlay);
|
void setDoubleClickToPlay(int _doubleClickToPlay);
|
||||||
void setHorizontalHand(int _horizontalHand);
|
void setHorizontalHand(int _horizontalHand);
|
||||||
void setEconomicGrid(int _economicGrid);
|
void setEconomicalGrid(int _economicalGrid);
|
||||||
|
void setTapAnimation(int _tapAnimation);
|
||||||
void setZoneViewSortByName(int _zoneViewSortByName);
|
void setZoneViewSortByName(int _zoneViewSortByName);
|
||||||
void setZoneViewSortByType(int _zoneViewSortByType);
|
void setZoneViewSortByType(int _zoneViewSortByType);
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,10 +12,10 @@ TableZone::TableZone(Player *_p, QGraphicsItem *parent)
|
||||||
: CardZone(_p, "table", true, false, true, parent), active(false)
|
: CardZone(_p, "table", true, false, true, parent), active(false)
|
||||||
{
|
{
|
||||||
connect(settingsCache, SIGNAL(tableBgPathChanged()), this, SLOT(updateBgPixmap()));
|
connect(settingsCache, SIGNAL(tableBgPathChanged()), this, SLOT(updateBgPixmap()));
|
||||||
connect(settingsCache, SIGNAL(economicGridChanged()), this, SLOT(reorganizeCards()));
|
connect(settingsCache, SIGNAL(economicalGridChanged()), this, SLOT(reorganizeCards()));
|
||||||
updateBgPixmap();
|
updateBgPixmap();
|
||||||
|
|
||||||
if (settingsCache->getEconomicGrid())
|
if (settingsCache->getEconomicalGrid())
|
||||||
height = 2 * boxLineWidth + (int) (14.0 / 3 * CARD_HEIGHT + 3 * paddingY);
|
height = 2 * boxLineWidth + (int) (14.0 / 3 * CARD_HEIGHT + 3 * paddingY);
|
||||||
else
|
else
|
||||||
height = 2 * boxLineWidth + 4 * CARD_HEIGHT + 3 * paddingY;
|
height = 2 * boxLineWidth + 4 * CARD_HEIGHT + 3 * paddingY;
|
||||||
|
@ -210,7 +210,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->getEconomicGrid())) {
|
if ((gridPoint.y() == 3) && (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 {
|
||||||
|
@ -245,7 +245,7 @@ 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->getEconomicGrid()))
|
if ((resultY == 3) && (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
|
3
|
||||||
|
|
Loading…
Reference in a new issue