diff --git a/include/mainwindow.h b/include/mainwindow.h index 4ccaa6ff..224b8c24 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -288,6 +288,7 @@ private slots: void togglePreferenceSpecificUi(); void on_actionEdit_Project_Settings_triggered(); void on_actionCustom_Scripts_triggered(); + void reloadScriptEngine(); public: Ui::MainWindow *ui; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ef9f90c6..c667151d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2736,11 +2736,23 @@ void MainWindow::on_actionEdit_Project_Settings_triggered() { void MainWindow::on_actionCustom_Scripts_triggered() { if (!this->customScriptsEditor) { this->customScriptsEditor = new CustomScriptsEditor(this); + connect(this->customScriptsEditor, &CustomScriptsEditor::reloadScriptEngine, + this, &MainWindow::reloadScriptEngine); } openSubWindow(this->customScriptsEditor); } +void MainWindow::reloadScriptEngine() { + Scripting::init(this); + this->ui->graphicsView_Map->clearOverlayMap(); + Scripting::populateGlobalObject(this); + // Lying to the scripts here, simulating a project reload + Scripting::cb_ProjectOpened(projectConfig.getProjectDir()); + if (editor && editor->map) + Scripting::cb_MapOpened(editor->map->name); +} + void MainWindow::on_pushButton_AddCustomHeaderField_clicked() { bool ok; diff --git a/src/ui/customscriptseditor.cpp b/src/ui/customscriptseditor.cpp index c54ec1c7..d2ad791d 100644 --- a/src/ui/customscriptseditor.cpp +++ b/src/ui/customscriptseditor.cpp @@ -198,7 +198,7 @@ void CustomScriptsEditor::reloadScripts() { return; this->save(); } - emit reloadScriptEngine(); // TODO: Catch this signal + emit reloadScriptEngine(); } void CustomScriptsEditor::save() {