Simplify TilesetEditorMetatileSelector::buildImage
This commit is contained in:
parent
56e24bba18
commit
564d24c4f3
2 changed files with 8 additions and 10 deletions
|
@ -43,7 +43,7 @@ private:
|
||||||
void drawUnused();
|
void drawUnused();
|
||||||
void drawCounts();
|
void drawCounts();
|
||||||
QImage buildAllMetatilesImage();
|
QImage buildAllMetatilesImage();
|
||||||
QImage buildImage(int metatileIdStart, int metatileIdEnd);
|
QImage buildImage(int metatileIdStart, int numMetatiles);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void hoveredMetatileChanged(uint16_t);
|
void hoveredMetatileChanged(uint16_t);
|
||||||
|
|
|
@ -13,29 +13,27 @@ TilesetEditorMetatileSelector::TilesetEditorMetatileSelector(Tileset *primaryTil
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage TilesetEditorMetatileSelector::buildAllMetatilesImage() {
|
QImage TilesetEditorMetatileSelector::buildAllMetatilesImage() {
|
||||||
return this->buildImage(0, Project::getNumMetatilesPrimary() + this->secondaryTileset->metatiles.length() - 1);
|
return this->buildImage(0, Project::getNumMetatilesPrimary() + this->secondaryTileset->metatiles.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage TilesetEditorMetatileSelector::buildPrimaryMetatilesImage() {
|
QImage TilesetEditorMetatileSelector::buildPrimaryMetatilesImage() {
|
||||||
return this->buildImage(0, this->primaryTileset->metatiles.length() - 1);
|
return this->buildImage(0, this->primaryTileset->metatiles.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage TilesetEditorMetatileSelector::buildSecondaryMetatilesImage() {
|
QImage TilesetEditorMetatileSelector::buildSecondaryMetatilesImage() {
|
||||||
int numPrimary = Project::getNumMetatilesPrimary();
|
return this->buildImage(Project::getNumMetatilesPrimary(), this->secondaryTileset->metatiles.length());
|
||||||
return this->buildImage(numPrimary, numPrimary + this->secondaryTileset->metatiles.length() - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage TilesetEditorMetatileSelector::buildImage(int metatileIdStart, int metatileIdEnd) {
|
QImage TilesetEditorMetatileSelector::buildImage(int metatileIdStart, int numMetatiles) {
|
||||||
int totalMetatiles = metatileIdEnd - metatileIdStart + 1;
|
int numMetatilesHigh = numMetatiles / this->numMetatilesWide;
|
||||||
int numMetatilesHigh = totalMetatiles / this->numMetatilesWide;
|
if (numMetatiles % this->numMetatilesWide != 0) {
|
||||||
if (totalMetatiles % this->numMetatilesWide != 0) {
|
|
||||||
// Round up height for incomplete last row
|
// Round up height for incomplete last row
|
||||||
numMetatilesHigh++;
|
numMetatilesHigh++;
|
||||||
}
|
}
|
||||||
QImage image(this->numMetatilesWide * 32, numMetatilesHigh * 32, QImage::Format_RGBA8888);
|
QImage image(this->numMetatilesWide * 32, numMetatilesHigh * 32, QImage::Format_RGBA8888);
|
||||||
image.fill(Qt::magenta);
|
image.fill(Qt::magenta);
|
||||||
QPainter painter(&image);
|
QPainter painter(&image);
|
||||||
for (int i = 0; i < totalMetatiles; i++) {
|
for (int i = 0; i < numMetatiles; i++) {
|
||||||
QImage metatile_image = getMetatileImage(
|
QImage metatile_image = getMetatileImage(
|
||||||
i + metatileIdStart,
|
i + metatileIdStart,
|
||||||
this->primaryTileset,
|
this->primaryTileset,
|
||||||
|
|
Loading…
Reference in a new issue