mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-14 21:07:44 -05:00
Add ability to register custom actions
This commit is contained in:
@@ -348,6 +348,10 @@ bool MainWindow::openProject(QString dir) {
|
||||
|
||||
}
|
||||
|
||||
if (success) {
|
||||
Scripting::cb_ProjectOpened(dir);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -2844,3 +2848,16 @@ void MainWindow::setSecondaryTilesetPalettePreview(int paletteIndex, QList<QList
|
||||
return;
|
||||
this->setTilesetPalettePreview(this->editor->map->layout->tileset_secondary, paletteIndex, colors);
|
||||
}
|
||||
|
||||
void MainWindow::registerAction(QString functionName, QString actionName) {
|
||||
if (!this->ui || !this->ui->menuTools)
|
||||
return;
|
||||
|
||||
Scripting::registerAction(functionName, actionName);
|
||||
if (Scripting::numRegisteredActions() == 1) {
|
||||
this->ui->menuTools->addSeparator();
|
||||
}
|
||||
this->ui->menuTools->addAction(actionName, [actionName](){
|
||||
Scripting::invokeAction(actionName);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user