Support 'mirror' editing for dive and emerge connections
This commit is contained in:
parent
1a10eac29f
commit
9533042c4c
1 changed files with 10 additions and 3 deletions
13
editor.cpp
13
editor.cpp
|
@ -611,7 +611,9 @@ void Editor::updateMirroredConnection(Connection* connection, QString originalDi
|
||||||
return;
|
return;
|
||||||
|
|
||||||
static QMap<QString, QString> oppositeDirections = QMap<QString, QString>({
|
static QMap<QString, QString> oppositeDirections = QMap<QString, QString>({
|
||||||
{"up", "down"}, {"right", "left"}, {"down", "up"}, {"left", "right"}});
|
{"up", "down"}, {"right", "left"},
|
||||||
|
{"down", "up"}, {"left", "right"},
|
||||||
|
{"dive", "emerge"},{"emerge", "dive"}});
|
||||||
QString oppositeDirection = oppositeDirections.value(originalDirection);
|
QString oppositeDirection = oppositeDirections.value(originalDirection);
|
||||||
|
|
||||||
// Find the matching connection in the connected map.
|
// Find the matching connection in the connected map.
|
||||||
|
@ -698,16 +700,21 @@ void Editor::updateDiveEmergeMap(QString mapName, QString direction) {
|
||||||
// Remove dive/emerge connection
|
// Remove dive/emerge connection
|
||||||
if (connection) {
|
if (connection) {
|
||||||
map->connections.removeOne(connection);
|
map->connections.removeOne(connection);
|
||||||
|
removeMirroredConnection(connection);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!connection) {
|
if (!connection) {
|
||||||
connection = new Connection;
|
connection = new Connection;
|
||||||
connection->direction = direction;
|
connection->direction = direction;
|
||||||
connection->offset = "0";
|
connection->offset = "0";
|
||||||
|
connection->map_name = mapName;
|
||||||
map->connections.append(connection);
|
map->connections.append(connection);
|
||||||
|
updateMirroredConnection(connection, connection->direction, connection->map_name);
|
||||||
|
} else {
|
||||||
|
QString originalMapName = connection->map_name;
|
||||||
|
connection->map_name = mapName;
|
||||||
|
updateMirroredConnectionMap(connection, originalMapName);
|
||||||
}
|
}
|
||||||
|
|
||||||
connection->map_name = mapName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->label_NumConnections->setText(QString::number(map->connections.length()));
|
ui->label_NumConnections->setText(QString::number(map->connections.length()));
|
||||||
|
|
Loading…
Reference in a new issue