diff --git a/include/config.h b/include/config.h index e9aa6943..54f592ea 100644 --- a/include/config.h +++ b/include/config.h @@ -52,6 +52,7 @@ public: void setPrettyCursors(bool enabled); void setMainGeometry(QByteArray, QByteArray, QByteArray, QByteArray); void setTilesetEditorGeometry(QByteArray, QByteArray); + void setRegionMapEditorGeometry(QByteArray, QByteArray); void setCollisionOpacity(int opacity); void setMetatilesZoom(int zoom); void setShowPlayerView(bool enabled); @@ -65,6 +66,7 @@ public: bool getPrettyCursors(); QMap getMainGeometry(); QMap getTilesetEditorGeometry(); + QMap getRegionMapEditorGeometry(); int getCollisionOpacity(); int getMetatilesZoom(); bool getShowPlayerView(); @@ -92,6 +94,8 @@ private: QByteArray mainSplitterState; QByteArray tilesetEditorGeometry; QByteArray tilesetEditorState; + QByteArray regionMapEditorGeometry; + QByteArray regionMapEditorState; int collisionOpacity; int metatilesZoom; bool showPlayerView; diff --git a/src/config.cpp b/src/config.cpp index f12c3789..349cb0e2 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -141,6 +141,10 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) { this->tilesetEditorGeometry = bytesFromString(value); } else if (key == "tileset_editor_state") { this->tilesetEditorState = bytesFromString(value); + } else if (key == "region_map_editor_geometry") { + this->regionMapEditorGeometry = bytesFromString(value); + } else if (key == "region_map_editor_state") { + this->regionMapEditorState = bytesFromString(value); } else if (key == "metatiles_zoom") { bool ok; this->metatilesZoom = qMax(10, qMin(100, value.toInt(&ok))); @@ -196,6 +200,8 @@ QMap PorymapConfig::getKeyValueMap() { map.insert("main_splitter_state", stringFromByteArray(this->mainSplitterState)); map.insert("tileset_editor_geometry", stringFromByteArray(this->tilesetEditorGeometry)); map.insert("tileset_editor_state", stringFromByteArray(this->tilesetEditorState)); + map.insert("region_map_editor_geometry", stringFromByteArray(this->regionMapEditorGeometry)); + map.insert("region_map_editor_state", stringFromByteArray(this->regionMapEditorState)); map.insert("collision_opacity", QString("%1").arg(this->collisionOpacity)); map.insert("metatiles_zoom", QString("%1").arg(this->metatilesZoom)); map.insert("show_player_view", this->showPlayerView ? "1" : "0"); @@ -264,6 +270,12 @@ void PorymapConfig::setTilesetEditorGeometry(QByteArray tilesetEditorGeometry_, this->save(); } +void PorymapConfig::setRegionMapEditorGeometry(QByteArray regionMapEditorGeometry_, QByteArray regionMapEditorState_) { + this->regionMapEditorGeometry = regionMapEditorGeometry_; + this->regionMapEditorState = regionMapEditorState_; + this->save(); +} + void PorymapConfig::setCollisionOpacity(int opacity) { this->collisionOpacity = opacity; // don't auto-save here because this can be called very frequently. @@ -328,6 +340,15 @@ QMap PorymapConfig::getTilesetEditorGeometry() { return geometry; } +QMap PorymapConfig::getRegionMapEditorGeometry() { + QMap geometry; + + geometry.insert("region_map_editor_geometry", this->regionMapEditorGeometry); + geometry.insert("region_map_editor_state", this->regionMapEditorState); + + return geometry; +} + int PorymapConfig::getCollisionOpacity() { return this->collisionOpacity; } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4738d004..0e77fffc 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2661,7 +2661,10 @@ void MainWindow::on_actionRegion_Map_Editor_triggered() { return; } connect(this->regionMapEditor, &QObject::destroyed, [=](QObject *) { this->regionMapEditor = nullptr; }); - this->regionMapEditor->setAttribute(Qt::WA_DeleteOnClose); + logInfo("Restoring region map editor geometry from previous session."); + QMap geometry = porymapConfig.getRegionMapEditorGeometry(); + this->regionMapEditor->restoreGeometry(geometry.value("region_map_editor_geometry")); + this->regionMapEditor->restoreState(geometry.value("region_map_editor_state")); } if (!this->regionMapEditor->isVisible()) { diff --git a/src/ui/regionmapeditor.cpp b/src/ui/regionmapeditor.cpp index 1ced19b6..b6d9030b 100644 --- a/src/ui/regionmapeditor.cpp +++ b/src/ui/regionmapeditor.cpp @@ -899,6 +899,11 @@ void RegionMapEditor::closeEvent(QCloseEvent *event) } else { event->accept(); } + + porymapConfig.setRegionMapEditorGeometry( + this->saveGeometry(), + this->saveState() + ); } void RegionMapEditor::on_verticalSlider_Zoom_Map_Image_valueChanged(int val) {