diff --git a/NEWS.md b/NEWS.md index b8cf53103a..a3467d320d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -26,6 +26,7 @@ * tmxrasterizer: Added --frames and --frame-duration arguments to export animated maps as multiple images (#3868) * tmxrasterizer: Fixed --hide/show-layer to work on group layers (#3899) * tmxviewer: Added support for viewing JSON maps (#3866) +* tmxrasterizer/viewer: Fixed loading of XML object templates (with Christian Schaadt, #3977) * AutoMapping: Ignore empty outputs per-rule (#3523) * Automapping: Added per-input-layer properties for ignoring flip flags (#3803) * AutoMapping: Always apply output sets with empty index diff --git a/src/libtiled/libtiled.qbs b/src/libtiled/libtiled.qbs index 555da8e968..6dda343a71 100644 --- a/src/libtiled/libtiled.qbs +++ b/src/libtiled/libtiled.qbs @@ -175,6 +175,8 @@ DynamicLibrary { "tilesetformat.h", "tilesetmanager.cpp", "tilesetmanager.h", + "tmxmapformat.cpp", + "tmxmapformat.h", "varianttomapconverter.cpp", "varianttomapconverter.h", "wangset.cpp", diff --git a/src/tiled/tmxmapformat.cpp b/src/libtiled/tmxmapformat.cpp similarity index 77% rename from src/tiled/tmxmapformat.cpp rename to src/libtiled/tmxmapformat.cpp index cf2f10f9a2..b12ae6644e 100644 --- a/src/tiled/tmxmapformat.cpp +++ b/src/libtiled/tmxmapformat.cpp @@ -2,20 +2,28 @@ * tmxmapformat.cpp * Copyright 2008-2015, Thorbjørn Lindeijer * - * This file is part of Tiled. + * This file is part of libtiled. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "tmxmapformat.h" @@ -23,7 +31,6 @@ #include "map.h" #include "mapreader.h" #include "mapwriter.h" -#include "tilesetmanager.h" #include #include diff --git a/src/tiled/tmxmapformat.h b/src/libtiled/tmxmapformat.h similarity index 64% rename from src/tiled/tmxmapformat.h rename to src/libtiled/tmxmapformat.h index 4a5a750908..d82df8c8d1 100644 --- a/src/tiled/tmxmapformat.h +++ b/src/libtiled/tmxmapformat.h @@ -2,27 +2,35 @@ * tmxmapformat.h * Copyright 2008-2015, Thorbjørn Lindeijer * - * This file is part of Tiled. + * This file is part of libtiled. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #pragma once #include "mapformat.h" #include "objecttemplateformat.h" -#include "tilededitor_global.h" +#include "tiled_global.h" #include "tilesetformat.h" namespace Tiled { @@ -33,7 +41,7 @@ class MapObject; /** * A reader and writer for Tiled's .tmx map format. */ -class TILED_EDITOR_EXPORT TmxMapFormat : public MapFormat +class TILEDSHARED_EXPORT TmxMapFormat : public MapFormat { Q_OBJECT Q_INTERFACES(Tiled::MapFormat) @@ -77,7 +85,7 @@ class TILED_EDITOR_EXPORT TmxMapFormat : public MapFormat /** * A reader and writer for Tiled's .tsx tileset format. */ -class TILED_EDITOR_EXPORT TsxTilesetFormat : public TilesetFormat +class TILEDSHARED_EXPORT TsxTilesetFormat : public TilesetFormat { Q_OBJECT Q_INTERFACES(Tiled::TilesetFormat) @@ -104,7 +112,7 @@ class TILED_EDITOR_EXPORT TsxTilesetFormat : public TilesetFormat /** * A reader and writer for Tiled's .tx template format. */ -class TILED_EDITOR_EXPORT XmlObjectTemplateFormat : public ObjectTemplateFormat +class TILEDSHARED_EXPORT XmlObjectTemplateFormat : public ObjectTemplateFormat { Q_OBJECT Q_INTERFACES(Tiled::ObjectTemplateFormat) diff --git a/src/tiled/libtilededitor.qbs b/src/tiled/libtilededitor.qbs index 859053d67e..9e576776b4 100644 --- a/src/tiled/libtilededitor.qbs +++ b/src/tiled/libtilededitor.qbs @@ -541,8 +541,6 @@ DynamicLibrary { "tilestampmodel.h", "tilestampsdock.cpp", "tilestampsdock.h", - "tmxmapformat.cpp", - "tmxmapformat.h", "toolmanager.cpp", "toolmanager.h", "transformmapobjects.cpp", diff --git a/src/tmxrasterizer/main.cpp b/src/tmxrasterizer/main.cpp index 717bdd60bd..275df8facd 100644 --- a/src/tmxrasterizer/main.cpp +++ b/src/tmxrasterizer/main.cpp @@ -28,6 +28,7 @@ #include "pluginmanager.h" #include "tmxrasterizer.h" +#include "tmxmapformat.h" #include #include @@ -53,6 +54,10 @@ int main(int argc, char *argv[]) PluginManager::instance()->loadPlugins(); + // Necessary to enable loading of object templates in XML format + XmlObjectTemplateFormat xmlObjectTemplateFormat; + PluginManager::addObject(&xmlObjectTemplateFormat); + QCommandLineParser parser; parser.setApplicationDescription(QCoreApplication::translate("main", "Renders a Tiled map or world to an image.")); parser.addHelpOption(); diff --git a/src/tmxviewer/main.cpp b/src/tmxviewer/main.cpp index 63bc6f9876..b4f91baf94 100644 --- a/src/tmxviewer/main.cpp +++ b/src/tmxviewer/main.cpp @@ -30,6 +30,7 @@ #include "pluginmanager.h" #include "tiled.h" +#include "tmxmapformat.h" #include #include @@ -60,6 +61,10 @@ int main(int argc, char *argv[]) Tiled::PluginManager::instance()->loadPlugins(); + // Necessary to enable loading of object templates in XML format + Tiled::XmlObjectTemplateFormat xmlObjectTemplateFormat; + Tiled::PluginManager::addObject(&xmlObjectTemplateFormat); + QCommandLineParser parser; parser.setApplicationDescription(QCoreApplication::translate("main", "Displays a Tiled map.")); parser.addHelpOption();