diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index 9e1fabe4..2428b619 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -1715,7 +1715,7 @@ 0 0 100 - 30 + 16 @@ -1809,7 +1809,7 @@ 0 0 100 - 30 + 16 @@ -1903,7 +1903,7 @@ 0 0 100 - 30 + 16 @@ -2003,7 +2003,7 @@ 0 0 100 - 30 + 16 @@ -2097,7 +2097,7 @@ 0 0 100 - 30 + 16 @@ -2601,34 +2601,7 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Open the selected Emerge Map - - - ... - - - - :/icons/map_go.ico:/icons/map_go.ico - - - - + If enabled, connections will automatically be updated on the connected map. @@ -2641,20 +2614,6 @@ - - - - Open the selected Dive Map - - - ... - - - - :/icons/map_go.ico:/icons/map_go.ico - - - @@ -2662,6 +2621,13 @@ + + + + Emerge Map + + + @@ -2675,10 +2641,161 @@ - - + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Open the selected Dive Map + - Emerge Map + ... + + + + :/icons/map_go.ico:/icons/map_go.ico + + + + + + + Show Emerge/Dive Maps + + + true + + + true + + + true + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 1 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 10 + + + 90 + + + 30 + + + Qt::Horizontal + + + + + + + 10 + + + 90 + + + 30 + + + Qt::Horizontal + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 10 + + + 90 + + + 30 + + + Qt::Horizontal + + + + + + + + + + + + + + Open the selected Emerge Map + + + ... + + + + :/icons/map_go.ico:/icons/map_go.ico @@ -2763,8 +2880,8 @@ 0 0 - 100 - 30 + 365 + 651 diff --git a/include/config.h b/include/config.h index 3f77aa90..a039e4eb 100644 --- a/include/config.h +++ b/include/config.h @@ -58,6 +58,10 @@ public: this->reopenOnLaunch = true; this->mapSortOrder = MapSortOrder::Group; this->prettyCursors = true; + this->showDiveEmergeMaps = false; + this->diveEmergeMapOpacity = 30; + this->diveMapOpacity = 15; + this->emergeMapOpacity = 15; this->collisionOpacity = 50; this->collisionZoom = 30; this->metatilesZoom = 30; @@ -103,6 +107,10 @@ public: bool projectManuallyClosed; MapSortOrder mapSortOrder; bool prettyCursors; + bool showDiveEmergeMaps; + int diveEmergeMapOpacity; + int diveMapOpacity; + int emergeMapOpacity; int collisionOpacity; int collisionZoom; int metatilesZoom; diff --git a/include/editor.h b/include/editor.h index 2c566abc..d4dd0e85 100644 --- a/include/editor.h +++ b/include/editor.h @@ -75,10 +75,11 @@ public: void setEditingConnections(); void setMapEditingButtonsEnabled(bool enabled); void setConnectionsVisibility(bool visible); + void updateDiveEmergeVisibility(); void addNewConnection(); - void addConnection(Map* map, MapConnection* connection); - void removeConnection(Map* map, MapConnection* connection); - void removeConnectionItem(ConnectionPixmapItem* connectionItem, bool removeMirror = true); + void addConnection(Map* map, MapConnection* connection, bool addMirror = true); + void removeConnection(Map* map, MapConnection* connection, bool removeMirror = true); + void removeConnectionItem(ConnectionPixmapItem* connectionItem); void removeSelectedConnection(); void addNewWildMonGroup(QWidget *window); void deleteWildMonGroup(); @@ -111,6 +112,8 @@ public: QPointer map_item = nullptr; ConnectionPixmapItem* selected_connection_item = nullptr; QList connection_items; + QGraphicsPixmapItem *dive_map_overlay = nullptr; + QGraphicsPixmapItem *emerge_map_overlay = nullptr; QGraphicsPathItem *connection_mask = nullptr; QPointer collision_item = nullptr; QGraphicsItemGroup *events_group = nullptr; @@ -175,6 +178,8 @@ private: void clearCurrentMetatilesSelection(); void clearMapEvents(); void clearMapConnections(); + void clearDiveMap(); + void clearEmergeMap(); void clearConnectionMask(); void clearMapBorder(); void clearMapGrid(); @@ -186,7 +191,8 @@ private: void updateConnectionItemPos(ConnectionPixmapItem* connectionItem); void createConnectionItem(MapConnection* connection); void addConnectionToList(ConnectionPixmapItem* connection); - void updateDiveEmergeMap(QString mapName, QString direction); + void createDiveEmergeConnection(MapConnection* connection); + void setDiveEmergeMapName(QString mapName, QString direction); MapConnectionMirror getMirroredConnection(MapConnection*); void addMirroredConnection(MapConnection*); void removeMirroredConnection(MapConnection*); diff --git a/include/mainwindow.h b/include/mainwindow.h index f859ded9..20d3965f 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -269,6 +269,10 @@ private slots: void eventTabChanged(int index); + void on_groupBox_DiveMapOpacity_toggled(bool on); + void on_slider_DiveEmergeMapOpacity_valueChanged(int value); + void on_slider_DiveMapOpacity_valueChanged(int value); + void on_slider_EmergeMapOpacity_valueChanged(int value); void on_horizontalSlider_CollisionTransparency_valueChanged(int value); void on_toolButton_ExpandAll_clicked(); void on_toolButton_CollapseAll_clicked(); diff --git a/include/ui/connectionpixmapitem.h b/include/ui/connectionpixmapitem.h index a856eb45..e5577d2f 100644 --- a/include/ui/connectionpixmapitem.h +++ b/include/ui/connectionpixmapitem.h @@ -9,10 +9,10 @@ class ConnectionPixmapItem : public QObject, public QGraphicsPixmapItem { Q_OBJECT public: ConnectionPixmapItem(QPixmap pixmap, MapConnection* connection, int x, int y) - : QGraphicsPixmapItem(pixmap), - connection(connection) + : QGraphicsPixmapItem(pixmap) { this->basePixmap = pixmap; + this->connection = connection; setFlag(ItemIsMovable); setFlag(ItemSendsGeometryChanges); this->initialX = x; @@ -22,7 +22,7 @@ public: this->setY(y); } QPixmap basePixmap; - MapConnection* const connection; + MapConnection* connection; int initialX; int initialY; int initialOffset; diff --git a/src/config.cpp b/src/config.cpp index 16853e8f..eb87adf2 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -330,6 +330,14 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) { this->mainSplitterState = bytesFromString(value); } else if (key == "metatiles_splitter_state") { this->metatilesSplitterState = bytesFromString(value); + } else if (key == "show_dive_emerge_maps") { + this->showDiveEmergeMaps = getConfigBool(key, value); + } else if (key == "dive_emerge_map_opacity") { + this->diveEmergeMapOpacity = getConfigInteger(key, value, 10, 90, 30); + } else if (key == "dive_map_opacity") { + this->diveMapOpacity = getConfigInteger(key, value, 10, 90, 15); + } else if (key == "emerge_map_opacity") { + this->emergeMapOpacity = getConfigInteger(key, value, 10, 90, 15); } else if (key == "collision_opacity") { this->collisionOpacity = getConfigInteger(key, value, 0, 100, 50); } else if (key == "tileset_editor_geometry") { @@ -439,6 +447,10 @@ 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("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)); + map.insert("emerge_map_opacity", QString::number(this->emergeMapOpacity)); map.insert("collision_opacity", QString::number(this->collisionOpacity)); map.insert("collision_zoom", QString::number(this->collisionZoom)); map.insert("metatiles_zoom", QString::number(this->metatilesZoom)); diff --git a/src/editor.cpp b/src/editor.cpp index f427676b..ba079f50 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -725,6 +725,26 @@ void Editor::updateEncounterFields(EncounterFields newFields) { project->wildMonFields = newFields; } +void Editor::createConnectionItem(MapConnection* connection) { + if (!connection) + return; + QPixmap pixmap = getConnectionPixmap(*connection); + QPoint pos = calculateConnectionPosition(*connection, pixmap); + ConnectionPixmapItem *item = new ConnectionPixmapItem(pixmap, connection, pos.x(), pos.y()); + item->render(); + scene->addItem(item); + + connect(item, &ConnectionPixmapItem::selectionChanged, [this, item](bool selected) { + if (selected) setSelectedConnection(item); + }); + connect(item, &ConnectionPixmapItem::connectionItemDoubleClicked, [this, item] { + emit this->connectionItemDoubleClicked(item->connection->map_name, map->name); + }); + + connection_items.append(item); + addConnectionToList(item); +} + void Editor::addConnectionToList(ConnectionPixmapItem * connectionItem) { ConnectionsListItem *listItem = new ConnectionsListItem(ui->scrollAreaContents_ConnectionsList, connectionItem->connection, project->mapNames); ui->layout_ConnectionsList->insertWidget(ui->layout_ConnectionsList->count() - 1, listItem); // Insert above the vertical spacer @@ -799,25 +819,20 @@ void Editor::addNewConnection() { newConnection->map_name = defaultMapName; addConnection(map, newConnection); setSelectedConnection(connection_items.last()); - addMirroredConnection(newConnection); } -void Editor::addConnection(Map* map, MapConnection * connection) { +void Editor::addConnection(Map* map, MapConnection * connection, bool addMirror) { if (!map || !connection) return; + if (addMirror) + addMirroredConnection(connection); + map->connections.append(connection); if (map == this->map) { // Adding a connection to the current map, we need to display it visually. - // Note that for the Dive/Emerge combo boxes this is normally redundant - // as the user can only create these by having already set the text, - // *except* in the case where they're connecting a map to itself. - if (connection->direction == "dive") { - const QSignalBlocker blocker(ui->comboBox_DiveMap); - ui->comboBox_DiveMap->setCurrentText(connection->map_name); - } else if (connection->direction == "emerge") { - const QSignalBlocker blocker(ui->comboBox_EmergeMap); - ui->comboBox_EmergeMap->setCurrentText(connection->map_name); + if (connection->direction == "dive" || connection->direction == "emerge") { + createDiveEmergeConnection(connection); } else { createConnectionItem(connection); } @@ -825,19 +840,10 @@ void Editor::addConnection(Map* map, MapConnection * connection) { emit editedMapData(map); } -void Editor::removeConnectionItem(ConnectionPixmapItem* connectionItem, bool removeMirror) { +void Editor::removeConnectionItem(ConnectionPixmapItem* connectionItem) { if (!connectionItem) return; - if (removeMirror) { - // If a map is connected to itself and we delete the connection then this function - // will be called twice, once for the target of the delete and once for its mirror. - // We only want to try deleting the mirror once, on the first call (because the mirror - // of the mirror is the original target again, and we already deleted it). - removeMirroredConnection(connectionItem->connection); - } - removeConnection(map, connectionItem->connection); - connection_items.removeOne(connectionItem); if (connectionItem->scene()) connectionItem->scene()->removeItem(connectionItem); @@ -847,21 +853,48 @@ void Editor::removeConnectionItem(ConnectionPixmapItem* connectionItem, bool rem if (!connection_items.isEmpty()) setSelectedConnection(connection_items.first()); } - delete connectionItem; -} -void Editor::removeConnection(Map* map, MapConnection* connection) { - if (!map) - return; - map->connections.removeOne(connection); - delete connection; - emit editedMapData(map); + removeConnection(map, connectionItem->connection); + + delete connectionItem; } void Editor::removeSelectedConnection() { removeConnectionItem(selected_connection_item); } +void Editor::removeConnection(Map* map, MapConnection* connection, bool removeMirror) { + if (!map || !connection) + return; + + if (removeMirror) + removeMirroredConnection(connection); + + if (map == this->map) { + // The connection to delete is displayed on the currently-opened map, we need to delete it visually as well. + if (connection->direction == "dive") { + clearDiveMap(); + } else if (connection->direction == "emerge") { + clearEmergeMap(); + } else { + // Find and delete the matching connection graphics. + // If this was called via removeConnectionItem we rely on + // the item having already been removed from this list. + for (auto item :connection_items) { + if (item->connection == connection) { + item->connection = nullptr; + removeConnectionItem(item); + break; + } + } + } + } + + map->connections.removeOne(connection); + delete connection; + emit editedMapData(map); +} + MapConnectionMirror Editor::getMirroredConnection(MapConnection* source) { MapConnectionMirror mirror; if (!map || !source || !ui->checkBox_MirrorConnections->isChecked()) @@ -890,46 +923,58 @@ void Editor::addMirroredConnection(MapConnection* source) { if (!mirror.map) return; - mirror.connection = new MapConnection; + mirror.connection = new MapConnection; // TODO: Are we leaking memory here if mirror.connection != nullptr *mirror.connection = MapConnection::mirror(*source, map->name); - addConnection(mirror.map, mirror.connection); + addConnection(mirror.map, mirror.connection, false); } void Editor::removeMirroredConnection(MapConnection* source) { MapConnectionMirror mirror = getMirroredConnection(source); - if (!mirror.map || !mirror.connection) - return; + removeConnection(mirror.map, mirror.connection, false); +} - if (map == mirror.map) { - // The connection to delete is displayed on the currently-opened map, we need to delete it visually as well. - if (source->direction == "dive") { - const QSignalBlocker blocker(ui->comboBox_DiveMap); - ui->comboBox_DiveMap->setCurrentText(""); - } else if (source->direction == "emerge") { - const QSignalBlocker blocker(ui->comboBox_EmergeMap); - ui->comboBox_EmergeMap->setCurrentText(""); - } else { - // Find and delete the matching connection graphics - for (auto item :connection_items) { - if (item->connection == mirror.connection) { - removeConnectionItem(item, false); - return; - } - } - } +void Editor::createDiveEmergeConnection(MapConnection* connection) { + if (!connection) + return; + + QGraphicsPixmapItem *item; + Map *connectedMap = project->getMap(connection->map_name); + if (!connectedMap || connectedMap == this->map) { + // There's no point in rendering a map on top of itself. + // We create an empty image anyway to allow for changes later. + item = new QGraphicsPixmapItem(QPixmap()); + } else { + item = new QGraphicsPixmapItem(connectedMap->render()); + } + // TODO: Set pos. In-game, how are diving coordinates converted if the maps are different sizes? + scene->addItem(item); + + if (connection->direction == "dive") { + clearDiveMap(); + dive_map_overlay = item; + const QSignalBlocker blocker(ui->comboBox_DiveMap); + ui->comboBox_DiveMap->setCurrentText(connection->map_name); + } else if (connection->direction == "emerge") { + clearEmergeMap(); + emerge_map_overlay = item; + const QSignalBlocker blocker(ui->comboBox_EmergeMap); + ui->comboBox_EmergeMap->setCurrentText(connection->map_name); + } else { + // Shouldn't happen + scene->removeItem(item); + delete item; } - removeConnection(mirror.map, mirror.connection); } void Editor::updateDiveMap(QString mapName) { - updateDiveEmergeMap(mapName, "dive"); + setDiveEmergeMapName(mapName, "dive"); } void Editor::updateEmergeMap(QString mapName) { - updateDiveEmergeMap(mapName, "emerge"); + setDiveEmergeMapName(mapName, "emerge"); } -void Editor::updateDiveEmergeMap(QString mapName, QString direction) { +void Editor::setDiveEmergeMapName(QString mapName, QString direction) { if (!mapName.isEmpty() && !project->mapNamesToMapConstants.contains(mapName)) { logError(QString("Invalid %1 connection map name: '%2'").arg(direction).arg(mapName)); return; @@ -944,12 +989,12 @@ void Editor::updateDiveEmergeMap(QString mapName, QString direction) { } } - // Dive/Emerge maps aren't represented visually (aside from their combo boxes), - // so we have less to do here than a normal connection. if (connection) { + if (connection->map_name == mapName) + return; + // Update existing connection if (mapName.isEmpty()) { - removeMirroredConnection(connection); removeConnection(map, connection); } else { setConnectionMap(connection, mapName); @@ -961,7 +1006,24 @@ void Editor::updateDiveEmergeMap(QString mapName, QString direction) { connection->offset = 0; connection->map_name = mapName; addConnection(map, connection); - addMirroredConnection(connection); + } + updateDiveEmergeVisibility(); +} + +void Editor::updateDiveEmergeVisibility() { + if (dive_map_overlay && emerge_map_overlay) { + // Both connections in use, use separate sliders + ui->stackedWidget_DiveMapOpacity->setCurrentIndex(0); + dive_map_overlay->setOpacity(!porymapConfig.showDiveEmergeMaps ? 0 : static_cast(porymapConfig.diveMapOpacity) / 100); + emerge_map_overlay->setOpacity(!porymapConfig.showDiveEmergeMaps ? 0 : static_cast(porymapConfig.emergeMapOpacity) / 100); + } else { + // One connection in use (or none), use single slider + ui->stackedWidget_DiveMapOpacity->setCurrentIndex(1); + qreal opacity = !porymapConfig.showDiveEmergeMaps ? 0 : static_cast(porymapConfig.diveEmergeMapOpacity) / 100; + if (dive_map_overlay) + dive_map_overlay->setOpacity(opacity); + else if (emerge_map_overlay) + emerge_map_overlay->setOpacity(opacity); } } @@ -1040,7 +1102,7 @@ void Editor::updateConnectionItemPos(ConnectionPixmapItem* connectionItem) { } void Editor::setConnectionOffset(MapConnection *connection, int offset) { - if (!connection || !map || connection->offset == offset) + if (!connection || !map || connection->offset == offset || !MapConnection::isCardinal(connection->direction)) return; MapConnectionMirror mirror = getMirroredConnection(connection); @@ -1808,29 +1870,55 @@ void Editor::clearMapConnections() { } delete item; } - selected_connection_item = nullptr; connection_items.clear(); + + clearDiveMap(); + clearEmergeMap(); + + selected_connection_item = nullptr; +} + +void Editor::clearDiveMap() { + const QSignalBlocker blocker(ui->comboBox_DiveMap); + ui->comboBox_DiveMap->setCurrentText(""); + + if (dive_map_overlay) { + if (dive_map_overlay->scene()){ + dive_map_overlay->scene()->removeItem(dive_map_overlay); + } + delete dive_map_overlay; + dive_map_overlay = nullptr; + } +} + +void Editor::clearEmergeMap() { + const QSignalBlocker blocker(ui->comboBox_EmergeMap); + ui->comboBox_EmergeMap->setCurrentText(""); + + if (emerge_map_overlay) { + if (emerge_map_overlay->scene()){ + emerge_map_overlay->scene()->removeItem(emerge_map_overlay); + } + delete emerge_map_overlay; + emerge_map_overlay = nullptr; + } } void Editor::displayMapConnections() { clearMapConnections(); - const QSignalBlocker blocker1(ui->comboBox_DiveMap); - const QSignalBlocker blocker2(ui->comboBox_EmergeMap); - ui->comboBox_DiveMap->setCurrentText(""); - ui->comboBox_EmergeMap->setCurrentText(""); - // Note: We only support editing 1 Dive and Emerge connection per map. // In a vanilla game only the first Dive/Emerge connection is considered, so allowing // users to have multiple is likely to lead to confusion. In case users have changed // this we won't delete extra diving connections, but we'll only display the first one. + // TODO: Move text check to inside createDiveEmergeConnection? for (MapConnection *connection : map->connections) { if (connection->direction == "dive") { if (ui->comboBox_DiveMap->currentText().isEmpty()) - ui->comboBox_DiveMap->setCurrentText(connection->map_name); + createDiveEmergeConnection(connection); } else if (connection->direction == "emerge") { if (ui->comboBox_EmergeMap->currentText().isEmpty()) - ui->comboBox_EmergeMap->setCurrentText(connection->map_name); + createDiveEmergeConnection(connection); } else { // We allow any unknown direction names here. They'll be editable from the list menu. createConnectionItem(connection); @@ -1839,26 +1927,8 @@ void Editor::displayMapConnections() { if (!connection_items.empty()) setSelectedConnection(connection_items.first()); -} -void Editor::createConnectionItem(MapConnection* connection) { - if (!connection) - return; - QPixmap pixmap = getConnectionPixmap(*connection); - QPoint pos = calculateConnectionPosition(*connection, pixmap); - ConnectionPixmapItem *item = new ConnectionPixmapItem(pixmap, connection, pos.x(), pos.y()); - item->render(); - scene->addItem(item); - - connect(item, &ConnectionPixmapItem::selectionChanged, [this, item](bool selected) { - if (selected) setSelectedConnection(item); - }); - connect(item, &ConnectionPixmapItem::connectionItemDoubleClicked, [this, item] { - emit this->connectionItemDoubleClicked(item->connection->map_name, map->name); - }); - - connection_items.append(item); - addConnectionToList(item); + updateDiveEmergeVisibility(); } void Editor::clearConnectionMask() { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index fc7c72f3..07a21fbc 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -471,6 +471,13 @@ void MainWindow::applyMapListFilter(QString filterText) } void MainWindow::loadUserSettings() { + const QSignalBlocker blocker1(ui->horizontalSlider_CollisionTransparency); + const QSignalBlocker blocker2(ui->slider_DiveEmergeMapOpacity); + const QSignalBlocker blocker3(ui->slider_DiveMapOpacity); + const QSignalBlocker blocker4(ui->slider_EmergeMapOpacity); + const QSignalBlocker blocker5(ui->horizontalSlider_MetatileZoom); + const QSignalBlocker blocker6(ui->horizontalSlider_CollisionZoom); + ui->actionBetter_Cursors->setChecked(porymapConfig.prettyCursors); this->editor->settings->betterCursors = porymapConfig.prettyCursors; ui->actionPlayer_View_Rectangle->setChecked(porymapConfig.showPlayerView); @@ -479,17 +486,17 @@ void MainWindow::loadUserSettings() { this->editor->settings->cursorTileRectEnabled = porymapConfig.showCursorTile; ui->checkBox_ToggleBorder->setChecked(porymapConfig.showBorder); ui->checkBox_ToggleGrid->setChecked(porymapConfig.showGrid); + ui->groupBox_DiveMapOpacity->setChecked(porymapConfig.showDiveEmergeMaps); mapSortOrder = porymapConfig.mapSortOrder; - ui->horizontalSlider_CollisionTransparency->blockSignals(true); + this->editor->collisionOpacity = static_cast(porymapConfig.collisionOpacity) / 100; ui->horizontalSlider_CollisionTransparency->setValue(porymapConfig.collisionOpacity); - ui->horizontalSlider_CollisionTransparency->blockSignals(false); - ui->horizontalSlider_MetatileZoom->blockSignals(true); + ui->slider_DiveEmergeMapOpacity->setValue(porymapConfig.diveEmergeMapOpacity); + ui->slider_DiveMapOpacity->setValue(porymapConfig.diveMapOpacity); + ui->slider_EmergeMapOpacity->setValue(porymapConfig.emergeMapOpacity); ui->horizontalSlider_MetatileZoom->setValue(porymapConfig.metatilesZoom); - ui->horizontalSlider_MetatileZoom->blockSignals(false); - ui->horizontalSlider_CollisionZoom->blockSignals(true); ui->horizontalSlider_CollisionZoom->setValue(porymapConfig.collisionZoom); - ui->horizontalSlider_CollisionZoom->blockSignals(false); + setTheme(porymapConfig.theme); } @@ -2263,6 +2270,37 @@ void MainWindow::eventTabChanged(int index) { isProgrammaticEventTabChange = false; } +void MainWindow::on_groupBox_DiveMapOpacity_toggled(bool on) { + // Qt doesn't change the style of disabled sliders, so we do it ourselves + QString stylesheet = on ? "" : "QSlider::groove:horizontal {border: 1px solid #999999; border-radius: 3px; height: 2px; background: #B1B1B1;}" + "QSlider::handle:horizontal {border: 1px solid #444444; border-radius: 3px; width: 10px; height: 9px; margin: -5px -1px; background: #5C5C5C; }"; + ui->slider_DiveEmergeMapOpacity->setStyleSheet(stylesheet); + ui->slider_DiveMapOpacity->setStyleSheet(stylesheet); + ui->slider_EmergeMapOpacity->setStyleSheet(stylesheet); + + porymapConfig.showDiveEmergeMaps = on; + this->editor->updateDiveEmergeVisibility(); +} + +// Normally a map only has either a Dive map connection or an Emerge map connection, +// in which case we only show a single opacity slider to modify the one in use. +// If a user has both connections we show two separate opacity sliders so they can +// modify them independently. +void MainWindow::on_slider_DiveEmergeMapOpacity_valueChanged(int value) { + porymapConfig.diveEmergeMapOpacity = value; + this->editor->updateDiveEmergeVisibility(); +} + +void MainWindow::on_slider_DiveMapOpacity_valueChanged(int value) { + porymapConfig.diveMapOpacity = value; + this->editor->updateDiveEmergeVisibility(); +} + +void MainWindow::on_slider_EmergeMapOpacity_valueChanged(int value) { + porymapConfig.emergeMapOpacity = value; + this->editor->updateDiveEmergeVisibility(); +} + void MainWindow::on_horizontalSlider_CollisionTransparency_valueChanged(int value) { this->editor->collisionOpacity = static_cast(value) / 100; porymapConfig.collisionOpacity = value;