Fix Region Map Editor being opened by Shortcuts Editor

This commit is contained in:
GriffinR 2023-01-06 15:48:46 -05:00 committed by t
parent f27c4e9ab4
commit d9324368a2
5 changed files with 15 additions and 22 deletions

View file

@ -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. - Hovering on border metatiles with the mouse will now display their information in the bottom bar.
### Fixed ### Fixed
- Fix the Region Map Editor being opened by the Shortcuts Editor.
- Fix New Map settings being preserved when switching projects. - Fix New Map settings being preserved when switching projects.
- Fix scripting API callback `onMapResized` not triggering. - Fix scripting API callback `onMapResized` not triggering.
- Fix crash when importing AdvanceMap metatiles while `enable_triple_layer_metatiles` is enabled. - Fix crash when importing AdvanceMap metatiles while `enable_triple_layer_metatiles` is enabled.

View file

@ -379,7 +379,7 @@ private:
void setWindowDisabled(bool); void setWindowDisabled(bool);
void initTilesetEditor(); void initTilesetEditor();
bool initRegionMapEditor(); bool initRegionMapEditor(bool silent = false);
void initShortcutsEditor(); void initShortcutsEditor();
void connectSubEditorsToShortcutsEditor(); void connectSubEditorsToShortcutsEditor();

View file

@ -26,7 +26,7 @@ public:
explicit RegionMapEditor(QWidget *parent = 0, Project *pro = nullptr); explicit RegionMapEditor(QWidget *parent = 0, Project *pro = nullptr);
~RegionMapEditor(); ~RegionMapEditor();
bool load(); bool load(bool silent = false);
void onRegionMapTileSelectorSelectedTileChanged(unsigned id); void onRegionMapTileSelectorSelectedTileChanged(unsigned id);
void onRegionMapTileSelectorHoveredTileChanged(unsigned id); void onRegionMapTileSelectorHoveredTileChanged(unsigned id);

View file

@ -1815,7 +1815,7 @@ void MainWindow::connectSubEditorsToShortcutsEditor() {
tilesetEditor, &TilesetEditor::applyUserShortcuts); tilesetEditor, &TilesetEditor::applyUserShortcuts);
if (!regionMapEditor) if (!regionMapEditor)
initRegionMapEditor(); initRegionMapEditor(true);
if (regionMapEditor) if (regionMapEditor)
connect(shortcutsEditor, &ShortcutsEditor::shortcutsSaved, connect(shortcutsEditor, &ShortcutsEditor::shortcutsSaved,
regionMapEditor, &RegionMapEditor::applyUserShortcuts); 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 = new RegionMapEditor(this, this->editor->project);
this->regionMapEditor->setAttribute(Qt::WA_DeleteOnClose); bool success = this->regionMapEditor->load(silent);
connect(this->regionMapEditor, &QObject::destroyed, [this](){
this->regionMapEditor = nullptr;
});
bool success = this->regionMapEditor->load();
if (!success) { if (!success) {
delete this->regionMapEditor; delete this->regionMapEditor;
this->regionMapEditor = nullptr; this->regionMapEditor = nullptr;
QMessageBox msgBox(this); if (!silent) {
QString errorMsg = QString("There was an error opening the region map data. Please see %1 for full error details.\n\n%3") QMessageBox msgBox(this);
.arg(getLogPath()) QString errorMsg = QString("There was an error opening the region map data. Please see %1 for full error details.\n\n%3")
.arg(getMostRecentError()); .arg(getLogPath())
msgBox.critical(nullptr, "Error Opening Region Map Editor", errorMsg); .arg(getMostRecentError());
msgBox.critical(nullptr, "Error Opening Region Map Editor", errorMsg);
}
return false; return false;
} }

View file

@ -498,15 +498,10 @@ bool RegionMapEditor::setup() {
if (!region_maps.empty()) { if (!region_maps.empty()) {
setRegionMap(region_maps.begin()->second); setRegionMap(region_maps.begin()->second);
} }
this->show();
this->setWindowState(Qt::WindowState::WindowActive);
this->activateWindow();
return true; return true;
} }
bool RegionMapEditor::load() { bool RegionMapEditor::load(bool silent) {
// check for config json file // check for config json file
QString jsonConfigFilepath = this->project->root + "/" + projectConfig.getFilePath(ProjectFilePath::json_region_porymap_cfg); QString jsonConfigFilepath = this->project->root + "/" + projectConfig.getFilePath(ProjectFilePath::json_region_porymap_cfg);
@ -526,6 +521,7 @@ bool RegionMapEditor::load() {
} }
if (badConfig) { if (badConfig) {
if (silent) return false;
// show popup explaining next window // show popup explaining next window
QMessageBox warning; QMessageBox warning;
warning.setIcon(QMessageBox::Warning); warning.setIcon(QMessageBox::Warning);