Remove option to turn off script warning messages

This commit is contained in:
GriffinR 2023-02-12 14:09:25 -05:00
parent bc256053d0
commit f4f93f4c98
3 changed files with 13 additions and 59 deletions

View file

@ -61,8 +61,6 @@ public:
this->theme = "default";
this->textEditorOpenFolder = "";
this->textEditorGotoLine = "";
this->warnScriptLoad = true;
this->warnScriptAction = true;
}
void setRecentProject(QString project);
void setReopenOnLaunch(bool enabled);
@ -80,8 +78,6 @@ public:
void setShowGrid(bool enabled);
void setMonitorFiles(bool monitor);
void setTilesetCheckerboardFill(bool checkerboard);
void setWarnScriptLoad(bool enabled);
void setWarnScriptAction(bool enabled);
void setTheme(QString theme);
void setTextEditorOpenFolder(const QString &command);
void setTextEditorGotoLine(const QString &command);
@ -101,8 +97,6 @@ public:
bool getShowGrid();
bool getMonitorFiles();
bool getTilesetCheckerboardFill();
bool getWarnScriptLoad();
bool getWarnScriptAction();
QString getTheme();
QString getTextEditorOpenFolder();
QString getTextEditorGotoLine();
@ -138,8 +132,6 @@ private:
bool showGrid;
bool monitorFiles;
bool tilesetCheckerboardFill;
bool warnScriptLoad;
bool warnScriptAction;
QString theme;
QString textEditorOpenFolder;
QString textEditorGotoLine;

View file

@ -240,10 +240,6 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) {
this->monitorFiles = getConfigBool(key, value);
} else if (key == "tileset_checkerboard_fill") {
this->tilesetCheckerboardFill = getConfigBool(key, value);
} else if (key == "warn_script_load") {
this->warnScriptLoad = getConfigBool(key, value);
} else if (key == "warn_script_action") {
this->warnScriptAction = getConfigBool(key, value);
} else if (key == "theme") {
this->theme = value;
} else if (key == "text_editor_open_directory") {
@ -279,8 +275,6 @@ QMap<QString, QString> PorymapConfig::getKeyValueMap() {
map.insert("show_grid", this->showGrid ? "1" : "0");
map.insert("monitor_files", this->monitorFiles ? "1" : "0");
map.insert("tileset_checkerboard_fill", this->tilesetCheckerboardFill ? "1" : "0");
map.insert("warn_script_load", this->warnScriptLoad ? "1" : "0");
map.insert("warn_script_action", this->warnScriptAction ? "1" : "0");
map.insert("theme", this->theme);
map.insert("text_editor_open_directory", this->textEditorOpenFolder);
map.insert("text_editor_goto_line", this->textEditorGotoLine);
@ -335,16 +329,6 @@ void PorymapConfig::setTilesetCheckerboardFill(bool checkerboard) {
this->save();
}
void PorymapConfig::setWarnScriptLoad(bool enabled) {
this->warnScriptLoad = enabled;
this->save();
}
void PorymapConfig::setWarnScriptAction(bool enabled) {
this->warnScriptAction = enabled;
this->save();
}
void PorymapConfig::setMainGeometry(QByteArray mainWindowGeometry_, QByteArray mainWindowState_,
QByteArray mapSplitterState_, QByteArray mainSplitterState_) {
this->mainWindowGeometry = mainWindowGeometry_;
@ -502,14 +486,6 @@ bool PorymapConfig::getTilesetCheckerboardFill() {
return this->tilesetCheckerboardFill;
}
bool PorymapConfig::getWarnScriptLoad() {
return this->warnScriptLoad;
}
bool PorymapConfig::getWarnScriptAction() {
return this->warnScriptAction;
}
QString PorymapConfig::getTheme() {
return this->theme;
}

View file

@ -50,20 +50,13 @@ void Scripting::loadModules(QStringList moduleFiles) {
QString relativePath = QDir::cleanPath(userConfig.getProjectDir() + QDir::separator() + filepath);
module = this->engine->importModule(relativePath);
if (tryErrorJS(module)) {
if (porymapConfig.getWarnScriptLoad()) {
QMessageBox messageBox(this->mainWindow);
messageBox.setText("Failed to load script");
messageBox.setInformativeText(QString("An error occurred while loading custom script file '%1'").arg(filepath));
messageBox.setDetailedText(getMostRecentError());
messageBox.setIcon(QMessageBox::Warning);
messageBox.addButton(QMessageBox::Ok);
QCheckBox * checkbox = new QCheckBox("Don't show this warning again");
messageBox.setCheckBox(checkbox);
QObject::connect(checkbox, &QCheckBox::stateChanged, [](int state) {
porymapConfig.setWarnScriptLoad(static_cast<Qt::CheckState>(state) != Qt::CheckState::Checked);
});
messageBox.exec();
}
QMessageBox messageBox(this->mainWindow);
messageBox.setText("Failed to load script");
messageBox.setInformativeText(QString("An error occurred while loading custom script file '%1'").arg(filepath));
messageBox.setDetailedText(getMostRecentError());
messageBox.setIcon(QMessageBox::Warning);
messageBox.addButton(QMessageBox::Ok);
messageBox.exec();
continue;
}
}
@ -160,19 +153,12 @@ void Scripting::invokeAction(int actionIndex) {
}
if (!foundFunction) {
logError(QString("Unknown custom script function '%1'").arg(functionName));
if (porymapConfig.getWarnScriptAction()) {
QMessageBox messageBox(instance->mainWindow);
messageBox.setText("Failed to run custom action");
messageBox.setInformativeText(getMostRecentError());
messageBox.setIcon(QMessageBox::Warning);
messageBox.addButton(QMessageBox::Ok);
QCheckBox * checkbox = new QCheckBox("Don't show this warning again");
messageBox.setCheckBox(checkbox);
QObject::connect(checkbox, &QCheckBox::stateChanged, [](int state) {
porymapConfig.setWarnScriptAction(static_cast<Qt::CheckState>(state) != Qt::CheckState::Checked);
});
messageBox.exec();
}
QMessageBox messageBox(instance->mainWindow);
messageBox.setText("Failed to run custom action");
messageBox.setInformativeText(getMostRecentError());
messageBox.setIcon(QMessageBox::Warning);
messageBox.addButton(QMessageBox::Ok);
messageBox.exec();
}
}