Add option to bypass the API image cache
This commit is contained in:
parent
fee9ffcd44
commit
8ed891d501
4 changed files with 12 additions and 9 deletions
|
@ -90,8 +90,11 @@ 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 layer = 0);
|
||||
Q_INVOKABLE void createImage(int x, int y, QString filepath, int width = -1, int height = -1, unsigned offset = 0, bool xflip = false, bool yflip = false, int paletteId = -1, bool setTransparency = false, int layer = 0);
|
||||
Q_INVOKABLE void addImage(int x, int y, QString filepath, int layer = 0, bool useCache = true);
|
||||
Q_INVOKABLE void createImage(int x, int y, QString filepath,
|
||||
int width = -1, int height = -1, unsigned offset = 0,
|
||||
bool xflip = false, bool yflip = false, int paletteId = -1, bool setTransparency = false,
|
||||
int layer = 0, bool useCache = true);
|
||||
Q_INVOKABLE void addTileImage(int x, int y, int tileId, bool xflip, bool yflip, int paletteId, 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);
|
||||
|
|
|
@ -92,7 +92,7 @@ public:
|
|||
void clearItems();
|
||||
void addText(QString text, int x, int y, QString color = "#000000", int fontSize = 12);
|
||||
void addRect(int x, int y, int width, int height, QString color = "#000000", bool filled = false);
|
||||
bool addImage(int x, int y, QString filepath, int width = -1, int height = -1, unsigned offset = 0, bool xflip = false, bool yflip = false, QList<QRgb> palette = QList<QRgb>(), bool setTransparency = false);
|
||||
bool addImage(int x, int y, QString filepath, bool useCache = true, int width = -1, int height = -1, unsigned offset = 0, bool xflip = false, bool yflip = false, QList<QRgb> palette = QList<QRgb>(), bool setTransparency = false);
|
||||
bool addImage(int x, int y, QImage image);
|
||||
private:
|
||||
QList<OverlayItem*> items;
|
||||
|
|
|
@ -374,21 +374,21 @@ 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 layer) {
|
||||
void MainWindow::addImage(int x, int y, QString filepath, int layer, bool useCache) {
|
||||
if (!this->ui || !this->ui->graphicsView_Map)
|
||||
return;
|
||||
if (this->ui->graphicsView_Map->getOverlay(layer)->addImage(x, y, filepath))
|
||||
if (this->ui->graphicsView_Map->getOverlay(layer)->addImage(x, y, filepath, useCache))
|
||||
this->ui->graphicsView_Map->scene()->update();
|
||||
}
|
||||
|
||||
void MainWindow::createImage(int x, int y, QString filepath, int width, int height, unsigned offset, bool xflip, bool yflip, int paletteId, bool setTransparency, int layer) {
|
||||
void MainWindow::createImage(int x, int y, QString filepath, int width, int height, unsigned offset, bool xflip, bool yflip, int paletteId, bool setTransparency, int layer, bool useCache) {
|
||||
if (!this->ui || !this->ui->graphicsView_Map || !this->editor || !this->editor->map || !this->editor->map->layout
|
||||
|| !this->editor->map->layout->tileset_primary || !this->editor->map->layout->tileset_secondary)
|
||||
return;
|
||||
QList<QRgb> palette;
|
||||
if (paletteId != -1)
|
||||
palette = Tileset::getPalette(paletteId, this->editor->map->layout->tileset_primary, this->editor->map->layout->tileset_secondary);
|
||||
if (this->ui->graphicsView_Map->getOverlay(layer)->addImage(x, y, filepath, width, height, offset, xflip, yflip, palette, setTransparency))
|
||||
if (this->ui->graphicsView_Map->getOverlay(layer)->addImage(x, y, filepath, useCache, width, height, offset, xflip, yflip, palette, setTransparency))
|
||||
this->ui->graphicsView_Map->scene()->update();
|
||||
}
|
||||
|
||||
|
|
|
@ -83,8 +83,8 @@ void Overlay::addRect(int x, int y, int width, int height, QString color, bool f
|
|||
this->items.append(new OverlayRect(x, y, width, height, QColor(color), filled));
|
||||
}
|
||||
|
||||
bool Overlay::addImage(int x, int y, QString filepath, int width, int height, unsigned offset, bool xflip, bool yflip, QList<QRgb> palette, bool setTransparency) {
|
||||
QImage image = Scripting::getImage(filepath);
|
||||
bool Overlay::addImage(int x, int y, QString filepath, bool useCache, int width, int height, unsigned offset, bool xflip, bool yflip, QList<QRgb> palette, bool setTransparency) {
|
||||
QImage image = useCache ? Scripting::getImage(filepath) : QImage(filepath);
|
||||
if (image.isNull()) {
|
||||
logError(QString("Failed to load image '%1'").arg(filepath));
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue