diff --git a/src/tmxrasterizer/main.cpp b/src/tmxrasterizer/main.cpp index 46dfd6dc95..a0f9a362a6 100644 --- a/src/tmxrasterizer/main.cpp +++ b/src/tmxrasterizer/main.cpp @@ -74,6 +74,9 @@ int main(int argc, char *argv[]) { "hide-layer", QCoreApplication::translate("main", "Specifies a layer to omit from the output image. Can be repeated to hide multiple layers."), QCoreApplication::translate("main", "name") }, + { "show-layer", + QCoreApplication::translate("main", "If used only specified layers are shown. Can be repeated to show multiple specified layers only."), + QCoreApplication::translate("main", "name") }, }); parser.addPositionalArgument("map|world", QCoreApplication::translate("main", "Map or world file to render.")); parser.addPositionalArgument("image", QCoreApplication::translate("main", "Image file to output.")); @@ -94,6 +97,7 @@ int main(int argc, char *argv[]) w.setSmoothImages(!parser.isSet(QLatin1String("no-smoothing"))); w.setIgnoreVisibility(parser.isSet(QLatin1String("ignore-visibility"))); w.setLayersToHide(parser.values(QLatin1String("hide-layer"))); + w.setLayersToShow(parser.values(QLatin1String("show-layer"))); if (parser.isSet(QLatin1String("size"))) { bool ok; diff --git a/src/tmxrasterizer/tmxrasterizer.cpp b/src/tmxrasterizer/tmxrasterizer.cpp index a9ea0dc70f..db6d4340be 100644 --- a/src/tmxrasterizer/tmxrasterizer.cpp +++ b/src/tmxrasterizer/tmxrasterizer.cpp @@ -132,6 +132,11 @@ bool TmxRasterizer::shouldDrawLayer(const Layer *layer) const if (mLayersToHide.contains(layer->name(), Qt::CaseInsensitive)) return false; + if (!mLayersToShow.empty()) { + if (!mLayersToShow.contains(layer->name(), Qt::CaseInsensitive)) + return false; + } + if (mIgnoreVisibility) return true; @@ -230,7 +235,7 @@ int TmxRasterizer::renderWorld(const QString &worldFileName, qUtf8Printable(errorString)); return 1; } - + auto const maps = world->allMaps(); if (maps.isEmpty()) { qWarning("Error: The world file to rasterize contains no maps : \"%s\"", diff --git a/src/tmxrasterizer/tmxrasterizer.h b/src/tmxrasterizer/tmxrasterizer.h index a91ca966f9..b12e08c886 100644 --- a/src/tmxrasterizer/tmxrasterizer.h +++ b/src/tmxrasterizer/tmxrasterizer.h @@ -61,6 +61,7 @@ class TmxRasterizer void setIgnoreVisibility(bool IgnoreVisibility) { mIgnoreVisibility = IgnoreVisibility; } void setLayersToHide(QStringList layersToHide) { mLayersToHide = layersToHide; } + void setLayersToShow(QStringList layersToShow) { mLayersToShow = layersToShow; } int render(const QString &fileName, const QString &imageFileName); @@ -72,6 +73,7 @@ class TmxRasterizer bool mSmoothImages; bool mIgnoreVisibility; QStringList mLayersToHide; + QStringList mLayersToShow; void drawMapLayers(MapRenderer &renderer, QPainter &painter, Map &map, QPoint mapOffset = QPoint(0, 0)) const; int renderMap(const QString &mapFileName, const QString &imageFileName);