Add getMaxTilesetMetatiles to API

This commit is contained in:
GriffinR 2021-12-01 17:13:50 -05:00 committed by huderlem
parent b5bdac8d36
commit 6c1e5b516d
2 changed files with 14 additions and 0 deletions

View file

@ -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();

View file

@ -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;