porymap/src/core/tileset.cpp

42 lines
1.2 KiB
C++
Raw Normal View History

2018-09-25 01:12:29 +01:00
#include "tileset.h"
#include "metatile.h"
#include "project.h"
#include <QPainter>
#include <QImage>
#include <QDebug>
Tileset::Tileset()
{
}
Tileset* Tileset::getBlockTileset(int metatile_index, Tileset *primaryTileset, Tileset *secondaryTileset) {
if (metatile_index < Project::getNumMetatilesPrimary()) {
return primaryTileset;
} else {
return secondaryTileset;
}
}
Metatile* Tileset::getMetatile(int index, Tileset *primaryTileset, Tileset *secondaryTileset) {
Tileset *tileset = Tileset::getBlockTileset(index, primaryTileset, secondaryTileset);
int local_index = Metatile::getBlockIndex(index);
if (!tileset || !tileset->metatiles) {
return nullptr;
}
Metatile *metatile = tileset->metatiles->value(local_index, nullptr);
return metatile;
}
QList<QList<QRgb>> Tileset::getBlockPalettes(Tileset *primaryTileset, Tileset *secondaryTileset) {
QList<QList<QRgb>> palettes;
for (int i = 0; i < Project::getNumPalettesPrimary(); i++) {
palettes.append(primaryTileset->palettes->at(i));
}
for (int i = Project::getNumPalettesPrimary(); i < Project::getNumPalettesTotal(); i++) {
palettes.append(secondaryTileset->palettes->at(i));
}
return palettes;
}