mirror of
https://github.com/huderlem/porymap.git
synced 2026-09-08 08:55:37 -05:00
More usage of Tile/Metatile size constants
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#define CONNECTIONPIXMAPITEM_H
|
||||
|
||||
#include "mapconnection.h"
|
||||
#include "metatile.h"
|
||||
#include <QGraphicsPixmapItem>
|
||||
#include <QPainter>
|
||||
#include <QPointer>
|
||||
@@ -31,8 +32,8 @@ private:
|
||||
bool selected = false;
|
||||
unsigned actionId = 0;
|
||||
|
||||
static const int mWidth = 16;
|
||||
static const int mHeight = 16;
|
||||
static const int mWidth = Metatile::pixelWidth();
|
||||
static const int mHeight = Metatile::pixelHeight();
|
||||
|
||||
void updatePos();
|
||||
void updateOrigin();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <QGraphicsObject>
|
||||
#include <QLine>
|
||||
#include "metatile.h"
|
||||
|
||||
|
||||
class MapRuler : public QGraphicsObject, private QLine
|
||||
@@ -63,8 +64,8 @@ private:
|
||||
QPoint snapToWithinBounds(QPoint pos) const;
|
||||
void updateGeometry();
|
||||
void updateStatus(Qt::Corner corner);
|
||||
int pixWidth() const { return width() * 16; }
|
||||
int pixHeight() const { return height() * 16; }
|
||||
int pixWidth() const { return width() * Metatile::pixelWidth(); }
|
||||
int pixHeight() const { return height() * Metatile::pixelHeight(); }
|
||||
};
|
||||
|
||||
#endif // MAPRULER_H
|
||||
|
||||
@@ -31,7 +31,7 @@ struct MetatileSelection
|
||||
class MetatileSelector: public SelectablePixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MetatileSelector(int numMetatilesWide, Layout *layout): SelectablePixmapItem(16, 16) {
|
||||
MetatileSelector(int numMetatilesWide, Layout *layout): SelectablePixmapItem(Metatile::pixelWidth(), Metatile::pixelHeight()) {
|
||||
this->externalSelection = false;
|
||||
this->prefabSelection = false;
|
||||
this->numMetatilesWide = numMetatilesWide;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
class MovableRect : public QGraphicsRectItem
|
||||
{
|
||||
public:
|
||||
MovableRect(const QRectF &rect, const QRgb &color);
|
||||
MovableRect(const QRectF &rect, const QSize &cellSize, const QRgb &color);
|
||||
QRectF boundingRect() const override {
|
||||
qreal penWidth = 4;
|
||||
return QRectF(-penWidth,
|
||||
@@ -31,6 +31,7 @@ public:
|
||||
|
||||
protected:
|
||||
QRectF baseRect;
|
||||
QSize cellSize;
|
||||
QRgb color;
|
||||
|
||||
void updateVisibility();
|
||||
@@ -43,7 +44,7 @@ class ResizableRect : public QObject, public MovableRect
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ResizableRect(QObject *parent, int width, int height, QRgb color);
|
||||
ResizableRect(QObject *parent, const QSize &cellSize, const QSize &size, const QRgb &color);
|
||||
|
||||
QRectF boundingRect() const override {
|
||||
return QRectF(this->rect() + QMargins(lineWidth, lineWidth, lineWidth, lineWidth));
|
||||
|
||||
@@ -45,10 +45,10 @@ private:
|
||||
|
||||
/// PixmapItem subclass which allows for creating a boundary which determine whether
|
||||
/// the pixmap paints normally or with a black tint.
|
||||
/// This item is movable and snaps on a 16x16 grid.
|
||||
/// This item is movable and snaps on a 'cellSize' grid.
|
||||
class BoundedPixmapItem : public QGraphicsPixmapItem {
|
||||
public:
|
||||
BoundedPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent = nullptr);
|
||||
BoundedPixmapItem(const QPixmap &pixmap, const QSize &cellSize, QGraphicsItem *parent = nullptr);
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override;
|
||||
|
||||
void setBoundary(ResizableRect *rect) { this->boundary = rect; }
|
||||
@@ -59,6 +59,7 @@ protected:
|
||||
private:
|
||||
ResizableRect *boundary = nullptr;
|
||||
QPointF clickedPos = QPointF();
|
||||
QSize cellSize;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -7,13 +7,18 @@
|
||||
class SelectablePixmapItem : public QObject, public QGraphicsPixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
SelectablePixmapItem(int cellWidth, int cellHeight): SelectablePixmapItem(cellWidth, cellHeight, INT_MAX, INT_MAX) {}
|
||||
SelectablePixmapItem(int cellWidth, int cellHeight, int maxSelectionWidth, int maxSelectionHeight) {
|
||||
this->cellWidth = cellWidth;
|
||||
this->cellHeight = cellHeight;
|
||||
this->maxSelectionWidth = maxSelectionWidth;
|
||||
this->maxSelectionHeight = maxSelectionHeight;
|
||||
}
|
||||
SelectablePixmapItem(const QSize &size, const QSize &maxSelectionSize = QSize(INT_MAX, INT_MAX))
|
||||
: SelectablePixmapItem(size.width(), size.height(), maxSelectionSize.width(), maxSelectionSize.height()) {}
|
||||
SelectablePixmapItem(int cellWidth, int cellHeight, int maxSelectionWidth = INT_MAX, int maxSelectionHeight = INT_MAX)
|
||||
: cellWidth(cellWidth),
|
||||
cellHeight(cellHeight),
|
||||
maxSelectionWidth(maxSelectionWidth),
|
||||
maxSelectionHeight(maxSelectionHeight),
|
||||
selectionInitialX(0),
|
||||
selectionInitialY(0),
|
||||
selectionOffsetX(0),
|
||||
selectionOffsetY(0)
|
||||
{}
|
||||
virtual QPoint getSelectionDimensions();
|
||||
virtual void draw() = 0;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ class TilesetEditorTileSelector: public SelectablePixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
TilesetEditorTileSelector(Tileset *primaryTileset, Tileset *secondaryTileset, int numLayers)
|
||||
: SelectablePixmapItem(16, 16, numLayers * 2, 2) {
|
||||
: SelectablePixmapItem(16, 16, numLayers * Metatile::tileWidth(), Metatile::tileHeight()) {
|
||||
this->primaryTileset = primaryTileset;
|
||||
this->secondaryTileset = secondaryTileset;
|
||||
this->numTilesWide = 16;
|
||||
|
||||
Reference in New Issue
Block a user