Fix memory leaks in Tileset
This commit is contained in:
parent
6a825d0b39
commit
cc7a5f5819
16 changed files with 147 additions and 215 deletions
|
@ -10,7 +10,7 @@ class MetatileParser
|
|||
{
|
||||
public:
|
||||
MetatileParser();
|
||||
QList<Metatile*> *parse(QString filepath, bool *error, bool primaryTileset);
|
||||
QList<Metatile*> parse(QString filepath, bool *error, bool primaryTileset);
|
||||
};
|
||||
|
||||
#endif // METATILEPARSER_H
|
||||
|
|
|
@ -6,8 +6,20 @@
|
|||
class Tile
|
||||
{
|
||||
public:
|
||||
Tile() {}
|
||||
Tile(int tile, bool xflip, bool yflip, int palette);
|
||||
Tile() :
|
||||
tile(0),
|
||||
xflip(false),
|
||||
yflip(false),
|
||||
palette(0)
|
||||
{ }
|
||||
|
||||
Tile(int tile, bool xflip, bool yflip, int palette) :
|
||||
tile(tile),
|
||||
xflip(xflip),
|
||||
yflip(yflip),
|
||||
palette(palette)
|
||||
{ }
|
||||
|
||||
public:
|
||||
int tile;
|
||||
bool xflip;
|
||||
|
|
|
@ -9,7 +9,10 @@
|
|||
class Tileset
|
||||
{
|
||||
public:
|
||||
Tileset();
|
||||
Tileset() = default;
|
||||
Tileset(const Tileset &other) = default;
|
||||
Tileset &operator=(const Tileset &other) = default;
|
||||
|
||||
public:
|
||||
QString name;
|
||||
QString is_compressed;
|
||||
|
@ -24,14 +27,12 @@ public:
|
|||
QString metatile_attrs_path;
|
||||
QString tilesImagePath;
|
||||
QImage tilesImage;
|
||||
QList<QString> palettePaths;
|
||||
QStringList palettePaths;
|
||||
|
||||
QList<QImage> *tiles = nullptr;
|
||||
QList<Metatile*> *metatiles = nullptr;
|
||||
QList<QList<QRgb>> *palettes = nullptr;
|
||||
QList<QList<QRgb>> *palettePreviews = nullptr;
|
||||
|
||||
Tileset* copy();
|
||||
QList<QImage> tiles;
|
||||
QList<Metatile*> metatiles;
|
||||
QList<QList<QRgb>> palettes;
|
||||
QList<QList<QRgb>> palettePreviews;
|
||||
|
||||
static Tileset* getBlockTileset(int, Tileset*, Tileset*);
|
||||
static Metatile* getMetatile(int, Tileset*, Tileset*);
|
||||
|
|
|
@ -77,8 +77,8 @@ public:
|
|||
Q_INVOKABLE void setPrimaryTilesetPalettes(QList<QList<QList<int>>> palettes);
|
||||
Q_INVOKABLE void setSecondaryTilesetPalette(int paletteIndex, QList<QList<int>> colors);
|
||||
Q_INVOKABLE void setSecondaryTilesetPalettes(QList<QList<QList<int>>> palettes);
|
||||
QJSValue getTilesetPalette(QList<QList<QRgb>> *palettes, int paletteIndex);
|
||||
QJSValue getTilesetPalettes(QList<QList<QRgb>> *palettes);
|
||||
QJSValue getTilesetPalette(const QList<QList<QRgb>> &palettes, int paletteIndex);
|
||||
QJSValue getTilesetPalettes(const QList<QList<QRgb>> &palettes);
|
||||
Q_INVOKABLE QJSValue getPrimaryTilesetPalette(int paletteIndex);
|
||||
Q_INVOKABLE QJSValue getPrimaryTilesetPalettes();
|
||||
Q_INVOKABLE QJSValue getSecondaryTilesetPalette(int paletteIndex);
|
||||
|
|
|
@ -8,13 +8,13 @@ MetatileParser::MetatileParser()
|
|||
|
||||
}
|
||||
|
||||
QList<Metatile*> *MetatileParser::parse(QString filepath, bool *error, bool primaryTileset)
|
||||
QList<Metatile*> MetatileParser::parse(QString filepath, bool *error, bool primaryTileset)
|
||||
{
|
||||
QFile file(filepath);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
*error = true;
|
||||
logError(QString("Could not open Advance Map 1.92 Metatile .bvd file '%1': ").arg(filepath) + file.errorString());
|
||||
return nullptr;
|
||||
return { };
|
||||
}
|
||||
|
||||
QByteArray in = file.readAll();
|
||||
|
@ -23,7 +23,7 @@ QList<Metatile*> *MetatileParser::parse(QString filepath, bool *error, bool prim
|
|||
if (in.length() < 9 || in.length() % 2 != 0) {
|
||||
*error = true;
|
||||
logError(QString("Advance Map 1.92 Metatile .bvd file '%1' is an unexpected size.").arg(filepath));
|
||||
return nullptr;
|
||||
return { };
|
||||
}
|
||||
|
||||
int projIdOffset = in.length() - 4;
|
||||
|
@ -46,7 +46,7 @@ QList<Metatile*> *MetatileParser::parse(QString filepath, bool *error, bool prim
|
|||
} else {
|
||||
*error = true;
|
||||
logError(QString("Detected unsupported game type from .bvd file. Last 4 bytes of file must be 'RSE ' or 'FRLG'."));
|
||||
return nullptr;
|
||||
return { };
|
||||
}
|
||||
|
||||
int maxMetatiles = primaryTileset ? Project::getNumMetatilesPrimary() : Project::getNumMetatilesTotal() - Project::getNumMetatilesPrimary();
|
||||
|
@ -57,22 +57,22 @@ QList<Metatile*> *MetatileParser::parse(QString filepath, bool *error, bool prim
|
|||
if (numMetatiles > maxMetatiles) {
|
||||
*error = true;
|
||||
logError(QString(".bvd file contains data for %1 metatiles, but the maximum number of metatiles is %2.").arg(numMetatiles).arg(maxMetatiles));
|
||||
return nullptr;
|
||||
return { };
|
||||
}
|
||||
if (numMetatiles < 1) {
|
||||
*error = true;
|
||||
logError(QString(".bvd file contains no data for metatiles."));
|
||||
return nullptr;
|
||||
return { };
|
||||
}
|
||||
|
||||
int expectedFileSize = 4 + (metatileSize * numMetatiles) + (attrSize * numMetatiles) + 4;
|
||||
if (in.length() != expectedFileSize) {
|
||||
*error = true;
|
||||
logError(QString(".bvd file is an unexpected size. Expected %1 bytes, but it has %2 bytes.").arg(expectedFileSize).arg(in.length()));
|
||||
return nullptr;
|
||||
return { };
|
||||
}
|
||||
|
||||
QList<Metatile*> *metatiles = new QList<Metatile*>();
|
||||
QList<Metatile*> metatiles;
|
||||
for (int i = 0; i < numMetatiles; i++) {
|
||||
Metatile *metatile = new Metatile();
|
||||
QList<Tile> tiles;
|
||||
|
@ -104,7 +104,7 @@ QList<Metatile*> *MetatileParser::parse(QString filepath, bool *error, bool prim
|
|||
metatile->terrainType = 0;
|
||||
}
|
||||
metatile->tiles = tiles;
|
||||
metatiles->append(metatile);
|
||||
metatiles.append(metatile);
|
||||
}
|
||||
|
||||
return metatiles;
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
#include "tile.h"
|
||||
|
||||
Tile::Tile(int tile, bool xflip, bool yflip, int palette)
|
||||
{
|
||||
this->tile = tile;
|
||||
this->xflip = xflip;
|
||||
this->yflip = yflip;
|
||||
this->palette = palette;
|
||||
}
|
|
@ -7,55 +7,6 @@
|
|||
#include <QPainter>
|
||||
#include <QImage>
|
||||
|
||||
Tileset::Tileset()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Tileset* Tileset::copy() {
|
||||
Tileset *copy = new Tileset;
|
||||
copy->name = this->name;
|
||||
copy->is_compressed = this->is_compressed;
|
||||
copy->is_secondary = this->is_secondary;
|
||||
copy->padding = this->padding;
|
||||
copy->tiles_label = this->tiles_label;
|
||||
copy->palettes_label = this->palettes_label;
|
||||
copy->metatiles_label = this->metatiles_label;
|
||||
copy->metatiles_path = this->metatiles_path;
|
||||
copy->callback_label = this->callback_label;
|
||||
copy->metatile_attrs_label = this->metatile_attrs_label;
|
||||
copy->metatile_attrs_path = this->metatile_attrs_path;
|
||||
copy->tilesImage = this->tilesImage.copy();
|
||||
copy->tilesImagePath = this->tilesImagePath;
|
||||
for (int i = 0; i < this->palettePaths.length(); i++) {
|
||||
copy->palettePaths.append(this->palettePaths.at(i));
|
||||
}
|
||||
copy->tiles = new QList<QImage>;
|
||||
for (QImage tile : *this->tiles) {
|
||||
copy->tiles->append(tile.copy());
|
||||
}
|
||||
copy->metatiles = new QList<Metatile*>;
|
||||
for (Metatile *metatile : *this->metatiles) {
|
||||
copy->metatiles->append(new Metatile(*metatile));
|
||||
}
|
||||
copy->palettes = new QList<QList<QRgb>>;
|
||||
for (QList<QRgb> palette : *this->palettes) {
|
||||
QList<QRgb> copyPalette;
|
||||
for (QRgb color : palette) {
|
||||
copyPalette.append(color);
|
||||
}
|
||||
copy->palettes->append(copyPalette);
|
||||
}
|
||||
copy->palettePreviews = new QList<QList<QRgb>>;
|
||||
for (QList<QRgb> palette : *this->palettePreviews) {
|
||||
QList<QRgb> copyPalette;
|
||||
for (QRgb color : palette) {
|
||||
copyPalette.append(color);
|
||||
}
|
||||
copy->palettePreviews->append(copyPalette);
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
Tileset* Tileset::getBlockTileset(int metatile_index, Tileset *primaryTileset, Tileset *secondaryTileset) {
|
||||
if (metatile_index < Project::getNumMetatilesPrimary()) {
|
||||
|
@ -68,20 +19,20 @@ Tileset* Tileset::getBlockTileset(int metatile_index, Tileset *primaryTileset, T
|
|||
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) {
|
||||
if (!tileset) {
|
||||
return nullptr;
|
||||
}
|
||||
return tileset->metatiles->value(local_index, nullptr);
|
||||
return tileset->metatiles.value(local_index, nullptr);
|
||||
}
|
||||
|
||||
bool Tileset::metatileIsValid(uint16_t metatileId, Tileset *primaryTileset, Tileset *secondaryTileset) {
|
||||
if (metatileId >= Project::getNumMetatilesTotal())
|
||||
return false;
|
||||
|
||||
if (metatileId < Project::getNumMetatilesPrimary() && metatileId >= primaryTileset->metatiles->length())
|
||||
if (metatileId < Project::getNumMetatilesPrimary() && metatileId >= primaryTileset->metatiles.length())
|
||||
return false;
|
||||
|
||||
if (metatileId >= Project::getNumMetatilesPrimary() + secondaryTileset->metatiles->length())
|
||||
if (metatileId >= Project::getNumMetatilesPrimary() + secondaryTileset->metatiles.length())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -91,11 +42,11 @@ QList<QList<QRgb>> Tileset::getBlockPalettes(Tileset *primaryTileset, Tileset *s
|
|||
QList<QList<QRgb>> palettes;
|
||||
auto primaryPalettes = useTruePalettes ? primaryTileset->palettes : primaryTileset->palettePreviews;
|
||||
for (int i = 0; i < Project::getNumPalettesPrimary(); i++) {
|
||||
palettes.append(primaryPalettes->at(i));
|
||||
palettes.append(primaryPalettes.at(i));
|
||||
}
|
||||
auto secondaryPalettes = useTruePalettes ? secondaryTileset->palettes : secondaryTileset->palettePreviews;
|
||||
for (int i = Project::getNumPalettesPrimary(); i < Project::getNumPalettesTotal(); i++) {
|
||||
palettes.append(secondaryPalettes->at(i));
|
||||
palettes.append(secondaryPalettes.at(i));
|
||||
}
|
||||
return palettes;
|
||||
}
|
||||
|
@ -106,8 +57,8 @@ QList<QRgb> Tileset::getPalette(int paletteId, Tileset *primaryTileset, Tileset
|
|||
? primaryTileset
|
||||
: secondaryTileset;
|
||||
auto palettes = useTruePalettes ? tileset->palettes : tileset->palettePreviews;
|
||||
for (int i = 0; i < palettes->at(paletteId).length(); i++) {
|
||||
paletteTable.append(palettes->at(paletteId).at(i));
|
||||
for (int i = 0; i < palettes.at(paletteId).length(); i++) {
|
||||
paletteTable.append(palettes.at(paletteId).at(i));
|
||||
}
|
||||
return paletteTable;
|
||||
}
|
||||
|
|
|
@ -1212,22 +1212,18 @@ void MainWindow::on_actionNew_Tileset_triggered() {
|
|||
newSet->metatile_attrs_path = fullDirectoryPath + "/metatile_attributes.bin";
|
||||
newSet->is_secondary = createTilesetDialog->isSecondary ? "TRUE" : "FALSE";
|
||||
int numMetaTiles = createTilesetDialog->isSecondary ? (Project::getNumTilesTotal() - Project::getNumTilesPrimary()) : Project::getNumTilesPrimary();
|
||||
QImage *tilesImage = new QImage(":/images/blank_tileset.png");
|
||||
editor->project->loadTilesetTiles(newSet, *tilesImage);
|
||||
newSet->metatiles = new QList<Metatile*>();
|
||||
QImage tilesImage(":/images/blank_tileset.png");
|
||||
editor->project->loadTilesetTiles(newSet, tilesImage);
|
||||
for(int i = 0; i < numMetaTiles; ++i) {
|
||||
int tilesPerMetatile = projectConfig.getTripleLayerMetatilesEnabled() ? 12 : 8;
|
||||
Metatile *mt = new Metatile();
|
||||
for(int j = 0; j < tilesPerMetatile; ++j){
|
||||
Tile tile;
|
||||
Tile tile(0, false, false, 0);
|
||||
//Create a checkerboard-style dummy tileset
|
||||
if(((i / 8) % 2) == 0)
|
||||
tile.tile = ((i % 2) == 0) ? 1 : 2;
|
||||
else
|
||||
tile.tile = ((i % 2) == 1) ? 1 : 2;
|
||||
tile.xflip = false;
|
||||
tile.yflip = false;
|
||||
tile.palette = 0;
|
||||
mt->tiles.append(tile);
|
||||
}
|
||||
mt->behavior = 0;
|
||||
|
@ -1235,23 +1231,20 @@ void MainWindow::on_actionNew_Tileset_triggered() {
|
|||
mt->encounterType = 0;
|
||||
mt->terrainType = 0;
|
||||
|
||||
newSet->metatiles->append(mt);
|
||||
newSet->metatiles.append(mt);
|
||||
}
|
||||
newSet->palettes = new QList<QList<QRgb>>();
|
||||
newSet->palettePreviews = new QList<QList<QRgb>>();
|
||||
newSet->palettePaths.clear();
|
||||
for(int i = 0; i < 16; ++i) {
|
||||
QList<QRgb> *currentPal = new QList<QRgb>();
|
||||
QList<QRgb> currentPal;
|
||||
for(int i = 0; i < 16;++i) {
|
||||
currentPal->append(qRgb(0,0,0));
|
||||
currentPal.append(qRgb(0,0,0));
|
||||
}
|
||||
newSet->palettes->append(*currentPal);
|
||||
newSet->palettePreviews->append(*currentPal);
|
||||
newSet->palettes.append(currentPal);
|
||||
newSet->palettePreviews.append(currentPal);
|
||||
QString fileName = QString("%1.pal").arg(i, 2, 10, QLatin1Char('0'));
|
||||
newSet->palettePaths.append(fullDirectoryPath+"/palettes/" + fileName);
|
||||
}
|
||||
(*newSet->palettes)[0][1] = qRgb(255,0,255);
|
||||
(*newSet->palettePreviews)[0][1] = qRgb(255,0,255);
|
||||
newSet->palettes[0][1] = qRgb(255,0,255);
|
||||
newSet->palettePreviews[0][1] = qRgb(255,0,255);
|
||||
newSet->is_compressed = "TRUE";
|
||||
newSet->padding = "0";
|
||||
editor->project->saveTilesetTilesImage(newSet);
|
||||
|
|
|
@ -260,7 +260,7 @@ void MainWindow::refreshAfterPaletteChange(Tileset *tileset) {
|
|||
void MainWindow::setTilesetPalette(Tileset *tileset, int paletteIndex, QList<QList<int>> colors) {
|
||||
if (!this->editor || !this->editor->map || !this->editor->map->layout)
|
||||
return;
|
||||
if (paletteIndex >= tileset->palettes->size())
|
||||
if (paletteIndex >= tileset->palettes.size())
|
||||
return;
|
||||
if (colors.size() != 16)
|
||||
return;
|
||||
|
@ -268,8 +268,8 @@ void MainWindow::setTilesetPalette(Tileset *tileset, int paletteIndex, QList<QLi
|
|||
for (int i = 0; i < 16; i++) {
|
||||
if (colors[i].size() != 3)
|
||||
continue;
|
||||
(*tileset->palettes)[paletteIndex][i] = qRgb(colors[i][0], colors[i][1], colors[i][2]);
|
||||
(*tileset->palettePreviews)[paletteIndex][i] = qRgb(colors[i][0], colors[i][1], colors[i][2]);
|
||||
tileset->palettes[paletteIndex][i] = qRgb(colors[i][0], colors[i][1], colors[i][2]);
|
||||
tileset->palettePreviews[paletteIndex][i] = qRgb(colors[i][0], colors[i][1], colors[i][2]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -305,22 +305,22 @@ void MainWindow::setSecondaryTilesetPalettes(QList<QList<QList<int>>> palettes)
|
|||
this->refreshAfterPaletteChange(this->editor->map->layout->tileset_secondary);
|
||||
}
|
||||
|
||||
QJSValue MainWindow::getTilesetPalette(QList<QList<QRgb>> *palettes, int paletteIndex) {
|
||||
if (paletteIndex >= palettes->size())
|
||||
QJSValue MainWindow::getTilesetPalette(const QList<QList<QRgb>> &palettes, int paletteIndex) {
|
||||
if (paletteIndex >= palettes.size())
|
||||
return QJSValue();
|
||||
|
||||
QList<QList<int>> palette;
|
||||
for (auto color : palettes->value(paletteIndex)) {
|
||||
for (auto color : palettes.value(paletteIndex)) {
|
||||
palette.append(QList<int>({qRed(color), qGreen(color), qBlue(color)}));
|
||||
}
|
||||
return Scripting::getEngine()->toScriptValue(palette);
|
||||
}
|
||||
|
||||
QJSValue MainWindow::getTilesetPalettes(QList<QList<QRgb>> *palettes) {
|
||||
QJSValue MainWindow::getTilesetPalettes(const QList<QList<QRgb>> &palettes) {
|
||||
QList<QList<QList<int>>> outPalettes;
|
||||
for (int i = 0; i < palettes->size(); i++) {
|
||||
for (int i = 0; i < palettes.size(); i++) {
|
||||
QList<QList<int>> colors;
|
||||
for (auto color : palettes->value(i)) {
|
||||
for (auto color : palettes.value(i)) {
|
||||
colors.append(QList<int>({qRed(color), qGreen(color), qBlue(color)}));
|
||||
}
|
||||
outPalettes.append(colors);
|
||||
|
@ -363,7 +363,7 @@ void MainWindow::refreshAfterPalettePreviewChange() {
|
|||
void MainWindow::setTilesetPalettePreview(Tileset *tileset, int paletteIndex, QList<QList<int>> colors) {
|
||||
if (!this->editor || !this->editor->map || !this->editor->map->layout)
|
||||
return;
|
||||
if (paletteIndex >= tileset->palettePreviews->size())
|
||||
if (paletteIndex >= tileset->palettePreviews.size())
|
||||
return;
|
||||
if (colors.size() != 16)
|
||||
return;
|
||||
|
@ -371,8 +371,7 @@ void MainWindow::setTilesetPalettePreview(Tileset *tileset, int paletteIndex, QL
|
|||
for (int i = 0; i < 16; i++) {
|
||||
if (colors[i].size() != 3)
|
||||
continue;
|
||||
auto palettes = tileset->palettePreviews;
|
||||
(*palettes)[paletteIndex][i] = qRgb(colors[i][0], colors[i][1], colors[i][2]);
|
||||
tileset->palettePreviews[paletteIndex][i] = qRgb(colors[i][0], colors[i][1], colors[i][2]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -995,16 +995,16 @@ void Project::saveTilesetMetatileLabels(Tileset *primaryTileset, Tileset *second
|
|||
}
|
||||
|
||||
// Add the new labels.
|
||||
for (int i = 0; i < primaryTileset->metatiles->size(); i++) {
|
||||
Metatile *metatile = primaryTileset->metatiles->at(i);
|
||||
for (int i = 0; i < primaryTileset->metatiles.size(); i++) {
|
||||
Metatile *metatile = primaryTileset->metatiles.at(i);
|
||||
if (metatile->label.size() != 0) {
|
||||
QString defineName = QString("%1%2").arg(primaryPrefix, metatile->label);
|
||||
defines.insert(defineName, i);
|
||||
definesFileModified = true;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < secondaryTileset->metatiles->size(); i++) {
|
||||
Metatile *metatile = secondaryTileset->metatiles->at(i);
|
||||
for (int i = 0; i < secondaryTileset->metatiles.size(); i++) {
|
||||
Metatile *metatile = secondaryTileset->metatiles.at(i);
|
||||
if (metatile->label.size() != 0) {
|
||||
QString defineName = QString("%1%2").arg(secondaryPrefix, metatile->label);
|
||||
defines.insert(defineName, i + Project::num_tiles_primary);
|
||||
|
@ -1061,7 +1061,7 @@ void Project::saveTilesetMetatileAttributes(Tileset *tileset) {
|
|||
QByteArray data;
|
||||
|
||||
if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered) {
|
||||
for (Metatile *metatile : *tileset->metatiles) {
|
||||
for (Metatile *metatile : tileset->metatiles) {
|
||||
data.append(static_cast<char>(metatile->behavior));
|
||||
data.append(static_cast<char>(metatile->behavior >> 8) |
|
||||
static_cast<char>(metatile->terrainType << 1));
|
||||
|
@ -1070,7 +1070,7 @@ void Project::saveTilesetMetatileAttributes(Tileset *tileset) {
|
|||
static_cast<char>(metatile->layerType << 5));
|
||||
}
|
||||
} else {
|
||||
for (Metatile *metatile : *tileset->metatiles) {
|
||||
for (Metatile *metatile : tileset->metatiles) {
|
||||
data.append(static_cast<char>(metatile->behavior));
|
||||
data.append(static_cast<char>((metatile->layerType << 4) & 0xF0));
|
||||
}
|
||||
|
@ -1085,7 +1085,7 @@ void Project::saveTilesetMetatiles(Tileset *tileset) {
|
|||
QFile metatiles_file(tileset->metatiles_path);
|
||||
if (metatiles_file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||
QByteArray data;
|
||||
for (Metatile *metatile : *tileset->metatiles) {
|
||||
for (Metatile *metatile : tileset->metatiles) {
|
||||
int numTiles = projectConfig.getTripleLayerMetatilesEnabled() ? 12 : 8;
|
||||
for (int i = 0; i < numTiles; i++) {
|
||||
Tile tile = metatile->tiles.at(i);
|
||||
|
@ -1099,7 +1099,7 @@ void Project::saveTilesetMetatiles(Tileset *tileset) {
|
|||
}
|
||||
metatiles_file.write(data);
|
||||
} else {
|
||||
tileset->metatiles = new QList<Metatile*>;
|
||||
tileset->metatiles.clear();
|
||||
logError(QString("Could not open tileset metatiles file '%1'").arg(tileset->metatiles_path));
|
||||
}
|
||||
}
|
||||
|
@ -1112,7 +1112,7 @@ void Project::saveTilesetPalettes(Tileset *tileset) {
|
|||
PaletteUtil paletteParser;
|
||||
for (int i = 0; i < Project::getNumPalettesTotal(); i++) {
|
||||
QString filepath = tileset->palettePaths.at(i);
|
||||
paletteParser.writeJASC(filepath, tileset->palettes->at(i).toVector(), 0, 16);
|
||||
paletteParser.writeJASC(filepath, tileset->palettes.at(i).toVector(), 0, 16);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1552,8 +1552,8 @@ void Project::loadTilesetAssets(Tileset* tileset) {
|
|||
this->loadTilesetMetatileLabels(tileset);
|
||||
|
||||
// palettes
|
||||
QList<QList<QRgb>> *palettes = new QList<QList<QRgb>>;
|
||||
QList<QList<QRgb>> *palettePreviews = new QList<QList<QRgb>>;
|
||||
QList<QList<QRgb>> palettes;
|
||||
QList<QList<QRgb>> palettePreviews;
|
||||
for (int i = 0; i < tileset->palettePaths.length(); i++) {
|
||||
QList<QRgb> palette;
|
||||
QString path = tileset->palettePaths.value(i);
|
||||
|
@ -1587,21 +1587,21 @@ void Project::loadTilesetAssets(Tileset* tileset) {
|
|||
logError(QString("Could not open tileset palette path '%1'").arg(path));
|
||||
}
|
||||
|
||||
palettes->append(palette);
|
||||
palettePreviews->append(palette);
|
||||
palettes.append(palette);
|
||||
palettePreviews.append(palette);
|
||||
}
|
||||
tileset->palettes = palettes;
|
||||
tileset->palettePreviews = palettePreviews;
|
||||
}
|
||||
|
||||
void Project::loadTilesetTiles(Tileset *tileset, QImage image) {
|
||||
QList<QImage> *tiles = new QList<QImage>;
|
||||
QList<QImage> tiles;
|
||||
int w = 8;
|
||||
int h = 8;
|
||||
for (int y = 0; y < image.height(); y += h)
|
||||
for (int x = 0; x < image.width(); x += w) {
|
||||
QImage tile = image.copy(x, y, w, h);
|
||||
tiles->append(tile);
|
||||
tiles.append(tile);
|
||||
}
|
||||
tileset->tilesImage = image;
|
||||
tileset->tiles = tiles;
|
||||
|
@ -1614,7 +1614,7 @@ void Project::loadTilesetMetatiles(Tileset* tileset) {
|
|||
int metatile_data_length = projectConfig.getTripleLayerMetatilesEnabled() ? 24 : 16;
|
||||
int num_metatiles = data.length() / metatile_data_length;
|
||||
int num_layers = projectConfig.getTripleLayerMetatilesEnabled() ? 3 : 2;
|
||||
QList<Metatile*> *metatiles = new QList<Metatile*>;
|
||||
QList<Metatile*> metatiles;
|
||||
for (int i = 0; i < num_metatiles; i++) {
|
||||
Metatile *metatile = new Metatile;
|
||||
int index = i * (2 * 4 * num_layers);
|
||||
|
@ -1628,18 +1628,18 @@ void Project::loadTilesetMetatiles(Tileset* tileset) {
|
|||
tile.palette = (word >> 12) & 0xf;
|
||||
metatile->tiles.append(tile);
|
||||
}
|
||||
metatiles->append(metatile);
|
||||
metatiles.append(metatile);
|
||||
}
|
||||
tileset->metatiles = metatiles;
|
||||
} else {
|
||||
tileset->metatiles = new QList<Metatile*>;
|
||||
tileset->metatiles.clear();
|
||||
logError(QString("Could not open tileset metatiles file '%1'").arg(tileset->metatiles_path));
|
||||
}
|
||||
|
||||
QFile attrs_file(tileset->metatile_attrs_path);
|
||||
if (attrs_file.open(QIODevice::ReadOnly)) {
|
||||
QByteArray data = attrs_file.readAll();
|
||||
int num_metatiles = tileset->metatiles->count();
|
||||
int num_metatiles = tileset->metatiles.count();
|
||||
|
||||
if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered) {
|
||||
int num_metatileAttrs = data.length() / 4;
|
||||
|
@ -1654,10 +1654,10 @@ void Project::loadTilesetMetatiles(Tileset* tileset) {
|
|||
(static_cast<unsigned char>(data.at(i * 4 + 2)) << 16) |
|
||||
(static_cast<unsigned char>(data.at(i * 4 + 1)) << 8) |
|
||||
(static_cast<unsigned char>(data.at(i * 4 + 0)));
|
||||
tileset->metatiles->at(i)->behavior = value & 0x1FF;
|
||||
tileset->metatiles->at(i)->terrainType = (value & 0x3E00) >> 9;
|
||||
tileset->metatiles->at(i)->encounterType = (value & 0x7000000) >> 24;
|
||||
tileset->metatiles->at(i)->layerType = (value & 0x60000000) >> 29;
|
||||
tileset->metatiles.at(i)->behavior = value & 0x1FF;
|
||||
tileset->metatiles.at(i)->terrainType = (value & 0x3E00) >> 9;
|
||||
tileset->metatiles.at(i)->encounterType = (value & 0x7000000) >> 24;
|
||||
tileset->metatiles.at(i)->layerType = (value & 0x60000000) >> 29;
|
||||
if (value & ~(0x67003FFF))
|
||||
unusedAttribute = true;
|
||||
}
|
||||
|
@ -1672,10 +1672,10 @@ void Project::loadTilesetMetatiles(Tileset* tileset) {
|
|||
}
|
||||
for (int i = 0; i < num_metatileAttrs; i++) {
|
||||
int value = (static_cast<unsigned char>(data.at(i * 2 + 1)) << 8) | static_cast<unsigned char>(data.at(i * 2));
|
||||
tileset->metatiles->at(i)->behavior = value & 0xFF;
|
||||
tileset->metatiles->at(i)->layerType = (value & 0xF000) >> 12;
|
||||
tileset->metatiles->at(i)->encounterType = 0;
|
||||
tileset->metatiles->at(i)->terrainType = 0;
|
||||
tileset->metatiles.at(i)->behavior = value & 0xFF;
|
||||
tileset->metatiles.at(i)->layerType = (value & 0xF000) >> 12;
|
||||
tileset->metatiles.at(i)->encounterType = 0;
|
||||
tileset->metatiles.at(i)->terrainType = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -1734,7 +1734,7 @@ Tileset* Project::getTileset(QString label, bool forceLoad) {
|
|||
}
|
||||
|
||||
if (existingTileset && !forceLoad) {
|
||||
return tilesetCache->value(label);
|
||||
return existingTileset;
|
||||
} else {
|
||||
Tileset *tileset = loadTileset(label, existingTileset);
|
||||
return tileset;
|
||||
|
|
|
@ -97,10 +97,10 @@ QImage getMetatileImage(
|
|||
QImage getTileImage(uint16_t tile, Tileset *primaryTileset, Tileset *secondaryTileset) {
|
||||
Tileset *tileset = Tileset::getBlockTileset(tile, primaryTileset, secondaryTileset);
|
||||
int local_index = Metatile::getBlockIndex(tile);
|
||||
if (!tileset || !tileset->tiles) {
|
||||
if (!tileset) {
|
||||
return QImage();
|
||||
}
|
||||
return tileset->tiles->value(local_index, QImage());
|
||||
return tileset->tiles.value(local_index, QImage());
|
||||
}
|
||||
|
||||
QImage getColoredTileImage(uint16_t tile, Tileset *primaryTileset, Tileset *secondaryTileset, QList<QRgb> palette) {
|
||||
|
|
|
@ -12,13 +12,12 @@ QPoint MetatileSelector::getSelectionDimensions() {
|
|||
}
|
||||
|
||||
void MetatileSelector::draw() {
|
||||
if (!this->primaryTileset || !this->primaryTileset->metatiles
|
||||
|| !this->secondaryTileset || !this->secondaryTileset->metatiles) {
|
||||
if (!this->primaryTileset || !this->secondaryTileset) {
|
||||
this->setPixmap(QPixmap());
|
||||
}
|
||||
|
||||
int primaryLength = this->primaryTileset->metatiles->length();
|
||||
int length_ = primaryLength + this->secondaryTileset->metatiles->length();
|
||||
int primaryLength = this->primaryTileset->metatiles.length();
|
||||
int length_ = primaryLength + this->secondaryTileset->metatiles.length();
|
||||
int height_ = length_ / this->numMetatilesWide;
|
||||
if (length_ % this->numMetatilesWide != 0) {
|
||||
height_++;
|
||||
|
@ -69,7 +68,7 @@ void MetatileSelector::setTilesets(Tileset *primaryTileset, Tileset *secondaryTi
|
|||
if (this->externalSelection) {
|
||||
this->select(0);
|
||||
} else {
|
||||
this->select(Project::getNumMetatilesPrimary() + this->secondaryTileset->metatiles->length() - 1);
|
||||
this->select(Project::getNumMetatilesPrimary() + this->secondaryTileset->metatiles.length() - 1);
|
||||
}
|
||||
} else if (this->externalSelection) {
|
||||
emit selectedMetatilesChanged();
|
||||
|
@ -181,10 +180,10 @@ bool MetatileSelector::selectionIsValid() {
|
|||
|
||||
uint16_t MetatileSelector::getMetatileId(int x, int y) {
|
||||
int index = y * this->numMetatilesWide + x;
|
||||
if (index < this->primaryTileset->metatiles->length()) {
|
||||
if (index < this->primaryTileset->metatiles.length()) {
|
||||
return static_cast<uint16_t>(index);
|
||||
} else {
|
||||
return static_cast<uint16_t>(Project::getNumMetatilesPrimary() + index - this->primaryTileset->metatiles->length());
|
||||
return static_cast<uint16_t>(Project::getNumMetatilesPrimary() + index - this->primaryTileset->metatiles.length());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,7 +196,7 @@ QPoint MetatileSelector::getMetatileIdCoords(uint16_t metatileId) {
|
|||
|
||||
int index = metatileId < Project::getNumMetatilesPrimary()
|
||||
? metatileId
|
||||
: metatileId - Project::getNumMetatilesPrimary() + this->primaryTileset->metatiles->length();
|
||||
: metatileId - Project::getNumMetatilesPrimary() + this->primaryTileset->metatiles.length();
|
||||
return QPoint(index % this->numMetatilesWide, index / this->numMetatilesWide);
|
||||
}
|
||||
|
||||
|
|
|
@ -151,9 +151,9 @@ void PaletteEditor::refreshColorSliders() {
|
|||
for (int i = 0; i < 16; i++) {
|
||||
QRgb color;
|
||||
if (paletteNum < Project::getNumPalettesPrimary()) {
|
||||
color = this->primaryTileset->palettes->at(paletteNum).at(i);
|
||||
color = this->primaryTileset->palettes.at(paletteNum).at(i);
|
||||
} else {
|
||||
color = this->secondaryTileset->palettes->at(paletteNum).at(i);
|
||||
color = this->secondaryTileset->palettes.at(paletteNum).at(i);
|
||||
}
|
||||
|
||||
this->sliders[i][0]->setValue(qRed(color) / 8);
|
||||
|
@ -204,8 +204,8 @@ void PaletteEditor::setColor(int colorIndex) {
|
|||
Tileset *tileset = paletteNum < Project::getNumPalettesPrimary()
|
||||
? this->primaryTileset
|
||||
: this->secondaryTileset;
|
||||
(*tileset->palettes)[paletteNum][colorIndex] = qRgb(red, green, blue);
|
||||
(*tileset->palettePreviews)[paletteNum][colorIndex] = qRgb(red, green, blue);
|
||||
tileset->palettes[paletteNum][colorIndex] = qRgb(red, green, blue);
|
||||
tileset->palettePreviews[paletteNum][colorIndex] = qRgb(red, green, blue);
|
||||
this->refreshColor(colorIndex);
|
||||
this->commitEditHistory(paletteNum);
|
||||
emit this->changedPaletteColor();
|
||||
|
@ -255,11 +255,11 @@ void PaletteEditor::setColorsFromHistory(PaletteHistoryItem *history, int palett
|
|||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if (paletteId < Project::getNumPalettesPrimary()) {
|
||||
(*this->primaryTileset->palettes)[paletteId][i] = history->colors.at(i);
|
||||
(*this->primaryTileset->palettePreviews)[paletteId][i] = history->colors.at(i);
|
||||
this->primaryTileset->palettes[paletteId][i] = history->colors.at(i);
|
||||
this->primaryTileset->palettePreviews[paletteId][i] = history->colors.at(i);
|
||||
} else {
|
||||
(*this->secondaryTileset->palettes)[paletteId][i] = history->colors.at(i);
|
||||
(*this->secondaryTileset->palettePreviews)[paletteId][i] = history->colors.at(i);
|
||||
this->secondaryTileset->palettes[paletteId][i] = history->colors.at(i);
|
||||
this->secondaryTileset->palettePreviews[paletteId][i] = history->colors.at(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -307,11 +307,11 @@ void PaletteEditor::on_actionImport_Palette_triggered()
|
|||
int paletteId = this->ui->spinBox_PaletteId->value();
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if (paletteId < Project::getNumPalettesPrimary()) {
|
||||
(*this->primaryTileset->palettes)[paletteId][i] = palette.at(i);
|
||||
(*this->primaryTileset->palettePreviews)[paletteId][i] = palette.at(i);
|
||||
this->primaryTileset->palettes[paletteId][i] = palette.at(i);
|
||||
this->primaryTileset->palettePreviews[paletteId][i] = palette.at(i);
|
||||
} else {
|
||||
(*this->secondaryTileset->palettes)[paletteId][i] = palette.at(i);
|
||||
(*this->secondaryTileset->palettePreviews)[paletteId][i] = palette.at(i);
|
||||
this->secondaryTileset->palettes[paletteId][i] = palette.at(i);
|
||||
this->secondaryTileset->palettePreviews[paletteId][i] = palette.at(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,8 +81,8 @@ void TilesetEditor::setTilesets(QString primaryTilesetLabel, QString secondaryTi
|
|||
Tileset *secondaryTileset = project->getTileset(secondaryTilesetLabel);
|
||||
if (this->primaryTileset) delete this->primaryTileset;
|
||||
if (this->secondaryTileset) delete this->secondaryTileset;
|
||||
this->primaryTileset = primaryTileset->copy();
|
||||
this->secondaryTileset = secondaryTileset->copy();
|
||||
this->primaryTileset = new Tileset(*primaryTileset);
|
||||
this->secondaryTileset = new Tileset(*secondaryTileset);
|
||||
if (paletteEditor) paletteEditor->setTilesets(this->primaryTileset, this->secondaryTileset);
|
||||
}
|
||||
|
||||
|
@ -716,8 +716,8 @@ void TilesetEditor::on_actionChange_Metatiles_Count_triggered()
|
|||
secondarySpinBox->setMinimum(1);
|
||||
primarySpinBox->setMaximum(Project::getNumMetatilesPrimary());
|
||||
secondarySpinBox->setMaximum(Project::getNumMetatilesTotal() - Project::getNumMetatilesPrimary());
|
||||
primarySpinBox->setValue(this->primaryTileset->metatiles->length());
|
||||
secondarySpinBox->setValue(this->secondaryTileset->metatiles->length());
|
||||
primarySpinBox->setValue(this->primaryTileset->metatiles.length());
|
||||
secondarySpinBox->setValue(this->secondaryTileset->metatiles.length());
|
||||
form.addRow(new QLabel("Primary Tileset"), primarySpinBox);
|
||||
form.addRow(new QLabel("Secondary Tileset"), secondarySpinBox);
|
||||
|
||||
|
@ -730,16 +730,11 @@ void TilesetEditor::on_actionChange_Metatiles_Count_triggered()
|
|||
int numPrimaryMetatiles = primarySpinBox->value();
|
||||
int numSecondaryMetatiles = secondarySpinBox->value();
|
||||
int numTiles = projectConfig.getTripleLayerMetatilesEnabled() ? 12 : 8;
|
||||
while (this->primaryTileset->metatiles->length() > numPrimaryMetatiles) {
|
||||
Metatile *metatile = this->primaryTileset->metatiles->takeLast();
|
||||
delete metatile;
|
||||
while (this->primaryTileset->metatiles.length() > numPrimaryMetatiles) {
|
||||
delete this->primaryTileset->metatiles.takeLast();
|
||||
}
|
||||
while (this->primaryTileset->metatiles->length() < numPrimaryMetatiles) {
|
||||
Tile tile;
|
||||
tile.palette = 0;
|
||||
tile.tile = 0;
|
||||
tile.xflip = false;
|
||||
tile.yflip = false;
|
||||
while (this->primaryTileset->metatiles.length() < numPrimaryMetatiles) {
|
||||
Tile tile(0, false, false, 0);
|
||||
Metatile *metatile = new Metatile;
|
||||
metatile->behavior = 0;
|
||||
metatile->layerType = 0;
|
||||
|
@ -748,18 +743,13 @@ void TilesetEditor::on_actionChange_Metatiles_Count_triggered()
|
|||
for (int i = 0; i < numTiles; i++) {
|
||||
metatile->tiles.append(tile);
|
||||
}
|
||||
this->primaryTileset->metatiles->append(metatile);
|
||||
this->primaryTileset->metatiles.append(metatile);
|
||||
}
|
||||
while (this->secondaryTileset->metatiles->length() > numSecondaryMetatiles) {
|
||||
Metatile *metatile = this->secondaryTileset->metatiles->takeLast();
|
||||
delete metatile;
|
||||
while (this->secondaryTileset->metatiles.length() > numSecondaryMetatiles) {
|
||||
delete this->secondaryTileset->metatiles.takeLast();
|
||||
}
|
||||
while (this->secondaryTileset->metatiles->length() < numSecondaryMetatiles) {
|
||||
Tile tile;
|
||||
tile.palette = 0;
|
||||
tile.tile = 0;
|
||||
tile.xflip = 0;
|
||||
tile.yflip = 0;
|
||||
while (this->secondaryTileset->metatiles.length() < numSecondaryMetatiles) {
|
||||
Tile tile(0, false, false, 0);
|
||||
Metatile *metatile = new Metatile;
|
||||
metatile->behavior = 0;
|
||||
metatile->layerType = 0;
|
||||
|
@ -768,7 +758,7 @@ void TilesetEditor::on_actionChange_Metatiles_Count_triggered()
|
|||
for (int i = 0; i < numTiles; i++) {
|
||||
metatile->tiles.append(tile);
|
||||
}
|
||||
this->secondaryTileset->metatiles->append(metatile);
|
||||
this->secondaryTileset->metatiles.append(metatile);
|
||||
}
|
||||
|
||||
this->metatileSelector->updateSelectedMetatile();
|
||||
|
@ -891,7 +881,7 @@ void TilesetEditor::importTilesetMetatiles(Tileset *tileset, bool primary)
|
|||
|
||||
MetatileParser parser;
|
||||
bool error = false;
|
||||
QList<Metatile*> *metatiles = parser.parse(filepath, &error, primary);
|
||||
QList<Metatile*> metatiles = parser.parse(filepath, &error, primary);
|
||||
if (error) {
|
||||
QMessageBox msgBox(this);
|
||||
msgBox.setText("Failed to import metatiles from Advance Map 1.92 .bvd file.");
|
||||
|
@ -906,14 +896,14 @@ void TilesetEditor::importTilesetMetatiles(Tileset *tileset, bool primary)
|
|||
// TODO: This is crude because it makes a history entry for every newly-imported metatile.
|
||||
// Revisit this when tiles and num metatiles are added to tileset editory history.
|
||||
int metatileIdBase = primary ? 0 : Project::getNumMetatilesPrimary();
|
||||
for (int i = 0; i < metatiles->length(); i++) {
|
||||
if (i >= tileset->metatiles->length()) {
|
||||
for (int i = 0; i < metatiles.length(); i++) {
|
||||
if (i >= tileset->metatiles.length()) {
|
||||
break;
|
||||
}
|
||||
|
||||
Metatile *prevMetatile = new Metatile(*tileset->metatiles->at(i));
|
||||
Metatile *prevMetatile = new Metatile(*tileset->metatiles.at(i));
|
||||
MetatileHistoryItem *commit = new MetatileHistoryItem(static_cast<uint16_t>(metatileIdBase + i),
|
||||
prevMetatile, new Metatile(*metatiles->at(i)));
|
||||
prevMetatile, new Metatile(*metatiles.at(i)));
|
||||
metatileHistory.push(commit);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,13 +4,12 @@
|
|||
#include <QPainter>
|
||||
|
||||
void TilesetEditorMetatileSelector::draw() {
|
||||
if (!this->primaryTileset || !this->primaryTileset->metatiles
|
||||
|| !this->secondaryTileset || !this->secondaryTileset->metatiles) {
|
||||
if (!this->primaryTileset || !this->secondaryTileset) {
|
||||
this->setPixmap(QPixmap());
|
||||
}
|
||||
|
||||
int primaryLength = this->primaryTileset->metatiles->length();
|
||||
int length_ = primaryLength + this->secondaryTileset->metatiles->length();
|
||||
int primaryLength = this->primaryTileset->metatiles.length();
|
||||
int length_ = primaryLength + this->secondaryTileset->metatiles.length();
|
||||
int height_ = length_ / this->numMetatilesWide;
|
||||
if (length_ % this->numMetatilesWide != 0) {
|
||||
height_++;
|
||||
|
@ -63,7 +62,7 @@ void TilesetEditorMetatileSelector::updateSelectedMetatile() {
|
|||
if (Tileset::metatileIsValid(metatileId, this->primaryTileset, this->secondaryTileset))
|
||||
this->selectedMetatile = metatileId;
|
||||
else
|
||||
this->selectedMetatile = Project::getNumMetatilesPrimary() + this->secondaryTileset->metatiles->length() - 1;
|
||||
this->selectedMetatile = Project::getNumMetatilesPrimary() + this->secondaryTileset->metatiles.length() - 1;
|
||||
emit selectedMetatileChanged(this->selectedMetatile);
|
||||
}
|
||||
|
||||
|
@ -73,10 +72,10 @@ uint16_t TilesetEditorMetatileSelector::getSelectedMetatile() {
|
|||
|
||||
uint16_t TilesetEditorMetatileSelector::getMetatileId(int x, int y) {
|
||||
int index = y * this->numMetatilesWide + x;
|
||||
if (index < this->primaryTileset->metatiles->length()) {
|
||||
if (index < this->primaryTileset->metatiles.length()) {
|
||||
return static_cast<uint16_t>(index);
|
||||
} else {
|
||||
return static_cast<uint16_t>(Project::getNumMetatilesPrimary() + index - this->primaryTileset->metatiles->length());
|
||||
return static_cast<uint16_t>(Project::getNumMetatilesPrimary() + index - this->primaryTileset->metatiles.length());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,10 +118,10 @@ QPoint TilesetEditorMetatileSelector::getMetatileIdCoords(uint16_t metatileId) {
|
|||
{
|
||||
// Invalid metatile id.
|
||||
return QPoint(0, 0);
|
||||
}
|
||||
}
|
||||
int index = metatileId < Project::getNumMetatilesPrimary()
|
||||
? metatileId
|
||||
: metatileId - Project::getNumMetatilesPrimary() + this->primaryTileset->metatiles->length();
|
||||
: metatileId - Project::getNumMetatilesPrimary() + this->primaryTileset->metatiles.length();
|
||||
return QPoint(index % this->numMetatilesWide, index / this->numMetatilesWide);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,14 +13,13 @@ QPoint TilesetEditorTileSelector::getSelectionDimensions() {
|
|||
}
|
||||
|
||||
void TilesetEditorTileSelector::draw() {
|
||||
if (!this->primaryTileset || !this->primaryTileset->tiles
|
||||
|| !this->secondaryTileset || !this->secondaryTileset->tiles) {
|
||||
if (!this->primaryTileset || !this->secondaryTileset) {
|
||||
this->setPixmap(QPixmap());
|
||||
}
|
||||
|
||||
int totalTiles = Project::getNumTilesTotal();
|
||||
int primaryLength = this->primaryTileset->tiles->length();
|
||||
int secondaryLength = this->secondaryTileset->tiles->length();
|
||||
int primaryLength = this->primaryTileset->tiles.length();
|
||||
int secondaryLength = this->secondaryTileset->tiles.length();
|
||||
int height = totalTiles / this->numTilesWide;
|
||||
QList<QRgb> palette = Tileset::getPalette(this->paletteId, this->primaryTileset, this->secondaryTileset, true);
|
||||
QImage image(this->numTilesWide * 16, height * 16, QImage::Format_RGBA8888);
|
||||
|
@ -218,12 +217,11 @@ QPoint TilesetEditorTileSelector::getTileCoordsOnWidget(uint16_t tile) {
|
|||
}
|
||||
|
||||
QImage TilesetEditorTileSelector::buildPrimaryTilesIndexedImage() {
|
||||
if (!this->primaryTileset || !this->primaryTileset->tiles
|
||||
|| !this->secondaryTileset || !this->secondaryTileset->tiles) {
|
||||
if (!this->primaryTileset || !this->secondaryTileset) {
|
||||
return QImage();
|
||||
}
|
||||
|
||||
int primaryLength = this->primaryTileset->tiles->length();
|
||||
int primaryLength = this->primaryTileset->tiles.length();
|
||||
int height = qCeil(primaryLength / static_cast<double>(this->numTilesWide));
|
||||
QImage image(this->numTilesWide * 8, height * 8, QImage::Format_RGBA8888);
|
||||
|
||||
|
@ -254,12 +252,11 @@ QImage TilesetEditorTileSelector::buildPrimaryTilesIndexedImage() {
|
|||
}
|
||||
|
||||
QImage TilesetEditorTileSelector::buildSecondaryTilesIndexedImage() {
|
||||
if (!this->primaryTileset || !this->primaryTileset->tiles
|
||||
|| !this->secondaryTileset || !this->secondaryTileset->tiles) {
|
||||
if (!this->primaryTileset || !this->secondaryTileset) {
|
||||
return QImage();
|
||||
}
|
||||
|
||||
int secondaryLength = this->secondaryTileset->tiles->length();
|
||||
int secondaryLength = this->secondaryTileset->tiles.length();
|
||||
int height = qCeil(secondaryLength / static_cast<double>(this->numTilesWide));
|
||||
QImage image(this->numTilesWide * 8, height * 8, QImage::Format_RGBA8888);
|
||||
|
||||
|
|
Loading…
Reference in a new issue