mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-12 20:05:55 -05:00
Allow vertical layout for layer view
This commit is contained in:
@@ -108,6 +108,7 @@ public:
|
||||
int metatilesZoom;
|
||||
int tilesetEditorMetatilesZoom;
|
||||
int tilesetEditorTilesZoom;
|
||||
Qt::Orientation tilesetEditorLayerOrientation;
|
||||
bool showPlayerView;
|
||||
bool showCursorTile;
|
||||
bool showBorder;
|
||||
|
||||
@@ -9,28 +9,40 @@
|
||||
class MetatileLayersItem: public SelectablePixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MetatileLayersItem(Metatile *metatile, Tileset *primaryTileset, Tileset *secondaryTileset);
|
||||
MetatileLayersItem(Metatile *metatile,
|
||||
Tileset *primaryTileset,
|
||||
Tileset *secondaryTileset,
|
||||
Qt::Orientation orientation = Qt::Horizontal);
|
||||
void draw();
|
||||
void setTilesets(Tileset*, Tileset*);
|
||||
void setMetatile(Metatile*);
|
||||
void clearLastModifiedCoords();
|
||||
void clearLastHoveredCoords();
|
||||
|
||||
QPoint tileIndexToPos(int index) const { return this->tilePositions.value(index); }
|
||||
int posToTileIndex(const QPoint &pos) const { return this->tilePositions.indexOf(pos); }
|
||||
int posToTileIndex(int x, int y) const { return posToTileIndex(QPoint(x, y)); }
|
||||
|
||||
void setOrientation(Qt::Orientation orientation);
|
||||
|
||||
bool showGrid;
|
||||
private:
|
||||
Metatile* metatile;
|
||||
Tileset *primaryTileset;
|
||||
Tileset *secondaryTileset;
|
||||
Qt::Orientation orientation;
|
||||
QPoint prevChangedPos;
|
||||
QPoint prevHoveredPos;
|
||||
|
||||
QList<QPoint> tilePositions;
|
||||
|
||||
QPoint getBoundedPos(const QPointF &);
|
||||
void requestTileChange(const QPoint &pos);
|
||||
void requestPaletteChange(const QPoint &pos);
|
||||
void updateSelection();
|
||||
void hover(const QPoint &pos);
|
||||
signals:
|
||||
void tileChanged(const QPoint &pos);
|
||||
void paletteChanged(const QPoint &pos);
|
||||
void selectedTilesChanged(QPoint, int, int);
|
||||
void selectedTilesChanged(const QPoint &pos, const QSize &dimensions);
|
||||
void hoveredTileChanged(const Tile &tile);
|
||||
void hoveredTileCleared();
|
||||
protected:
|
||||
|
||||
@@ -19,9 +19,13 @@ public:
|
||||
selectionOffsetX(0),
|
||||
selectionOffsetY(0)
|
||||
{}
|
||||
virtual QSize getSelectionDimensions() const;
|
||||
virtual QSize getSelectionDimensions() const { return QSize(abs(this->selectionOffsetX) + 1, abs(this->selectionOffsetY) + 1); }
|
||||
virtual void draw() = 0;
|
||||
|
||||
virtual void setMaxSelectionSize(const QSize &size) { setMaxSelectionSize(size.width(), size.height()); }
|
||||
virtual void setMaxSelectionSize(int width, int height);
|
||||
QSize maxSelectionSize() { return QSize(this->maxSelectionWidth, this->maxSelectionHeight); }
|
||||
|
||||
protected:
|
||||
int cellWidth;
|
||||
int cellHeight;
|
||||
@@ -33,17 +37,22 @@ protected:
|
||||
int selectionOffsetY;
|
||||
|
||||
QPoint getSelectionStart();
|
||||
void select(int x, int y, int width = 0, int height = 0);
|
||||
void select(const QPoint &pos, const QSize &size = QSize(0,0)) { select(pos.x(), pos.y(), size.width(), size.height()); }
|
||||
void updateSelection(int, int);
|
||||
void select(const QPoint &pos, const QSize &size = QSize(1,1));
|
||||
void select(int x, int y, int width = 1, int height = 1) { select(QPoint(x, y), QSize(width, height)); }
|
||||
void updateSelection(const QPoint &pos);
|
||||
QPoint getCellPos(QPointF);
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent*) override;
|
||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*) override;
|
||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent*) override;
|
||||
virtual void drawSelection();
|
||||
virtual int cellsWide() const { return this->cellWidth ? (pixmap().width() / this->cellWidth) : 0; }
|
||||
virtual int cellsTall() const { return this->cellHeight ? (pixmap().height() / this->cellHeight) : 0; }
|
||||
|
||||
signals:
|
||||
void selectionChanged(int, int, int, int);
|
||||
void selectionChanged(const QPoint&, const QSize&);
|
||||
|
||||
private:
|
||||
QPoint prevCellPos = QPoint(-1,-1);
|
||||
};
|
||||
|
||||
#endif // SELECTABLEPIXMAPITEM_H
|
||||
|
||||
@@ -69,7 +69,7 @@ private slots:
|
||||
void onHoveredTileChanged(const Tile&);
|
||||
void onHoveredTileChanged(uint16_t);
|
||||
void onHoveredTileCleared();
|
||||
void onMetatileLayerSelectionChanged(QPoint, int, int);
|
||||
void onMetatileLayerSelectionChanged(const QPoint&, const QSize&);
|
||||
void onPaletteEditorChangedPaletteColor();
|
||||
|
||||
void on_actionChange_Metatiles_Count_triggered();
|
||||
@@ -138,6 +138,7 @@ private:
|
||||
void refreshTileFlips();
|
||||
void refreshPaletteId();
|
||||
void paintSelectedLayerTiles(const QPoint &pos, bool paletteOnly = false);
|
||||
void setMetatileLayerOrientation(Qt::Orientation orientation);
|
||||
|
||||
Ui::TilesetEditor *ui;
|
||||
History<MetatileHistoryItem*> metatileHistory;
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
class TilesetEditorTileSelector: public SelectablePixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
TilesetEditorTileSelector(Tileset *primaryTileset, Tileset *secondaryTileset, int numLayers)
|
||||
: SelectablePixmapItem(16, 16, numLayers * Metatile::tileWidth(), Metatile::tileHeight()) {
|
||||
TilesetEditorTileSelector(Tileset *primaryTileset, Tileset *secondaryTileset)
|
||||
: SelectablePixmapItem(16, 16, Metatile::tileWidth(), Metatile::tileWidth()) {
|
||||
this->primaryTileset = primaryTileset;
|
||||
this->secondaryTileset = secondaryTileset;
|
||||
this->numTilesWide = 16;
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
QSize getSelectionDimensions() const override;
|
||||
void setMaxSelectionSize(int width, int height) override;
|
||||
void draw() override;
|
||||
void select(uint16_t metatileId);
|
||||
void highlight(uint16_t metatileId);
|
||||
@@ -31,6 +32,7 @@ public:
|
||||
QImage buildPrimaryTilesIndexedImage();
|
||||
QImage buildSecondaryTilesIndexedImage();
|
||||
|
||||
|
||||
QVector<uint16_t> usedTiles;
|
||||
bool showUnused = false;
|
||||
bool showDivider = false;
|
||||
@@ -49,6 +51,7 @@ private:
|
||||
int externalSelectionHeight;
|
||||
QList<Tile> externalSelectedTiles;
|
||||
QList<int> externalSelectedPos;
|
||||
QPoint prevCellPos = QPoint(-1,-1);
|
||||
|
||||
Tileset *primaryTileset;
|
||||
Tileset *secondaryTileset;
|
||||
|
||||
Reference in New Issue
Block a user