Allow users to fix faulty region map settings
This commit is contained in:
parent
4a79114b98
commit
1c2be70ff0
5 changed files with 40 additions and 10 deletions
|
@ -388,6 +388,7 @@ private:
|
|||
|
||||
void initTilesetEditor();
|
||||
bool initRegionMapEditor(bool silent = false);
|
||||
bool askToFixRegionMapEditor();
|
||||
void initShortcutsEditor();
|
||||
void initCustomScriptsEditor();
|
||||
void connectSubEditorsToShortcutsEditor();
|
||||
|
|
|
@ -42,6 +42,8 @@ public:
|
|||
|
||||
void resizeTilemap(int width, int height);
|
||||
|
||||
bool reconfigure();
|
||||
|
||||
QObjectList shortcutableObjects() const;
|
||||
|
||||
public slots:
|
||||
|
|
|
@ -303,7 +303,7 @@ bool RegionMap::loadLayout(poryjson::Json layoutJson) {
|
|||
}
|
||||
setLayout("main", layout);
|
||||
} else {
|
||||
logError("Region map layout is not readable.");
|
||||
logError(QString("Failed to read region map layout from '%1'.").arg(this->layout_path));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2958,14 +2958,12 @@ void MainWindow::on_pushButton_CreatePrefab_clicked() {
|
|||
|
||||
bool MainWindow::initRegionMapEditor(bool silent) {
|
||||
this->regionMapEditor = new RegionMapEditor(this, this->editor->project);
|
||||
bool success = this->regionMapEditor->load(silent);
|
||||
if (!success) {
|
||||
if (!this->regionMapEditor->load(silent)) {
|
||||
// The region map editor either failed to load,
|
||||
// or the user declined configuring their settings.
|
||||
if (!silent && this->regionMapEditor->setupErrored()) {
|
||||
QMessageBox msgBox(this);
|
||||
QString errorMsg = QString("There was an error opening the region map data. Please see %1 for full error details.\n\n%2")
|
||||
.arg(getLogPath())
|
||||
.arg(getMostRecentError());
|
||||
msgBox.critical(nullptr, "Error Opening Region Map Editor", errorMsg);
|
||||
if (this->askToFixRegionMapEditor())
|
||||
return true;
|
||||
}
|
||||
delete this->regionMapEditor;
|
||||
return false;
|
||||
|
@ -2974,6 +2972,29 @@ bool MainWindow::initRegionMapEditor(bool silent) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool MainWindow::askToFixRegionMapEditor() {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setText(QString("There was an error opening the region map data. Please see %1 for full error details.").arg(getLogPath()));
|
||||
msgBox.setDetailedText(getMostRecentError());
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
auto reconfigButton = msgBox.addButton("Reconfigure", QMessageBox::ActionRole);
|
||||
msgBox.exec();
|
||||
if (msgBox.clickedButton() == reconfigButton) {
|
||||
if (this->regionMapEditor->reconfigure()) {
|
||||
// User fixed error
|
||||
return true;
|
||||
}
|
||||
if (this->regionMapEditor->setupErrored()) {
|
||||
// User's new settings still fail, show error and ask again
|
||||
return this->askToFixRegionMapEditor();
|
||||
}
|
||||
}
|
||||
// User accepted error
|
||||
return false;
|
||||
}
|
||||
|
||||
void MainWindow::closeSupplementaryWindows() {
|
||||
delete this->tilesetEditor;
|
||||
delete this->regionMapEditor;
|
||||
|
|
|
@ -599,6 +599,11 @@ void RegionMapEditor::on_actionSave_All_triggered() {
|
|||
}
|
||||
|
||||
void RegionMapEditor::on_action_Configure_triggered() {
|
||||
reconfigure();
|
||||
}
|
||||
|
||||
bool RegionMapEditor::reconfigure() {
|
||||
this->setupError = false;
|
||||
if (this->modified()) {
|
||||
QMessageBox warning;
|
||||
warning.setIcon(QMessageBox::Warning);
|
||||
|
@ -609,15 +614,16 @@ void RegionMapEditor::on_action_Configure_triggered() {
|
|||
|
||||
if (warning.exec() == QMessageBox::Ok) {
|
||||
if (buildConfigDialog()) {
|
||||
reload();
|
||||
return reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (buildConfigDialog()) {
|
||||
reload();
|
||||
return reload();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void RegionMapEditor::displayRegionMap() {
|
||||
|
|
Loading…
Reference in a new issue