Double-clicking on a connection will load the destination map

This commit is contained in:
Marcus Huderle 2018-03-11 14:20:52 -07:00
parent f47e3bf4ea
commit bd2c782021
4 changed files with 30 additions and 1 deletions

View file

@ -254,13 +254,26 @@ void Editor::onConnectionItemSelected(ConnectionPixmapItem* connectionItem) {
}
}
current_connection_edit_item = connectionItem;
current_connection_edit_item->setZValue(0);
setConnectionEditControlsEnabled(true);
setConnectionEditControlValues(current_connection_edit_item->connection);
ui->spinBox_ConnectionOffset->setMaximum(current_connection_edit_item->getMaxOffset());
ui->spinBox_ConnectionOffset->setMinimum(current_connection_edit_item->getMinOffset());
}
void Editor::setSelectedConnectionFromMap(QString mapName) {
// Search for the first connection that connects to the given map map.
for (ConnectionPixmapItem* item : connection_edit_items) {
if (item->connection->map_name == mapName) {
onConnectionItemSelected(item);
break;
}
}
}
void Editor::onConnectionItemDoubleClicked(ConnectionPixmapItem* connectionItem) {
emit loadMapRequested(connectionItem->connection->map_name, map->name);
}
void Editor::onConnectionDirectionChanged(QString newDirection) {
ui->comboBox_ConnectionDirection->blockSignals(true);
ui->comboBox_ConnectionDirection->setCurrentText(newDirection);
@ -460,6 +473,7 @@ void Editor::createConnectionItem(Connection* connection, bool hide) {
scene->addItem(connection_edit_item);
connect(connection_edit_item, SIGNAL(connectionMoved(int)), this, SLOT(onConnectionOffsetChanged(int)));
connect(connection_edit_item, SIGNAL(connectionItemSelected(ConnectionPixmapItem*)), this, SLOT(onConnectionItemSelected(ConnectionPixmapItem*)));
connect(connection_edit_item, SIGNAL(connectionItemDoubleClicked(ConnectionPixmapItem*)), this, SLOT(onConnectionItemDoubleClicked(ConnectionPixmapItem*)));
connection_edit_items.append(connection_edit_item);
}
@ -746,6 +760,9 @@ QVariant ConnectionPixmapItem::itemChange(GraphicsItemChange change, const QVari
void ConnectionPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent* event) {
emit connectionItemSelected(this);
}
void ConnectionPixmapItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent*) {
emit connectionItemDoubleClicked(this);
}
void ElevationMetatilesPixmapItem::updateCurHoveredMetatile(QPointF pos) {
int x = ((int)pos.x()) / 16;

View file

@ -55,6 +55,7 @@ public:
void removeCurrentConnection();
void updateDiveMap(QString mapName);
void updateEmergeMap(QString mapName);
void setSelectedConnectionFromMap(QString mapName);
DraggablePixmapItem *addMapObject(Event *event);
void selectMapObject(DraggablePixmapItem *object);
@ -106,11 +107,13 @@ private slots:
void mouseEvent_collision(QGraphicsSceneMouseEvent *event, CollisionPixmapItem *item);
void onConnectionOffsetChanged(int newOffset);
void onConnectionItemSelected(ConnectionPixmapItem* connectionItem);
void onConnectionItemDoubleClicked(ConnectionPixmapItem* connectionItem);
void onConnectionDirectionChanged(QString newDirection);
signals:
void objectsChanged();
void selectedObjectsChanged();
void loadMapRequested(QString, QString);
};
@ -303,8 +306,10 @@ public:
protected:
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
void mousePressEvent(QGraphicsSceneMouseEvent*);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*);
signals:
void connectionItemSelected(ConnectionPixmapItem* connectionItem);
void connectionItemDoubleClicked(ConnectionPixmapItem* connectionItem);
void connectionMoved(int offset);
};

View file

@ -29,6 +29,7 @@ MainWindow::MainWindow(QWidget *parent) :
editor = new Editor(ui);
connect(editor, SIGNAL(objectsChanged()), this, SLOT(updateSelectedObjects()));
connect(editor, SIGNAL(selectedObjectsChanged()), this, SLOT(updateSelectedObjects()));
connect(editor, SIGNAL(loadMapRequested(QString, QString)), this, SLOT(onLoadMapRequested(QString, QString)));
on_toolButton_Paint_clicked();
@ -754,6 +755,11 @@ void MainWindow::checkToolButtons() {
ui->toolButton_Dropper->setChecked(editor->map_edit_mode == "pick");
}
void MainWindow::onLoadMapRequested(QString mapName, QString fromMapName) {
setMap(mapName);
editor->setSelectedConnectionFromMap(fromMapName);
}
void MainWindow::onMapChanged(Map *map) {
updateMapList();
}

View file

@ -36,6 +36,7 @@ private slots:
void undo();
void redo();
void onLoadMapRequested(QString, QString);
void onMapChanged(Map *map);
void on_action_Save_triggered();