Skip to content

Commit 94829bf

Browse files
authored
Add "class" attribute to several elements. (#64)
* Add "class" attribute to several elements. In the TMX version 1.9 (https://doc.mapeditor.org/en/stable/reference/tmx-changelog/#tiled-1-9), the "type" attribute for <tile> and <object> was renamed to "class". Also, the "class" field was added to several elements, namely, <map>, <tileset>, <layer>, <imagelayer>, <objectgroup>, <group>, <wangset> and <wangcolor>. This patch adds the "class" attribute to all of the elements that are specified in version 1.9 and that are implemented by the go-tiled library. * Add deprecated comments to <object> and <tile>.
1 parent 025534c commit 94829bf

File tree

6 files changed

+22
-2
lines changed

6 files changed

+22
-2
lines changed

tmx_group.go

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ type Group struct {
3434
ID uint32 `xml:"id,attr"`
3535
// The name of the group layer.
3636
Name string `xml:"name,attr"`
37+
// The class of the group layer (since 1.9, defaults to "").
38+
Class string `xml:"class,attr"`
3739
// Rendering offset of the image layer in pixels. Defaults to 0. (since 0.15)
3840
OffsetX int `xml:"offsetx,attr"`
3941
// Rendering offset of the image layer in pixels. Defaults to 0. (since 0.15)

tmx_image.go

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ type ImageLayer struct {
3434
ID uint32 `xml:"id,attr"`
3535
// The name of the image layer.
3636
Name string `xml:"name,attr"`
37+
// The class of the image layer (since 1.9, defaults to "").
38+
Class string `xml:"class,attr"`
3739
// Rendering offset of the image layer in pixels. Defaults to 0. (since 0.15)
3840
OffsetX int `xml:"offsetx,attr"`
3941
// Rendering offset of the image layer in pixels. Defaults to 0. (since 0.15)

tmx_layer.go

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ type Layer struct {
7070
ID uint32 `xml:"id,attr"`
7171
// The name of the layer.
7272
Name string `xml:"name,attr"`
73+
// The class of this layer (since 1.9, defaults to "").
74+
Class string `xml:"class,attr"`
7375
// The opacity of the layer as a value from 0 to 1. Defaults to 1.
7476
Opacity float32 `xml:"opacity,attr"`
7577
// Whether the layer is shown (1) or hidden (0). Defaults to 1.

tmx_map.go

+2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ type Map struct {
5555
Version string `xml:"version,attr"`
5656
// The Tiled version used to generate this file
5757
TiledVersion string `xml:"tiledversion,attr"`
58+
// The class of this map (since 1.9, defaults to "").
59+
Class string `xml:"class,attr"`
5860
// Map orientation. Tiled supports "orthogonal", "isometric", "staggered" (since 0.9) and "hexagonal" (since 0.11).
5961
Orientation string `xml:"orientation,attr"`
6062
// The order in which tiles on tile layers are rendered. Valid values are right-down (the default), right-up, left-down and left-up.

tmx_object.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ type ObjectGroup struct {
4343
ID uint32 `xml:"id,attr"`
4444
// The name of the object group.
4545
Name string `xml:"name,attr"`
46+
// The class of the object group (since 1.9, defaults to "").
47+
Class string `xml:"class,attr"`
4648
// The color used to display the objects in this group.
4749
Color *HexColor `xml:"color,attr"`
4850
// The opacity of the layer as a value from 0 to 1. Defaults to 1.
@@ -97,8 +99,12 @@ type Object struct {
9799
ID uint32 `xml:"id,attr"`
98100
// The name of the object. An arbitrary string.
99101
Name string `xml:"name,attr"`
100-
// The type of the object. An arbitrary string.
102+
// The type of the object. An arbitrary string. (until 1.8)
103+
//
104+
// Deprecated: replaced by Class since 1.9
101105
Type string `xml:"type,attr"`
106+
// The class of the object. An arbitrary string. (defaults to "", renamed from 'type' since 1.9)
107+
Class string `xml:"class,attr"`
102108
// The x coordinate of the object.
103109
X float64 `xml:"x,attr"`
104110
// The y coordinate of the object.

tmx_tileset.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ type Tileset struct {
2525
SourceLoaded bool `xml:"-"`
2626
// The name of this tileset.
2727
Name string `xml:"name,attr"`
28+
// The class of this tileset (since 1.9, defaults to "").
29+
Class string `xml:"class,attr"`
2830
// The (maximum) width of the tiles in this tileset.
2931
TileWidth int `xml:"tilewidth,attr"`
3032
// The (maximum) height of the tiles in this tileset.
@@ -76,8 +78,12 @@ type Terrain struct {
7678
type TilesetTile struct {
7779
// The local tile ID within its tileset.
7880
ID uint32 `xml:"id,attr"`
79-
// The type of the tile. Refers to an object type and is used by tile objects. (optional) (since 1.0)
81+
// The type of the tile. Refers to an object type and is used by tile objects. (optional) (since 1.0, until 1.8)
82+
//
83+
// Deprecated: replaced by Class since 1.9
8084
Type string `xml:"type,attr"`
85+
// The type of the tile. Refers to an object type and is used by tile objects. (optional) (renamed from 'type' since 1.9)
86+
Class string `xml:"class,attr"`
8187
// Defines the terrain type of each corner of the tile, given as comma-separated indexes in the terrain types
8288
// array in the order top-left, top-right, bottom-left, bottom-right.
8389
// Leaving out a value means that corner has no terrain. (optional) (since 0.9)

0 commit comments

Comments
 (0)