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

View file

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

View file

@ -50,20 +50,13 @@ void Scripting::loadModules(QStringList moduleFiles) {
QString relativePath = QDir::cleanPath(userConfig.getProjectDir() + QDir::separator() + filepath); QString relativePath = QDir::cleanPath(userConfig.getProjectDir() + QDir::separator() + filepath);
module = this->engine->importModule(relativePath); module = this->engine->importModule(relativePath);
if (tryErrorJS(module)) { if (tryErrorJS(module)) {
if (porymapConfig.getWarnScriptLoad()) { QMessageBox messageBox(this->mainWindow);
QMessageBox messageBox(this->mainWindow); messageBox.setText("Failed to load script");
messageBox.setText("Failed to load script"); messageBox.setInformativeText(QString("An error occurred while loading custom script file '%1'").arg(filepath));
messageBox.setInformativeText(QString("An error occurred while loading custom script file '%1'").arg(filepath)); messageBox.setDetailedText(getMostRecentError());
messageBox.setDetailedText(getMostRecentError()); messageBox.setIcon(QMessageBox::Warning);
messageBox.setIcon(QMessageBox::Warning); messageBox.addButton(QMessageBox::Ok);
messageBox.addButton(QMessageBox::Ok); messageBox.exec();
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();
}
continue; continue;
} }
} }
@ -160,19 +153,12 @@ void Scripting::invokeAction(int actionIndex) {
} }
if (!foundFunction) { if (!foundFunction) {
logError(QString("Unknown custom script function '%1'").arg(functionName)); logError(QString("Unknown custom script function '%1'").arg(functionName));
if (porymapConfig.getWarnScriptAction()) { QMessageBox messageBox(instance->mainWindow);
QMessageBox messageBox(instance->mainWindow); messageBox.setText("Failed to run custom action");
messageBox.setText("Failed to run custom action"); messageBox.setInformativeText(getMostRecentError());
messageBox.setInformativeText(getMostRecentError()); messageBox.setIcon(QMessageBox::Warning);
messageBox.setIcon(QMessageBox::Warning); messageBox.addButton(QMessageBox::Ok);
messageBox.addButton(QMessageBox::Ok); messageBox.exec();
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();
}
} }
} }