Add script action warning
This commit is contained in:
parent
7dacfeb52b
commit
880dabade3
3 changed files with 31 additions and 2 deletions
|
@ -62,6 +62,7 @@ public:
|
||||||
this->textEditorOpenFolder = "";
|
this->textEditorOpenFolder = "";
|
||||||
this->textEditorGotoLine = "";
|
this->textEditorGotoLine = "";
|
||||||
this->warnScriptLoad = true;
|
this->warnScriptLoad = true;
|
||||||
|
this->warnScriptAction = true;
|
||||||
}
|
}
|
||||||
void setRecentProject(QString project);
|
void setRecentProject(QString project);
|
||||||
void setReopenOnLaunch(bool enabled);
|
void setReopenOnLaunch(bool enabled);
|
||||||
|
@ -80,6 +81,7 @@ public:
|
||||||
void setMonitorFiles(bool monitor);
|
void setMonitorFiles(bool monitor);
|
||||||
void setTilesetCheckerboardFill(bool checkerboard);
|
void setTilesetCheckerboardFill(bool checkerboard);
|
||||||
void setWarnScriptLoad(bool enabled);
|
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);
|
||||||
|
@ -100,6 +102,7 @@ public:
|
||||||
bool getMonitorFiles();
|
bool getMonitorFiles();
|
||||||
bool getTilesetCheckerboardFill();
|
bool getTilesetCheckerboardFill();
|
||||||
bool getWarnScriptLoad();
|
bool getWarnScriptLoad();
|
||||||
|
bool getWarnScriptAction();
|
||||||
QString getTheme();
|
QString getTheme();
|
||||||
QString getTextEditorOpenFolder();
|
QString getTextEditorOpenFolder();
|
||||||
QString getTextEditorGotoLine();
|
QString getTextEditorGotoLine();
|
||||||
|
@ -136,6 +139,7 @@ private:
|
||||||
bool monitorFiles;
|
bool monitorFiles;
|
||||||
bool tilesetCheckerboardFill;
|
bool tilesetCheckerboardFill;
|
||||||
bool warnScriptLoad;
|
bool warnScriptLoad;
|
||||||
|
bool warnScriptAction;
|
||||||
QString theme;
|
QString theme;
|
||||||
QString textEditorOpenFolder;
|
QString textEditorOpenFolder;
|
||||||
QString textEditorGotoLine;
|
QString textEditorGotoLine;
|
||||||
|
|
|
@ -242,6 +242,8 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) {
|
||||||
this->tilesetCheckerboardFill = getConfigBool(key, value);
|
this->tilesetCheckerboardFill = getConfigBool(key, value);
|
||||||
} else if (key == "warn_script_load") {
|
} else if (key == "warn_script_load") {
|
||||||
this->warnScriptLoad = getConfigBool(key, value);
|
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") {
|
||||||
|
@ -278,6 +280,7 @@ QMap<QString, QString> PorymapConfig::getKeyValueMap() {
|
||||||
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_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);
|
||||||
|
@ -337,6 +340,11 @@ void PorymapConfig::setWarnScriptLoad(bool enabled) {
|
||||||
this->save();
|
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_;
|
||||||
|
@ -498,6 +506,10 @@ bool PorymapConfig::getWarnScriptLoad() {
|
||||||
return this->warnScriptLoad;
|
return this->warnScriptLoad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PorymapConfig::getWarnScriptAction() {
|
||||||
|
return this->warnScriptAction;
|
||||||
|
}
|
||||||
|
|
||||||
QString PorymapConfig::getTheme() {
|
QString PorymapConfig::getTheme() {
|
||||||
return this->theme;
|
return this->theme;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,6 @@ void Scripting::loadModules(QStringList moduleFiles) {
|
||||||
messageBox.setDetailedText(getMostRecentError());
|
messageBox.setDetailedText(getMostRecentError());
|
||||||
messageBox.setIcon(QMessageBox::Warning);
|
messageBox.setIcon(QMessageBox::Warning);
|
||||||
messageBox.addButton(QMessageBox::Ok);
|
messageBox.addButton(QMessageBox::Ok);
|
||||||
messageBox.setDefaultButton(QMessageBox::Ok);
|
|
||||||
QCheckBox * checkbox = new QCheckBox("Don't show this warning again");
|
QCheckBox * checkbox = new QCheckBox("Don't show this warning again");
|
||||||
messageBox.setCheckBox(checkbox);
|
messageBox.setCheckBox(checkbox);
|
||||||
QObject::connect(checkbox, &QCheckBox::stateChanged, [](int state) {
|
QObject::connect(checkbox, &QCheckBox::stateChanged, [](int state) {
|
||||||
|
@ -159,8 +158,22 @@ void Scripting::invokeAction(QString actionName) {
|
||||||
QJSValue result = callbackFunction.call(QJSValueList());
|
QJSValue result = callbackFunction.call(QJSValueList());
|
||||||
if (tryErrorJS(result)) continue;
|
if (tryErrorJS(result)) continue;
|
||||||
}
|
}
|
||||||
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);
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scripting::cb_ProjectOpened(QString projectPath) {
|
void Scripting::cb_ProjectOpened(QString projectPath) {
|
||||||
|
|
Loading…
Reference in a new issue