mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-23 15:13:55 -07:00
new table layout with inverted y coordinate
This commit is contained in:
parent
2543a5b241
commit
bc7b48a7aa
9 changed files with 464 additions and 425 deletions
|
|
@ -220,8 +220,13 @@ AppearanceSettingsPage::AppearanceSettingsPage()
|
|||
economicalGridCheckBox->setChecked(settingsCache->getEconomicalGrid());
|
||||
connect(economicalGridCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setEconomicalGrid(int)));
|
||||
|
||||
invertVerticalCoordinateCheckBox = new QCheckBox;
|
||||
invertVerticalCoordinateCheckBox->setChecked(settingsCache->getInvertVerticalCoordinate());
|
||||
connect(invertVerticalCoordinateCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setInvertVerticalCoordinate(int)));
|
||||
|
||||
QGridLayout *tableGrid = new QGridLayout;
|
||||
tableGrid->addWidget(economicalGridCheckBox, 0, 0, 1, 2);
|
||||
tableGrid->addWidget(invertVerticalCoordinateCheckBox, 1, 0, 1, 2);
|
||||
|
||||
tableGroupBox = new QGroupBox;
|
||||
tableGroupBox->setLayout(tableGrid);
|
||||
|
|
@ -247,7 +252,6 @@ AppearanceSettingsPage::AppearanceSettingsPage()
|
|||
mainLayout->addWidget(zoneViewGroupBox);
|
||||
|
||||
setLayout(mainLayout);
|
||||
|
||||
}
|
||||
|
||||
void AppearanceSettingsPage::retranslateUi()
|
||||
|
|
@ -263,6 +267,7 @@ void AppearanceSettingsPage::retranslateUi()
|
|||
|
||||
tableGroupBox->setTitle(tr("Table grid layout"));
|
||||
economicalGridCheckBox->setText(tr("Economical layout"));
|
||||
invertVerticalCoordinateCheckBox->setText(tr("Invert vertical coordinate"));
|
||||
|
||||
zoneViewGroupBox->setTitle(tr("Zone view layout"));
|
||||
zoneViewSortByNameCheckBox->setText(tr("Sort by name"));
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ signals:
|
|||
private:
|
||||
QLabel *handBgLabel, *tableBgLabel, *playerAreaBgLabel, *cardBackPicturePathLabel;
|
||||
QLineEdit *handBgEdit, *tableBgEdit, *playerAreaBgEdit, *cardBackPicturePathEdit;
|
||||
QCheckBox *horizontalHandCheckBox, *economicalGridCheckBox, *zoneViewSortByNameCheckBox, *zoneViewSortByTypeCheckBox;
|
||||
QCheckBox *horizontalHandCheckBox, *economicalGridCheckBox, *invertVerticalCoordinateCheckBox, *zoneViewSortByNameCheckBox, *zoneViewSortByTypeCheckBox;
|
||||
QGroupBox *zoneBgGroupBox, *handGroupBox, *tableGroupBox, *zoneViewGroupBox;
|
||||
public:
|
||||
AppearanceSettingsPage();
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ SettingsCache::SettingsCache()
|
|||
cardInfoMinimized = settings->value("interface/cardinfominimized", false).toBool();
|
||||
horizontalHand = settings->value("hand/horizontal", false).toBool();
|
||||
economicalGrid = settings->value("table/economic", false).toBool();
|
||||
invertVerticalCoordinate = settings->value("table/invert_vertical", false).toBool();
|
||||
tapAnimation = settings->value("cards/tapanimation", true).toBool();
|
||||
|
||||
zoneViewSortByName = settings->value("zoneview/sortbyname", false).toBool();
|
||||
|
|
@ -115,6 +116,13 @@ void SettingsCache::setEconomicalGrid(int _economicalGrid)
|
|||
emit economicalGridChanged();
|
||||
}
|
||||
|
||||
void SettingsCache::setInvertVerticalCoordinate(int _invertVerticalCoordinate)
|
||||
{
|
||||
invertVerticalCoordinate = _invertVerticalCoordinate;
|
||||
settings->setValue("table/invert_vertical", invertVerticalCoordinate);
|
||||
emit invertVerticalCoordinateChanged();
|
||||
}
|
||||
|
||||
void SettingsCache::setTapAnimation(int _tapAnimation)
|
||||
{
|
||||
tapAnimation = _tapAnimation;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ signals:
|
|||
void picDownloadChanged();
|
||||
void horizontalHandChanged();
|
||||
void economicalGridChanged();
|
||||
void invertVerticalCoordinateChanged();
|
||||
private:
|
||||
QSettings *settings;
|
||||
|
||||
|
|
@ -29,6 +30,7 @@ private:
|
|||
bool cardInfoMinimized;
|
||||
bool horizontalHand;
|
||||
bool economicalGrid;
|
||||
bool invertVerticalCoordinate;
|
||||
bool tapAnimation;
|
||||
bool zoneViewSortByName, zoneViewSortByType;
|
||||
public:
|
||||
|
|
@ -46,6 +48,7 @@ public:
|
|||
bool getCardInfoMinimized() const { return cardInfoMinimized; }
|
||||
bool getHorizontalHand() const { return horizontalHand; }
|
||||
bool getEconomicalGrid() const { return economicalGrid; }
|
||||
bool getInvertVerticalCoordinate() const { return invertVerticalCoordinate; }
|
||||
bool getTapAnimation() const { return tapAnimation; }
|
||||
bool getZoneViewSortByName() const { return zoneViewSortByName; }
|
||||
bool getZoneViewSortByType() const { return zoneViewSortByType; }
|
||||
|
|
@ -63,6 +66,7 @@ public slots:
|
|||
void setCardInfoMinimized(bool _cardInfoMinimized);
|
||||
void setHorizontalHand(int _horizontalHand);
|
||||
void setEconomicalGrid(int _economicalGrid);
|
||||
void setInvertVerticalCoordinate(int _invertVerticalCoordinate);
|
||||
void setTapAnimation(int _tapAnimation);
|
||||
void setZoneViewSortByName(int _zoneViewSortByName);
|
||||
void setZoneViewSortByType(int _zoneViewSortByType);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ TableZone::TableZone(Player *_p, QGraphicsItem *parent)
|
|||
{
|
||||
connect(settingsCache, SIGNAL(tableBgPathChanged()), this, SLOT(updateBgPixmap()));
|
||||
connect(settingsCache, SIGNAL(economicalGridChanged()), this, SLOT(reorganizeCards()));
|
||||
connect(settingsCache, SIGNAL(invertVerticalCoordinateChanged()), this, SLOT(reorganizeCards()));
|
||||
updateBgPixmap();
|
||||
|
||||
if (settingsCache->getEconomicalGrid())
|
||||
|
|
@ -39,6 +40,11 @@ QRectF TableZone::boundingRect() const
|
|||
return QRectF(0, 0, width, height);
|
||||
}
|
||||
|
||||
bool TableZone::isInverted() const
|
||||
{
|
||||
return ((player->getMirrored() && !settingsCache->getInvertVerticalCoordinate()) || (!player->getMirrored() && settingsCache->getInvertVerticalCoordinate()));
|
||||
}
|
||||
|
||||
void TableZone::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
|
||||
{
|
||||
if (bgPixmap.isNull())
|
||||
|
|
@ -47,7 +53,7 @@ void TableZone::paint(QPainter *painter, const QStyleOptionGraphicsItem */*optio
|
|||
painter->fillRect(boundingRect(), QBrush(bgPixmap));
|
||||
painter->setPen(QColor(255, 255, 255, 40));
|
||||
qreal separatorY = 3 * (CARD_HEIGHT + paddingY) + boxLineWidth - paddingY / 2;
|
||||
if (player->getMirrored())
|
||||
if (isInverted())
|
||||
separatorY = height - separatorY;
|
||||
painter->drawLine(QPointF(0, separatorY), QPointF(width, separatorY));
|
||||
|
||||
|
|
@ -220,7 +226,7 @@ QPointF TableZone::mapFromGrid(const QPoint &gridPoint) const
|
|||
|
||||
y = boxLineWidth + (CARD_HEIGHT + paddingY) * gridPoint.y();
|
||||
}
|
||||
if (player->getMirrored())
|
||||
if (isInverted())
|
||||
y = height - CARD_HEIGHT - y;
|
||||
|
||||
return QPointF(x, y);
|
||||
|
|
@ -230,7 +236,7 @@ QPoint TableZone::mapToGrid(const QPointF &mapPoint) const
|
|||
{
|
||||
qreal x = mapPoint.x() - marginX;
|
||||
qreal y = mapPoint.y();
|
||||
if (player->getMirrored())
|
||||
if (isInverted())
|
||||
y = height - y;
|
||||
y += paddingY / 2 - boxLineWidth;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ private:
|
|||
int currentMinimumWidth;
|
||||
QPixmap bgPixmap;
|
||||
bool active;
|
||||
bool isInverted() const;
|
||||
private slots:
|
||||
void updateBgPixmap();
|
||||
public slots:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue