Skip to content

Commit

Permalink
Scripting: Added TileLayerWangEdit.wangSet
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn committed Jul 4, 2023
1 parent 94e1bbc commit 00be12d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/scripting-doc/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2946,6 +2946,12 @@ interface TileLayerWangEdit {
*/
readonly target : TileLayer

/**
* The Wang set that will be used when {@link apply} or {@link generate} is
* called.
*/
readonly wangSet : WangSet

/**
* Whether applied edits are mergeable with previous edits. Starts out as
* `false` and is automatically set to `true` by {@link apply}.
Expand Down
3 changes: 2 additions & 1 deletion src/tiled/tilelayerwangedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace Tiled {
TileLayerWangEdit::TileLayerWangEdit(EditableTileLayer *tileLayer, EditableWangSet *wangSet, QObject *parent)
: QObject(parent)
, mTargetLayer(tileLayer)
, mWangSet(wangSet)
, mMap(tileLayer->map()->map()->parameters())
, mRenderer(MapRenderer::create(&mMap))
, mWangFiller(std::make_unique<WangFiller>(*wangSet->wangSet(),
Expand All @@ -43,7 +44,7 @@ TileLayerWangEdit::TileLayerWangEdit(EditableTileLayer *tileLayer, EditableWangS

// Avoid usage of this object when the WangSet is deleted (this actually
// requires keeping the EditableWangSet alive).
connect(wangSet, &QObject::destroyed, this, &QObject::deleteLater);
connect(mWangSet, &QObject::destroyed, this, &QObject::deleteLater);
}

TileLayerWangEdit::~TileLayerWangEdit()
Expand Down
8 changes: 8 additions & 0 deletions src/tiled/tilelayerwangedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class TileLayerWangEdit : public QObject
Q_OBJECT

Q_PROPERTY(Tiled::EditableTileLayer *target READ target CONSTANT)
Q_PROPERTY(Tiled::EditableWangSet *wangSet READ wangSet CONSTANT)
Q_PROPERTY(bool mergeable READ isMergeable WRITE setMergeable)
Q_PROPERTY(bool correctionsEnabled READ correctionsEnabled WRITE setCorrectionsEnabled)

Expand All @@ -82,6 +83,7 @@ class TileLayerWangEdit : public QObject
void setCorrectionsEnabled(bool newCorrectionsEnabled);

EditableTileLayer *target() const;
EditableWangSet *wangSet() const;

Q_INVOKABLE Tiled::EditableTileLayer *generate();

Expand All @@ -97,6 +99,7 @@ public slots:

private:
EditableTileLayer *mTargetLayer;
EditableWangSet *mWangSet;
bool mMergeable = false;
const Map mMap; // Copy for the configuration
std::unique_ptr<MapRenderer> mRenderer;
Expand All @@ -119,6 +122,11 @@ inline EditableTileLayer *TileLayerWangEdit::target() const
return mTargetLayer;
}

inline EditableWangSet *TileLayerWangEdit::wangSet() const
{
return mWangSet;
}

inline void TileLayerWangEdit::setWangIndex(int x, int y, WangIndex::Value index, int color)
{
setWangIndex(QPoint(x, y), index, color);
Expand Down

0 comments on commit 00be12d

Please sign in to comment.