diff --git a/include/mainwindow.h b/include/mainwindow.h index 2d4622d5..8a2579fe 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -102,7 +102,9 @@ public: Q_INVOKABLE QJSValue getSecondaryTilesetPalettePreview(int paletteIndex); Q_INVOKABLE QJSValue getSecondaryTilesetPalettesPreview(); Q_INVOKABLE int getNumPrimaryTilesetMetatiles(); + Q_INVOKABLE int getMaxPrimaryTilesetMetatiles(); Q_INVOKABLE int getNumSecondaryTilesetMetatiles(); + Q_INVOKABLE int getMaxSecondaryTilesetMetatiles(); Q_INVOKABLE bool isPrimaryTileset(QString tilesetName); Q_INVOKABLE bool isSecondaryTileset(QString tilesetName); Q_INVOKABLE QString getPrimaryTileset(); diff --git a/src/mainwindow_scriptapi.cpp b/src/mainwindow_scriptapi.cpp index 933991d7..3144794a 100644 --- a/src/mainwindow_scriptapi.cpp +++ b/src/mainwindow_scriptapi.cpp @@ -538,12 +538,24 @@ int MainWindow::getNumPrimaryTilesetMetatiles() { return this->editor->map->layout->tileset_primary->metatiles.length(); } +int MainWindow::getMaxPrimaryTilesetMetatiles() { + if (!this->editor || !this->editor->project) + return 0; + return this->editor->project->getNumMetatilesPrimary(); +} + int MainWindow::getNumSecondaryTilesetMetatiles() { if (!this->editor || !this->editor->map || !this->editor->map->layout || !this->editor->map->layout->tileset_secondary) return 0; return this->editor->map->layout->tileset_secondary->metatiles.length(); } +int MainWindow::getMaxSecondaryTilesetMetatiles() { + if (!this->editor || !this->editor->project) + return 0; + return this->editor->project->getNumMetatilesTotal() - this->editor->project->getNumMetatilesPrimary(); +} + bool MainWindow::isPrimaryTileset(QString tilesetName) { if (!this->editor || !this->editor->project) return false;