Fix tileset editor grid layering

This commit is contained in:
GriffinR 2023-12-31 14:06:47 -05:00
parent 331dc1f5c4
commit 2fc906b5ae
2 changed files with 23 additions and 18 deletions

View file

@ -42,6 +42,7 @@ private:
bool shouldAcceptEvent(QGraphicsSceneMouseEvent*); bool shouldAcceptEvent(QGraphicsSceneMouseEvent*);
int numRows(int numMetatiles); int numRows(int numMetatiles);
int numRows(); int numRows();
void drawGrid();
void drawFilters(); void drawFilters();
void drawUnused(); void drawUnused();
void drawCounts(); void drawCounts();

View file

@ -69,9 +69,9 @@ QImage TilesetEditorMetatileSelector::buildImage(int metatileIdStart, int numMet
void TilesetEditorMetatileSelector::draw() { void TilesetEditorMetatileSelector::draw() {
this->setPixmap(QPixmap::fromImage(this->buildAllMetatilesImage())); this->setPixmap(QPixmap::fromImage(this->buildAllMetatilesImage()));
this->drawGrid();
this->drawSelection(); this->drawSelection();
this->drawFilters();
drawFilters();
} }
bool TilesetEditorMetatileSelector::select(uint16_t metatileId) { bool TilesetEditorMetatileSelector::select(uint16_t metatileId) {
@ -166,23 +166,27 @@ QPoint TilesetEditorMetatileSelector::getMetatileIdCoordsOnWidget(uint16_t metat
return pos; return pos;
} }
void TilesetEditorMetatileSelector::drawFilters() { void TilesetEditorMetatileSelector::drawGrid() {
if (this->showGrid) { if (!this->showGrid)
QPixmap pixmap = this->pixmap(); return;
QPainter painter(&pixmap);
const int numColumns = this->numMetatilesWide; QPixmap pixmap = this->pixmap();
const int numRows = this->numRows(); QPainter painter(&pixmap);
for (int column = 1; column < numColumns; column++) { const int numColumns = this->numMetatilesWide;
int x = column * 32; const int numRows = this->numRows();
painter.drawLine(x, 0, x, numRows * 32); for (int column = 1; column < numColumns; column++) {
} int x = column * 32;
for (int row = 1; row < numRows; row++) { painter.drawLine(x, 0, x, numRows * 32);
int y = row * 32;
painter.drawLine(0, y, numColumns * 32, y);
}
painter.end();
this->setPixmap(pixmap);
} }
for (int row = 1; row < numRows; row++) {
int y = row * 32;
painter.drawLine(0, y, numColumns * 32, y);
}
painter.end();
this->setPixmap(pixmap);
}
void TilesetEditorMetatileSelector::drawFilters() {
if (selectorShowUnused) { if (selectorShowUnused) {
drawUnused(); drawUnused();
} }