Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Scripting: Added 'tiled.cell' function, 'cell.flags' property and 'TileLayerEdit.setCell' function (#4538)
* Scripting: Added MapObject.resolvedClassName() (by MatusGuy, #4529)
* Fixed crash when the selection becomes empty while starting a move (#4536)
* Fixed Properties view update on 'Reset Template Instance' and 'Replace With Template' actions
* Linux: Added file associations for .tmj, .tsj, .tiled-project and .world files (by miffe, #4550)
* macOS: Declared UTIs and file associations for all supported Tiled formats (with Jyotish, #4469)
* snap: Updated to Qt 6
Expand Down
40 changes: 39 additions & 1 deletion docs/reference/json-map-format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -753,10 +753,44 @@ Property
:widths: 1, 1, 4

name, string, "Name of the property"
type, string, "Type of the property (``string`` (default), ``int``, ``float``, ``bool``, ``color``, ``file``, ``object`` or ``class`` (since 0.16, with ``color`` and ``file`` added in 0.17, ``object`` added in 1.4 and ``class`` added in 1.8))"
type, string, "Type of the property (``string`` (default), ``int``, ``float``, ``bool``, ``color``, ``file``, ``object``, ``class`` or ``list`` (since 0.16, with ``color`` and ``file`` added in 0.17, ``object`` added in 1.4, ``class`` added in 1.8 and ``list`` added in 1.12))"
propertytype, string, "Name of the :ref:`custom property type <custom-property-types>`, when applicable (since 1.8)"
value, value, "Value of the property"

When the type is ``list``, the ``value`` is an array storing each item of the
list as an object with ``type``, ``value`` and (when applicable)
``propertytype`` fields, like a property without a name. Class items store
their set members as a JSON object, and list items store their values as a
nested array.

Example of a list property with a nested list:

.. code:: json

{
"name":"list property",
"type":"list",
"value":[
{
"type":"int",
"value":10
},
{
"type":"string",
"value":"text"
},
{
"type":"list",
"value":[
{
"type":"bool",
"value":true
}
]
}
]
}

.. _json-point:

Point
Expand Down Expand Up @@ -784,6 +818,10 @@ Tiled 1.12

* Added ``opacity`` property to :ref:`json-object`.

* Added ``list`` as a possible type of :ref:`json-property`. The ``value`` of
a list property is an array storing each item as an object with ``type``,
``propertytype`` and ``value`` fields.

Tiled 1.11.1
~~~~~~~~~~~~

Expand Down
8 changes: 6 additions & 2 deletions docs/reference/tmx-changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Below are described the changes/additions that were made to the
Tiled 1.12
----------

- Added ``mode`` attribute on :ref:`tmx-layer` to specific its blend mode.
- Added ``mode`` attribute on :ref:`tmx-layer` to specify its blend mode.

- Added ``oblique`` to the supported values for the ``orientation`` attribute
on the :ref:`tmx-map` element, along with the ``skewx`` and ``skewy``
Expand All @@ -22,7 +22,11 @@ Tiled 1.12
<capsule/>
</object>

- Added ``opacity`` attribute to :ref:`tmx-object` to specificy its opacity.
- Added ``opacity`` attribute to :ref:`tmx-object` to specify its opacity.

- Added ``list`` to the supported values for the ``type`` attribute on the
:ref:`tmx-property` element. Each value of a list property is stored in a
nested :ref:`item <tmx-item>` element.


Tiled 1.10
Expand Down
44 changes: 41 additions & 3 deletions docs/reference/tmx-map-format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -755,9 +755,9 @@ Can contain any number: :ref:`tmx-property`

- **name:** The name of the property.
- **type:** The type of the property. Can be ``string`` (default), ``int``,
``float``, ``bool``, ``color``, ``file``, ``object`` or ``class`` (since
0.16, with ``color`` and ``file`` added in 0.17, ``object`` added in 1.4 and
``class`` added in 1.8).
``float``, ``bool``, ``color``, ``file``, ``object``, ``class`` or ``list``
(since 0.16, with ``color`` and ``file`` added in 0.17, ``object`` added in
1.4, ``class`` added in 1.8 and ``list`` added in 1.12).
- **propertytype:** The name of the
:ref:`custom property type <custom-property-types>`, when applicable
(since 1.8).
Expand All @@ -781,6 +781,9 @@ Class properties will have their member values stored in a nested
:ref:`tmx-properties` element. Only the actually set members are saved. When no
members have been set the ``properties`` element is left out entirely.

List properties store each of their values in a nested :ref:`tmx-item`
element and have no ``value`` attribute of their own.

When a string property contains newlines, the current version of Tiled
will write out the value as characters contained inside the ``property``
element rather than as the ``value`` attribute. It is possible that a
Expand All @@ -789,6 +792,41 @@ values inside the element rather than as an attribute.

Can contain at most one: :ref:`tmx-properties` (since 1.8)

Can contain any number: :ref:`tmx-item` (since 1.12)

.. _tmx-item:

<item>
~~~~~~

- **type:** The type of the value. Same as the ``type`` attribute on the
:ref:`tmx-property` element (default ``string``).
- **propertytype:** The name of the
:ref:`custom property type <custom-property-types>`, when applicable.
- **value:** The value of this item.

Stores one value of a ``list`` property (since 1.12). Apart from having no
``name`` attribute, an item is structured like a :ref:`tmx-property` element:
``class`` items store their set members in a nested :ref:`tmx-properties`
element, ``list`` items contain their own ``item`` elements and multiline
strings are written as characters contained inside the ``item`` element.

Example of a list property with a nested list:

.. code:: xml

<property name="list property" type="list">
<item type="int" value="10"/>
<item value="text"/>
<item type="list">
<item type="bool" value="true"/>
</item>
</property>

Can contain at most one: :ref:`tmx-properties`

Can contain any number: :ref:`tmx-item`

.. _tmx-template-files:

Template Files
Expand Down
22 changes: 16 additions & 6 deletions src/tiled/changemapobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ void ResetInstances::redo()

for (auto object : mMapObjects) {
// Template instances initially don't hold any custom properties
object->clearProperties();
if (!object->properties().isEmpty())
mDocument->setProperties(object, Properties());

affectedProperties |= object->changedProperties();

Expand All @@ -266,18 +267,21 @@ void ResetInstances::redo()
}

emit mDocument->changed(MapObjectsChangeEvent(mMapObjects, affectedProperties));

// This signal forces updating custom properties in the properties dock
// emit mMapDocument->selectedObjectsChanged();
}

void ResetInstances::undo()
{
MapObject::ChangedProperties affectedProperties = MapObject::CustomProperties;

for (int i = 0; i < mMapObjects.size(); ++i) {
mMapObjects.at(i)->copyPropertiesFrom(mOldMapObjects.at(i));
affectedProperties |= mOldMapObjects.at(i)->changedProperties();
MapObject *object = mMapObjects.at(i);
const MapObject *oldObject = mOldMapObjects.at(i);

object->copyPropertiesFrom(oldObject);
affectedProperties |= oldObject->changedProperties();

if (!oldObject->properties().isEmpty())
emit mDocument->propertiesChanged(object);
}

emit mDocument->changed(MapObjectsChangeEvent(mMapObjects, affectedProperties));
Expand Down Expand Up @@ -314,6 +318,9 @@ void ReplaceObjectsWithTemplate::redo()
}

emit mDocument->changed(MapObjectsChangeEvent(mMapObjects, MapObject::AllProperties));

for (MapObject *object : std::as_const(mMapObjects))
emit mDocument->propertiesChanged(object);
}

void ReplaceObjectsWithTemplate::undo()
Expand All @@ -322,4 +329,7 @@ void ReplaceObjectsWithTemplate::undo()
mMapObjects.at(i)->copyPropertiesFrom(mOldMapObjects.at(i));

emit mDocument->changed(MapObjectsChangeEvent(mMapObjects, MapObject::AllProperties));

for (MapObject *object : std::as_const(mMapObjects))
emit mDocument->propertiesChanged(object);
}
Loading