Never send wrong row numbers
This commit is contained in:
parent
ed24b38add
commit
f84d6fec1b
3 changed files with 18 additions and 6 deletions
|
@ -1036,7 +1036,7 @@ void Player::actCreateToken()
|
|||
lastTokenPT = dlg.getPT();
|
||||
if (CardInfo *correctedCard = db->getCardBySimpleName(lastTokenName, false)) {
|
||||
lastTokenName = correctedCard->getName();
|
||||
lastTokenTableRow = 2 - correctedCard->getTableRow();
|
||||
lastTokenTableRow = table->clampValidTableRow(2 - correctedCard->getTableRow());
|
||||
if (lastTokenPT.isEmpty())
|
||||
lastTokenPT = correctedCard->getPowTough();
|
||||
}
|
||||
|
@ -1072,7 +1072,7 @@ void Player::actCreatePredefinedToken()
|
|||
lastTokenColor = cardInfo->getColors().isEmpty() ? QString() : cardInfo->getColors().first().toLower();
|
||||
lastTokenPT = cardInfo->getPowTough();
|
||||
lastTokenAnnotation = cardInfo->getText();
|
||||
lastTokenTableRow = 2 - cardInfo->getTableRow();
|
||||
lastTokenTableRow = table->clampValidTableRow(2 - cardInfo->getTableRow());
|
||||
lastTokenDestroy = true;
|
||||
aCreateAnotherToken->setEnabled(true);
|
||||
|
||||
|
@ -1660,7 +1660,7 @@ void Player::playCard(CardItem *c, bool faceDown, bool tapped)
|
|||
cmd.set_y(0);
|
||||
} else {
|
||||
int tableRow = faceDown ? 2 : ci->getTableRow();
|
||||
QPoint gridPoint = QPoint(-1, 2 - tableRow);
|
||||
QPoint gridPoint = QPoint(-1, table->clampValidTableRow(2 - tableRow));
|
||||
cardToMove->set_face_down(faceDown);
|
||||
cardToMove->set_pt(ci->getPowTough().toStdString());
|
||||
cardToMove->set_tapped(faceDown ? false : tapped);
|
||||
|
|
|
@ -31,7 +31,7 @@ TableZone::TableZone(Player *_p, QGraphicsItem *parent)
|
|||
|
||||
updateBgPixmap();
|
||||
|
||||
height = 2 * BOX_LINE_WIDTH + 3 * (CARD_HEIGHT + 20) + 2 * PADDING_Y;
|
||||
height = 2 * BOX_LINE_WIDTH + TABLEROWS * (CARD_HEIGHT + 20) + 2 * PADDING_Y;
|
||||
width = MIN_WIDTH + 2 * MARGIN_X + 2 * BOX_LINE_WIDTH;
|
||||
currentMinimumWidth = MIN_WIDTH;
|
||||
|
||||
|
@ -311,7 +311,7 @@ QPointF TableZone::mapFromGrid(QPoint gridPoint) const
|
|||
if (isInverted())
|
||||
gridPoint.setY(2 - gridPoint.y());
|
||||
|
||||
y = BOX_LINE_WIDTH + gridPoint.y() * (CARD_HEIGHT + PADDING_Y + 20) + (gridPoint.x() % 3) * 10;
|
||||
y = BOX_LINE_WIDTH + gridPoint.y() * (CARD_HEIGHT + PADDING_Y + 20) + (gridPoint.x() % TABLEROWS) * 10;
|
||||
/*
|
||||
if (isInverted())
|
||||
y = height - CARD_HEIGHT - y;
|
||||
|
@ -339,7 +339,7 @@ QPoint TableZone::mapToGrid(const QPointF &mapPoint) const
|
|||
|
||||
int resultY = round(y / (CARD_HEIGHT + PADDING_Y + 20));
|
||||
if (isInverted())
|
||||
resultY = 2 - resultY;
|
||||
resultY = TABLEROWS - 1 - resultY;
|
||||
|
||||
int baseX = -1;
|
||||
qreal oldTempX = 0, tempX = 0;
|
||||
|
@ -365,3 +365,12 @@ QPointF TableZone::closestGridPoint(const QPointF &point)
|
|||
gridPoint.setX(gridPoint.x() + 1);
|
||||
return mapFromGrid(gridPoint);
|
||||
}
|
||||
|
||||
int TableZone::clampValidTableRow(const int row)
|
||||
{
|
||||
if(row < 0)
|
||||
return 0;
|
||||
if(row >= TABLEROWS)
|
||||
return TABLEROWS - 1;
|
||||
return row;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ private:
|
|||
static const int PADDING_Y = 10;
|
||||
static const int MARGIN_X = 20;
|
||||
static const int MIN_WIDTH = 10 * CARD_WIDTH / 2;
|
||||
static const int TABLEROWS = 3;
|
||||
|
||||
/*
|
||||
Default background color, inactive mask and boarder gradient
|
||||
|
@ -117,6 +118,8 @@ public:
|
|||
QPoint mapToGrid(const QPointF &mapPoint) const;
|
||||
QPointF closestGridPoint(const QPointF &point);
|
||||
|
||||
int clampValidTableRow(const int row);
|
||||
|
||||
/**
|
||||
Removes a card from view.
|
||||
|
||||
|
|
Loading…
Reference in a new issue