Browse Source

Double-clicking on a connection will load the destination map

Marcus Huderle 6 years ago
parent
commit
bd2c782021
4 changed files with 30 additions and 1 deletions
  1. 18
    1
      editor.cpp
  2. 5
    0
      editor.h
  3. 6
    0
      mainwindow.cpp
  4. 1
    0
      mainwindow.h

+ 18
- 1
editor.cpp View File

254
         }
254
         }
255
     }
255
     }
256
     current_connection_edit_item = connectionItem;
256
     current_connection_edit_item = connectionItem;
257
-    current_connection_edit_item->setZValue(0);
258
     setConnectionEditControlsEnabled(true);
257
     setConnectionEditControlsEnabled(true);
259
     setConnectionEditControlValues(current_connection_edit_item->connection);
258
     setConnectionEditControlValues(current_connection_edit_item->connection);
260
     ui->spinBox_ConnectionOffset->setMaximum(current_connection_edit_item->getMaxOffset());
259
     ui->spinBox_ConnectionOffset->setMaximum(current_connection_edit_item->getMaxOffset());
261
     ui->spinBox_ConnectionOffset->setMinimum(current_connection_edit_item->getMinOffset());
260
     ui->spinBox_ConnectionOffset->setMinimum(current_connection_edit_item->getMinOffset());
262
 }
261
 }
263
 
262
 
263
+void Editor::setSelectedConnectionFromMap(QString mapName) {
264
+    // Search for the first connection that connects to the given map map.
265
+    for (ConnectionPixmapItem* item : connection_edit_items) {
266
+        if (item->connection->map_name == mapName) {
267
+            onConnectionItemSelected(item);
268
+            break;
269
+        }
270
+    }
271
+}
272
+
273
+void Editor::onConnectionItemDoubleClicked(ConnectionPixmapItem* connectionItem) {
274
+    emit loadMapRequested(connectionItem->connection->map_name, map->name);
275
+}
276
+
264
 void Editor::onConnectionDirectionChanged(QString newDirection) {
277
 void Editor::onConnectionDirectionChanged(QString newDirection) {
265
     ui->comboBox_ConnectionDirection->blockSignals(true);
278
     ui->comboBox_ConnectionDirection->blockSignals(true);
266
     ui->comboBox_ConnectionDirection->setCurrentText(newDirection);
279
     ui->comboBox_ConnectionDirection->setCurrentText(newDirection);
460
     scene->addItem(connection_edit_item);
473
     scene->addItem(connection_edit_item);
461
     connect(connection_edit_item, SIGNAL(connectionMoved(int)), this, SLOT(onConnectionOffsetChanged(int)));
474
     connect(connection_edit_item, SIGNAL(connectionMoved(int)), this, SLOT(onConnectionOffsetChanged(int)));
462
     connect(connection_edit_item, SIGNAL(connectionItemSelected(ConnectionPixmapItem*)), this, SLOT(onConnectionItemSelected(ConnectionPixmapItem*)));
475
     connect(connection_edit_item, SIGNAL(connectionItemSelected(ConnectionPixmapItem*)), this, SLOT(onConnectionItemSelected(ConnectionPixmapItem*)));
476
+    connect(connection_edit_item, SIGNAL(connectionItemDoubleClicked(ConnectionPixmapItem*)), this, SLOT(onConnectionItemDoubleClicked(ConnectionPixmapItem*)));
463
     connection_edit_items.append(connection_edit_item);
477
     connection_edit_items.append(connection_edit_item);
464
 }
478
 }
465
 
479
 
746
 void ConnectionPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent* event) {
760
 void ConnectionPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent* event) {
747
     emit connectionItemSelected(this);
761
     emit connectionItemSelected(this);
748
 }
762
 }
763
+void ConnectionPixmapItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent*) {
764
+    emit connectionItemDoubleClicked(this);
765
+}
749
 
766
 
750
 void ElevationMetatilesPixmapItem::updateCurHoveredMetatile(QPointF pos) {
767
 void ElevationMetatilesPixmapItem::updateCurHoveredMetatile(QPointF pos) {
751
     int x = ((int)pos.x()) / 16;
768
     int x = ((int)pos.x()) / 16;

+ 5
- 0
editor.h View File

55
     void removeCurrentConnection();
55
     void removeCurrentConnection();
56
     void updateDiveMap(QString mapName);
56
     void updateDiveMap(QString mapName);
57
     void updateEmergeMap(QString mapName);
57
     void updateEmergeMap(QString mapName);
58
+    void setSelectedConnectionFromMap(QString mapName);
58
 
59
 
59
     DraggablePixmapItem *addMapObject(Event *event);
60
     DraggablePixmapItem *addMapObject(Event *event);
60
     void selectMapObject(DraggablePixmapItem *object);
61
     void selectMapObject(DraggablePixmapItem *object);
106
     void mouseEvent_collision(QGraphicsSceneMouseEvent *event, CollisionPixmapItem *item);
107
     void mouseEvent_collision(QGraphicsSceneMouseEvent *event, CollisionPixmapItem *item);
107
     void onConnectionOffsetChanged(int newOffset);
108
     void onConnectionOffsetChanged(int newOffset);
108
     void onConnectionItemSelected(ConnectionPixmapItem* connectionItem);
109
     void onConnectionItemSelected(ConnectionPixmapItem* connectionItem);
110
+    void onConnectionItemDoubleClicked(ConnectionPixmapItem* connectionItem);
109
     void onConnectionDirectionChanged(QString newDirection);
111
     void onConnectionDirectionChanged(QString newDirection);
110
 
112
 
111
 signals:
113
 signals:
112
     void objectsChanged();
114
     void objectsChanged();
113
     void selectedObjectsChanged();
115
     void selectedObjectsChanged();
116
+    void loadMapRequested(QString, QString);
114
 };
117
 };
115
 
118
 
116
 
119
 
303
 protected:
306
 protected:
304
     QVariant itemChange(GraphicsItemChange change, const QVariant &value);
307
     QVariant itemChange(GraphicsItemChange change, const QVariant &value);
305
     void mousePressEvent(QGraphicsSceneMouseEvent*);
308
     void mousePressEvent(QGraphicsSceneMouseEvent*);
309
+    void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*);
306
 signals:
310
 signals:
307
     void connectionItemSelected(ConnectionPixmapItem* connectionItem);
311
     void connectionItemSelected(ConnectionPixmapItem* connectionItem);
312
+    void connectionItemDoubleClicked(ConnectionPixmapItem* connectionItem);
308
     void connectionMoved(int offset);
313
     void connectionMoved(int offset);
309
 };
314
 };
310
 
315
 

+ 6
- 0
mainwindow.cpp View File

29
     editor = new Editor(ui);
29
     editor = new Editor(ui);
30
     connect(editor, SIGNAL(objectsChanged()), this, SLOT(updateSelectedObjects()));
30
     connect(editor, SIGNAL(objectsChanged()), this, SLOT(updateSelectedObjects()));
31
     connect(editor, SIGNAL(selectedObjectsChanged()), this, SLOT(updateSelectedObjects()));
31
     connect(editor, SIGNAL(selectedObjectsChanged()), this, SLOT(updateSelectedObjects()));
32
+    connect(editor, SIGNAL(loadMapRequested(QString, QString)), this, SLOT(onLoadMapRequested(QString, QString)));
32
 
33
 
33
     on_toolButton_Paint_clicked();
34
     on_toolButton_Paint_clicked();
34
 
35
 
754
     ui->toolButton_Dropper->setChecked(editor->map_edit_mode == "pick");
755
     ui->toolButton_Dropper->setChecked(editor->map_edit_mode == "pick");
755
 }
756
 }
756
 
757
 
758
+void MainWindow::onLoadMapRequested(QString mapName, QString fromMapName) {
759
+    setMap(mapName);
760
+    editor->setSelectedConnectionFromMap(fromMapName);
761
+}
762
+
757
 void MainWindow::onMapChanged(Map *map) {
763
 void MainWindow::onMapChanged(Map *map) {
758
     updateMapList();
764
     updateMapList();
759
 }
765
 }

+ 1
- 0
mainwindow.h View File

36
     void undo();
36
     void undo();
37
     void redo();
37
     void redo();
38
 
38
 
39
+    void onLoadMapRequested(QString, QString);
39
     void onMapChanged(Map *map);
40
     void onMapChanged(Map *map);
40
 
41
 
41
     void on_action_Save_triggered();
42
     void on_action_Save_triggered();