Browse Source

Support 'mirror' editing for dive and emerge connections

Marcus Huderle 6 years ago
parent
commit
9533042c4c
1 changed files with 10 additions and 3 deletions
  1. 10
    3
      editor.cpp

+ 10
- 3
editor.cpp View File

611
         return;
611
         return;
612
 
612
 
613
     static QMap<QString, QString> oppositeDirections = QMap<QString, QString>({
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
     QString oppositeDirection = oppositeDirections.value(originalDirection);
617
     QString oppositeDirection = oppositeDirections.value(originalDirection);
616
 
618
 
617
     // Find the matching connection in the connected map.
619
     // Find the matching connection in the connected map.
698
         // Remove dive/emerge connection
700
         // Remove dive/emerge connection
699
         if (connection) {
701
         if (connection) {
700
             map->connections.removeOne(connection);
702
             map->connections.removeOne(connection);
703
+            removeMirroredConnection(connection);
701
         }
704
         }
702
     } else {
705
     } else {
703
         if (!connection) {
706
         if (!connection) {
704
             connection = new Connection;
707
             connection = new Connection;
705
             connection->direction = direction;
708
             connection->direction = direction;
706
             connection->offset = "0";
709
             connection->offset = "0";
710
+            connection->map_name = mapName;
707
             map->connections.append(connection);
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
     ui->label_NumConnections->setText(QString::number(map->connections.length()));
720
     ui->label_NumConnections->setText(QString::number(map->connections.length()));