Skip to content

Commit

Permalink
tmxviewer: Added support for viewing JSON maps
Browse files Browse the repository at this point in the history
The viewer can now read any default-enabled map format, which currently
only covers the JSON map format in addition to TMX.

Closes #3866
  • Loading branch information
bjorn committed Jan 9, 2024
1 parent 4fd5551 commit 66509ac
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* JSON format: Fixed tile order when loading a tileset using the old format
* tmxrasterizer: Added --hide-object and --show-object arguments (by Lars Luz, #3819)
* tmxviewer: Added support for viewing JSON maps (#3866)
* Windows: Fixed the support for WebP images (updated to Qt 6.5.3)

### Tiled 1.10.2 (4 August 2023)
Expand Down
5 changes: 4 additions & 1 deletion src/tmxviewer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include "tmxviewer.h"

#include "pluginmanager.h"
#include "tiled.h"

#include <QApplication>
Expand Down Expand Up @@ -57,8 +58,10 @@ int main(int argc, char *argv[])
a.setApplicationName(QStringLiteral("TmxViewer"));
a.setApplicationVersion(QStringLiteral("1.0"));

Tiled::PluginManager::instance()->loadPlugins();

QCommandLineParser parser;
parser.setApplicationDescription(QCoreApplication::translate("main", "Displays a Tiled map (TMX format)."));
parser.setApplicationDescription(QCoreApplication::translate("main", "Displays a Tiled map."));
parser.addHelpOption();
parser.addVersionOption();
parser.addPositionalArgument(QStringLiteral("file"), QCoreApplication::translate("main", "Map file to display."));
Expand Down
7 changes: 4 additions & 3 deletions src/tmxviewer/tmxviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "tmxviewer.h"

#include "map.h"
#include "mapformat.h"
#include "mapobject.h"
#include "mapreader.h"
#include "maprenderer.h"
Expand Down Expand Up @@ -193,10 +194,10 @@ bool TmxViewer::viewMap(const QString &fileName)

mRenderer.reset();

MapReader reader;
mMap = reader.readMap(fileName);
QString errorString;
mMap = Tiled::readMap(fileName, &errorString);
if (!mMap) {
qWarning().noquote() << "Error:" << reader.errorString();
qWarning().noquote() << "Error:" << errorString;
return false;
}

Expand Down

0 comments on commit 66509ac

Please sign in to comment.