Skip to content

Commit

Permalink
CSV plugin: Include flipping flags in exported tile IDs
Browse files Browse the repository at this point in the history
Might be confusing to some, but this could be preferable to not having
this information for those who need it.

Forum-topic: https://discourse.mapeditor.org/t/layer-data-base64/4772
  • Loading branch information
bjorn committed Oct 20, 2020
1 parent ac62edc commit e0293ed
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/plugins/csv/csvplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
using namespace Tiled;
using namespace Csv;

// Bits on the far end of the 32-bit tile ID are used for tile flags
const unsigned FlippedHorizontallyFlag = 0x80000000;
const unsigned FlippedVerticallyFlag = 0x40000000;
const unsigned FlippedAntiDiagonallyFlag = 0x20000000;
const unsigned RotatedHexagonal120Flag = 0x10000000;

CsvPlugin::CsvPlugin()
{
}
Expand Down Expand Up @@ -72,7 +78,21 @@ bool CsvPlugin::write(const Map *map, const QString &fileName, Options options)
if (tile && tile->hasProperty(QLatin1String("name"))) {
device->write(tile->property(QLatin1String("name")).toString().toUtf8());
} else {
const int id = tile ? tile->id() : -1;
int id = -1;

if (tile) {
id = tile->id();

if (cell.flippedHorizontally())
id |= FlippedHorizontallyFlag;
if (cell.flippedVertically())
id |= FlippedVerticallyFlag;
if (cell.flippedAntiDiagonally())
id |= FlippedAntiDiagonallyFlag;
if (cell.rotatedHexagonal120())
id |= RotatedHexagonal120Flag;
}

device->write(QByteArray::number(id));
}
}
Expand Down

0 comments on commit e0293ed

Please sign in to comment.