mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-08 02:53:25 -08:00
[Refactor] Move table row mapping from TableZone into TableZoneLogic
This commit is contained in:
parent
c02576b827
commit
c7605a51e2
5 changed files with 43 additions and 38 deletions
|
|
@ -423,7 +423,7 @@ QPoint TableZone::mapToGrid(const QPointF &mapPoint) const
|
|||
const int gridPointHeight = CardDimensions::HEIGHT + PADDING_Y;
|
||||
int gridPointY = (y + PADDING_Y / 2) / gridPointHeight;
|
||||
|
||||
gridPointY = clampValidTableRow(gridPointY);
|
||||
gridPointY = TableZoneLogic::clampValidTableRow(gridPointY);
|
||||
|
||||
if (isInverted()) {
|
||||
gridPointY = TABLEROWS - 1 - gridPointY;
|
||||
|
|
@ -471,22 +471,3 @@ QPointF TableZone::closestGridPoint(const QPointF &point)
|
|||
}
|
||||
return mapFromGrid(gridPoint);
|
||||
}
|
||||
|
||||
int TableZone::clampValidTableRow(const int row)
|
||||
{
|
||||
if (row < 0) {
|
||||
return 0;
|
||||
}
|
||||
if (row >= TABLEROWS) {
|
||||
return TABLEROWS - 1;
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
int TableZone::tableRowToGridY(int tableRow)
|
||||
{
|
||||
if (tableRow > 2) {
|
||||
tableRow = 1;
|
||||
}
|
||||
return clampValidTableRow(2 - tableRow);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ signals:
|
|||
void sizeChanged();
|
||||
|
||||
private:
|
||||
static const int TABLEROWS = 3;
|
||||
static const int TABLEROWS = TableZoneLogic::ROW_COUNT;
|
||||
|
||||
/*
|
||||
Margins between table edges and cards, paddings between cards
|
||||
|
|
@ -181,15 +181,6 @@ public:
|
|||
|
||||
QPointF closestGridPoint(const QPointF &point) override;
|
||||
|
||||
static int clampValidTableRow(const int row);
|
||||
|
||||
/**
|
||||
* Converts a card's logical table row (0=creatures, 1=noncreatures, 2=lands)
|
||||
* to the corresponding grid Y coordinate. Cards with tableRow > 2 (e.g.,
|
||||
* instants/sorceries) default to the noncreatures row.
|
||||
*/
|
||||
static int tableRowToGridY(int tableRow);
|
||||
|
||||
/**
|
||||
Resizes the TableZone in case CardItems are within or
|
||||
outside of the TableZone constraints.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue