From b5c7f9f86b4d1deebe3d6191d5b67bd18970a612 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 4 Aug 2024 17:39:56 -0400 Subject: [PATCH] Save mirroring in config --- include/config.h | 2 ++ include/mainwindow.h | 1 + src/config.cpp | 3 +++ src/editor.cpp | 4 ++-- src/mainwindow.cpp | 6 ++++++ 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/config.h b/include/config.h index a039e4eb..7486919f 100644 --- a/include/config.h +++ b/include/config.h @@ -58,6 +58,7 @@ public: this->reopenOnLaunch = true; this->mapSortOrder = MapSortOrder::Group; this->prettyCursors = true; + this->mirrorConnectingMaps = true; this->showDiveEmergeMaps = false; this->diveEmergeMapOpacity = 30; this->diveMapOpacity = 15; @@ -107,6 +108,7 @@ public: bool projectManuallyClosed; MapSortOrder mapSortOrder; bool prettyCursors; + bool mirrorConnectingMaps; bool showDiveEmergeMaps; int diveEmergeMapOpacity; int diveMapOpacity; diff --git a/include/mainwindow.h b/include/mainwindow.h index eb6f4be1..e37c2c56 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -269,6 +269,7 @@ private slots: void eventTabChanged(int index); + void on_checkBox_MirrorConnections_stateChanged(int selected); void on_actionDive_Emerge_Map_triggered(); void on_groupBox_DiveMapOpacity_toggled(bool on); void on_slider_DiveEmergeMapOpacity_valueChanged(int value); diff --git a/src/config.cpp b/src/config.cpp index eb87adf2..818dd714 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -330,6 +330,8 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) { this->mainSplitterState = bytesFromString(value); } else if (key == "metatiles_splitter_state") { this->metatilesSplitterState = bytesFromString(value); + } else if (key == "mirror_connecting_maps") { + this->mirrorConnectingMaps = getConfigBool(key, value); } else if (key == "show_dive_emerge_maps") { this->showDiveEmergeMaps = getConfigBool(key, value); } else if (key == "dive_emerge_map_opacity") { @@ -447,6 +449,7 @@ QMap PorymapConfig::getKeyValueMap() { map.insert("project_settings_editor_state", stringFromByteArray(this->projectSettingsEditorState)); map.insert("custom_scripts_editor_geometry", stringFromByteArray(this->customScriptsEditorGeometry)); map.insert("custom_scripts_editor_state", stringFromByteArray(this->customScriptsEditorState)); + map.insert("mirror_connecting_maps", this->mirrorConnectingMaps ? "1" : "0"); map.insert("show_dive_emerge_maps", this->showDiveEmergeMaps ? "1" : "0"); map.insert("dive_emerge_map_opacity", QString::number(this->diveEmergeMapOpacity)); map.insert("dive_map_opacity", QString::number(this->diveMapOpacity)); diff --git a/src/editor.cpp b/src/editor.cpp index 817e02eb..8fc3b842 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -905,7 +905,7 @@ void Editor::removeConnection(MapConnection* connection, bool removeMirror) { } MapConnection* Editor::getMirroredConnection(MapConnection* source) { - if (!source || !ui->checkBox_MirrorConnections->isChecked()) + if (!source || !porymapConfig.mirrorConnectingMaps) return nullptr; // Note: It's possible (and ok) for connectedMap == this->map @@ -925,7 +925,7 @@ MapConnection* Editor::getMirroredConnection(MapConnection* source) { } void Editor::addMirroredConnection(MapConnection* source) { - if (!source || !ui->checkBox_MirrorConnections->isChecked()) + if (!source || !porymapConfig.mirrorConnectingMaps) return; addConnection(source->createMirror(), false); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 519fee16..588547f2 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -486,6 +486,7 @@ void MainWindow::loadUserSettings() { this->editor->settings->cursorTileRectEnabled = porymapConfig.showCursorTile; ui->checkBox_ToggleBorder->setChecked(porymapConfig.showBorder); ui->checkBox_ToggleGrid->setChecked(porymapConfig.showGrid); + ui->checkBox_MirrorConnections->setChecked(porymapConfig.mirrorConnectingMaps); mapSortOrder = porymapConfig.mapSortOrder; this->editor->collisionOpacity = static_cast(porymapConfig.collisionOpacity) / 100; @@ -2807,6 +2808,11 @@ void MainWindow::on_checkBox_ToggleBorder_stateChanged(int selected) editor->toggleBorderVisibility(selected != 0); } +void MainWindow::on_checkBox_MirrorConnections_stateChanged(int selected) +{ + porymapConfig.mirrorConnectingMaps = (selected == Qt::Checked); +} + void MainWindow::on_actionTileset_Editor_triggered() { if (!this->tilesetEditor) {