Kaynağa Gözat

Add dive/emerge map pickers

Marcus Huderle 6 yıl önce
ebeveyn
işleme
6f71c15629
5 değiştirilmiş dosya ile 296 ekleme ve 123 silme
  1. 87
    7
      editor.cpp
  2. 5
    0
      editor.h
  3. 10
    0
      mainwindow.cpp
  4. 4
    0
      mainwindow.h
  5. 190
    116
      mainwindow.ui

+ 87
- 7
editor.cpp Dosyayı Görüntüle

@@ -93,12 +93,10 @@ void Editor::setEditingConnections() {
93 93
         map_item->draw();
94 94
         map_item->setVisible(true);
95 95
         map_item->setEnabled(false);
96
-        ui->comboBox_ConnectedMap->blockSignals(true);
97
-        ui->comboBox_ConnectedMap->clear();
98
-        ui->comboBox_ConnectedMap->addItems(*project->mapNames);
99
-        ui->comboBox_ConnectedMap->blockSignals(false);
96
+        populateConnectionMapPickers();
100 97
         ui->label_NumConnections->setText(QString::number(map->connections.length()));
101 98
         setConnectionsVisibility(false);
99
+        setDiveEmergeControls();
102 100
         if (current_connection_edit_item) {
103 101
             onConnectionOffsetChanged(current_connection_edit_item->connection->offset.toInt());
104 102
             updateConnectionMap(current_connection_edit_item->connection->map_name, current_connection_edit_item->connection->direction);
@@ -114,6 +112,39 @@ void Editor::setEditingConnections() {
114 112
     setConnectionItemsVisible(true);
115 113
 }
116 114
 
115
+void Editor::setDiveEmergeControls() {
116
+    ui->comboBox_DiveMap->blockSignals(true);
117
+    ui->comboBox_EmergeMap->blockSignals(true);
118
+    ui->comboBox_DiveMap->setCurrentText("");
119
+    ui->comboBox_EmergeMap->setCurrentText("");
120
+    for (Connection* connection : map->connections) {
121
+        if (connection->direction == "dive") {
122
+            ui->comboBox_DiveMap->setCurrentText(connection->map_name);
123
+        } else if (connection->direction == "emerge") {
124
+            ui->comboBox_EmergeMap->setCurrentText(connection->map_name);
125
+        }
126
+    }
127
+    ui->comboBox_DiveMap->blockSignals(false);
128
+    ui->comboBox_EmergeMap->blockSignals(false);
129
+}
130
+
131
+void Editor::populateConnectionMapPickers() {
132
+    ui->comboBox_ConnectedMap->blockSignals(true);
133
+    ui->comboBox_DiveMap->blockSignals(true);
134
+    ui->comboBox_EmergeMap->blockSignals(true);
135
+
136
+    ui->comboBox_ConnectedMap->clear();
137
+    ui->comboBox_ConnectedMap->addItems(*project->mapNames);
138
+    ui->comboBox_DiveMap->clear();
139
+    ui->comboBox_DiveMap->addItems(*project->mapNames);
140
+    ui->comboBox_EmergeMap->clear();
141
+    ui->comboBox_EmergeMap->addItems(*project->mapNames);
142
+
143
+    ui->comboBox_ConnectedMap->blockSignals(false);
144
+    ui->comboBox_DiveMap->blockSignals(true);
145
+    ui->comboBox_EmergeMap->blockSignals(true);
146
+}
147
+
117 148
 void Editor::setConnectionItemsVisible(bool visible) {
118 149
     for (ConnectionPixmapItem* item : connection_edit_items) {
119 150
         item->setVisible(visible);
@@ -176,13 +207,17 @@ void Editor::onConnectionOffsetChanged(int newOffset) {
176 207
 }
177 208
 
178 209
 void Editor::setConnectionEditControlValues(Connection* connection) {
210
+    QString mapName = connection ? connection->map_name : "";
211
+    QString direction = connection ? connection->direction : "";
212
+    int offset = connection ? connection->offset.toInt() : 0;
213
+
179 214
     ui->comboBox_ConnectedMap->blockSignals(true);
180 215
     ui->comboBox_ConnectionDirection->blockSignals(true);
181 216
     ui->spinBox_ConnectionOffset->blockSignals(true);
182 217
 
183
-    ui->comboBox_ConnectedMap->setCurrentText(connection->map_name);
184
-    ui->comboBox_ConnectionDirection->setCurrentText(connection->direction);
185
-    ui->spinBox_ConnectionOffset->setValue(connection->offset.toInt());
218
+    ui->comboBox_ConnectedMap->setCurrentText(mapName);
219
+    ui->comboBox_ConnectionDirection->setCurrentText(direction);
220
+    ui->spinBox_ConnectionOffset->setValue(offset);
186 221
 
187 222
     ui->comboBox_ConnectedMap->blockSignals(false);
188 223
     ui->comboBox_ConnectionDirection->blockSignals(false);
@@ -193,6 +228,10 @@ void Editor::setConnectionEditControlsEnabled(bool enabled) {
193 228
     ui->comboBox_ConnectionDirection->setEnabled(enabled);
194 229
     ui->comboBox_ConnectedMap->setEnabled(enabled);
195 230
     ui->spinBox_ConnectionOffset->setEnabled(enabled);
231
+
232
+    if (!enabled) {
233
+        setConnectionEditControlValues(false);
234
+    }
196 235
 }
197 236
 
198 237
 void Editor::onConnectionItemSelected(ConnectionPixmapItem* connectionItem) {
@@ -527,6 +566,47 @@ void Editor::removeCurrentConnection() {
527 566
     }
528 567
 }
529 568
 
569
+void Editor::updateDiveMap(QString mapName) {
570
+    updateDiveEmergeMap(mapName, "dive");
571
+}
572
+
573
+void Editor::updateEmergeMap(QString mapName) {
574
+    updateDiveEmergeMap(mapName, "emerge");
575
+}
576
+
577
+void Editor::updateDiveEmergeMap(QString mapName, QString direction) {
578
+    if (!mapName.isEmpty() && !project->mapNamesToMapConstants->contains(mapName)) {
579
+        qDebug() << "Invalid " << direction << " map connection: " << mapName;
580
+        return;
581
+    }
582
+
583
+    Connection* connection = NULL;
584
+    for (Connection* conn : map->connections) {
585
+        if (conn->direction == direction) {
586
+            connection = conn;
587
+            break;
588
+        }
589
+    }
590
+
591
+    if (mapName.isEmpty()) {
592
+        // Remove dive/emerge connection
593
+        if (connection) {
594
+            map->connections.removeOne(connection);
595
+        }
596
+    } else {
597
+        if (!connection) {
598
+            connection = new Connection;
599
+            connection->direction = direction;
600
+            connection->offset = "0";
601
+            map->connections.append(connection);
602
+        }
603
+
604
+        connection->map_name = mapName;
605
+    }
606
+
607
+    ui->label_NumConnections->setText(QString::number(map->connections.length()));
608
+}
609
+
530 610
 void MetatilesPixmapItem::paintTileChanged(Map *map) {
531 611
     draw();
532 612
 }

+ 5
- 0
editor.h Dosyayı Görüntüle

@@ -53,6 +53,8 @@ public:
53 53
     void updateConnectionMap(QString mapName, QString direction);
54 54
     void addNewConnection();
55 55
     void removeCurrentConnection();
56
+    void updateDiveMap(QString mapName);
57
+    void updateEmergeMap(QString mapName);
56 58
 
57 59
     DraggablePixmapItem *addMapObject(Event *event);
58 60
     void selectMapObject(DraggablePixmapItem *object);
@@ -95,6 +97,9 @@ private:
95 97
     void setConnectionEditControlValues(Connection*);
96 98
     void setConnectionEditControlsEnabled(bool);
97 99
     void createConnectionItem(Connection* connection, bool hide);
100
+    void populateConnectionMapPickers();
101
+    void setDiveEmergeControls();
102
+    void updateDiveEmergeMap(QString mapName, QString direction);
98 103
 
99 104
 private slots:
100 105
     void mouseEvent_map(QGraphicsSceneMouseEvent *event, MapPixmapItem *item);

+ 10
- 0
mainwindow.cpp Dosyayı Görüntüle

@@ -790,3 +790,13 @@ void MainWindow::on_pushButton_RemoveConnection_clicked()
790 790
 {
791 791
     editor->removeCurrentConnection();
792 792
 }
793
+
794
+void MainWindow::on_comboBox_DiveMap_currentTextChanged(const QString &mapName)
795
+{
796
+    editor->updateDiveMap(mapName);
797
+}
798
+
799
+void MainWindow::on_comboBox_EmergeMap_currentTextChanged(const QString &mapName)
800
+{
801
+    editor->updateEmergeMap(mapName);
802
+}

+ 4
- 0
mainwindow.h Dosyayı Görüntüle

@@ -84,6 +84,10 @@ private slots:
84 84
 
85 85
     void on_pushButton_RemoveConnection_clicked();
86 86
 
87
+    void on_comboBox_DiveMap_currentTextChanged(const QString &mapName);
88
+
89
+    void on_comboBox_EmergeMap_currentTextChanged(const QString &mapName);
90
+
87 91
 private:
88 92
     Ui::MainWindow *ui;
89 93
     QStandardItemModel *mapListModel;

+ 190
- 116
mainwindow.ui Dosyayı Görüntüle

@@ -60,7 +60,7 @@
60 60
         </sizepolicy>
61 61
        </property>
62 62
        <property name="currentIndex">
63
-        <number>3</number>
63
+        <number>0</number>
64 64
        </property>
65 65
        <property name="tabsClosable">
66 66
         <bool>false</bool>
@@ -1266,6 +1266,102 @@
1266 1266
               <property name="frameShadow">
1267 1267
                <enum>QFrame::Raised</enum>
1268 1268
               </property>
1269
+              <layout class="QHBoxLayout" name="horizontalLayout_4">
1270
+               <property name="spacing">
1271
+                <number>4</number>
1272
+               </property>
1273
+               <property name="leftMargin">
1274
+                <number>4</number>
1275
+               </property>
1276
+               <property name="topMargin">
1277
+                <number>4</number>
1278
+               </property>
1279
+               <property name="rightMargin">
1280
+                <number>4</number>
1281
+               </property>
1282
+               <property name="bottomMargin">
1283
+                <number>4</number>
1284
+               </property>
1285
+               <item>
1286
+                <widget class="QPushButton" name="pushButton_AddConnection">
1287
+                 <property name="sizePolicy">
1288
+                  <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
1289
+                   <horstretch>0</horstretch>
1290
+                   <verstretch>0</verstretch>
1291
+                  </sizepolicy>
1292
+                 </property>
1293
+                 <property name="text">
1294
+                  <string/>
1295
+                 </property>
1296
+                 <property name="icon">
1297
+                  <iconset>
1298
+                   <activeon>:/icons/add.ico</activeon>
1299
+                  </iconset>
1300
+                 </property>
1301
+                </widget>
1302
+               </item>
1303
+               <item>
1304
+                <widget class="QPushButton" name="pushButton_RemoveConnection">
1305
+                 <property name="text">
1306
+                  <string/>
1307
+                 </property>
1308
+                 <property name="icon">
1309
+                  <iconset>
1310
+                   <activeon>:/icons/delete.ico</activeon>
1311
+                  </iconset>
1312
+                 </property>
1313
+                </widget>
1314
+               </item>
1315
+               <item>
1316
+                <widget class="QLabel" name="label_13">
1317
+                 <property name="text">
1318
+                  <string>Number of Connections:</string>
1319
+                 </property>
1320
+                </widget>
1321
+               </item>
1322
+               <item>
1323
+                <widget class="QLabel" name="label_NumConnections">
1324
+                 <property name="text">
1325
+                  <string/>
1326
+                 </property>
1327
+                </widget>
1328
+               </item>
1329
+               <item>
1330
+                <spacer name="horizontalSpacer_9">
1331
+                 <property name="orientation">
1332
+                  <enum>Qt::Horizontal</enum>
1333
+                 </property>
1334
+                 <property name="sizeHint" stdset="0">
1335
+                  <size>
1336
+                   <width>40</width>
1337
+                   <height>20</height>
1338
+                  </size>
1339
+                 </property>
1340
+                </spacer>
1341
+               </item>
1342
+              </layout>
1343
+             </widget>
1344
+            </item>
1345
+            <item row="2" column="0">
1346
+             <widget class="QFrame" name="horizontalFrame">
1347
+              <property name="sizePolicy">
1348
+               <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
1349
+                <horstretch>0</horstretch>
1350
+                <verstretch>0</verstretch>
1351
+               </sizepolicy>
1352
+              </property>
1353
+              <property name="minimumSize">
1354
+               <size>
1355
+                <width>0</width>
1356
+                <height>32</height>
1357
+               </size>
1358
+              </property>
1359
+              <property name="frameShape">
1360
+               <enum>QFrame::StyledPanel</enum>
1361
+              </property>
1362
+              <property name="frameShadow">
1363
+               <enum>QFrame::Raised</enum>
1364
+              </property>
1269 1365
               <layout class="QHBoxLayout" name="horizontalLayout_3" stretch="0,0,0,0,0,0,0">
1270 1366
                <property name="spacing">
1271 1367
                 <number>4</number>
@@ -1369,7 +1465,7 @@
1369 1465
               </layout>
1370 1466
              </widget>
1371 1467
             </item>
1372
-            <item row="2" column="0">
1468
+            <item row="3" column="0">
1373 1469
              <widget class="QFrame" name="gridFrame">
1374 1470
               <property name="frameShape">
1375 1471
                <enum>QFrame::StyledPanel</enum>
@@ -1393,7 +1489,7 @@
1393 1489
                <property name="spacing">
1394 1490
                 <number>0</number>
1395 1491
                </property>
1396
-               <item row="0" column="0">
1492
+               <item row="1" column="0">
1397 1493
                 <widget class="QScrollArea" name="scrollArea_5">
1398 1494
                  <property name="sizePolicy">
1399 1495
                   <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
@@ -1410,25 +1506,12 @@
1410 1506
                     <x>0</x>
1411 1507
                     <y>0</y>
1412 1508
                     <width>826</width>
1413
-                    <height>587</height>
1509
+                    <height>557</height>
1414 1510
                    </rect>
1415 1511
                   </property>
1416 1512
                   <layout class="QGridLayout" name="gridLayout_14">
1417
-                   <item row="1" column="1">
1418
-                    <widget class="QGraphicsView" name="graphicsView_Connections">
1419
-                     <property name="backgroundBrush">
1420
-                      <brush brushstyle="SolidPattern">
1421
-                       <color alpha="255">
1422
-                        <red>0</red>
1423
-                        <green>0</green>
1424
-                        <blue>0</blue>
1425
-                       </color>
1426
-                      </brush>
1427
-                     </property>
1428
-                    </widget>
1429
-                   </item>
1430
-                   <item row="1" column="0">
1431
-                    <spacer name="horizontalSpacer_7">
1513
+                   <item row="1" column="2">
1514
+                    <spacer name="horizontalSpacer_8">
1432 1515
                      <property name="orientation">
1433 1516
                       <enum>Qt::Horizontal</enum>
1434 1517
                      </property>
@@ -1440,15 +1523,15 @@
1440 1523
                      </property>
1441 1524
                     </spacer>
1442 1525
                    </item>
1443
-                   <item row="1" column="2">
1444
-                    <spacer name="horizontalSpacer_8">
1526
+                   <item row="2" column="1">
1527
+                    <spacer name="verticalSpacer_2">
1445 1528
                      <property name="orientation">
1446
-                      <enum>Qt::Horizontal</enum>
1529
+                      <enum>Qt::Vertical</enum>
1447 1530
                      </property>
1448 1531
                      <property name="sizeHint" stdset="0">
1449 1532
                       <size>
1450
-                       <width>40</width>
1451
-                       <height>20</height>
1533
+                       <width>20</width>
1534
+                       <height>40</height>
1452 1535
                       </size>
1453 1536
                      </property>
1454 1537
                     </spacer>
@@ -1466,15 +1549,28 @@
1466 1549
                      </property>
1467 1550
                     </spacer>
1468 1551
                    </item>
1469
-                   <item row="2" column="1">
1470
-                    <spacer name="verticalSpacer_2">
1552
+                   <item row="1" column="1">
1553
+                    <widget class="QGraphicsView" name="graphicsView_Connections">
1554
+                     <property name="backgroundBrush">
1555
+                      <brush brushstyle="SolidPattern">
1556
+                       <color alpha="255">
1557
+                        <red>0</red>
1558
+                        <green>0</green>
1559
+                        <blue>0</blue>
1560
+                       </color>
1561
+                      </brush>
1562
+                     </property>
1563
+                    </widget>
1564
+                   </item>
1565
+                   <item row="1" column="0">
1566
+                    <spacer name="horizontalSpacer_7">
1471 1567
                      <property name="orientation">
1472
-                      <enum>Qt::Vertical</enum>
1568
+                      <enum>Qt::Horizontal</enum>
1473 1569
                      </property>
1474 1570
                      <property name="sizeHint" stdset="0">
1475 1571
                       <size>
1476
-                       <width>20</width>
1477
-                       <height>40</height>
1572
+                       <width>40</width>
1573
+                       <height>20</height>
1478 1574
                       </size>
1479 1575
                      </property>
1480 1576
                     </spacer>
@@ -1483,102 +1579,80 @@
1483 1579
                  </widget>
1484 1580
                 </widget>
1485 1581
                </item>
1486
-              </layout>
1487
-             </widget>
1488
-            </item>
1489
-            <item row="0" column="0">
1490
-             <widget class="QFrame" name="horizontalFrame">
1491
-              <property name="sizePolicy">
1492
-               <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
1493
-                <horstretch>0</horstretch>
1494
-                <verstretch>0</verstretch>
1495
-               </sizepolicy>
1496
-              </property>
1497
-              <property name="minimumSize">
1498
-               <size>
1499
-                <width>0</width>
1500
-                <height>32</height>
1501
-               </size>
1502
-              </property>
1503
-              <property name="frameShape">
1504
-               <enum>QFrame::StyledPanel</enum>
1505
-              </property>
1506
-              <property name="frameShadow">
1507
-               <enum>QFrame::Raised</enum>
1508
-              </property>
1509
-              <layout class="QHBoxLayout" name="horizontalLayout_4">
1510
-               <property name="spacing">
1511
-                <number>4</number>
1512
-               </property>
1513
-               <property name="leftMargin">
1514
-                <number>4</number>
1515
-               </property>
1516
-               <property name="topMargin">
1517
-                <number>4</number>
1518
-               </property>
1519
-               <property name="rightMargin">
1520
-                <number>4</number>
1521
-               </property>
1522
-               <property name="bottomMargin">
1523
-                <number>4</number>
1524
-               </property>
1525
-               <item>
1526
-                <widget class="QPushButton" name="pushButton_AddConnection">
1582
+               <item row="0" column="0">
1583
+                <widget class="QFrame" name="horizontalFrame">
1527 1584
                  <property name="sizePolicy">
1528
-                  <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
1585
+                  <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
1529 1586
                    <horstretch>0</horstretch>
1530 1587
                    <verstretch>0</verstretch>
1531 1588
                   </sizepolicy>
1532 1589
                  </property>
1533
-                 <property name="text">
1534
-                  <string/>
1535
-                 </property>
1536
-                 <property name="icon">
1537
-                  <iconset>
1538
-                   <activeon>:/icons/add.ico</activeon>
1539
-                  </iconset>
1540
-                 </property>
1541
-                </widget>
1542
-               </item>
1543
-               <item>
1544
-                <widget class="QPushButton" name="pushButton_RemoveConnection">
1545
-                 <property name="text">
1546
-                  <string/>
1547
-                 </property>
1548
-                 <property name="icon">
1549
-                  <iconset>
1550
-                   <activeon>:/icons/delete.ico</activeon>
1551
-                  </iconset>
1552
-                 </property>
1553
-                </widget>
1554
-               </item>
1555
-               <item>
1556
-                <widget class="QLabel" name="label_13">
1557
-                 <property name="text">
1558
-                  <string>Number of Connections:</string>
1590
+                 <property name="frameShape">
1591
+                  <enum>QFrame::StyledPanel</enum>
1559 1592
                  </property>
1560
-                </widget>
1561
-               </item>
1562
-               <item>
1563
-                <widget class="QLabel" name="label_NumConnections">
1564
-                 <property name="text">
1565
-                  <string/>
1593
+                 <property name="frameShadow">
1594
+                  <enum>QFrame::Raised</enum>
1566 1595
                  </property>
1596
+                 <layout class="QHBoxLayout" name="horizontalLayout_6">
1597
+                  <property name="spacing">
1598
+                   <number>4</number>
1599
+                  </property>
1600
+                  <property name="leftMargin">
1601
+                   <number>4</number>
1602
+                  </property>
1603
+                  <property name="topMargin">
1604
+                   <number>4</number>
1605
+                  </property>
1606
+                  <property name="rightMargin">
1607
+                   <number>4</number>
1608
+                  </property>
1609
+                  <property name="bottomMargin">
1610
+                   <number>4</number>
1611
+                  </property>
1612
+                  <item>
1613
+                   <widget class="QLabel" name="label_14">
1614
+                    <property name="text">
1615
+                     <string>Dive Map</string>
1616
+                    </property>
1617
+                   </widget>
1618
+                  </item>
1619
+                  <item>
1620
+                   <widget class="QComboBox" name="comboBox_DiveMap">
1621
+                    <property name="editable">
1622
+                     <bool>true</bool>
1623
+                    </property>
1624
+                   </widget>
1625
+                  </item>
1626
+                  <item>
1627
+                   <widget class="QLabel" name="label_15">
1628
+                    <property name="text">
1629
+                     <string>Emerge Map</string>
1630
+                    </property>
1631
+                   </widget>
1632
+                  </item>
1633
+                  <item>
1634
+                   <widget class="QComboBox" name="comboBox_EmergeMap">
1635
+                    <property name="editable">
1636
+                     <bool>true</bool>
1637
+                    </property>
1638
+                   </widget>
1639
+                  </item>
1640
+                  <item>
1641
+                   <spacer name="horizontalSpacer_10">
1642
+                    <property name="orientation">
1643
+                     <enum>Qt::Horizontal</enum>
1644
+                    </property>
1645
+                    <property name="sizeHint" stdset="0">
1646
+                     <size>
1647
+                      <width>40</width>
1648
+                      <height>20</height>
1649
+                     </size>
1650
+                    </property>
1651
+                   </spacer>
1652
+                  </item>
1653
+                 </layout>
1567 1654
                 </widget>
1568 1655
                </item>
1569
-               <item>
1570
-                <spacer name="horizontalSpacer_9">
1571
-                 <property name="orientation">
1572
-                  <enum>Qt::Horizontal</enum>
1573
-                 </property>
1574
-                 <property name="sizeHint" stdset="0">
1575
-                  <size>
1576
-                   <width>40</width>
1577
-                   <height>20</height>
1578
-                  </size>
1579
-                 </property>
1580
-                </spacer>
1581
-               </item>
1582 1656
               </layout>
1583 1657
              </widget>
1584 1658
             </item>