From b16c971f0090ebbe4172a0450fabee36890321bc Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 9 Dec 2021 08:37:22 -0500 Subject: [PATCH] Add some config settings to scripting API --- include/mainwindow.h | 5 ++++- src/mainwindow_scriptapi.cpp | 20 ++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/include/mainwindow.h b/include/mainwindow.h index 7dc6d63f..f9a016a9 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -140,7 +140,6 @@ public: Q_INVOKABLE void setMetatileTerrainType(int metatileId, int terrainType); Q_INVOKABLE int getMetatileBehavior(int metatileId); Q_INVOKABLE void setMetatileBehavior(int metatileId, int behavior); - Q_INVOKABLE int getNumTilesInMetatile(); Q_INVOKABLE QJSValue getMetatileTile(int metatileId, int tileIndex); Q_INVOKABLE void setMetatileTile(int metatileId, int tileIndex, int tileId, bool xflip, bool yflip, int palette, bool forceRedraw = true); Q_INVOKABLE void setMetatileTile(int metatileId, int tileIndex, QJSValue tileObj, bool forceRedraw = true); @@ -148,6 +147,10 @@ public: Q_INVOKABLE QJSValue getMetatileTiles(int metatileId, int tileStart = 0, int tileEnd = -1); Q_INVOKABLE void setMetatileTiles(int metatileId, QJSValue tilesObj, int tileStart = 0, int tileEnd = -1, bool forceRedraw = true); Q_INVOKABLE void setMetatileTiles(int metatileId, int tileId, bool xflip, bool yflip, int palette, int tileStart = 0, int tileEnd = -1, bool forceRedraw = true); + Q_INVOKABLE int getNumTilesInMetatile(); + Q_INVOKABLE int getNumMetatileLayers(); + Q_INVOKABLE int getBaseGameVersion(); + Q_INVOKABLE QList getCustomScripts(); private slots: diff --git a/src/mainwindow_scriptapi.cpp b/src/mainwindow_scriptapi.cpp index 8a5eaf8c..2bd38649 100644 --- a/src/mainwindow_scriptapi.cpp +++ b/src/mainwindow_scriptapi.cpp @@ -810,10 +810,6 @@ void MainWindow::setMetatileBehavior(int metatileId, int behavior) { this->saveMetatileAttributesByMetatileId(metatileId); } -int MainWindow::getNumTilesInMetatile() { - return projectConfig.getTripleLayerMetatilesEnabled() ? 12 : 8; -} - int MainWindow::calculateTileBounds(int * tileStart, int * tileEnd) { int maxNumTiles = this->getNumTilesInMetatile(); if (*tileEnd >= maxNumTiles || *tileEnd < 0) @@ -885,3 +881,19 @@ void MainWindow::setMetatileTile(int metatileId, int tileIndex, QJSValue tileObj Tile tile = Scripting::toTile(tileObj); this->setMetatileTiles(metatileId, tile.tileId, tile.xflip, tile.yflip, tile.palette, tileIndex, tileIndex, forceRedraw); } + +int MainWindow::getNumTilesInMetatile() { + return projectConfig.getTripleLayerMetatilesEnabled() ? 12 : 8; +} + +int MainWindow::getNumMetatileLayers() { + return projectConfig.getTripleLayerMetatilesEnabled() ? 3 : 2; +} + +int MainWindow::getBaseGameVersion() { + return projectConfig.getBaseGameVersion(); +} + +QList MainWindow::getCustomScripts() { + return projectConfig.getCustomScripts(); +}