Skip to content
Permalink
Browse files

Automapping: Apply rules to selected area when there is one

Suggested on the forum and seems like a sensible thing to do.

See http://discourse.mapeditor.org/t/selective-automapping/3093
  • Loading branch information...
bjorn committed Mar 27, 2018
1 parent b3e461b commit 935401d95fb6fce8f4eb659ef1645ad020544825
Showing with 18 additions and 14 deletions.
  1. +1 −1 src/tiled/automapperwrapper.h
  2. +15 −12 src/tiled/automappingmanager.cpp
  3. +2 −1 src/tiled/automappingmanager.h
@@ -43,7 +43,7 @@ class AutoMapperWrapper : public QUndoCommand
public:
AutoMapperWrapper(MapDocument *mapDocument, QVector<AutoMapper*> autoMapper,
QRegion *where);
~AutoMapperWrapper();
~AutoMapperWrapper() override;

void undo() override;
void redo() override;
@@ -52,23 +52,26 @@ void AutomappingManager::autoMap()
return;

Map *map = mMapDocument->map();
QRegion region = mMapDocument->selectedArea();

QRect bounds;
if (region.isEmpty()) {
if (map->infinite()) {
LayerIterator iterator(map);

if (map->infinite()) {
LayerIterator iterator(map);

while (Layer *layer = iterator.next()) {
if (TileLayer *tileLayer = dynamic_cast<TileLayer*>(layer))
bounds = bounds.united(tileLayer->bounds());
QRect bounds;
while (Layer *layer = iterator.next()) {
if (TileLayer *tileLayer = dynamic_cast<TileLayer*>(layer))
bounds = bounds.united(tileLayer->bounds());
}
region = bounds;
} else {
int w = map->width();
int h = map->height();
region = QRect(0, 0, w, h);
}
} else {
int w = map->width();
int h = map->height();
bounds = QRect(0, 0, w, h);
}

autoMapInternal(bounds, nullptr);
autoMapInternal(region, nullptr);
}

void AutomappingManager::autoMap(const QRegion &where, Layer *touchedLayer)
@@ -69,7 +69,8 @@ class AutomappingManager : public QObject

public slots:
/**
* This triggers an automapping on the whole current map document.
* This triggers an automapping on the current map document. Starts with
* the currently selected area, or the entire map if there is no selection.
*/
void autoMap();

0 comments on commit 935401d

Please sign in to comment.
You can’t perform that action at this time.