diff --git a/editor.cpp b/editor.cpp
index 62f82804..a2680c5d 100755
--- a/editor.cpp
+++ b/editor.cpp
@@ -93,12 +93,10 @@ void Editor::setEditingConnections() {
map_item->draw();
map_item->setVisible(true);
map_item->setEnabled(false);
- ui->comboBox_ConnectedMap->blockSignals(true);
- ui->comboBox_ConnectedMap->clear();
- ui->comboBox_ConnectedMap->addItems(*project->mapNames);
- ui->comboBox_ConnectedMap->blockSignals(false);
+ populateConnectionMapPickers();
ui->label_NumConnections->setText(QString::number(map->connections.length()));
setConnectionsVisibility(false);
+ setDiveEmergeControls();
if (current_connection_edit_item) {
onConnectionOffsetChanged(current_connection_edit_item->connection->offset.toInt());
updateConnectionMap(current_connection_edit_item->connection->map_name, current_connection_edit_item->connection->direction);
@@ -114,6 +112,39 @@ void Editor::setEditingConnections() {
setConnectionItemsVisible(true);
}
+void Editor::setDiveEmergeControls() {
+ ui->comboBox_DiveMap->blockSignals(true);
+ ui->comboBox_EmergeMap->blockSignals(true);
+ ui->comboBox_DiveMap->setCurrentText("");
+ ui->comboBox_EmergeMap->setCurrentText("");
+ for (Connection* connection : map->connections) {
+ if (connection->direction == "dive") {
+ ui->comboBox_DiveMap->setCurrentText(connection->map_name);
+ } else if (connection->direction == "emerge") {
+ ui->comboBox_EmergeMap->setCurrentText(connection->map_name);
+ }
+ }
+ ui->comboBox_DiveMap->blockSignals(false);
+ ui->comboBox_EmergeMap->blockSignals(false);
+}
+
+void Editor::populateConnectionMapPickers() {
+ ui->comboBox_ConnectedMap->blockSignals(true);
+ ui->comboBox_DiveMap->blockSignals(true);
+ ui->comboBox_EmergeMap->blockSignals(true);
+
+ ui->comboBox_ConnectedMap->clear();
+ ui->comboBox_ConnectedMap->addItems(*project->mapNames);
+ ui->comboBox_DiveMap->clear();
+ ui->comboBox_DiveMap->addItems(*project->mapNames);
+ ui->comboBox_EmergeMap->clear();
+ ui->comboBox_EmergeMap->addItems(*project->mapNames);
+
+ ui->comboBox_ConnectedMap->blockSignals(false);
+ ui->comboBox_DiveMap->blockSignals(true);
+ ui->comboBox_EmergeMap->blockSignals(true);
+}
+
void Editor::setConnectionItemsVisible(bool visible) {
for (ConnectionPixmapItem* item : connection_edit_items) {
item->setVisible(visible);
@@ -176,13 +207,17 @@ void Editor::onConnectionOffsetChanged(int newOffset) {
}
void Editor::setConnectionEditControlValues(Connection* connection) {
+ QString mapName = connection ? connection->map_name : "";
+ QString direction = connection ? connection->direction : "";
+ int offset = connection ? connection->offset.toInt() : 0;
+
ui->comboBox_ConnectedMap->blockSignals(true);
ui->comboBox_ConnectionDirection->blockSignals(true);
ui->spinBox_ConnectionOffset->blockSignals(true);
- ui->comboBox_ConnectedMap->setCurrentText(connection->map_name);
- ui->comboBox_ConnectionDirection->setCurrentText(connection->direction);
- ui->spinBox_ConnectionOffset->setValue(connection->offset.toInt());
+ ui->comboBox_ConnectedMap->setCurrentText(mapName);
+ ui->comboBox_ConnectionDirection->setCurrentText(direction);
+ ui->spinBox_ConnectionOffset->setValue(offset);
ui->comboBox_ConnectedMap->blockSignals(false);
ui->comboBox_ConnectionDirection->blockSignals(false);
@@ -193,6 +228,10 @@ void Editor::setConnectionEditControlsEnabled(bool enabled) {
ui->comboBox_ConnectionDirection->setEnabled(enabled);
ui->comboBox_ConnectedMap->setEnabled(enabled);
ui->spinBox_ConnectionOffset->setEnabled(enabled);
+
+ if (!enabled) {
+ setConnectionEditControlValues(false);
+ }
}
void Editor::onConnectionItemSelected(ConnectionPixmapItem* connectionItem) {
@@ -527,6 +566,47 @@ void Editor::removeCurrentConnection() {
}
}
+void Editor::updateDiveMap(QString mapName) {
+ updateDiveEmergeMap(mapName, "dive");
+}
+
+void Editor::updateEmergeMap(QString mapName) {
+ updateDiveEmergeMap(mapName, "emerge");
+}
+
+void Editor::updateDiveEmergeMap(QString mapName, QString direction) {
+ if (!mapName.isEmpty() && !project->mapNamesToMapConstants->contains(mapName)) {
+ qDebug() << "Invalid " << direction << " map connection: " << mapName;
+ return;
+ }
+
+ Connection* connection = NULL;
+ for (Connection* conn : map->connections) {
+ if (conn->direction == direction) {
+ connection = conn;
+ break;
+ }
+ }
+
+ if (mapName.isEmpty()) {
+ // Remove dive/emerge connection
+ if (connection) {
+ map->connections.removeOne(connection);
+ }
+ } else {
+ if (!connection) {
+ connection = new Connection;
+ connection->direction = direction;
+ connection->offset = "0";
+ map->connections.append(connection);
+ }
+
+ connection->map_name = mapName;
+ }
+
+ ui->label_NumConnections->setText(QString::number(map->connections.length()));
+}
+
void MetatilesPixmapItem::paintTileChanged(Map *map) {
draw();
}
diff --git a/editor.h b/editor.h
index 590d3bcf..a9b43624 100755
--- a/editor.h
+++ b/editor.h
@@ -53,6 +53,8 @@ public:
void updateConnectionMap(QString mapName, QString direction);
void addNewConnection();
void removeCurrentConnection();
+ void updateDiveMap(QString mapName);
+ void updateEmergeMap(QString mapName);
DraggablePixmapItem *addMapObject(Event *event);
void selectMapObject(DraggablePixmapItem *object);
@@ -95,6 +97,9 @@ private:
void setConnectionEditControlValues(Connection*);
void setConnectionEditControlsEnabled(bool);
void createConnectionItem(Connection* connection, bool hide);
+ void populateConnectionMapPickers();
+ void setDiveEmergeControls();
+ void updateDiveEmergeMap(QString mapName, QString direction);
private slots:
void mouseEvent_map(QGraphicsSceneMouseEvent *event, MapPixmapItem *item);
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 8bd0dd4b..d7f076b3 100755
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -790,3 +790,13 @@ void MainWindow::on_pushButton_RemoveConnection_clicked()
{
editor->removeCurrentConnection();
}
+
+void MainWindow::on_comboBox_DiveMap_currentTextChanged(const QString &mapName)
+{
+ editor->updateDiveMap(mapName);
+}
+
+void MainWindow::on_comboBox_EmergeMap_currentTextChanged(const QString &mapName)
+{
+ editor->updateEmergeMap(mapName);
+}
diff --git a/mainwindow.h b/mainwindow.h
index 3f6c84d8..3b4c02dc 100755
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -84,6 +84,10 @@ private slots:
void on_pushButton_RemoveConnection_clicked();
+ void on_comboBox_DiveMap_currentTextChanged(const QString &mapName);
+
+ void on_comboBox_EmergeMap_currentTextChanged(const QString &mapName);
+
private:
Ui::MainWindow *ui;
QStandardItemModel *mapListModel;
diff --git a/mainwindow.ui b/mainwindow.ui
index c2269b6b..57d6ad54 100755
--- a/mainwindow.ui
+++ b/mainwindow.ui
@@ -60,7 +60,7 @@
- 3
+ 0
false
@@ -1247,6 +1247,102 @@
0
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 32
+
+
+
+ QFrame::StyledPanel
+
+
+ QFrame::Raised
+
+
+
+ 4
+
+
+ 4
+
+
+ 4
+
+
+ 4
+
+
+ 4
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+
+ :/icons/add.ico
+
+
+
+
+ -
+
+
+
+
+
+
+ :/icons/delete.ico
+
+
+
+
+ -
+
+
+ Number of Connections:
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+
+ -
@@ -1369,7 +1465,7 @@
- -
+
-
QFrame::StyledPanel
@@ -1393,7 +1489,7 @@
0
-
-
+
-
@@ -1410,10 +1506,49 @@
0
0
826
- 587
+ 557
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
-
@@ -1440,145 +1575,84 @@
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 0
- 32
-
-
-
- QFrame::StyledPanel
-
-
- QFrame::Raised
-
-
-
- 4
-
-
- 4
-
-
- 4
-
-
- 4
-
-
- 4
-
-
-
-
+
-
+
-
+
0
0
-
-
+
+ QFrame::StyledPanel
-
-
- :/icons/add.ico
-
+
+ QFrame::Raised
+
+
+ 4
+
+
+ 4
+
+
+ 4
+
+
+ 4
+
+
+ 4
+
+
-
+
+
+ Dive Map
+
+
+
+ -
+
+
+ true
+
+
+
+ -
+
+
+ Emerge Map
+
+
+
+ -
+
+
+ true
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
- -
-
-
-
-
-
-
- :/icons/delete.ico
-
-
-
-
- -
-
-
- Number of Connections:
-
-
-
- -
-
-
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-