Implement script engine reload

This commit is contained in:
GriffinR 2023-09-06 13:40:55 -04:00
parent 40e8824eca
commit 2aa18da255
3 changed files with 14 additions and 1 deletions

View file

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

View file

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

View file

@ -198,7 +198,7 @@ void CustomScriptsEditor::reloadScripts() {
return;
this->save();
}
emit reloadScriptEngine(); // TODO: Catch this signal
emit reloadScriptEngine();
}
void CustomScriptsEditor::save() {