2
* Tiled Map Editor (Qt)
3
* Copyright 2008 Tiled (Qt) developers (see AUTHORS file)
5
* This file is part of Tiled (Qt).
7
* This program is free software; you can redistribute it and/or modify it
8
* under the terms of the GNU General Public License as published by the Free
9
* Software Foundation; either version 2 of the License, or (at your option)
12
* This program is distributed in the hope that it will be useful, but WITHOUT
13
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17
* You should have received a copy of the GNU General Public License along with
18
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19
* Place, Suite 330, Boston, MA 02111-1307, USA.
22
#ifndef TMXMAPWRITER_H
23
#define TMXMAPWRITER_H
25
#include "mapwriterinterface.h"
27
#include <QCoreApplication>
31
#include <QXmlStreamWriter>
45
* A writer for Tiled's .tmx map format.
47
class TmxMapWriter : public MapWriterInterface
49
Q_DECLARE_TR_FUNCTIONS(TmxMapReader)
54
bool write(const Map *map, const QString &fileName);
57
* Converts the given map to a string (in .tmx format). This is for
58
* storing a map in the clipboard. References to other files (like tileset
59
* images) will be saved as absolute paths.
61
* @see TmxMapReader::fromString
63
QString toString(const Map *map);
65
QString name() const { return tr("XML map writer (*.tmx)"); }
67
QString errorString() const { return mError; }
70
* The different formats in which the tile layer data can be stored.
72
enum LayerDataFormat {
81
* Sets the format in which the tile layer data is stored.
83
void setLayerDataFormat(LayerDataFormat format)
84
{ mLayerDataFormat = format; }
86
LayerDataFormat layerDataFormat() const
87
{ return mLayerDataFormat; }
90
* Sets whether the DTD reference is written when saving the map.
92
void setDtdEnabled(bool enabled)
93
{ mDtdEnabled = enabled; }
95
bool isDtdEnabled() const
96
{ return mDtdEnabled; }
99
void writeMap(QXmlStreamWriter &w, const Map *map);
100
void writeTileset(QXmlStreamWriter &w, const Tileset *tileset,
102
void writeTileLayer(QXmlStreamWriter &w, const TileLayer *tileLayer);
103
void writeLayerAttributes(QXmlStreamWriter &w, const Layer *layer);
104
int gidForTile(const Tile *tile) const;
105
void writeObjectGroup(QXmlStreamWriter &w, const ObjectGroup *objectGroup);
106
void writeObject(QXmlStreamWriter &w, const MapObject *mapObject);
107
void writeProperties(QXmlStreamWriter &w,
108
const QMap<QString, QString> &properties);
111
QDir mMapDir; // The directory in which the map is being saved
112
QMap<int, const Tileset*> mFirstGidToTileset;
113
bool mUseAbsolutePaths;
114
LayerDataFormat mLayerDataFormat;
118
} // namespace Internal
121
#endif // TMXMAPWRITER_H