Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/tiled/editablewangset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,34 @@ void EditableWangSet::setName(const QString &name)
wangSet()->setName(name);
}

void EditableWangSet::setColorImageTile(int colorIndex, EditableTile *imageTile)
{
if (colorIndex <= 0 || colorIndex > colorCount()) {
ScriptManager::instance().throwError(QCoreApplication::translate("Script Errors", "Index out of range"));
return;
}

int tileId = imageTile ? imageTile->id() : -1;
if (auto doc = tilesetDocument())
asset()->push(new ChangeWangColorImage(doc, wangSet()->colorAt(colorIndex).data(), tileId));
else if (!checkReadOnly())
wangSet()->colorAt(colorIndex)->setImageId(name);
}

void EditableWangSet::setColorProbability(int colorIndex, qreal probability)
{
if (colorIndex <= 0 || colorIndex > colorCount()) {
ScriptManager::instance().throwError(QCoreApplication::translate("Script Errors", "Index out of range"));
return;
}

int tileId = imageTile ? imageTile->id() : -1;
if (auto doc = tilesetDocument())
asset()->push(new ChangeWangColorProbability(doc, wangSet()->colorAt(colorIndex).data(), probability));
else if (!checkReadOnly())
wangSet()->colorAt(colorIndex)->setProbability(probability);
}

void EditableWangSet::setType(EditableWangSet::Type type)
{
if (auto document = tilesetDocument()) {
Expand Down
2 changes: 2 additions & 0 deletions src/tiled/editablewangset.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class EditableWangSet : public EditableObject

Q_INVOKABLE QString colorName(int colorIndex) const;
Q_INVOKABLE void setColorName(int colorIndex, const QString &name);
Q_INVOKABLE void setColorImageTile(int colorIndex, Tiled::EditableTile *imageTile);
Q_INVOKABLE void setColorProbability(int colorIndex, qreal probability);

Q_INVOKABLE Type effectiveTypeForColor(int color) const;

Expand Down
Loading