From 6a5e4fe2477f8c83297869fa8792dc903df5f117 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 1 Dec 2021 10:33:18 -0500 Subject: [PATCH] Split createImage from addImage --- include/mainwindow.h | 3 ++- src/mainwindow_scriptapi.cpp | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/mainwindow.h b/include/mainwindow.h index ed31a4b0..f6ed14ab 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -74,7 +74,8 @@ public: Q_INVOKABLE void addText(QString text, int x, int y, QString color = "#000000", int fontSize = 12, int layer = 0); Q_INVOKABLE void addRect(int x, int y, int width, int height, QString color = "#000000", int layer = 0); 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 width = -1, int height = -1, unsigned offset = 0, bool hflip = false, bool vflip = false, bool setTransparency = false, 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); void refreshAfterPaletteChange(Tileset *tileset); void setTilesetPalette(Tileset *tileset, int paletteIndex, QList> colors); Q_INVOKABLE void setPrimaryTilesetPalette(int paletteIndex, QList> colors); diff --git a/src/mainwindow_scriptapi.cpp b/src/mainwindow_scriptapi.cpp index 31a05574..ef7a169c 100644 --- a/src/mainwindow_scriptapi.cpp +++ b/src/mainwindow_scriptapi.cpp @@ -277,7 +277,14 @@ void MainWindow::addFilledRect(int x, int y, int width, int height, QString colo this->ui->graphicsView_Map->scene()->update(); } -void MainWindow::addImage(int x, int y, QString filepath, int width, int height, unsigned offset, bool hflip, bool vflip, bool setTransparency, int layer) { +void MainWindow::addImage(int x, int y, QString filepath, int layer) { + if (!this->ui || !this->ui->graphicsView_Map || layer == INT_MAX) + return; + if (this->ui->graphicsView_Map->getOverlay(layer)->addImage(x, y, filepath, -1, -1, 0, false, false, false)) + this->ui->graphicsView_Map->scene()->update(); +} + +void MainWindow::createImage(int x, int y, QString filepath, int width, int height, unsigned offset, bool hflip, bool vflip, bool setTransparency, int layer) { if (!this->ui || !this->ui->graphicsView_Map || layer == INT_MAX) return; if (this->ui->graphicsView_Map->getOverlay(layer)->addImage(x, y, filepath, width, height, offset, hflip, vflip, setTransparency))