Skip to content

Commit

Permalink
CSV plugin: Improved handling of infinite maps
Browse files Browse the repository at this point in the history
When exporting an infinite map, use the exact bounding rectangle of the
tile layer content, rather than the bounds rounded to 16x16 chunks.
  • Loading branch information
bjorn committed Dec 22, 2021
1 parent afc963a commit 7fc0ecc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/plugins/csv/csvplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ bool CsvPlugin::write(const Map *map, const QString &fileName, Options options)
Q_UNUSED(options)

// Get file paths for each layer
QStringList layerPaths = outputFiles(map, fileName);
const QStringList layerPaths = outputFiles(map, fileName);

// Traverse all tile layers
int currentLayer = 0;
Expand All @@ -64,7 +64,7 @@ bool CsvPlugin::write(const Map *map, const QString &fileName, Options options)

auto device = file.device();

QRect bounds = map->infinite() ? tileLayer->bounds() : tileLayer->rect();
QRect bounds = map->infinite() ? tileLayer->region().boundingRect() : tileLayer->rect();
bounds.translate(-layer->position());

// Write out tiles either by ID or their name, if given. -1 is "empty"
Expand Down Expand Up @@ -112,6 +112,7 @@ bool CsvPlugin::write(const Map *map, const QString &fileName, Options options)

++currentLayer;
}

return true;
}

Expand Down

0 comments on commit 7fc0ecc

Please sign in to comment.