#include "tileset.h" #include "metatile.h" #include "project.h" #include #include #include 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> Tileset::getBlockPalettes(Tileset *primaryTileset, Tileset *secondaryTileset) { QList> 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; }