Apply the "map opened" API callback to layouts, add utility functions

This commit is contained in:
GriffinR
2025-02-07 16:25:58 -05:00
parent df861b59ad
commit 01126a888a
5 changed files with 59 additions and 6 deletions

View File

@@ -794,7 +794,7 @@ void MainWindow::setMetatileTile(int metatileId, int tileIndex, QJSValue tileObj
}
QJSValue MainWindow::getTilePixels(int tileId) {
if (tileId < 0 || !this->editor || !this->editor->project || !this->editor->map || !this->editor->layout)
if (tileId < 0 || !this->editor || !this->editor->layout)
return QJSValue();
QImage tileImage = getTileImage(tileId, this->editor->layout->tileset_primary, this->editor->layout->tileset_secondary);
if (tileImage.isNull() || tileImage.sizeInBytes() < 64)

View File

@@ -249,6 +249,27 @@ QList<QString> ScriptUtility::getMapNames() {
return window->editor->project->mapNames;
}
QList<QString> ScriptUtility::getMapConstants() {
if (!window || !window->editor || !window->editor->project)
return QList<QString>();
return window->editor->project->mapConstantsToMapNames.keys();
}
QList<QString> ScriptUtility::getLayoutNames() {
QList<QString> names;
if (!window || !window->editor || !window->editor->project)
return names;
for (const auto &layout : window->editor->project->mapLayouts)
names.append(layout->name);
return names;
}
QList<QString> ScriptUtility::getLayoutConstants() {
if (!window || !window->editor || !window->editor->project)
return QList<QString>();
return window->editor->project->layoutIds;
}
QList<QString> ScriptUtility::getTilesetNames() {
if (!window || !window->editor || !window->editor->project)
return QList<QString>();