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();
|
void initTilesetEditor();
|
||||||
bool initRegionMapEditor(bool silent = false);
|
bool initRegionMapEditor(bool silent = false);
|
||||||
|
bool askToFixRegionMapEditor();
|
||||||
void initShortcutsEditor();
|
void initShortcutsEditor();
|
||||||
void initCustomScriptsEditor();
|
void initCustomScriptsEditor();
|
||||||
void connectSubEditorsToShortcutsEditor();
|
void connectSubEditorsToShortcutsEditor();
|
||||||
|
|
|
@ -42,6 +42,8 @@ public:
|
||||||
|
|
||||||
void resizeTilemap(int width, int height);
|
void resizeTilemap(int width, int height);
|
||||||
|
|
||||||
|
bool reconfigure();
|
||||||
|
|
||||||
QObjectList shortcutableObjects() const;
|
QObjectList shortcutableObjects() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
@ -303,7 +303,7 @@ bool RegionMap::loadLayout(poryjson::Json layoutJson) {
|
||||||
}
|
}
|
||||||
setLayout("main", layout);
|
setLayout("main", layout);
|
||||||
} else {
|
} else {
|
||||||
logError("Region map layout is not readable.");
|
logError(QString("Failed to read region map layout from '%1'.").arg(this->layout_path));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2958,14 +2958,12 @@ void MainWindow::on_pushButton_CreatePrefab_clicked() {
|
||||||
|
|
||||||
bool MainWindow::initRegionMapEditor(bool silent) {
|
bool MainWindow::initRegionMapEditor(bool silent) {
|
||||||
this->regionMapEditor = new RegionMapEditor(this, this->editor->project);
|
this->regionMapEditor = new RegionMapEditor(this, this->editor->project);
|
||||||
bool success = this->regionMapEditor->load(silent);
|
if (!this->regionMapEditor->load(silent)) {
|
||||||
if (!success) {
|
// The region map editor either failed to load,
|
||||||
|
// or the user declined configuring their settings.
|
||||||
if (!silent && this->regionMapEditor->setupErrored()) {
|
if (!silent && this->regionMapEditor->setupErrored()) {
|
||||||
QMessageBox msgBox(this);
|
if (this->askToFixRegionMapEditor())
|
||||||
QString errorMsg = QString("There was an error opening the region map data. Please see %1 for full error details.\n\n%2")
|
return true;
|
||||||
.arg(getLogPath())
|
|
||||||
.arg(getMostRecentError());
|
|
||||||
msgBox.critical(nullptr, "Error Opening Region Map Editor", errorMsg);
|
|
||||||
}
|
}
|
||||||
delete this->regionMapEditor;
|
delete this->regionMapEditor;
|
||||||
return false;
|
return false;
|
||||||
|
@ -2974,6 +2972,29 @@ bool MainWindow::initRegionMapEditor(bool silent) {
|
||||||
return true;
|
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() {
|
void MainWindow::closeSupplementaryWindows() {
|
||||||
delete this->tilesetEditor;
|
delete this->tilesetEditor;
|
||||||
delete this->regionMapEditor;
|
delete this->regionMapEditor;
|
||||||
|
|
|
@ -599,6 +599,11 @@ void RegionMapEditor::on_actionSave_All_triggered() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::on_action_Configure_triggered() {
|
void RegionMapEditor::on_action_Configure_triggered() {
|
||||||
|
reconfigure();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RegionMapEditor::reconfigure() {
|
||||||
|
this->setupError = false;
|
||||||
if (this->modified()) {
|
if (this->modified()) {
|
||||||
QMessageBox warning;
|
QMessageBox warning;
|
||||||
warning.setIcon(QMessageBox::Warning);
|
warning.setIcon(QMessageBox::Warning);
|
||||||
|
@ -609,15 +614,16 @@ void RegionMapEditor::on_action_Configure_triggered() {
|
||||||
|
|
||||||
if (warning.exec() == QMessageBox::Ok) {
|
if (warning.exec() == QMessageBox::Ok) {
|
||||||
if (buildConfigDialog()) {
|
if (buildConfigDialog()) {
|
||||||
reload();
|
return reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (buildConfigDialog()) {
|
if (buildConfigDialog()) {
|
||||||
reload();
|
return reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionMapEditor::displayRegionMap() {
|
void RegionMapEditor::displayRegionMap() {
|
||||||
|
|
Loading…
Reference in a new issue