diff --git a/include/mainwindow.h b/include/mainwindow.h index 5fd80f18..fdcbc219 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -76,7 +76,7 @@ public: Q_INVOKABLE void addFilledRect(int x, int y, int width, int height, QString color = "#000000", int layer = 0); Q_INVOKABLE void addImage(int x, int y, QString filepath, int layer = 0); Q_INVOKABLE void createImage(int x, int y, QString filepath, int width = -1, int height = -1, unsigned offset = 0, bool hflip = false, bool vflip = false, bool setTransparency = false, int layer = 0); - Q_INVOKABLE void addTileImage(int x, int y, int tileId, bool xflip, bool yflip, int palette, int layer = 0); + Q_INVOKABLE void addTileImage(int x, int y, int tileId, bool xflip, bool yflip, int palette, bool setTransparency = false, int layer = 0); Q_INVOKABLE void addTilesImage(int x, int y, QJSValue tilesObj, int layer = 0); Q_INVOKABLE void addMetatileImage(int x, int y, int metatileId, int layer = 0); void refreshAfterPaletteChange(Tileset *tileset); diff --git a/src/mainwindow_scriptapi.cpp b/src/mainwindow_scriptapi.cpp index 605fb155..a61c2803 100644 --- a/src/mainwindow_scriptapi.cpp +++ b/src/mainwindow_scriptapi.cpp @@ -292,7 +292,7 @@ void MainWindow::createImage(int x, int y, QString filepath, int width, int heig this->ui->graphicsView_Map->scene()->update(); } -void MainWindow::addTileImage(int x, int y, int tileId, bool xflip, bool yflip, int palette, int layer) { +void MainWindow::addTileImage(int x, int y, int tileId, bool xflip, bool yflip, int palette, bool setTransparency, int layer) { if (!this->ui || !this->ui->graphicsView_Map || layer == INT_MAX || !this->editor || !this->editor->map || !this->editor->map->layout || !this->editor->map->layout->tileset_primary || !this->editor->map->layout->tileset_secondary) @@ -302,6 +302,8 @@ void MainWindow::addTileImage(int x, int y, int tileId, bool xflip, bool yflip, this->editor->map->layout->tileset_secondary, palette) .mirrored(xflip, yflip); + if (setTransparency) + image.setColor(0, qRgba(0, 0, 0, 0)); if (this->ui->graphicsView_Map->getOverlay(layer)->addImage(x, y, image)) this->ui->graphicsView_Map->scene()->update(); }