Skip to content

Commit

Permalink
Migrate properties set on tile collision layer to the tile
Browse files Browse the repository at this point in the history
Since Tiled 1.1, it is no longer possible to edit the properties of this
implicit object group, but some users may have set them in previous
versions. Migrating the properties to the tile seems like a helpful
things to do in this case.

Closes #1912
  • Loading branch information
bjorn committed Mar 27, 2018
1 parent a0e47d1 commit 528e6d4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
16 changes: 15 additions & 1 deletion src/libtiled/mapreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,21 @@ void MapReaderPrivate::readTilesetTile(Tileset &tileset)
imageReference.source);
}
} else if (xml.name() == QLatin1String("objectgroup")) {
tile->setObjectGroup(readObjectGroup());
ObjectGroup *objectGroup = readObjectGroup();
if (objectGroup) {
// Migrate properties from the object group to the tile. Since
// Tiled 1.1, it is no longer possible to edit the properties
// of this implicit object group, but some users may have set
// them in previous versions.
Properties p = objectGroup->properties();
if (!p.isEmpty()) {
p.merge(tile->properties());
tile->setProperties(p);
objectGroup->setProperties(Properties());
}

tile->setObjectGroup(objectGroup);
}
} else if (xml.name() == QLatin1String("animation")) {
tile->setFrames(readAnimationFrames());
} else {
Expand Down
17 changes: 15 additions & 2 deletions src/libtiled/varianttomapconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,22 @@ SharedTileset VariantToMapConverter::toTileset(const QVariant &variant)
QVariantMap objectGroupVariant = tileVar[QLatin1String("objectgroup")].toMap();
if (!objectGroupVariant.isEmpty()) {
ObjectGroup *objectGroup = toObjectGroup(objectGroupVariant);
if (objectGroup)
if (objectGroup) {
objectGroup->setProperties(extractProperties(objectGroupVariant));
tile->setObjectGroup(objectGroup);

// Migrate properties from the object group to the tile. Since
// Tiled 1.1, it is no longer possible to edit the properties
// of this implicit object group, but some users may have set
// them in previous versions.
Properties p = objectGroup->properties();
if (!p.isEmpty()) {
p.merge(tile->properties());
tile->setProperties(p);
objectGroup->setProperties(Properties());
}

tile->setObjectGroup(objectGroup);
}
}

QVariantList frameList = tileVar[QLatin1String("animation")].toList();
Expand Down

0 comments on commit 528e6d4

Please sign in to comment.