Bläddra i källkod

Support 'mirror' editing for dive and emerge connections

Marcus Huderle 6 år sedan
förälder
incheckning
9533042c4c
1 ändrade filer med 10 tillägg och 3 borttagningar
  1. 10
    3
      editor.cpp

+ 10
- 3
editor.cpp Visa fil

@@ -611,7 +611,9 @@ void Editor::updateMirroredConnection(Connection* connection, QString originalDi
611 611
         return;
612 612
 
613 613
     static QMap<QString, QString> oppositeDirections = QMap<QString, QString>({
614
-        {"up", "down"}, {"right", "left"}, {"down", "up"}, {"left", "right"}});
614
+        {"up", "down"}, {"right", "left"},
615
+        {"down", "up"}, {"left", "right"},
616
+        {"dive", "emerge"},{"emerge", "dive"}});
615 617
     QString oppositeDirection = oppositeDirections.value(originalDirection);
616 618
 
617 619
     // Find the matching connection in the connected map.
@@ -698,16 +700,21 @@ void Editor::updateDiveEmergeMap(QString mapName, QString direction) {
698 700
         // Remove dive/emerge connection
699 701
         if (connection) {
700 702
             map->connections.removeOne(connection);
703
+            removeMirroredConnection(connection);
701 704
         }
702 705
     } else {
703 706
         if (!connection) {
704 707
             connection = new Connection;
705 708
             connection->direction = direction;
706 709
             connection->offset = "0";
710
+            connection->map_name = mapName;
707 711
             map->connections.append(connection);
712
+            updateMirroredConnection(connection, connection->direction, connection->map_name);
713
+        } else {
714
+            QString originalMapName = connection->map_name;
715
+            connection->map_name = mapName;
716
+            updateMirroredConnectionMap(connection, originalMapName);
708 717
         }
709
-
710
-        connection->map_name = mapName;
711 718
     }
712 719
 
713 720
     ui->label_NumConnections->setText(QString::number(map->connections.length()));