Add some config settings to scripting API

This commit is contained in:
GriffinR 2021-12-09 08:37:22 -05:00 committed by huderlem
parent 05d04a5e2e
commit b16c971f00
2 changed files with 20 additions and 5 deletions

View file

@ -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<QString> getCustomScripts();
private slots:

View file

@ -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<QString> MainWindow::getCustomScripts() {
return projectConfig.getCustomScripts();
}