Browse code

Improved handling of external tilesets in Lua export

Since referring to the external .tsx file in XML format is generally
not very useful in a map exported to Lua, all the tileset information
is now included in the export.

Previously, tile properties were already being included, but this had
been by accident.

Thorbjørn Lindeijer authored on 09/06/2012 21:08:39
Showing 1 changed files
... ...
@@ -139,25 +139,28 @@ void LuaPlugin::writeTileset(LuaTableWriter &writer, const Tileset *tileset,
139 139
     if (!tileset->fileName().isEmpty()) {
140 140
         const QString rel = mMapDir.relativeFilePath(tileset->fileName());
141 141
         writer.writeKeyAndValue("filename", rel);
142
-    } else {
143
-        writer.writeKeyAndValue("tilewidth", tileset->tileWidth());
144
-        writer.writeKeyAndValue("tileheight", tileset->tileHeight());
145
-        writer.writeKeyAndValue("spacing", tileset->tileSpacing());
146
-        writer.writeKeyAndValue("margin", tileset->margin());
147
-
148
-        const QString rel = mMapDir.relativeFilePath(tileset->imageSource());
149
-        writer.writeKeyAndValue("image", rel);
150
-        writer.writeKeyAndValue("imagewidth", tileset->imageWidth());
151
-        writer.writeKeyAndValue("imageheight", tileset->imageHeight());
152
-
153
-        if (tileset->transparentColor().isValid()) {
154
-            writer.writeKeyAndValue("transparentColor",
155
-                                    tileset->transparentColor().name());
156
-        }
142
+    }
157 143
 
158
-        writeProperties(writer, tileset->properties());
144
+    /* Include all tileset information even for external tilesets, since the
145
+     * external reference is generally a .tsx file (in XML format).
146
+     */
147
+    writer.writeKeyAndValue("tilewidth", tileset->tileWidth());
148
+    writer.writeKeyAndValue("tileheight", tileset->tileHeight());
149
+    writer.writeKeyAndValue("spacing", tileset->tileSpacing());
150
+    writer.writeKeyAndValue("margin", tileset->margin());
151
+
152
+    const QString rel = mMapDir.relativeFilePath(tileset->imageSource());
153
+    writer.writeKeyAndValue("image", rel);
154
+    writer.writeKeyAndValue("imagewidth", tileset->imageWidth());
155
+    writer.writeKeyAndValue("imageheight", tileset->imageHeight());
156
+
157
+    if (tileset->transparentColor().isValid()) {
158
+        writer.writeKeyAndValue("transparentColor",
159
+                                tileset->transparentColor().name());
159 160
     }
160 161
 
162
+    writeProperties(writer, tileset->properties());
163
+
161 164
     writer.writeStartTable("tiles");
162 165
     for (int i = 0; i < tileset->tileCount(); ++i) {
163 166
         const Tile *tile = tileset->tileAt(i);