Browse Source

Merge pull request #2 from yenatch/master

syncing with source
Garak 6 years ago
parent
commit
8902102b2c
No account linked to committer's email address
17 changed files with 948 additions and 441 deletions
  1. 200
    70
      editor.cpp
  2. 6
    5
      editor.h
  3. 7
    10
      event.cpp
  4. 0
    6
      graphicsview.cpp
  5. 220
    28
      mainwindow.cpp
  6. 9
    0
      mainwindow.h
  7. 234
    202
      mainwindow.ui
  8. 62
    51
      map.cpp
  9. 16
    4
      map.h
  10. 15
    0
      noscrollcombobox.cpp
  11. 17
    0
      noscrollcombobox.h
  12. 16
    0
      noscrollspinbox.cpp
  13. 17
    0
      noscrollspinbox.h
  14. 40
    4
      objectpropertiesframe.ui
  15. 6
    2
      pretmap.pro
  16. 67
    55
      project.cpp
  17. 16
    4
      project.h

+ 200
- 70
editor.cpp View File

@@ -5,6 +5,8 @@
5 5
 #include <QMouseEvent>
6 6
 #include <math.h>
7 7
 
8
+bool selectingEvent = false;
9
+
8 10
 Editor::Editor(Ui::MainWindow* ui)
9 11
 {
10 12
     this->ui = ui;
@@ -27,13 +29,15 @@ void Editor::save() {
27 29
 
28 30
 void Editor::undo() {
29 31
     if (current_view) {
30
-        ((MapPixmapItem*)current_view)->undo();
32
+        map->undo();
33
+        map_item->draw();
31 34
     }
32 35
 }
33 36
 
34 37
 void Editor::redo() {
35 38
     if (current_view) {
36
-        ((MapPixmapItem*)current_view)->redo();
39
+        map->redo();
40
+        map_item->draw();
37 41
     }
38 42
 }
39 43
 
@@ -59,6 +63,7 @@ void Editor::setEditingMap() {
59 63
 void Editor::setEditingCollision() {
60 64
     current_view = collision_item;
61 65
     if (collision_item) {
66
+        displayMapConnections();
62 67
         collision_item->draw();
63 68
         collision_item->setVisible(true);
64 69
         setConnectionsVisibility(true);
@@ -319,8 +324,8 @@ void Editor::setMap(QString map_name) {
319 324
     }
320 325
     if (project) {
321 326
         map = project->loadMap(map_name);
322
-        displayMap();
323 327
         selected_events->clear();
328
+        displayMap();
324 329
         updateSelectedEvents();
325 330
     }
326 331
 }
@@ -467,6 +472,8 @@ void Editor::displayMapEvents() {
467 472
         delete events_group;
468 473
     }
469 474
 
475
+    selected_events->clear();
476
+
470 477
     events_group = new EventGroup;
471 478
     scene->addItem(events_group);
472 479
 
@@ -482,8 +489,7 @@ void Editor::displayMapEvents() {
482 489
 }
483 490
 
484 491
 DraggablePixmapItem *Editor::addMapEvent(Event *event) {
485
-    DraggablePixmapItem *object = new DraggablePixmapItem(event);
486
-    object->editor = this;
492
+    DraggablePixmapItem *object = new DraggablePixmapItem(event, this);
487 493
     events_group->addToGroup(object);
488 494
     return object;
489 495
 }
@@ -806,16 +812,22 @@ void Editor::updateDiveEmergeMap(QString mapName, QString direction) {
806 812
 
807 813
 void Editor::updatePrimaryTileset(QString tilesetLabel)
808 814
 {
809
-    map->layout->tileset_primary_label = tilesetLabel;
810
-    map->layout->tileset_primary = project->getTileset(tilesetLabel);
811
-    emit tilesetChanged(map->name);
815
+    if (map->layout->tileset_primary_label != tilesetLabel)
816
+    {
817
+        map->layout->tileset_primary_label = tilesetLabel;
818
+        map->layout->tileset_primary = project->getTileset(tilesetLabel);
819
+        emit tilesetChanged(map->name);
820
+    }
812 821
 }
813 822
 
814 823
 void Editor::updateSecondaryTileset(QString tilesetLabel)
815 824
 {
816
-    map->layout->tileset_secondary_label = tilesetLabel;
817
-    map->layout->tileset_secondary = project->getTileset(tilesetLabel);
818
-    emit tilesetChanged(map->name);
825
+    if (map->layout->tileset_secondary_label != tilesetLabel)
826
+    {
827
+        map->layout->tileset_secondary_label = tilesetLabel;
828
+        map->layout->tileset_secondary = project->getTileset(tilesetLabel);
829
+        emit tilesetChanged(map->name);
830
+    }
819 831
 }
820 832
 
821 833
 void MetatilesPixmapItem::paintTileChanged(Map *map) {
@@ -880,9 +892,6 @@ void MetatilesPixmapItem::updateSelection(QPointF pos, Qt::MouseButton button) {
880 892
         map->paint_tile_index = baseTileY * 8 + baseTileX;
881 893
         map->paint_tile_width = abs(map->paint_metatile_initial_x - x) + 1;
882 894
         map->paint_tile_height = abs(map->paint_metatile_initial_y - y) + 1;
883
-        map->smart_paths_enabled = button == Qt::RightButton
884
-                                && map->paint_tile_width == 3
885
-                                && map->paint_tile_height == 3;
886 895
         emit map->paintTileChanged(map);
887 896
     }
888 897
 }
@@ -1030,7 +1039,7 @@ void MapPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
1030 1039
         int x = (int)(pos.x()) / 16;
1031 1040
         int y = (int)(pos.y()) / 16;
1032 1041
 
1033
-        if (map->smart_paths_enabled) {
1042
+        if (map->smart_paths_enabled && map->paint_tile_width == 3 && map->paint_tile_height == 3) {
1034 1043
             paintSmartPath(x, y);
1035 1044
         } else {
1036 1045
             paintNormal(x, y);
@@ -1158,11 +1167,163 @@ void MapPixmapItem::floodFill(QGraphicsSceneMouseEvent *event) {
1158 1167
         QPointF pos = event->pos();
1159 1168
         int x = (int)(pos.x()) / 16;
1160 1169
         int y = (int)(pos.y()) / 16;
1161
-        map->floodFill(x, y, map->getSelectedBlockIndex(map->paint_tile_index));
1170
+        Block *block = map->getBlock(x, y);
1171
+        int tile = map->getSelectedBlockIndex(map->paint_tile_index);
1172
+        if (block && block->tile != tile) {
1173
+            if (map->smart_paths_enabled && map->paint_tile_width == 3 && map->paint_tile_height == 3)
1174
+                this->_floodFillSmartPath(x, y);
1175
+            else
1176
+                this->_floodFill(x, y);
1177
+        }
1178
+
1179
+        if (event->type() == QEvent::GraphicsSceneMouseRelease) {
1180
+            map->commit();
1181
+        }
1162 1182
         draw();
1163 1183
     }
1164 1184
 }
1165 1185
 
1186
+void MapPixmapItem::_floodFill(int initialX, int initialY) {
1187
+    QList<QPoint> todo;
1188
+    todo.append(QPoint(initialX, initialY));
1189
+    while (todo.length()) {
1190
+        QPoint point = todo.takeAt(0);
1191
+        int x = point.x();
1192
+        int y = point.y();
1193
+
1194
+        Block *block = map->getBlock(x, y);
1195
+        if (block == NULL) {
1196
+            continue;
1197
+        }
1198
+
1199
+        int xDiff = x - initialX;
1200
+        int yDiff = y - initialY;
1201
+        int i = xDiff % map->paint_tile_width;
1202
+        int j = yDiff % map->paint_tile_height;
1203
+        if (i < 0) i = map->paint_tile_width + i;
1204
+        if (j < 0) j = map->paint_tile_height + j;
1205
+        int tile = map->getSelectedBlockIndex(map->paint_tile_index + i + (j * 8));
1206
+        uint old_tile = block->tile;
1207
+        if (old_tile == tile) {
1208
+            continue;
1209
+        }
1210
+
1211
+        block->tile = tile;
1212
+        map->_setBlock(x, y, *block);
1213
+        if ((block = map->getBlock(x + 1, y)) && block->tile == old_tile) {
1214
+            todo.append(QPoint(x + 1, y));
1215
+        }
1216
+        if ((block = map->getBlock(x - 1, y)) && block->tile == old_tile) {
1217
+            todo.append(QPoint(x - 1, y));
1218
+        }
1219
+        if ((block = map->getBlock(x, y + 1)) && block->tile == old_tile) {
1220
+            todo.append(QPoint(x, y + 1));
1221
+        }
1222
+        if ((block = map->getBlock(x, y - 1)) && block->tile == old_tile) {
1223
+            todo.append(QPoint(x, y - 1));
1224
+        }
1225
+    }
1226
+}
1227
+
1228
+void MapPixmapItem::_floodFillSmartPath(int initialX, int initialY) {
1229
+    // Smart path should never be enabled without a 3x3 block selection.
1230
+    if (map->paint_tile_width != 3 || map->paint_tile_height != 3) return;
1231
+
1232
+    // Shift to the middle tile of the smart path selection.
1233
+    int openTile = map->paint_tile_index + 8 + 1;
1234
+
1235
+    // Flood fill the region with the open tile.
1236
+    QList<QPoint> todo;
1237
+    todo.append(QPoint(initialX, initialY));
1238
+    while (todo.length()) {
1239
+        QPoint point = todo.takeAt(0);
1240
+        int x = point.x();
1241
+        int y = point.y();
1242
+
1243
+        Block *block = map->getBlock(x, y);
1244
+        if (block == NULL) {
1245
+            continue;
1246
+        }
1247
+
1248
+        int tile = map->getSelectedBlockIndex(openTile);
1249
+        uint old_tile = block->tile;
1250
+        if (old_tile == tile) {
1251
+            continue;
1252
+        }
1253
+
1254
+        block->tile = tile;
1255
+        map->_setBlock(x, y, *block);
1256
+        if ((block = map->getBlock(x + 1, y)) && block->tile == old_tile) {
1257
+            todo.append(QPoint(x + 1, y));
1258
+        }
1259
+        if ((block = map->getBlock(x - 1, y)) && block->tile == old_tile) {
1260
+            todo.append(QPoint(x - 1, y));
1261
+        }
1262
+        if ((block = map->getBlock(x, y + 1)) && block->tile == old_tile) {
1263
+            todo.append(QPoint(x, y + 1));
1264
+        }
1265
+        if ((block = map->getBlock(x, y - 1)) && block->tile == old_tile) {
1266
+            todo.append(QPoint(x, y - 1));
1267
+        }
1268
+    }
1269
+
1270
+    // Go back and resolve the flood-filled edge tiles.
1271
+    // Mark tiles as visited while we go.
1272
+    bool visited[map->getWidth() * map->getHeight()];
1273
+    for (int i = 0; i < sizeof visited; i++)
1274
+        visited[i] = false;
1275
+
1276
+    todo.append(QPoint(initialX, initialY));
1277
+    while (todo.length()) {
1278
+        QPoint point = todo.takeAt(0);
1279
+        int x = point.x();
1280
+        int y = point.y();
1281
+        visited[x + y * map->getWidth()] = true;
1282
+
1283
+        Block *block = map->getBlock(x, y);
1284
+        if (block == NULL) {
1285
+            continue;
1286
+        }
1287
+
1288
+        int id = 0;
1289
+        Block *top = map->getBlock(x, y - 1);
1290
+        Block *right = map->getBlock(x + 1, y);
1291
+        Block *bottom = map->getBlock(x, y + 1);
1292
+        Block *left = map->getBlock(x - 1, y);
1293
+
1294
+        // Get marching squares value, to determine which tile to use.
1295
+        if (top && IS_SMART_PATH_TILE(top))
1296
+            id += 1;
1297
+        if (right && IS_SMART_PATH_TILE(right))
1298
+            id += 2;
1299
+        if (bottom && IS_SMART_PATH_TILE(bottom))
1300
+            id += 4;
1301
+        if (left && IS_SMART_PATH_TILE(left))
1302
+            id += 8;
1303
+
1304
+        block->tile = map->getSelectedBlockIndex(map->paint_tile_index + smartPathTable[id]);
1305
+        map->_setBlock(x, y, *block);
1306
+
1307
+        // Visit neighbors if they are smart-path tiles, and don't revisit any.
1308
+        if (!visited[x + 1 + y * map->getWidth()] && (block = map->getBlock(x + 1, y)) && IS_SMART_PATH_TILE(block)) {
1309
+            todo.append(QPoint(x + 1, y));
1310
+            visited[x + 1 + y * map->getWidth()] = true;
1311
+        }
1312
+        if (!visited[x - 1 + y * map->getWidth()] && (block = map->getBlock(x - 1, y)) && IS_SMART_PATH_TILE(block)) {
1313
+            todo.append(QPoint(x - 1, y));
1314
+            visited[x - 1 + y * map->getWidth()] = true;
1315
+        }
1316
+        if (!visited[x + (y + 1) * map->getWidth()] && (block = map->getBlock(x, y + 1)) && IS_SMART_PATH_TILE(block)) {
1317
+            todo.append(QPoint(x, y + 1));
1318
+            visited[x + (y + 1) * map->getWidth()] = true;
1319
+        }
1320
+        if (!visited[x + (y - 1) * map->getWidth()] && (block = map->getBlock(x, y - 1)) && IS_SMART_PATH_TILE(block)) {
1321
+            todo.append(QPoint(x, y - 1));
1322
+            visited[x + (y - 1) * map->getWidth()] = true;
1323
+        }
1324
+    }
1325
+}
1326
+
1166 1327
 void MapPixmapItem::pick(QGraphicsSceneMouseEvent *event) {
1167 1328
     QPointF pos = event->pos();
1168 1329
     int x = (int)(pos.x()) / 16;
@@ -1216,20 +1377,6 @@ void MapPixmapItem::draw(bool ignoreCache) {
1216 1377
     }
1217 1378
 }
1218 1379
 
1219
-void MapPixmapItem::undo() {
1220
-    if (map) {
1221
-        map->undo();
1222
-        draw();
1223
-    }
1224
-}
1225
-
1226
-void MapPixmapItem::redo() {
1227
-    if (map) {
1228
-        map->redo();
1229
-        draw();
1230
-    }
1231
-}
1232
-
1233 1380
 void MapPixmapItem::updateCurHoveredTile(QPointF pos) {
1234 1381
     int x = ((int)pos.x()) / 16;
1235 1382
     int y = ((int)pos.y()) / 16;
@@ -1334,9 +1481,11 @@ void CollisionPixmapItem::pick(QGraphicsSceneMouseEvent *event) {
1334 1481
 
1335 1482
 void DraggablePixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *mouse) {
1336 1483
     active = true;
1337
-    clicking = true;
1338 1484
     last_x = (mouse->pos().x() + this->pos().x()) / 16;
1339 1485
     last_y = (mouse->pos().y() + this->pos().y()) / 16;
1486
+    this->editor->selectMapEvent(this, mouse->modifiers() & Qt::ControlModifier);
1487
+    this->editor->updateSelectedEvents();
1488
+    selectingEvent = true;
1340 1489
     //qDebug() << QString("(%1, %2)").arg(event->get("x")).arg(event->get("y"));
1341 1490
 }
1342 1491
 
@@ -1352,7 +1501,6 @@ void DraggablePixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *mouse) {
1352 1501
         int x = (mouse->pos().x() + this->pos().x()) / 16;
1353 1502
         int y = (mouse->pos().y() + this->pos().y()) / 16;
1354 1503
         if (x != last_x || y != last_y) {
1355
-            clicking = false;
1356 1504
             if (editor->selected_events->contains(this)) {
1357 1505
                 for (DraggablePixmapItem *item : *editor->selected_events) {
1358 1506
                     item->move(x - last_x, y - last_y);
@@ -1368,13 +1516,15 @@ void DraggablePixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *mouse) {
1368 1516
 }
1369 1517
 
1370 1518
 void DraggablePixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouse) {
1371
-    if (clicking) {
1372
-        this->editor->selectMapEvent(this, mouse->modifiers() & Qt::ControlModifier);
1373
-        this->editor->updateSelectedEvents();
1374
-    }
1375 1519
     active = false;
1376 1520
 }
1377 1521
 
1522
+void DraggablePixmapItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *mouse) {
1523
+    if (this->event->get("event_type") == EventType::Warp) {
1524
+        emit editor->warpEventDoubleClicked(this->event->get("destination_map_name"), this->event->get("destination_warp"));
1525
+    }
1526
+}
1527
+
1378 1528
 QList<DraggablePixmapItem *> *Editor::getObjects() {
1379 1529
     QList<DraggablePixmapItem *> *list = new QList<DraggablePixmapItem *>;
1380 1530
     for (Event *event : map->getAllEvents()) {
@@ -1395,7 +1545,7 @@ void Editor::redrawObject(DraggablePixmapItem *item) {
1395 1545
         if (selected_events && selected_events->contains(item)) {
1396 1546
             QImage image = item->pixmap().toImage();
1397 1547
             QPainter painter(&image);
1398
-            painter.setPen(QColor(250, 100, 25));
1548
+            painter.setPen(QColor(250, 0, 255));
1399 1549
             painter.drawRect(0, 0, image.width() - 1, image.height() - 1);
1400 1550
             painter.end();
1401 1551
             item->setPixmap(QPixmap::fromImage(image));
@@ -1452,39 +1602,19 @@ void Editor::deleteEvent(Event *event) {
1452 1602
     //updateSelectedObjects();
1453 1603
 }
1454 1604
 
1455
-// dunno how to detect bubbling. QMouseEvent::isAccepted seems to always be true
1456
-// check if selected_events changed instead. this has the side effect of deselecting
1457
-// when you click on a selected event, since selected_events doesn't change.
1458
-
1459
-QList<DraggablePixmapItem *> selected_events_test;
1460
-bool clicking = false;
1461
-
1605
+// It doesn't seem to be possible to prevent the mousePress event
1606
+// from triggering both event's DraggablePixmapItem and the background mousePress.
1607
+// Since the DraggablePixmapItem's event fires first, we can set a temp
1608
+// variable "selectingEvent" so that we can detect whether or not the user
1609
+// is clicking on the background instead of an event.
1462 1610
 void Editor::objectsView_onMousePress(QMouseEvent *event) {
1463
-    clicking = true;
1464
-    selected_events_test = *selected_events;
1465
-}
1466
-
1467
-void Editor::objectsView_onMouseMove(QMouseEvent *event) {
1468
-    clicking = false;
1469
-}
1470
-
1471
-void Editor::objectsView_onMouseRelease(QMouseEvent *event) {
1472
-    if (clicking) {
1473
-        if (selected_events_test.length()) {
1474
-            if (selected_events_test.length() == selected_events->length()) {
1475
-                bool deselect = true;
1476
-                for (int i = 0; i < selected_events_test.length(); i++) {
1477
-                    if (selected_events_test.at(i) != selected_events->at(i)) {
1478
-                        deselect = false;
1479
-                        break;
1480
-                    }
1481
-                }
1482
-                if (deselect) {
1483
-                    selected_events->clear();
1484
-                    updateSelectedEvents();
1485
-                }
1486
-            }
1487
-        }
1488
-        clicking = false;
1611
+    bool multiSelect = event->modifiers() & Qt::ControlModifier;
1612
+    if (!selectingEvent && !multiSelect && selected_events->length() > 1) {
1613
+        DraggablePixmapItem *first = selected_events->first();
1614
+        selected_events->clear();
1615
+        selected_events->append(first);
1616
+        updateSelectedEvents();
1489 1617
     }
1618
+
1619
+    selectingEvent = false;
1490 1620
 }

+ 6
- 5
editor.h View File

@@ -138,6 +138,7 @@ signals:
138 138
     void selectedObjectsChanged();
139 139
     void loadMapRequested(QString, QString);
140 140
     void tilesetChanged(QString);
141
+    void warpEventDoubleClicked(QString mapName, QString warpNum);
141 142
 };
142 143
 
143 144
 
@@ -150,13 +151,12 @@ public:
150 151
     Editor *editor = NULL;
151 152
     Event *event = NULL;
152 153
     QGraphicsItemAnimation *pos_anim = NULL;
153
-    DraggablePixmapItem(Event *event_) : QGraphicsPixmapItem(event_->pixmap) {
154
+    DraggablePixmapItem(Event *event_, Editor *editor_) : QGraphicsPixmapItem(event_->pixmap) {
154 155
         event = event_;
156
+        editor = editor_;
155 157
         updatePosition();
156 158
     }
157 159
     bool active;
158
-    bool right_click;
159
-    bool clicking;
160 160
     int last_x;
161 161
     int last_y;
162 162
     void updatePosition() {
@@ -229,6 +229,7 @@ protected:
229 229
     void mousePressEvent(QGraphicsSceneMouseEvent*);
230 230
     void mouseMoveEvent(QGraphicsSceneMouseEvent*);
231 231
     void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
232
+    void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*);
232 233
 };
233 234
 
234 235
 class EventGroup : public QGraphicsItemGroup {
@@ -250,10 +251,10 @@ public:
250 251
     QList<QPoint> selection;
251 252
     virtual void paint(QGraphicsSceneMouseEvent*);
252 253
     virtual void floodFill(QGraphicsSceneMouseEvent*);
254
+    void _floodFill(int x, int y);
255
+    void _floodFillSmartPath(int initialX, int initialY);
253 256
     virtual void pick(QGraphicsSceneMouseEvent*);
254 257
     virtual void select(QGraphicsSceneMouseEvent*);
255
-    virtual void undo();
256
-    virtual void redo();
257 258
     virtual void draw(bool ignoreCache = false);
258 259
 
259 260
 private:

+ 7
- 10
event.cpp View File

@@ -43,13 +43,13 @@ Event* Event::createNewObjectEvent()
43 43
     event->put("event_group_type", "object_event_group");
44 44
     event->put("event_type", EventType::Object);
45 45
     event->put("sprite", "EVENT_OBJ_GFX_BOY_1");
46
-    event->put("behavior", "1");
46
+    event->put("movement_type", "MOVEMENT_TYPE_LOOK_AROUND");
47 47
     event->put("radius_x", 0);
48 48
     event->put("radius_y", 0);
49 49
     event->put("script_label", "NULL");
50 50
     event->put("event_flag", "0");
51 51
     event->put("replacement", "0");
52
-    event->put("trainer_see_type", "0");
52
+    event->put("is_trainer", "FALSE");
53 53
     event->put("sight_radius_tree_id", 0);
54 54
     return event;
55 55
 }
@@ -89,7 +89,7 @@ Event* Event::createNewSignEvent()
89 89
     Event *event = new Event;
90 90
     event->put("event_group_type", "bg_event_group");
91 91
     event->put("event_type", EventType::Sign);
92
-    event->put("player_facing_direction", "0");
92
+    event->put("player_facing_direction", "BG_EVENT_PLAYER_FACING_ANY");
93 93
     event->put("script_label", "NULL");
94 94
     return event;
95 95
 }
@@ -109,7 +109,7 @@ Event* Event::createNewSecretBaseEvent()
109 109
     Event *event = new Event;
110 110
     event->put("event_group_type", "bg_event_group");
111 111
     event->put("event_type", EventType::SecretBase);
112
-    event->put("secret_base_map", "SECRET_BASE_RED_CAVE2_1");
112
+    event->put("secret_base_id", "SECRET_BASE_RED_CAVE2_1");
113 113
     return event;
114 114
 }
115 115
 
@@ -127,10 +127,10 @@ QString Event::buildObjectEventMacro(int item_index)
127 127
     text += QString(", %1").arg(x);
128 128
     text += QString(", %1").arg(y);
129 129
     text += QString(", %1").arg(this->get("elevation"));
130
-    text += QString(", %1").arg(this->get("behavior"));
130
+    text += QString(", %1").arg(this->get("movement_type"));
131 131
     text += QString(", %1").arg(radius_x);
132 132
     text += QString(", %1").arg(radius_y);
133
-    text += QString(", %1").arg(this->get("trainer_see_type"));
133
+    text += QString(", %1").arg(this->get("is_trainer"));
134 134
     text += QString(", %1").arg(this->get("sight_radius_tree_id"));
135 135
     text += QString(", %1").arg(this->get("script_label"));
136 136
     text += QString(", %1").arg(this->get("event_flag"));
@@ -156,10 +156,8 @@ QString Event::buildCoordScriptEventMacro()
156 156
     text += QString("\tcoord_event %1").arg(this->get("x"));
157 157
     text += QString(", %1").arg(this->get("y"));
158 158
     text += QString(", %1").arg(this->get("elevation"));
159
-    text += QString(", 0");
160 159
     text += QString(", %1").arg(this->get("script_var"));
161 160
     text += QString(", %1").arg(this->get("script_var_value"));
162
-    text += QString(", 0");
163 161
     text += QString(", %1").arg(this->get("script_label"));
164 162
     text += "\n";
165 163
     return text;
@@ -183,7 +181,6 @@ QString Event::buildSignEventMacro()
183 181
     text += QString(", %1").arg(this->get("y"));
184 182
     text += QString(", %1").arg(this->get("elevation"));
185 183
     text += QString(", %1").arg(this->get("player_facing_direction"));
186
-    text += QString(", 0");
187 184
     text += QString(", %1").arg(this->get("script_label"));
188 185
     text += "\n";
189 186
     return text;
@@ -207,7 +204,7 @@ QString Event::buildSecretBaseEventMacro()
207 204
     text += QString("\tbg_secret_base_event %1").arg(this->get("x"));
208 205
     text += QString(", %1").arg(this->get("y"));
209 206
     text += QString(", %1").arg(this->get("elevation"));
210
-    text += QString(", %1").arg(this->get("secret_base_map"));
207
+    text += QString(", %1").arg(this->get("secret_base_id"));
211 208
     text += "\n";
212 209
     return text;
213 210
 }

+ 0
- 6
graphicsview.cpp View File

@@ -10,14 +10,8 @@ void GraphicsView::mousePressEvent(QMouseEvent *event) {
10 10
 
11 11
 void GraphicsView::mouseMoveEvent(QMouseEvent *event) {
12 12
     QGraphicsView::mouseMoveEvent(event);
13
-    if (editor) {
14
-        editor->objectsView_onMouseMove(event);
15
-    }
16 13
 }
17 14
 
18 15
 void GraphicsView::mouseReleaseEvent(QMouseEvent *event) {
19 16
     QGraphicsView::mouseReleaseEvent(event);
20
-    if (editor) {
21
-        editor->objectsView_onMouseRelease(event);
22
-    }
23 17
 }

+ 220
- 28
mainwindow.cpp View File

@@ -15,6 +15,8 @@
15 15
 #include <QSpacerItem>
16 16
 #include <QFont>
17 17
 #include <QScrollBar>
18
+#include <QMessageBox>
19
+#include <QDialogButtonBox>
18 20
 
19 21
 MainWindow::MainWindow(QWidget *parent) :
20 22
     QMainWindow(parent),
@@ -35,6 +37,7 @@ MainWindow::MainWindow(QWidget *parent) :
35 37
     connect(editor, SIGNAL(selectedObjectsChanged()), this, SLOT(updateSelectedObjects()));
36 38
     connect(editor, SIGNAL(loadMapRequested(QString, QString)), this, SLOT(onLoadMapRequested(QString, QString)));
37 39
     connect(editor, SIGNAL(tilesetChanged(QString)), this, SLOT(onTilesetChanged(QString)));
40
+    connect(editor, SIGNAL(warpEventDoubleClicked(QString,QString)), this, SLOT(openWarpMap(QString,QString)));
38 41
 
39 42
     on_toolButton_Paint_clicked();
40 43
 
@@ -147,7 +150,22 @@ void MainWindow::setMap(QString map_name) {
147 150
         return;
148 151
     }
149 152
     editor->setMap(map_name);
153
+    redrawMapScene();
154
+    displayMapProperties();
155
+
156
+    setWindowTitle(map_name + " - " + editor->project->getProjectTitle() + " - pretmap");
157
+
158
+    connect(editor->map, SIGNAL(mapChanged(Map*)), this, SLOT(onMapChanged(Map *)));
159
+    connect(editor->map, SIGNAL(mapNeedsRedrawing(Map*)), this, SLOT(onMapNeedsRedrawing(Map *)));
160
+    connect(editor->map, SIGNAL(statusBarMessage(QString)), this, SLOT(setStatusBarMessage(QString)));
161
+
162
+    setRecentMap(map_name);
163
+    updateMapList();
164
+}
150 165
 
166
+void MainWindow::redrawMapScene()
167
+{
168
+    editor->displayMap();
151 169
     on_tabWidget_currentChanged(ui->tabWidget->currentIndex());
152 170
 
153 171
     ui->graphicsView_Map->setScene(editor->scene);
@@ -177,16 +195,39 @@ void MainWindow::setMap(QString map_name) {
177 195
     ui->graphicsView_Elevation->setScene(editor->scene_elevation_metatiles);
178 196
     //ui->graphicsView_Elevation->setSceneRect(editor->scene_elevation_metatiles->sceneRect());
179 197
     ui->graphicsView_Elevation->setFixedSize(editor->elevation_metatiles_item->pixmap().width() + 2, editor->elevation_metatiles_item->pixmap().height() + 2);
198
+}
180 199
 
181
-    displayMapProperties();
200
+void MainWindow::openWarpMap(QString map_name, QString warp_num) {
201
+    // Ensure valid destination map name.
202
+    if (!editor->project->mapNames->contains(map_name)) {
203
+        qDebug() << QString("Invalid warp destination map name '%1'").arg(map_name);
204
+        return;
205
+    }
182 206
 
183
-    setWindowTitle(map_name + " - " + editor->project->getProjectTitle() + " - pretmap");
207
+    // Ensure valid destination warp number.
208
+    bool ok;
209
+    int warpNum = warp_num.toInt(&ok, 0);
210
+    if (!ok) {
211
+        qDebug() << QString("Invalid warp number '%1' for destination map '%2'").arg(warp_num).arg(map_name);
212
+        return;
213
+    }
184 214
 
185
-    connect(editor->map, SIGNAL(mapChanged(Map*)), this, SLOT(onMapChanged(Map *)));
186
-    connect(editor->map, SIGNAL(statusBarMessage(QString)), this, SLOT(setStatusBarMessage(QString)));
215
+    // Open the destination map, and select the target warp event.
216
+    setMap(map_name);
217
+    QList<Event*> warp_events = editor->map->events["warp_event_group"];
218
+    if (warp_events.length() > warpNum) {
219
+        Event *warp_event = warp_events.at(warpNum);
220
+        QList<DraggablePixmapItem *> *all_events = editor->getObjects();
221
+        for (DraggablePixmapItem *item : *all_events) {
222
+            if (item->event == warp_event) {
223
+                editor->selected_events->clear();
224
+                editor->selected_events->append(item);
225
+                editor->updateSelectedEvents();
226
+            }
227
+        }
187 228
 
188
-    setRecentMap(map_name);
189
-    updateMapList();
229
+        delete all_events;
230
+    }
190 231
 }
191 232
 
192 233
 void MainWindow::setRecentMap(QString map_name) {
@@ -203,7 +244,7 @@ void MainWindow::setRecentMap(QString map_name) {
203 244
 void MainWindow::displayMapProperties() {
204 245
     ui->comboBox_Song->clear();
205 246
     ui->comboBox_Location->clear();
206
-    ui->comboBox_Visibility->clear();
247
+    ui->checkBox_Visibility->setChecked(false);
207 248
     ui->comboBox_Weather->clear();
208 249
     ui->comboBox_Type->clear();
209 250
     ui->comboBox_BattleScene->clear();
@@ -222,7 +263,7 @@ void MainWindow::displayMapProperties() {
222 263
     ui->comboBox_Song->addItems(songs);
223 264
     ui->comboBox_Song->setCurrentText(map->song);
224 265
 
225
-    ui->comboBox_Location->addItems(project->getLocations());
266
+    ui->comboBox_Location->addItems(*project->regionMapSections);
226 267
     ui->comboBox_Location->setCurrentText(map->location);
227 268
 
228 269
     QMap<QString, QStringList> tilesets = project->getTilesets();
@@ -231,16 +272,15 @@ void MainWindow::displayMapProperties() {
231 272
     ui->comboBox_SecondaryTileset->addItems(tilesets.value("secondary"));
232 273
     ui->comboBox_SecondaryTileset->setCurrentText(map->layout->tileset_secondary_label);
233 274
 
234
-    ui->comboBox_Visibility->addItems(project->getVisibilities());
235
-    ui->comboBox_Visibility->setCurrentText(map->visibility);
275
+    ui->checkBox_Visibility->setChecked(map->requiresFlash.toInt() > 0 || map->requiresFlash == "TRUE");
236 276
 
237
-    ui->comboBox_Weather->addItems(project->getWeathers());
277
+    ui->comboBox_Weather->addItems(*project->weatherNames);
238 278
     ui->comboBox_Weather->setCurrentText(map->weather);
239 279
 
240
-    ui->comboBox_Type->addItems(project->getMapTypes());
280
+    ui->comboBox_Type->addItems(*project->mapTypes);
241 281
     ui->comboBox_Type->setCurrentText(map->type);
242 282
 
243
-    ui->comboBox_BattleScene->addItems(project->getBattleScenes());
283
+    ui->comboBox_BattleScene->addItems(*project->mapBattleScenes);
244 284
     ui->comboBox_BattleScene->setCurrentText(map->battle_scene);
245 285
 
246 286
     ui->checkBox_ShowLocation->setChecked(map->show_location.toInt() > 0 || map->show_location == "TRUE");
@@ -260,10 +300,10 @@ void MainWindow::on_comboBox_Location_activated(const QString &location)
260 300
     }
261 301
 }
262 302
 
263
-void MainWindow::on_comboBox_Visibility_activated(const QString &visibility)
303
+void MainWindow::on_comboBox_Visibility_activated(const QString &requiresFlash)
264 304
 {
265 305
     if (editor && editor->map) {
266
-        editor->map->visibility = visibility;
306
+        editor->map->requiresFlash = requiresFlash;
267 307
     }
268 308
 }
269 309
 
@@ -288,6 +328,17 @@ void MainWindow::on_comboBox_BattleScene_activated(const QString &battle_scene)
288 328
     }
289 329
 }
290 330
 
331
+void MainWindow::on_checkBox_Visibility_clicked(bool checked)
332
+{
333
+    if (editor && editor->map) {
334
+        if (checked) {
335
+            editor->map->requiresFlash = "TRUE";
336
+        } else {
337
+            editor->map->requiresFlash = "FALSE";
338
+        }
339
+    }
340
+}
341
+
291 342
 void MainWindow::on_checkBox_ShowLocation_clicked(bool checked)
292 343
 {
293 344
     if (editor && editor->map) {
@@ -303,9 +354,17 @@ void MainWindow::loadDataStructures() {
303 354
     Project *project = editor->project;
304 355
     project->readMapLayoutsTable();
305 356
     project->readAllMapLayouts();
357
+    project->readRegionMapSections();
306 358
     project->readItemNames();
307 359
     project->readFlagNames();
308 360
     project->readVarNames();
361
+    project->readMovementTypes();
362
+    project->readMapTypes();
363
+    project->readMapBattleScenes();
364
+    project->readWeatherNames();
365
+    project->readCoordEventWeatherNames();
366
+    project->readSecretBaseIds();
367
+    project->readBgEventFacingDirections();
309 368
     project->readMapsWithConnections();
310 369
 }
311 370
 
@@ -537,12 +596,19 @@ void MainWindow::addNewEvent(QString event_type)
537 596
 
538 597
 // Should probably just pass layout and let the editor work it out
539 598
 void MainWindow::updateSelectedObjects() {
540
-
541 599
     QList<DraggablePixmapItem *> *all_events = editor->getObjects();
542
-    QList<DraggablePixmapItem *> *events = all_events;
600
+    QList<DraggablePixmapItem *> *events = NULL;
543 601
 
544 602
     if (editor->selected_events && editor->selected_events->length()) {
545 603
         events = editor->selected_events;
604
+    } else {
605
+        events = new QList<DraggablePixmapItem*>;
606
+        if (all_events && all_events->length()) {
607
+            DraggablePixmapItem *selectedEvent = all_events->first();
608
+            editor->selected_events->append(selectedEvent);
609
+            editor->redrawObject(selectedEvent);
610
+            events->append(selectedEvent);
611
+        }
546 612
     }
547 613
 
548 614
     QMap<QString, int> event_obj_gfx_constants = editor->project->getEventObjGfxConstants();
@@ -590,11 +656,10 @@ void MainWindow::updateSelectedObjects() {
590 656
         QMap<QString, QString> field_labels;
591 657
         field_labels["script_label"] = "Script";
592 658
         field_labels["event_flag"] = "Event Flag";
593
-        field_labels["replacement"] = "Replacement";
594
-        field_labels["behavior"] = "Behavior";
659
+        field_labels["movement_type"] = "Movement";
595 660
         field_labels["radius_x"] = "Movement Radius X";
596 661
         field_labels["radius_y"] = "Movement Radius Y";
597
-        field_labels["trainer_see_type"] = "Trainer See Type";
662
+        field_labels["is_trainer"] = "Trainer";
598 663
         field_labels["sight_radius_tree_id"] = "Sight Radius / Berry Tree ID";
599 664
         field_labels["destination_warp"] = "Destination Warp";
600 665
         field_labels["destination_map_name"] = "Destination Map";
@@ -606,7 +671,7 @@ void MainWindow::updateSelectedObjects() {
606 671
         field_labels["item_unknown6"] = "Unknown 6";
607 672
         field_labels["weather"] = "Weather";
608 673
         field_labels["flag"] = "Flag";
609
-        field_labels["secret_base_map"] = "Secret Base Map";
674
+        field_labels["secret_base_id"] = "Secret Base Id";
610 675
 
611 676
         QStringList fields;
612 677
 
@@ -627,13 +692,12 @@ void MainWindow::updateSelectedObjects() {
627 692
             //connect(item, SIGNAL(scriptChanged(QString)), frame->ui->comboBox_script, SLOT(setValue(QString)));
628 693
             */
629 694
 
630
-            fields << "behavior";
695
+            fields << "movement_type";
631 696
             fields << "radius_x";
632 697
             fields << "radius_y";
633 698
             fields << "script_label";
634 699
             fields << "event_flag";
635
-            fields << "replacement";
636
-            fields << "trainer_see_type";
700
+            fields << "is_trainer";
637 701
             fields << "sight_radius_tree_id";
638 702
         }
639 703
         else if (event_type == EventType::Warp) {
@@ -657,37 +721,96 @@ void MainWindow::updateSelectedObjects() {
657 721
             fields << "flag";
658 722
         }
659 723
         else if (event_type == EventType::SecretBase) {
660
-            fields << "secret_base_map";
724
+            fields << "secret_base_id";
661 725
         }
662 726
 
663 727
         for (QString key : fields) {
728
+            QString value = item->event->get(key);
664 729
             QWidget *widget = new QWidget(frame);
665 730
             QFormLayout *fl = new QFormLayout(widget);
666 731
             fl->setContentsMargins(9, 0, 9, 0);
667
-            QComboBox *combo = new QComboBox(widget);
732
+
733
+            // is_trainer is the only non-combobox item.
734
+            if (key == "is_trainer") {
735
+                QCheckBox *checkbox = new QCheckBox(widget);
736
+                checkbox->setEnabled(true);
737
+                checkbox->setChecked(value.toInt() != 0 && value != "FALSE");
738
+                checkbox->setToolTip("Whether or not this object is trainer.");
739
+                fl->addRow(new QLabel(field_labels[key], widget), checkbox);
740
+                widget->setLayout(fl);
741
+                frame->layout()->addWidget(widget);
742
+                connect(checkbox, &QCheckBox::stateChanged, [=](int state) {
743
+                    QString isTrainer = state == Qt::Checked ? "TRUE" : "FALSE";
744
+                    item->event->put("is_trainer", isTrainer);
745
+                });
746
+                continue;
747
+            }
748
+
749
+            NoScrollComboBox *combo = new NoScrollComboBox(widget);
668 750
             combo->setEditable(true);
669 751
 
670
-            QString value = item->event->get(key);
671 752
             if (key == "destination_map_name") {
672 753
                 if (!editor->project->mapNames->contains(value)) {
673 754
                     combo->addItem(value);
674 755
                 }
675 756
                 combo->addItems(*editor->project->mapNames);
757
+                combo->setToolTip("The destination map name of the warp.");
758
+            } else if (key == "destination_warp") {
759
+                combo->setToolTip("The warp id on the destination map.");
676 760
             } else if (key == "item") {
677 761
                 if (!editor->project->itemNames->contains(value)) {
678 762
                     combo->addItem(value);
679 763
                 }
680 764
                 combo->addItems(*editor->project->itemNames);
681
-            } else if (key == "flag") {
765
+            } else if (key == "flag" || key == "event_flag") {
682 766
                 if (!editor->project->flagNames->contains(value)) {
683 767
                     combo->addItem(value);
684 768
                 }
685 769
                 combo->addItems(*editor->project->flagNames);
770
+                if (key == "flag")
771
+                    combo->setToolTip("The flag which is set when the hidden item is picked up.");
772
+                else if (key == "event_flag")
773
+                    combo->setToolTip("The flag which hides the object when set.");
686 774
             } else if (key == "script_var") {
687 775
                 if (!editor->project->varNames->contains(value)) {
688 776
                     combo->addItem(value);
689 777
                 }
690 778
                 combo->addItems(*editor->project->varNames);
779
+                combo->setToolTip("The variable by which the script is triggered. The script is triggered when this variable's value matches 'Var Value'.");
780
+            } else if (key == "script_var_value")  {
781
+                combo->setToolTip("The variable's value which triggers the script.");
782
+            } else if (key == "movement_type") {
783
+                if (!editor->project->movementTypes->contains(value)) {
784
+                    combo->addItem(value);
785
+                }
786
+                combo->addItems(*editor->project->movementTypes);
787
+                combo->setToolTip("The object's natural movement behavior when the player is not interacting with it.");
788
+            } else if (key == "weather") {
789
+                if (!editor->project->coordEventWeatherNames->contains(value)) {
790
+                    combo->addItem(value);
791
+                }
792
+                combo->addItems(*editor->project->coordEventWeatherNames);
793
+                combo->setToolTip("The weather that starts when the player steps on this spot.");
794
+            } else if (key == "secret_base_id") {
795
+                if (!editor->project->secretBaseIds->contains(value)) {
796
+                    combo->addItem(value);
797
+                }
798
+                combo->addItems(*editor->project->secretBaseIds);
799
+                combo->setToolTip("The secret base id which is inside this secret base entrance. Secret base ids are meant to be unique to each and every secret base entrance.");
800
+            } else if (key == "player_facing_direction") {
801
+                if (!editor->project->bgEventFacingDirections->contains(value)) {
802
+                    combo->addItem(value);
803
+                }
804
+                combo->addItems(*editor->project->bgEventFacingDirections);
805
+                combo->setToolTip("The direction which the player must be facing to be able to interact with this event.");
806
+            } else if (key == "radius_x") {
807
+                combo->setToolTip("The maximum number of metatiles this object is allowed to move left or right during its normal movement behavior actions.");
808
+            } else if (key == "radius_y") {
809
+                combo->setToolTip("The maximum number of metatiles this object is allowed to move up or down during its normal movement behavior actions.");
810
+            } else if (key == "script_label") {
811
+                combo->setToolTip("The script which is executed with this event.");
812
+            } else if (key == "sight_radius_tree_id") {
813
+                combo->setToolTip("The maximum sight range of a trainer, OR the unique id of the berry tree.");
691 814
             } else {
692 815
                 combo->addItem(value);
693 816
             }
@@ -785,6 +908,10 @@ void MainWindow::onMapChanged(Map *map) {
785 908
     updateMapList();
786 909
 }
787 910
 
911
+void MainWindow::onMapNeedsRedrawing(Map *map) {
912
+    redrawMapScene();
913
+}
914
+
788 915
 void MainWindow::on_action_Export_Map_Image_triggered()
789 916
 {
790 917
     QString defaultFilepath = QString("%1/%2.png").arg(editor->project->root).arg(editor->map->name);
@@ -838,3 +965,68 @@ void MainWindow::on_comboBox_SecondaryTileset_activated(const QString &tilesetLa
838 965
 {
839 966
     editor->updateSecondaryTileset(tilesetLabel);
840 967
 }
968
+
969
+void MainWindow::on_pushButton_clicked()
970
+{
971
+    QDialog dialog(this, Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
972
+    dialog.setWindowTitle("Change Map Dimensions");
973
+    dialog.setWindowModality(Qt::NonModal);
974
+
975
+    QFormLayout form(&dialog);
976
+
977
+    QSpinBox *widthSpinBox = new QSpinBox();
978
+    QSpinBox *heightSpinBox = new QSpinBox();
979
+    widthSpinBox->setMinimum(1);
980
+    heightSpinBox->setMinimum(1);
981
+    // See below for explanation of maximum map dimensions
982
+    widthSpinBox->setMaximum(0x1E7);
983
+    heightSpinBox->setMaximum(0x1D1);
984
+    widthSpinBox->setValue(editor->map->getWidth());
985
+    heightSpinBox->setValue(editor->map->getHeight());
986
+    form.addRow(new QLabel("Width"), widthSpinBox);
987
+    form.addRow(new QLabel("Height"), heightSpinBox);
988
+
989
+    QLabel *errorLabel = new QLabel();
990
+    QPalette errorPalette;
991
+    errorPalette.setColor(QPalette::WindowText, Qt::red);
992
+    errorLabel->setPalette(errorPalette);
993
+    errorLabel->setVisible(false);
994
+
995
+    QDialogButtonBox buttonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &dialog);
996
+    form.addRow(&buttonBox);
997
+    connect(&buttonBox, &QDialogButtonBox::accepted, [&dialog, &widthSpinBox, &heightSpinBox, &errorLabel](){
998
+        // Ensure width and height are an acceptable size.
999
+        // The maximum number of metatiles in a map is the following:
1000
+        //    max = (width + 15) * (height + 14)
1001
+        // This limit can be found in fieldmap.c in pokeruby/pokeemerald.
1002
+        int realWidth = widthSpinBox->value() + 15;
1003
+        int realHeight = heightSpinBox->value() + 14;
1004
+        int numMetatiles = realWidth * realHeight;
1005
+        if (numMetatiles <= 0x2800) {
1006
+            dialog.accept();
1007
+        } else {
1008
+            QString errorText = QString("Error: The specified width and height are too large.\n"
1009
+                    "The maximum width and height is the following: (width + 15) * (height + 14) <= 10240\n"
1010
+                    "The specified width and height was: (%1 + 15) * (%2 + 14) = %3")
1011
+                        .arg(widthSpinBox->value())
1012
+                        .arg(heightSpinBox->value())
1013
+                        .arg(numMetatiles);
1014
+            errorLabel->setText(errorText);
1015
+            errorLabel->setVisible(true);
1016
+        }
1017
+    });
1018
+    connect(&buttonBox, SIGNAL(rejected()), &dialog, SLOT(reject()));
1019
+
1020
+    form.addRow(errorLabel);
1021
+
1022
+    if (dialog.exec() == QDialog::Accepted) {
1023
+        editor->map->setDimensions(widthSpinBox->value(), heightSpinBox->value());
1024
+        editor->map->commit();
1025
+        onMapNeedsRedrawing(editor->map);
1026
+    }
1027
+}
1028
+
1029
+void MainWindow::on_checkBox_smartPaths_stateChanged(int selected)
1030
+{
1031
+    editor->map->smart_paths_enabled = selected == Qt::Checked;
1032
+}

+ 9
- 0
mainwindow.h View File

@@ -32,12 +32,14 @@ private slots:
32 32
     void on_action_Open_Project_triggered();
33 33
     void on_mapList_activated(const QModelIndex &index);
34 34
     void on_action_Save_Project_triggered();
35
+    void openWarpMap(QString map_name, QString warp_num);
35 36
 
36 37
     void undo();
37 38
     void redo();
38 39
 
39 40
     void onLoadMapRequested(QString, QString);
40 41
     void onMapChanged(Map *map);
42
+    void onMapNeedsRedrawing(Map *map);
41 43
 
42 44
     void on_action_Save_triggered();
43 45
     void on_tabWidget_2_currentChanged(int index);
@@ -93,6 +95,12 @@ private slots:
93 95
 
94 96
     void on_comboBox_SecondaryTileset_activated(const QString &arg1);
95 97
 
98
+    void on_pushButton_clicked();
99
+
100
+    void on_checkBox_smartPaths_stateChanged(int selected);
101
+
102
+    void on_checkBox_Visibility_clicked(bool checked);
103
+
96 104
 private:
97 105
     Ui::MainWindow *ui;
98 106
     QStandardItemModel *mapListModel;
@@ -100,6 +108,7 @@ private:
100 108
     Editor *editor = NULL;
101 109
     QIcon* mapIcon;
102 110
     void setMap(QString);
111
+    void redrawMapScene();
103 112
     void loadDataStructures();
104 113
     void populateMapList();
105 114
     QString getExistingDirectory(QString);

+ 234
- 202
mainwindow.ui View File

@@ -69,6 +69,9 @@
69 69
         <bool>false</bool>
70 70
        </property>
71 71
        <widget class="QWidget" name="tab_Map">
72
+        <property name="toolTip">
73
+         <string/>
74
+        </property>
72 75
         <attribute name="icon">
73 76
          <iconset resource="resources/images.qrc">
74 77
           <normaloff>:/icons/map.ico</normaloff>:/icons/map.ico</iconset>
@@ -76,6 +79,9 @@
76 79
         <attribute name="title">
77 80
          <string>Map</string>
78 81
         </attribute>
82
+        <attribute name="toolTip">
83
+         <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Edit the map layout.&lt;/p&gt;&lt;p&gt;Select metatiles or collision attributes from the right panel, and paint them onto the map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
84
+        </attribute>
79 85
         <layout class="QGridLayout" name="gridLayout_9">
80 86
          <property name="leftMargin">
81 87
           <number>0</number>
@@ -164,6 +170,9 @@
164 170
                   <property name="enabled">
165 171
                    <bool>true</bool>
166 172
                   </property>
173
+                  <property name="toolTip">
174
+                   <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Pencil&lt;/p&gt;&lt;p&gt;Click and drag to draw on the map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
175
+                  </property>
167 176
                   <property name="text">
168 177
                    <string>Paint</string>
169 178
                   </property>
@@ -187,6 +196,9 @@
187 196
                   <property name="enabled">
188 197
                    <bool>true</bool>
189 198
                   </property>
199
+                  <property name="toolTip">
200
+                   <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Pointer&lt;/p&gt;&lt;p&gt;Does nothing&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
201
+                  </property>
190 202
                   <property name="text">
191 203
                    <string>Select</string>
192 204
                   </property>
@@ -201,6 +213,9 @@
201 213
                 </item>
202 214
                 <item>
203 215
                  <widget class="QToolButton" name="toolButton_Fill">
216
+                  <property name="toolTip">
217
+                   <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Flood Fill&lt;/p&gt;&lt;p&gt;Fills all similar tiles in a region with the selected metatiles or collision attributes&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
218
+                  </property>
204 219
                   <property name="text">
205 220
                    <string>Fill</string>
206 221
                   </property>
@@ -215,6 +230,9 @@
215 230
                 </item>
216 231
                 <item>
217 232
                  <widget class="QToolButton" name="toolButton_Dropper">
233
+                  <property name="toolTip">
234
+                   <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Eye Dropper&lt;/p&gt;&lt;p&gt;Click to select a metatile or collision attribute.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
235
+                  </property>
218 236
                   <property name="text">
219 237
                    <string>Dropper</string>
220 238
                   </property>
@@ -228,11 +246,27 @@
228 246
                  </widget>
229 247
                 </item>
230 248
                 <item>
231
-                 <widget class="QCheckBox" name="checkBox_ToggleGrid">
249
+                 <widget class="QCheckBox" name="checkBox_smartPaths">
250
+                  <property name="toolTip">
251
+                   <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Smart-path mode allows easier drawing of paths. If a 3x3 metatile block is selcted in the right panel, then smart path mode will automatically form a pathway using those selected blocks.&lt;/p&gt;&lt;p&gt;When smart-path mode is &lt;span style=&quot; font-weight:600;&quot;&gt;not&lt;/span&gt; enabled, clicking and dragging a selection will tile it in a grid.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
252
+                  </property>
232 253
                   <property name="styleSheet">
233 254
                    <string notr="true">margin-left: 10px</string>
234 255
                   </property>
235 256
                   <property name="text">
257
+                   <string>Smart Paths</string>
258
+                  </property>
259
+                 </widget>
260
+                </item>
261
+                <item>
262
+                 <widget class="QCheckBox" name="checkBox_ToggleGrid">
263
+                  <property name="toolTip">
264
+                   <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Toggles a grid over the map's metatile boundaries.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
265
+                  </property>
266
+                  <property name="styleSheet">
267
+                   <string notr="true"/>
268
+                  </property>
269
+                  <property name="text">
236 270
                    <string>Show Grid</string>
237 271
                   </property>
238 272
                  </widget>
@@ -250,6 +284,16 @@
250 284
                   </property>
251 285
                  </spacer>
252 286
                 </item>
287
+                <item>
288
+                 <widget class="QPushButton" name="pushButton">
289
+                  <property name="toolTip">
290
+                   <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Change a map layout's width and height.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
291
+                  </property>
292
+                  <property name="text">
293
+                   <string>Change Dimensions</string>
294
+                  </property>
295
+                 </widget>
296
+                </item>
253 297
                </layout>
254 298
               </widget>
255 299
              </item>
@@ -291,7 +335,7 @@
291 335
                      <x>0</x>
292 336
                      <y>0</y>
293 337
                      <width>436</width>
294
-                     <height>621</height>
338
+                     <height>620</height>
295 339
                     </rect>
296 340
                    </property>
297 341
                    <layout class="QGridLayout" name="gridLayout_8">
@@ -473,7 +517,13 @@
473 517
                      </widget>
474 518
                     </item>
475 519
                     <item row="0" column="1">
476
-                     <widget class="QComboBox" name="comboBox_PrimaryTileset">
520
+                     <widget class="NoScrollComboBox" name="comboBox_PrimaryTileset">
521
+                      <property name="focusPolicy">
522
+                       <enum>Qt::StrongFocus</enum>
523
+                      </property>
524
+                      <property name="toolTip">
525
+                       <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Primary Tileset&lt;/p&gt;&lt;p&gt;Defines the first 0x200 metatiles available for the map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
526
+                      </property>
477 527
                       <property name="editable">
478 528
                        <bool>true</bool>
479 529
                       </property>
@@ -487,7 +537,13 @@
487 537
                      </widget>
488 538
                     </item>
489 539
                     <item row="1" column="1">
490
-                     <widget class="QComboBox" name="comboBox_SecondaryTileset">
540
+                     <widget class="NoScrollComboBox" name="comboBox_SecondaryTileset">
541
+                      <property name="focusPolicy">
542
+                       <enum>Qt::StrongFocus</enum>
543
+                      </property>
544
+                      <property name="toolTip">
545
+                       <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Secondary Tileset&lt;/p&gt;&lt;p&gt;Defines the second 0x200 metatiles available for the map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
546
+                      </property>
491 547
                       <property name="editable">
492 548
                        <bool>true</bool>
493 549
                       </property>
@@ -557,6 +613,9 @@
557 613
                         <height>48</height>
558 614
                        </size>
559 615
                       </property>
616
+                      <property name="toolTip">
617
+                       <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The border is a 2x2 metatile which is repeated outside of the map layout's boundary. Draw on this border area to modify it.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
618
+                      </property>
560 619
                       <property name="frameShape">
561 620
                        <enum>QFrame::StyledPanel</enum>
562 621
                       </property>
@@ -829,7 +888,10 @@
829 888
          <bool>true</bool>
830 889
         </property>
831 890
         <attribute name="title">
832
-         <string>Objects</string>
891
+         <string>Events</string>
892
+        </attribute>
893
+        <attribute name="toolTip">
894
+         <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Edit the map's events.&lt;/p&gt;&lt;p&gt;View and modify objects, warps, signs, etc.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
833 895
         </attribute>
834 896
         <layout class="QGridLayout" name="gridLayout_10">
835 897
          <property name="leftMargin">
@@ -1090,6 +1152,9 @@
1090 1152
                     <height>32</height>
1091 1153
                    </size>
1092 1154
                   </property>
1155
+                  <property name="toolTip">
1156
+                   <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Add a new event to the map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1157
+                  </property>
1093 1158
                   <property name="text">
1094 1159
                    <string>New Object</string>
1095 1160
                   </property>
@@ -1116,6 +1181,9 @@
1116 1181
                     <height>32</height>
1117 1182
                    </size>
1118 1183
                   </property>
1184
+                  <property name="toolTip">
1185
+                   <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Delete the selected event from the map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1186
+                  </property>
1119 1187
                   <property name="text">
1120 1188
                    <string>Delete</string>
1121 1189
                   </property>
@@ -1155,7 +1223,7 @@
1155 1223
        </widget>
1156 1224
        <widget class="QWidget" name="tab_Attributes">
1157 1225
         <attribute name="title">
1158
-         <string>Attributes</string>
1226
+         <string>Header</string>
1159 1227
         </attribute>
1160 1228
         <widget class="QFrame" name="frame_3">
1161 1229
          <property name="enabled">
@@ -1165,211 +1233,146 @@
1165 1233
           <rect>
1166 1234
            <x>10</x>
1167 1235
            <y>10</y>
1168
-           <width>301</width>
1169
-           <height>251</height>
1236
+           <width>381</width>
1237
+           <height>311</height>
1170 1238
           </rect>
1171 1239
          </property>
1240
+         <property name="sizePolicy">
1241
+          <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
1242
+           <horstretch>0</horstretch>
1243
+           <verstretch>0</verstretch>
1244
+          </sizepolicy>
1245
+         </property>
1172 1246
          <property name="frameShape">
1173 1247
           <enum>QFrame::StyledPanel</enum>
1174 1248
          </property>
1175 1249
          <property name="frameShadow">
1176 1250
           <enum>QFrame::Raised</enum>
1177 1251
          </property>
1178
-         <widget class="QLabel" name="label_3">
1179
-          <property name="geometry">
1180
-           <rect>
1181
-            <x>20</x>
1182
-            <y>30</y>
1183
-            <width>47</width>
1184
-            <height>21</height>
1185
-           </rect>
1186
-          </property>
1187
-          <property name="text">
1188
-           <string>Song</string>
1189
-          </property>
1190
-         </widget>
1191
-         <widget class="QLabel" name="label_4">
1192
-          <property name="geometry">
1193
-           <rect>
1194
-            <x>20</x>
1195
-            <y>60</y>
1196
-            <width>47</width>
1197
-            <height>21</height>
1198
-           </rect>
1199
-          </property>
1200
-          <property name="text">
1201
-           <string>Location</string>
1202
-          </property>
1203
-         </widget>
1204
-         <widget class="QLabel" name="label_5">
1205
-          <property name="geometry">
1206
-           <rect>
1207
-            <x>20</x>
1208
-            <y>90</y>
1209
-            <width>47</width>
1210
-            <height>21</height>
1211
-           </rect>
1212
-          </property>
1213
-          <property name="text">
1214
-           <string>Visibility</string>
1215
-          </property>
1216
-         </widget>
1217
-         <widget class="QLabel" name="label_6">
1218
-          <property name="geometry">
1219
-           <rect>
1220
-            <x>20</x>
1221
-            <y>120</y>
1222
-            <width>47</width>
1223
-            <height>21</height>
1224
-           </rect>
1225
-          </property>
1226
-          <property name="text">
1227
-           <string>Weather</string>
1228
-          </property>
1229
-         </widget>
1230
-         <widget class="QLabel" name="label_7">
1231
-          <property name="geometry">
1232
-           <rect>
1233
-            <x>20</x>
1234
-            <y>150</y>
1235
-            <width>47</width>
1236
-            <height>21</height>
1237
-           </rect>
1238
-          </property>
1239
-          <property name="text">
1240
-           <string>Type</string>
1241
-          </property>
1242
-         </widget>
1243
-         <widget class="QLabel" name="label_8">
1244
-          <property name="geometry">
1245
-           <rect>
1246
-            <x>20</x>
1247
-            <y>180</y>
1248
-            <width>101</width>
1249
-            <height>21</height>
1250
-           </rect>
1251
-          </property>
1252
-          <property name="text">
1253
-           <string>Show location name</string>
1254
-          </property>
1255
-         </widget>
1256
-         <widget class="QLabel" name="label_9">
1257
-          <property name="geometry">
1258
-           <rect>
1259
-            <x>20</x>
1260
-            <y>210</y>
1261
-            <width>81</width>
1262
-            <height>21</height>
1263
-           </rect>
1264
-          </property>
1265
-          <property name="text">
1266
-           <string>Battle scene</string>
1267
-          </property>
1268
-         </widget>
1269
-         <widget class="QComboBox" name="comboBox_Location">
1270
-          <property name="geometry">
1271
-           <rect>
1272
-            <x>80</x>
1273
-            <y>60</y>
1274
-            <width>211</width>
1275
-            <height>22</height>
1276
-           </rect>
1277
-          </property>
1278
-          <property name="editable">
1279
-           <bool>true</bool>
1280
-          </property>
1281
-         </widget>
1282
-         <widget class="QComboBox" name="comboBox_Visibility">
1283
-          <property name="geometry">
1284
-           <rect>
1285
-            <x>80</x>
1286
-            <y>90</y>
1287
-            <width>211</width>
1288
-            <height>22</height>
1289
-           </rect>
1290
-          </property>
1291
-          <property name="editable">
1292
-           <bool>true</bool>
1293
-          </property>
1294
-         </widget>
1295
-         <widget class="QComboBox" name="comboBox_Song">
1296
-          <property name="geometry">
1297
-           <rect>
1298
-            <x>80</x>
1299
-            <y>30</y>
1300
-            <width>211</width>
1301
-            <height>22</height>
1302
-           </rect>
1303
-          </property>
1304
-          <property name="editable">
1305
-           <bool>true</bool>
1306
-          </property>
1307
-         </widget>
1308
-         <widget class="QComboBox" name="comboBox_Weather">
1309
-          <property name="geometry">
1310
-           <rect>
1311
-            <x>80</x>
1312
-            <y>120</y>
1313
-            <width>211</width>
1314
-            <height>22</height>
1315
-           </rect>
1316
-          </property>
1317
-          <property name="editable">
1318
-           <bool>true</bool>
1319
-          </property>
1320
-         </widget>
1321
-         <widget class="QComboBox" name="comboBox_Type">
1322
-          <property name="geometry">
1323
-           <rect>
1324
-            <x>80</x>
1325
-            <y>150</y>
1326
-            <width>211</width>
1327
-            <height>22</height>
1328
-           </rect>
1329
-          </property>
1330
-          <property name="editable">
1331
-           <bool>true</bool>
1332
-          </property>
1333
-         </widget>
1334
-         <widget class="QComboBox" name="comboBox_BattleScene">
1335
-          <property name="geometry">
1336
-           <rect>
1337
-            <x>90</x>
1338
-            <y>210</y>
1339
-            <width>201</width>
1340
-            <height>22</height>
1341
-           </rect>
1252
+         <layout class="QFormLayout" name="formLayout_2">
1253
+          <property name="verticalSpacing">
1254
+           <number>12</number>
1342 1255
           </property>
1343
-          <property name="editable">
1344
-           <bool>true</bool>
1345
-          </property>
1346
-         </widget>
1347
-         <widget class="QCheckBox" name="checkBox_ShowLocation">
1348
-          <property name="geometry">
1349
-           <rect>
1350
-            <x>130</x>
1351
-            <y>180</y>
1352
-            <width>161</width>
1353
-            <height>21</height>
1354
-           </rect>
1355
-          </property>
1356
-          <property name="text">
1357
-           <string/>
1358
-          </property>
1359
-         </widget>
1360
-         <widget class="QLabel" name="label_10">
1361
-          <property name="geometry">
1362
-           <rect>
1363
-            <x>0</x>
1364
-            <y>0</y>
1365
-            <width>47</width>
1366
-            <height>13</height>
1367
-           </rect>
1368
-          </property>
1369
-          <property name="text">
1370
-           <string>Header</string>
1371
-          </property>
1372
-         </widget>
1256
+          <item row="0" column="0">
1257
+           <widget class="QLabel" name="label_3">
1258
+            <property name="text">
1259
+             <string>Song</string>
1260
+            </property>
1261
+           </widget>
1262
+          </item>
1263
+          <item row="0" column="1">
1264
+           <widget class="QComboBox" name="comboBox_Song">
1265
+            <property name="toolTip">
1266
+             <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The default background music for this map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1267
+            </property>
1268
+            <property name="editable">
1269
+             <bool>true</bool>
1270
+            </property>
1271
+           </widget>
1272
+          </item>
1273
+          <item row="1" column="0">
1274
+           <widget class="QLabel" name="label_4">
1275
+            <property name="text">
1276
+             <string>Location</string>
1277
+            </property>
1278
+           </widget>
1279
+          </item>
1280
+          <item row="1" column="1">
1281
+           <widget class="QComboBox" name="comboBox_Location">
1282
+            <property name="toolTip">
1283
+             <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The section of the region map which the map is grouped under. This also determines the name of the map that is display when the player enters it.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1284
+            </property>
1285
+            <property name="editable">
1286
+             <bool>true</bool>
1287
+            </property>
1288
+           </widget>
1289
+          </item>
1290
+          <item row="2" column="0">
1291
+           <widget class="QLabel" name="label_5">
1292
+            <property name="text">
1293
+             <string>Requires Flash</string>
1294
+            </property>
1295
+           </widget>
1296
+          </item>
1297
+          <item row="3" column="0">
1298
+           <widget class="QLabel" name="label_6">
1299
+            <property name="text">
1300
+             <string>Weather</string>
1301
+            </property>
1302
+           </widget>
1303
+          </item>
1304
+          <item row="3" column="1">
1305
+           <widget class="QComboBox" name="comboBox_Weather">
1306
+            <property name="toolTip">
1307
+             <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The default weather for this map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1308
+            </property>
1309
+            <property name="editable">
1310
+             <bool>true</bool>
1311
+            </property>
1312
+           </widget>
1313
+          </item>
1314
+          <item row="4" column="0">
1315
+           <widget class="QLabel" name="label_7">
1316
+            <property name="text">
1317
+             <string>Type</string>
1318
+            </property>
1319
+           </widget>
1320
+          </item>
1321
+          <item row="4" column="1">
1322
+           <widget class="QComboBox" name="comboBox_Type">
1323
+            <property name="toolTip">
1324
+             <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The map type is a general attribute, which is used for many different things. For example. it determines whether biking or running is allowed.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1325
+            </property>
1326
+            <property name="editable">
1327
+             <bool>true</bool>
1328
+            </property>
1329
+           </widget>
1330
+          </item>
1331
+          <item row="5" column="0">
1332
+           <widget class="QLabel" name="label_8">
1333
+            <property name="text">
1334
+             <string>Show Location Name</string>
1335
+            </property>
1336
+           </widget>
1337
+          </item>
1338
+          <item row="5" column="1">
1339
+           <widget class="QCheckBox" name="checkBox_ShowLocation">
1340
+            <property name="toolTip">
1341
+             <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Whether or not to display the location name when the player enters the map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1342
+            </property>
1343
+            <property name="text">
1344
+             <string/>
1345
+            </property>
1346
+           </widget>
1347
+          </item>
1348
+          <item row="6" column="0">
1349
+           <widget class="QLabel" name="label_9">
1350
+            <property name="text">
1351
+             <string>Battle scene</string>
1352
+            </property>
1353
+           </widget>
1354
+          </item>
1355
+          <item row="6" column="1">
1356
+           <widget class="QComboBox" name="comboBox_BattleScene">
1357
+            <property name="toolTip">
1358
+             <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Determines the type of battle scene graphics to use.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1359
+            </property>
1360
+            <property name="editable">
1361
+             <bool>true</bool>
1362
+            </property>
1363
+           </widget>
1364
+          </item>
1365
+          <item row="2" column="1">
1366
+           <widget class="QCheckBox" name="checkBox_Visibility">
1367
+            <property name="toolTip">
1368
+             <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Whether or not the map is dark and requires Flash to illuminate.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1369
+            </property>
1370
+            <property name="text">
1371
+             <string/>
1372
+            </property>
1373
+           </widget>
1374
+          </item>
1375
+         </layout>
1373 1376
         </widget>
1374 1377
        </widget>
1375 1378
        <widget class="QWidget" name="tab_Connections">
@@ -1463,6 +1466,9 @@
1463 1466
                    <verstretch>0</verstretch>
1464 1467
                   </sizepolicy>
1465 1468
                  </property>
1469
+                 <property name="toolTip">
1470
+                  <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Add a new connection.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1471
+                 </property>
1466 1472
                  <property name="text">
1467 1473
                   <string/>
1468 1474
                  </property>
@@ -1475,6 +1481,9 @@
1475 1481
                </item>
1476 1482
                <item>
1477 1483
                 <widget class="QPushButton" name="pushButton_RemoveConnection">
1484
+                 <property name="toolTip">
1485
+                  <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Remove the currently-selected connection.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1486
+                 </property>
1478 1487
                  <property name="text">
1479 1488
                   <string/>
1480 1489
                  </property>
@@ -1523,6 +1532,9 @@
1523 1532
                    <verstretch>0</verstretch>
1524 1533
                   </sizepolicy>
1525 1534
                  </property>
1535
+                 <property name="toolTip">
1536
+                  <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If enabled, connections will automatically be updated on the connected map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1537
+                 </property>
1526 1538
                  <property name="text">
1527 1539
                   <string>Mirror</string>
1528 1540
                  </property>
@@ -1585,6 +1597,9 @@
1585 1597
                </property>
1586 1598
                <item>
1587 1599
                 <widget class="QComboBox" name="comboBox_ConnectionDirection">
1600
+                 <property name="toolTip">
1601
+                  <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The direction of the connection.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1602
+                 </property>
1588 1603
                  <item>
1589 1604
                   <property name="text">
1590 1605
                    <string>up</string>
@@ -1632,6 +1647,9 @@
1632 1647
                </item>
1633 1648
                <item>
1634 1649
                 <widget class="QComboBox" name="comboBox_ConnectedMap">
1650
+                 <property name="toolTip">
1651
+                  <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The destination map name of the connection.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1652
+                 </property>
1635 1653
                  <property name="editable">
1636 1654
                   <bool>true</bool>
1637 1655
                  </property>
@@ -1646,6 +1664,9 @@
1646 1664
                </item>
1647 1665
                <item>
1648 1666
                 <widget class="QSpinBox" name="spinBox_ConnectionOffset">
1667
+                 <property name="toolTip">
1668
+                  <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The number of metatiles to offset the connection.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1669
+                 </property>
1649 1670
                  <property name="minimum">
1650 1671
                   <number>-999</number>
1651 1672
                  </property>
@@ -1823,6 +1844,9 @@
1823 1844
                   </item>
1824 1845
                   <item>
1825 1846
                    <widget class="QComboBox" name="comboBox_DiveMap">
1847
+                    <property name="toolTip">
1848
+                     <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Destination map name when using &lt;span style=&quot; font-weight:600;&quot;&gt;Dive&lt;/span&gt;. If empty, no such connection will exist.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1849
+                    </property>
1826 1850
                     <property name="editable">
1827 1851
                      <bool>true</bool>
1828 1852
                     </property>
@@ -1837,6 +1861,9 @@
1837 1861
                   </item>
1838 1862
                   <item>
1839 1863
                    <widget class="QComboBox" name="comboBox_EmergeMap">
1864
+                    <property name="toolTip">
1865
+                     <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Destination map name when emerging using &lt;span style=&quot; font-weight:600;&quot;&gt;Dive&lt;/span&gt;. If empty, no such connection will exist.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1866
+                    </property>
1840 1867
                     <property name="editable">
1841 1868
                      <bool>true</bool>
1842 1869
                     </property>
@@ -1972,6 +1999,11 @@
1972 1999
    <extends>QToolButton</extends>
1973 2000
    <header>neweventtoolbutton.h</header>
1974 2001
   </customwidget>
2002
+  <customwidget>
2003
+   <class>NoScrollComboBox</class>
2004
+   <extends>QComboBox</extends>
2005
+   <header>noscrollcombobox.h</header>
2006
+  </customwidget>
1975 2007
  </customwidgets>
1976 2008
  <resources>
1977 2009
   <include location="resources/images.qrc"/>

+ 62
- 51
map.cpp View File

@@ -6,6 +6,7 @@
6 6
 #include <QImage>
7 7
 #include <QRegularExpression>
8 8
 
9
+
9 10
 Map::Map(QObject *parent) : QObject(parent)
10 11
 {
11 12
     paint_tile_index = 1;
@@ -276,6 +277,7 @@ QPixmap Map::render(bool ignoreCache = false) {
276 277
         cacheBlockdata();
277 278
         pixmap = pixmap.fromImage(image);
278 279
     }
280
+
279 281
     return pixmap;
280 282
 }
281 283
 
@@ -387,7 +389,7 @@ void Map::drawSelection(int i, int w, int selectionWidth, int selectionHeight, Q
387 389
     int y = i / w;
388 390
     painter->save();
389 391
 
390
-    QColor penColor = smart_paths_enabled ? QColor(0xff, 0x0, 0xff) : QColor(0xff, 0xff, 0xff);
392
+    QColor penColor = QColor(0xff, 0xff, 0xff);
391 393
     painter->setPen(penColor);
392 394
     int rectWidth = selectionWidth * 16;
393 395
     int rectHeight = selectionHeight * 16;
@@ -427,6 +429,36 @@ QPixmap Map::renderMetatiles() {
427 429
     return QPixmap::fromImage(image);
428 430
 }
429 431
 
432
+void Map::setNewDimensionsBlockdata(int newWidth, int newHeight) {
433
+    int oldWidth = getWidth();
434
+    int oldHeight = getHeight();
435
+
436
+    Blockdata* newBlockData = new Blockdata;
437
+
438
+    for (int y = 0; y < newHeight; y++)
439
+    for (int x = 0; x < newWidth; x++) {
440
+        if (x < oldWidth && y < oldHeight) {
441
+            int index = y * oldWidth + x;
442
+            newBlockData->addBlock(layout->blockdata->blocks->value(index));
443
+        } else {
444
+            newBlockData->addBlock(0);
445
+        }
446
+    }
447
+
448
+    layout->blockdata->copyFrom(newBlockData);
449
+}
450
+
451
+void Map::setDimensions(int newWidth, int newHeight, bool setNewBlockdata) {
452
+    if (setNewBlockdata) {
453
+        setNewDimensionsBlockdata(newWidth, newHeight);
454
+    }
455
+
456
+    layout->width = QString::number(newWidth);
457
+    layout->height = QString::number(newHeight);
458
+
459
+    emit mapChanged(this);
460
+}
461
+
430 462
 Block* Map::getBlock(int x, int y) {
431 463
     if (layout->blockdata && layout->blockdata->blocks) {
432 464
         if (x >= 0 && x < getWidth())
@@ -445,38 +477,6 @@ void Map::_setBlock(int x, int y, Block block) {
445 477
     }
446 478
 }
447 479
 
448
-void Map::_floodFill(int x, int y, uint tile) {
449
-    QList<QPoint> todo;
450
-    todo.append(QPoint(x, y));
451
-    while (todo.length()) {
452
-            QPoint point = todo.takeAt(0);
453
-            x = point.x();
454
-            y = point.y();
455
-            Block *block = getBlock(x, y);
456
-            if (block == NULL) {
457
-                continue;
458
-            }
459
-            uint old_tile = block->tile;
460
-            if (old_tile == tile) {
461
-                continue;
462
-            }
463
-            block->tile = tile;
464
-            _setBlock(x, y, *block);
465
-            if ((block = getBlock(x + 1, y)) && block->tile == old_tile) {
466
-                todo.append(QPoint(x + 1, y));
467
-            }
468
-            if ((block = getBlock(x - 1, y)) && block->tile == old_tile) {
469
-                todo.append(QPoint(x - 1, y));
470
-            }
471
-            if ((block = getBlock(x, y + 1)) && block->tile == old_tile) {
472
-                todo.append(QPoint(x, y + 1));
473
-            }
474
-            if ((block = getBlock(x, y - 1)) && block->tile == old_tile) {
475
-                todo.append(QPoint(x, y - 1));
476
-            }
477
-    }
478
-}
479
-
480 480
 void Map::_floodFillCollision(int x, int y, uint collision) {
481 481
     QList<QPoint> todo;
482 482
     todo.append(QPoint(x, y));
@@ -578,29 +578,48 @@ void Map::_floodFillCollisionElevation(int x, int y, uint collision, uint elevat
578 578
 
579 579
 
580 580
 void Map::undo() {
581
+    HistoryItem *commit = history.back();
582
+    if (!commit)
583
+        return;
584
+
581 585
     if (layout->blockdata) {
582
-        Blockdata *commit = history.back();
583
-        if (commit != NULL) {
584
-            layout->blockdata->copyFrom(commit);
585
-            emit mapChanged(this);
586
+        layout->blockdata->copyFrom(commit->metatiles);
587
+        if (commit->layoutWidth != this->getWidth() || commit->layoutHeight != this->getHeight())
588
+        {
589
+            this->setDimensions(commit->layoutWidth, commit->layoutHeight, false);
590
+            emit mapNeedsRedrawing(this);
586 591
         }
592
+
593
+        emit mapChanged(this);
587 594
     }
588 595
 }
589 596
 
590 597
 void Map::redo() {
598
+    HistoryItem *commit = history.next();
599
+    if (!commit)
600
+        return;
601
+
591 602
     if (layout->blockdata) {
592
-        Blockdata *commit = history.next();
593
-        if (commit != NULL) {
594
-            layout->blockdata->copyFrom(commit);
595
-            emit mapChanged(this);
603
+        layout->blockdata->copyFrom(commit->metatiles);
604
+        if (commit->layoutWidth != this->getWidth() || commit->layoutHeight != this->getHeight())
605
+        {
606
+            this->setDimensions(commit->layoutWidth, commit->layoutHeight, false);
607
+            emit mapNeedsRedrawing(this);
596 608
         }
609
+
610
+        emit mapChanged(this);
597 611
     }
598 612
 }
599 613
 
600 614
 void Map::commit() {
601 615
     if (layout->blockdata) {
602
-        if (!layout->blockdata->equals(history.current())) {
603
-            Blockdata* commit = layout->blockdata->copy();
616
+        HistoryItem *item = history.current();
617
+        bool atCurrentHistory = item
618
+                && layout->blockdata->equals(item->metatiles)
619
+                && this->getWidth() == item->layoutWidth
620
+                && this->getHeight() == item->layoutHeight;
621
+        if (!atCurrentHistory) {
622
+            HistoryItem *commit = new HistoryItem(layout->blockdata->copy(), this->getWidth(), this->getHeight());
604 623
             history.push(commit);
605 624
             emit mapChanged(this);
606 625
         }
@@ -615,14 +634,6 @@ void Map::setBlock(int x, int y, Block block) {
615 634
     }
616 635
 }
617 636
 
618
-void Map::floodFill(int x, int y, uint tile) {
619
-    Block *block = getBlock(x, y);
620
-    if (block && block->tile != tile) {
621
-        _floodFill(x, y, tile);
622
-        commit();
623
-    }
624
-}
625
-
626 637
 void Map::floodFillCollision(int x, int y, uint collision) {
627 638
     Block *block = getBlock(x, y);
628 639
     if (block && block->collision != collision) {

+ 16
- 4
map.h View File

@@ -10,6 +10,17 @@
10 10
 #include <QDebug>
11 11
 #include <QGraphicsPixmapItem>
12 12
 
13
+class HistoryItem {
14
+public:
15
+    Blockdata *metatiles;
16
+    short layoutWidth;
17
+    short layoutHeight;
18
+    HistoryItem(Blockdata *metatiles_, short layoutWidth_, short layoutHeight_) {
19
+        this->metatiles = metatiles_;
20
+        this->layoutWidth = layoutWidth_;
21
+        this->layoutHeight = layoutHeight_;
22
+    }
23
+};
13 24
 
14 25
 template <typename T>
15 26
 class History {
@@ -116,7 +127,7 @@ public:
116 127
     QString song;
117 128
     QString layout_id;
118 129
     QString location;
119
-    QString visibility;
130
+    QString requiresFlash;
120 131
     QString weather;
121 132
     QString type;
122 133
     QString unknown;
@@ -173,8 +184,6 @@ public:
173 184
     void setBlock(int x, int y, Block block);
174 185
     void _setBlock(int x, int y, Block block);
175 186
 
176
-    void floodFill(int x, int y, uint tile);
177
-    void _floodFill(int x, int y, uint tile);
178 187
     void floodFillCollision(int x, int y, uint collision);
179 188
     void _floodFillCollision(int x, int y, uint collision);
180 189
     void floodFillElevation(int x, int y, uint elevation);
@@ -182,7 +191,7 @@ public:
182 191
     void floodFillCollisionElevation(int x, int y, uint collision, uint elevation);
183 192
     void _floodFillCollisionElevation(int x, int y, uint collision, uint elevation);
184 193
 
185
-    History<Blockdata*> history;
194
+    History<HistoryItem*> history;
186 195
     void undo();
187 196
     void redo();
188 197
     void commit();
@@ -194,6 +203,8 @@ public:
194 203
 
195 204
     QList<Connection*> connections;
196 205
     QPixmap renderConnection(Connection);
206
+    void setNewDimensionsBlockdata(int newWidth, int newHeight);
207
+    void setDimensions(int newWidth, int newHeight, bool setNewBlockData = true);
197 208
 
198 209
     QPixmap renderBorder();
199 210
     void cacheBorder();
@@ -212,6 +223,7 @@ signals:
212 223
     void paintTileChanged(Map *map);
213 224
     void paintCollisionChanged(Map *map);
214 225
     void mapChanged(Map *map);
226
+    void mapNeedsRedrawing(Map *map);
215 227
     void statusBarMessage(QString);
216 228
 
217 229
 public slots:

+ 15
- 0
noscrollcombobox.cpp View File

@@ -0,0 +1,15 @@
1
+#include "noscrollcombobox.h"
2
+
3
+NoScrollComboBox::NoScrollComboBox(QWidget *parent)
4
+    : QComboBox(parent)
5
+{
6
+    // Don't let scrolling hijack focus.
7
+    setFocusPolicy(Qt::StrongFocus);
8
+}
9
+
10
+void NoScrollComboBox::wheelEvent(QWheelEvent *event)
11
+{
12
+    // Only allow scrolling to modify contents when it explicitly has focus.
13
+    if (hasFocus())
14
+        QComboBox::wheelEvent(event);
15
+}

+ 17
- 0
noscrollcombobox.h View File

@@ -0,0 +1,17 @@
1
+#ifndef NOSCROLLCOMBOBOX_H
2
+#define NOSCROLLCOMBOBOX_H
3
+
4
+#include <QComboBox>
5
+
6
+class NoScrollComboBox : public QComboBox
7
+{
8
+    Q_OBJECT
9
+
10
+public:
11
+    explicit NoScrollComboBox(QWidget *parent = nullptr);
12
+    void wheelEvent(QWheelEvent *event);
13
+
14
+private:
15
+};
16
+
17
+#endif // NOSCROLLCOMBOBOX_H

+ 16
- 0
noscrollspinbox.cpp View File

@@ -0,0 +1,16 @@
1
+#include "noscrollspinbox.h"
2
+
3
+NoScrollSpinBox::NoScrollSpinBox(QWidget *parent)
4
+    : QSpinBox(parent)
5
+{
6
+    // Don't let scrolling hijack focus.
7
+    setFocusPolicy(Qt::StrongFocus);
8
+}
9
+
10
+void NoScrollSpinBox::wheelEvent(QWheelEvent *event)
11
+{
12
+    // Only allow scrolling to modify contents when it explicitly has focus.
13
+    if (hasFocus())
14
+        QSpinBox::wheelEvent(event);
15
+}
16
+

+ 17
- 0
noscrollspinbox.h View File

@@ -0,0 +1,17 @@
1
+#ifndef NOSCROLLSPINBOX_H
2
+#define NOSCROLLSPINBOX_H
3
+
4
+#include <QSpinBox>
5
+
6
+class NoScrollSpinBox : public QSpinBox
7
+{
8
+    Q_OBJECT
9
+
10
+public:
11
+    explicit NoScrollSpinBox(QWidget *parent = nullptr);
12
+    void wheelEvent(QWheelEvent *event);
13
+
14
+private:
15
+};
16
+
17
+#endif // NOSCROLLSPINBOX_H

+ 40
- 4
objectpropertiesframe.ui View File

@@ -105,7 +105,13 @@
105 105
              </widget>
106 106
             </item>
107 107
             <item>
108
-             <widget class="QSpinBox" name="spinBox_x">
108
+             <widget class="NoScrollSpinBox" name="spinBox_x">
109
+              <property name="focusPolicy">
110
+               <enum>Qt::StrongFocus</enum>
111
+              </property>
112
+              <property name="toolTip">
113
+               <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The X coordinate of this object.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
114
+              </property>
109 115
               <property name="minimum">
110 116
                <number>-32768</number>
111 117
               </property>
@@ -129,7 +135,13 @@
129 135
              </widget>
130 136
             </item>
131 137
             <item>
132
-             <widget class="QSpinBox" name="spinBox_y">
138
+             <widget class="NoScrollSpinBox" name="spinBox_y">
139
+              <property name="focusPolicy">
140
+               <enum>Qt::StrongFocus</enum>
141
+              </property>
142
+              <property name="toolTip">
143
+               <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The Y coordinate of this object.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
144
+              </property>
133 145
               <property name="minimum">
134 146
                <number>-32768</number>
135 147
               </property>
@@ -153,7 +165,13 @@
153 165
              </widget>
154 166
             </item>
155 167
             <item>
156
-             <widget class="QSpinBox" name="spinBox_z">
168
+             <widget class="NoScrollSpinBox" name="spinBox_z">
169
+              <property name="focusPolicy">
170
+               <enum>Qt::StrongFocus</enum>
171
+              </property>
172
+              <property name="toolTip">
173
+               <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The elevation of this object.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
174
+              </property>
157 175
               <property name="maximum">
158 176
                <number>15</number>
159 177
               </property>
@@ -210,7 +228,7 @@
210 228
        </widget>
211 229
       </item>
212 230
       <item row="0" column="1">
213
-       <widget class="QComboBox" name="comboBox_sprite">
231
+       <widget class="NoScrollComboBox" name="comboBox_sprite">
214 232
         <property name="enabled">
215 233
          <bool>true</bool>
216 234
         </property>
@@ -220,6 +238,12 @@
220 238
           <verstretch>0</verstretch>
221 239
          </sizepolicy>
222 240
         </property>
241
+        <property name="focusPolicy">
242
+         <enum>Qt::StrongFocus</enum>
243
+        </property>
244
+        <property name="toolTip">
245
+         <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The sprite graphics to use for this object.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
246
+        </property>
223 247
         <property name="editable">
224 248
          <bool>true</bool>
225 249
         </property>
@@ -239,6 +263,18 @@
239 263
    </item>
240 264
   </layout>
241 265
  </widget>
266
+ <customwidgets>
267
+  <customwidget>
268
+   <class>NoScrollComboBox</class>
269
+   <extends>QComboBox</extends>
270
+   <header>noscrollcombobox.h</header>
271
+  </customwidget>
272
+  <customwidget>
273
+   <class>NoScrollSpinBox</class>
274
+   <extends>QSpinBox</extends>
275
+   <header>noscrollspinbox.h</header>
276
+  </customwidget>
277
+ </customwidgets>
242 278
  <tabstops>
243 279
   <tabstop>spinBox_x</tabstop>
244 280
   <tabstop>spinBox_y</tabstop>

+ 6
- 2
pretmap.pro View File

@@ -25,7 +25,9 @@ SOURCES += main.cpp\
25 25
     objectpropertiesframe.cpp \
26 26
     graphicsview.cpp \
27 27
     parseutil.cpp \
28
-    neweventtoolbutton.cpp
28
+    neweventtoolbutton.cpp \
29
+    noscrollcombobox.cpp \
30
+    noscrollspinbox.cpp
29 31
 
30 32
 HEADERS  += mainwindow.h \
31 33
     project.h \
@@ -39,7 +41,9 @@ HEADERS  += mainwindow.h \
39 41
     objectpropertiesframe.h \
40 42
     graphicsview.h \
41 43
     parseutil.h \
42
-    neweventtoolbutton.h
44
+    neweventtoolbutton.h \
45
+    noscrollcombobox.h \
46
+    noscrollspinbox.h
43 47
 
44 48
 FORMS    += mainwindow.ui \
45 49
     objectpropertiesframe.ui

+ 67
- 55
project.cpp View File

@@ -17,9 +17,17 @@ Project::Project()
17 17
     groupNames = new QStringList;
18 18
     map_groups = new QMap<QString, int>;
19 19
     mapNames = new QStringList;
20
+    regionMapSections = new QStringList;
20 21
     itemNames = new QStringList;
21 22
     flagNames = new QStringList;
22 23
     varNames = new QStringList;
24
+    movementTypes = new QStringList;
25
+    mapTypes = new QStringList;
26
+    mapBattleScenes = new QStringList;
27
+    weatherNames = new QStringList;
28
+    coordEventWeatherNames = new QStringList;
29
+    secretBaseIds = new QStringList;
30
+    bgEventFacingDirections = new QStringList;
23 31
     map_cache = new QMap<QString, Map*>;
24 32
     mapConstantsToMapNames = new QMap<QString, QString>;
25 33
     mapNamesToMapConstants = new QMap<QString, QString>;
@@ -164,7 +172,7 @@ void Project::readMapHeader(Map* map) {
164 172
     map->song = header->value(4);
165 173
     map->layout_id = header->value(5);
166 174
     map->location = header->value(6);
167
-    map->visibility = header->value(7);
175
+    map->requiresFlash = header->value(7);
168 176
     map->weather = header->value(8);
169 177
     map->type = header->value(9);
170 178
     map->unknown = header->value(10);
@@ -179,13 +187,13 @@ void Project::setNewMapHeader(Map* map, int mapIndex) {
179 187
     map->connections_label = "0x0";
180 188
     map->song = "MUS_DAN02";
181 189
     map->layout_id = QString("%1").arg(mapIndex);
182
-    map->location = "0";
183
-    map->visibility = "0";
184
-    map->weather = "2";
185
-    map->type = "1";
190
+    map->location = "MAPSEC_LITTLEROOT_TOWN";
191
+    map->requiresFlash = "FALSE";
192
+    map->weather = "WEATHER_SUNNY";
193
+    map->type = "MAP_TYPE_TOWN";
186 194
     map->unknown = "0";
187
-    map->show_location = "1";
188
-    map->battle_scene = "0";
195
+    map->show_location = "TRUE";
196
+    map->battle_scene = "MAP_BATTLE_SCENE_NORMAL";
189 197
 }
190 198
 
191 199
 void Project::saveMapHeader(Map *map) {
@@ -207,7 +215,7 @@ void Project::saveMapHeader(Map *map) {
207 215
     text += QString("\t.2byte %1\n").arg(map->song);
208 216
     text += QString("\t.2byte %1\n").arg(map->layout_id);
209 217
     text += QString("\t.byte %1\n").arg(map->location);
210
-    text += QString("\t.byte %1\n").arg(map->visibility);
218
+    text += QString("\t.byte %1\n").arg(map->requiresFlash);
211 219
     text += QString("\t.byte %1\n").arg(map->weather);
212 220
     text += QString("\t.byte %1\n").arg(map->type);
213 221
     text += QString("\t.2byte %1\n").arg(map->unknown);
@@ -982,15 +990,6 @@ QList<QStringList>* Project::parseAsm(QString text) {
982 990
     return parser->parseAsm(text);
983 991
 }
984 992
 
985
-QStringList Project::getLocations() {
986
-    // TODO
987
-    QStringList names;
988
-    for (int i = 0; i < 88; i++) {
989
-        names.append(QString("%1").arg(i));
990
-    }
991
-    return names;
992
-}
993
-
994 993
 QStringList Project::getVisibilities() {
995 994
     // TODO
996 995
     QStringList names;
@@ -1041,31 +1040,10 @@ QMap<QString, QStringList> Project::getTilesets() {
1041 1040
     return allTilesets;
1042 1041
 }
1043 1042
 
1044
-QStringList Project::getWeathers() {
1045
-    // TODO
1046
-    QStringList names;
1047
-    for (int i = 0; i < 16; i++) {
1048
-        names.append(QString("%1").arg(i));
1049
-    }
1050
-    return names;
1051
-}
1052
-
1053
-QStringList Project::getMapTypes() {
1054
-    // TODO
1055
-    QStringList names;
1056
-    for (int i = 0; i < 16; i++) {
1057
-        names.append(QString("%1").arg(i));
1058
-    }
1059
-    return names;
1060
-}
1061
-
1062
-QStringList Project::getBattleScenes() {
1063
-    // TODO
1064
-    QStringList names;
1065
-    for (int i = 0; i < 16; i++) {
1066
-        names.append(QString("%1").arg(i));
1067
-    }
1068
-    return names;
1043
+void Project::readRegionMapSections() {
1044
+    QString filepath = root + "/include/constants/region_map_sections.h";
1045
+    QStringList prefixes = (QStringList() << "MAPSEC_");
1046
+    readCDefinesSorted(filepath, prefixes, regionMapSections);
1069 1047
 }
1070 1048
 
1071 1049
 void Project::readItemNames() {
@@ -1086,6 +1064,48 @@ void Project::readVarNames() {
1086 1064
     readCDefinesSorted(filepath, prefixes, varNames);
1087 1065
 }
1088 1066
 
1067
+void Project::readMovementTypes() {
1068
+    QString filepath = root + "/include/constants/event_object_movement_constants.h";
1069
+    QStringList prefixes = (QStringList() << "MOVEMENT_TYPE_");
1070
+    readCDefinesSorted(filepath, prefixes, movementTypes);
1071
+}
1072
+
1073
+void Project::readMapTypes() {
1074
+    QString filepath = root + "/include/constants/map_types.h";
1075
+    QStringList prefixes = (QStringList() << "MAP_TYPE_");
1076
+    readCDefinesSorted(filepath, prefixes, mapTypes);
1077
+}
1078
+
1079
+void Project::readMapBattleScenes() {
1080
+    QString filepath = root + "/include/constants/map_types.h";
1081
+    QStringList prefixes = (QStringList() << "MAP_BATTLE_SCENE_");
1082
+    readCDefinesSorted(filepath, prefixes, mapBattleScenes);
1083
+}
1084
+
1085
+void Project::readWeatherNames() {
1086
+    QString filepath = root + "/include/constants/weather.h";
1087
+    QStringList prefixes = (QStringList() << "WEATHER_");
1088
+    readCDefinesSorted(filepath, prefixes, weatherNames);
1089
+}
1090
+
1091
+void Project::readCoordEventWeatherNames() {
1092
+    QString filepath = root + "/include/constants/weather.h";
1093
+    QStringList prefixes = (QStringList() << "COORD_EVENT_WEATHER_");
1094
+    readCDefinesSorted(filepath, prefixes, coordEventWeatherNames);
1095
+}
1096
+
1097
+void Project::readSecretBaseIds() {
1098
+    QString filepath = root + "/include/constants/secret_bases.h";
1099
+    QStringList prefixes = (QStringList() << "SECRET_BASE_");
1100
+    readCDefinesSorted(filepath, prefixes, secretBaseIds);
1101
+}
1102
+
1103
+void Project::readBgEventFacingDirections() {
1104
+    QString filepath = root + "/include/constants/bg_event_constants.h";
1105
+    QStringList prefixes = (QStringList() << "BG_EVENT_PLAYER_FACING_");
1106
+    readCDefinesSorted(filepath, prefixes, bgEventFacingDirections);
1107
+}
1108
+
1089 1109
 void Project::readCDefinesSorted(QString filepath, QStringList prefixes, QStringList* definesToSet) {
1090 1110
     QString text = readTextFile(filepath);
1091 1111
     if (!text.isNull()) {
@@ -1098,6 +1118,8 @@ void Project::readCDefinesSorted(QString filepath, QStringList prefixes, QString
1098 1118
             definesInverse.insert(defines[defineName], defineName);
1099 1119
         }
1100 1120
         *definesToSet = definesInverse.values();
1121
+    } else {
1122
+        qDebug() << "Failed to read C defines file: " << filepath;
1101 1123
     }
1102 1124
 }
1103 1125
 
@@ -1319,10 +1341,10 @@ void Project::readMapEvents(Map *map) {
1319 1341
             object->put("x", command.value(i++).toInt(nullptr, 0));
1320 1342
             object->put("y", command.value(i++).toInt(nullptr, 0));
1321 1343
             object->put("elevation", command.value(i++));
1322
-            object->put("behavior", command.value(i++));
1344
+            object->put("movement_type", command.value(i++));
1323 1345
             object->put("radius_x", command.value(i++).toInt(nullptr, 0));
1324 1346
             object->put("radius_y", command.value(i++).toInt(nullptr, 0));
1325
-            object->put("trainer_see_type", command.value(i++));
1347
+            object->put("is_trainer", command.value(i++));
1326 1348
             object->put("sight_radius_tree_id", command.value(i++));
1327 1349
             object->put("script_label", command.value(i++));
1328 1350
             object->put("event_flag", command.value(i++));
@@ -1363,12 +1385,6 @@ void Project::readMapEvents(Map *map) {
1363 1385
         if (command.value(0) == "coord_event") {
1364 1386
             Event *coord = new Event;
1365 1387
             coord->put("map_name", map->name);
1366
-            bool old_macro = false;
1367
-            if (command.length() >= 9) {
1368
-                command.removeAt(7);
1369
-                command.removeAt(4);
1370
-                old_macro = true;
1371
-            }
1372 1388
             int i = 1;
1373 1389
             coord->put("x", command.value(i++));
1374 1390
             coord->put("y", command.value(i++));
@@ -1376,9 +1392,6 @@ void Project::readMapEvents(Map *map) {
1376 1392
             coord->put("script_var", command.value(i++));
1377 1393
             coord->put("script_var_value", command.value(i++));
1378 1394
             coord->put("script_label", command.value(i++));
1379
-            //coord_unknown3
1380
-            //coord_unknown4
1381
-
1382 1395
             coord->put("event_group_type", "coord_event_group");
1383 1396
             coord->put("event_type", EventType::CoordScript);
1384 1397
             map->events["coord_event_group"].append(coord);
@@ -1407,7 +1420,6 @@ void Project::readMapEvents(Map *map) {
1407 1420
             bg->put("y", command.value(i++));
1408 1421
             bg->put("elevation", command.value(i++));
1409 1422
             bg->put("player_facing_direction", command.value(i++));
1410
-            i++;
1411 1423
             bg->put("script_label", command.value(i++));
1412 1424
             //sign_unknown7
1413 1425
             bg->put("event_group_type", "bg_event_group");
@@ -1432,7 +1444,7 @@ void Project::readMapEvents(Map *map) {
1432 1444
             bg->put("x", command.value(i++));
1433 1445
             bg->put("y", command.value(i++));
1434 1446
             bg->put("elevation", command.value(i++));
1435
-            bg->put("secret_base_map", command.value(i++));
1447
+            bg->put("secret_base_id", command.value(i++));
1436 1448
             bg->put("event_group_type", "bg_event_group");
1437 1449
             bg->put("event_type", EventType::SecretBase);
1438 1450
             map->events["bg_event_group"].append(bg);

+ 16
- 4
project.h View File

@@ -23,9 +23,17 @@ public:
23 23
     QList<QString> mapLayoutsTableMaster;
24 24
     QMap<QString, MapLayout*> mapLayouts;
25 25
     QMap<QString, MapLayout*> mapLayoutsMaster;
26
+    QStringList *regionMapSections = NULL;
26 27
     QStringList *itemNames = NULL;
27 28
     QStringList *flagNames = NULL;
28 29
     QStringList *varNames = NULL;
30
+    QStringList *movementTypes = NULL;
31
+    QStringList *mapTypes = NULL;
32
+    QStringList *mapBattleScenes = NULL;
33
+    QStringList *weatherNames = NULL;
34
+    QStringList *coordEventWeatherNames = NULL;
35
+    QStringList *secretBaseIds = NULL;
36
+    QStringList *bgEventFacingDirections = NULL;
29 37
     QStringList mapsWithConnections;
30 38
 
31 39
     QMap<QString, Map*> *map_cache;
@@ -72,15 +80,19 @@ public:
72 80
 
73 81
     QList<QStringList>* parseAsm(QString text);
74 82
     QStringList getSongNames();
75
-    QStringList getLocations();
76 83
     QStringList getVisibilities();
77 84
     QMap<QString, QStringList> getTilesets();
78
-    QStringList getWeathers();
79
-    QStringList getMapTypes();
80
-    QStringList getBattleScenes();
85
+    void readRegionMapSections();
81 86
     void readItemNames();
82 87
     void readFlagNames();
83 88
     void readVarNames();
89
+    void readMovementTypes();
90
+    void readMapTypes();
91
+    void readMapBattleScenes();
92
+    void readWeatherNames();
93
+    void readCoordEventWeatherNames();
94
+    void readSecretBaseIds();
95
+    void readBgEventFacingDirections();
84 96
 
85 97
     void loadEventPixmaps(QList<Event*> objects);
86 98
     QMap<QString, int> getEventObjGfxConstants();