diff --git a/CHANGELOG.md b/CHANGELOG.md index 321e1374..d12def26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d - Hovering on border metatiles with the mouse will now display their information in the bottom bar. ### Fixed +- Fix the Region Map Editor being opened by the Shortcuts Editor. - Fix New Map settings being preserved when switching projects. - Fix scripting API callback `onMapResized` not triggering. - Fix crash when importing AdvanceMap metatiles while `enable_triple_layer_metatiles` is enabled. diff --git a/include/mainwindow.h b/include/mainwindow.h index 896034f7..87ea30aa 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -379,7 +379,7 @@ private: void setWindowDisabled(bool); void initTilesetEditor(); - bool initRegionMapEditor(); + bool initRegionMapEditor(bool silent = false); void initShortcutsEditor(); void connectSubEditorsToShortcutsEditor(); diff --git a/include/ui/regionmapeditor.h b/include/ui/regionmapeditor.h index 182364d2..3cbc2515 100644 --- a/include/ui/regionmapeditor.h +++ b/include/ui/regionmapeditor.h @@ -26,7 +26,7 @@ public: explicit RegionMapEditor(QWidget *parent = 0, Project *pro = nullptr); ~RegionMapEditor(); - bool load(); + bool load(bool silent = false); void onRegionMapTileSelectorSelectedTileChanged(unsigned id); void onRegionMapTileSelectorHoveredTileChanged(unsigned id); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 522eadc7..a36e0255 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1815,7 +1815,7 @@ void MainWindow::connectSubEditorsToShortcutsEditor() { tilesetEditor, &TilesetEditor::applyUserShortcuts); if (!regionMapEditor) - initRegionMapEditor(); + initRegionMapEditor(true); if (regionMapEditor) connect(shortcutsEditor, &ShortcutsEditor::shortcutsSaved, regionMapEditor, &RegionMapEditor::applyUserShortcuts); @@ -2813,23 +2813,19 @@ void MainWindow::on_pushButton_CreatePrefab_clicked() { } } -bool MainWindow::initRegionMapEditor() { +bool MainWindow::initRegionMapEditor(bool silent) { this->regionMapEditor = new RegionMapEditor(this, this->editor->project); - this->regionMapEditor->setAttribute(Qt::WA_DeleteOnClose); - connect(this->regionMapEditor, &QObject::destroyed, [this](){ - this->regionMapEditor = nullptr; - }); - - bool success = this->regionMapEditor->load(); + bool success = this->regionMapEditor->load(silent); if (!success) { delete this->regionMapEditor; this->regionMapEditor = nullptr; - QMessageBox msgBox(this); - QString errorMsg = QString("There was an error opening the region map data. Please see %1 for full error details.\n\n%3") - .arg(getLogPath()) - .arg(getMostRecentError()); - msgBox.critical(nullptr, "Error Opening Region Map Editor", errorMsg); - + if (!silent) { + QMessageBox msgBox(this); + QString errorMsg = QString("There was an error opening the region map data. Please see %1 for full error details.\n\n%3") + .arg(getLogPath()) + .arg(getMostRecentError()); + msgBox.critical(nullptr, "Error Opening Region Map Editor", errorMsg); + } return false; } diff --git a/src/ui/regionmapeditor.cpp b/src/ui/regionmapeditor.cpp index 8257231c..39d79ca7 100644 --- a/src/ui/regionmapeditor.cpp +++ b/src/ui/regionmapeditor.cpp @@ -498,15 +498,10 @@ bool RegionMapEditor::setup() { if (!region_maps.empty()) { setRegionMap(region_maps.begin()->second); } - - this->show(); - this->setWindowState(Qt::WindowState::WindowActive); - this->activateWindow(); - return true; } -bool RegionMapEditor::load() { +bool RegionMapEditor::load(bool silent) { // check for config json file QString jsonConfigFilepath = this->project->root + "/" + projectConfig.getFilePath(ProjectFilePath::json_region_porymap_cfg); @@ -526,6 +521,7 @@ bool RegionMapEditor::load() { } if (badConfig) { + if (silent) return false; // show popup explaining next window QMessageBox warning; warning.setIcon(QMessageBox::Warning);