|
@@ -306,7 +306,7 @@ void Editor::onBorderMetatilesChanged() {
|
306
|
306
|
}
|
307
|
307
|
|
308
|
308
|
void Editor::setConnectionsVisibility(bool visible) {
|
309
|
|
- for (QGraphicsPixmapItem* item : map->connection_items) {
|
|
309
|
+ for (QGraphicsPixmapItem* item : connection_items) {
|
310
|
310
|
item->setVisible(visible);
|
311
|
311
|
item->setActive(visible);
|
312
|
312
|
}
|
|
@@ -348,8 +348,13 @@ void Editor::mouseEvent_collision(QGraphicsSceneMouseEvent *event, CollisionPixm
|
348
|
348
|
}
|
349
|
349
|
|
350
|
350
|
void Editor::displayMap() {
|
351
|
|
- scene = new QGraphicsScene;
|
|
351
|
+ if (!scene)
|
|
352
|
+ scene = new QGraphicsScene;
|
352
|
353
|
|
|
354
|
+ if (map_item && scene) {
|
|
355
|
+ scene->removeItem(map_item);
|
|
356
|
+ delete map_item;
|
|
357
|
+ }
|
353
|
358
|
map_item = new MapPixmapItem(map);
|
354
|
359
|
connect(map_item, SIGNAL(mouseEvent(QGraphicsSceneMouseEvent*,MapPixmapItem*)),
|
355
|
360
|
this, SLOT(mouseEvent_map(QGraphicsSceneMouseEvent*,MapPixmapItem*)));
|
|
@@ -357,6 +362,10 @@ void Editor::displayMap() {
|
357
|
362
|
map_item->draw(true);
|
358
|
363
|
scene->addItem(map_item);
|
359
|
364
|
|
|
365
|
+ if (collision_item && scene) {
|
|
366
|
+ scene->removeItem(collision_item);
|
|
367
|
+ delete collision_item;
|
|
368
|
+ }
|
360
|
369
|
collision_item = new CollisionPixmapItem(map);
|
361
|
370
|
connect(collision_item, SIGNAL(mouseEvent(QGraphicsSceneMouseEvent*,CollisionPixmapItem*)),
|
362
|
371
|
this, SLOT(mouseEvent_collision(QGraphicsSceneMouseEvent*,CollisionPixmapItem*)));
|
|
@@ -364,19 +373,6 @@ void Editor::displayMap() {
|
364
|
373
|
collision_item->draw(true);
|
365
|
374
|
scene->addItem(collision_item);
|
366
|
375
|
|
367
|
|
- events_group = new EventGroup;
|
368
|
|
- scene->addItem(events_group);
|
369
|
|
-
|
370
|
|
- if (map_item) {
|
371
|
|
- map_item->setVisible(false);
|
372
|
|
- }
|
373
|
|
- if (collision_item) {
|
374
|
|
- collision_item->setVisible(false);
|
375
|
|
- }
|
376
|
|
- if (events_group) {
|
377
|
|
- events_group->setVisible(false);
|
378
|
|
- }
|
379
|
|
-
|
380
|
376
|
int tw = 16;
|
381
|
377
|
int th = 16;
|
382
|
378
|
scene->setSceneRect(
|
|
@@ -394,9 +390,24 @@ void Editor::displayMap() {
|
394
|
390
|
displayMapConnections();
|
395
|
391
|
displayMapBorder();
|
396
|
392
|
displayMapGrid();
|
|
393
|
+
|
|
394
|
+ if (map_item) {
|
|
395
|
+ map_item->setVisible(false);
|
|
396
|
+ }
|
|
397
|
+ if (collision_item) {
|
|
398
|
+ collision_item->setVisible(false);
|
|
399
|
+ }
|
|
400
|
+ if (events_group) {
|
|
401
|
+ events_group->setVisible(false);
|
|
402
|
+ }
|
397
|
403
|
}
|
398
|
404
|
|
399
|
405
|
void Editor::displayMetatiles() {
|
|
406
|
+ if (metatiles_item && metatiles_item->scene()) {
|
|
407
|
+ metatiles_item->scene()->removeItem(metatiles_item);
|
|
408
|
+ delete metatiles_item;
|
|
409
|
+ }
|
|
410
|
+
|
400
|
411
|
scene_metatiles = new QGraphicsScene;
|
401
|
412
|
metatiles_item = new MetatilesPixmapItem(map);
|
402
|
413
|
metatiles_item->draw();
|
|
@@ -404,6 +415,11 @@ void Editor::displayMetatiles() {
|
404
|
415
|
}
|
405
|
416
|
|
406
|
417
|
void Editor::displayBorderMetatiles() {
|
|
418
|
+ if (selected_border_metatiles_item && selected_border_metatiles_item->scene()) {
|
|
419
|
+ selected_border_metatiles_item->scene()->removeItem(selected_border_metatiles_item);
|
|
420
|
+ delete selected_border_metatiles_item;
|
|
421
|
+ }
|
|
422
|
+
|
407
|
423
|
scene_selected_border_metatiles = new QGraphicsScene;
|
408
|
424
|
selected_border_metatiles_item = new BorderMetatilesPixmapItem(map);
|
409
|
425
|
selected_border_metatiles_item->draw();
|
|
@@ -413,6 +429,11 @@ void Editor::displayBorderMetatiles() {
|
413
|
429
|
}
|
414
|
430
|
|
415
|
431
|
void Editor::displayCollisionMetatiles() {
|
|
432
|
+ if (collision_metatiles_item && collision_metatiles_item->scene()) {
|
|
433
|
+ collision_metatiles_item->scene()->removeItem(collision_metatiles_item);
|
|
434
|
+ delete collision_metatiles_item;
|
|
435
|
+ }
|
|
436
|
+
|
416
|
437
|
scene_collision_metatiles = new QGraphicsScene;
|
417
|
438
|
collision_metatiles_item = new CollisionMetatilesPixmapItem(map);
|
418
|
439
|
collision_metatiles_item->draw();
|
|
@@ -420,6 +441,11 @@ void Editor::displayCollisionMetatiles() {
|
420
|
441
|
}
|
421
|
442
|
|
422
|
443
|
void Editor::displayElevationMetatiles() {
|
|
444
|
+ if (elevation_metatiles_item && elevation_metatiles_item->scene()) {
|
|
445
|
+ elevation_metatiles_item->scene()->removeItem(elevation_metatiles_item);
|
|
446
|
+ delete elevation_metatiles_item;
|
|
447
|
+ }
|
|
448
|
+
|
423
|
449
|
scene_elevation_metatiles = new QGraphicsScene;
|
424
|
450
|
elevation_metatiles_item = new ElevationMetatilesPixmapItem(map);
|
425
|
451
|
elevation_metatiles_item->draw();
|
|
@@ -427,10 +453,22 @@ void Editor::displayElevationMetatiles() {
|
427
|
453
|
}
|
428
|
454
|
|
429
|
455
|
void Editor::displayMapEvents() {
|
430
|
|
- for (QGraphicsItem *child : events_group->childItems()) {
|
431
|
|
- events_group->removeFromGroup(child);
|
|
456
|
+ if (events_group) {
|
|
457
|
+ for (QGraphicsItem *child : events_group->childItems()) {
|
|
458
|
+ events_group->removeFromGroup(child);
|
|
459
|
+ delete child;
|
|
460
|
+ }
|
|
461
|
+
|
|
462
|
+ if (events_group->scene()) {
|
|
463
|
+ events_group->scene()->removeItem(events_group);
|
|
464
|
+ }
|
|
465
|
+
|
|
466
|
+ delete events_group;
|
432
|
467
|
}
|
433
|
468
|
|
|
469
|
+ events_group = new EventGroup;
|
|
470
|
+ scene->addItem(events_group);
|
|
471
|
+
|
434
|
472
|
QList<Event *> events = map->getAllEvents();
|
435
|
473
|
project->loadEventPixmaps(events);
|
436
|
474
|
for (Event *event : events) {
|
|
@@ -450,12 +488,18 @@ DraggablePixmapItem *Editor::addMapEvent(Event *event) {
|
450
|
488
|
}
|
451
|
489
|
|
452
|
490
|
void Editor::displayMapConnections() {
|
453
|
|
- for (QGraphicsPixmapItem* item : map->connection_items) {
|
|
491
|
+ for (QGraphicsPixmapItem* item : connection_items) {
|
|
492
|
+ if (item->scene()) {
|
|
493
|
+ item->scene()->removeItem(item);
|
|
494
|
+ }
|
454
|
495
|
delete item;
|
455
|
496
|
}
|
456
|
|
- map->connection_items.clear();
|
|
497
|
+ connection_items.clear();
|
457
|
498
|
|
458
|
499
|
for (ConnectionPixmapItem* item : connection_edit_items) {
|
|
500
|
+ if (item->scene()) {
|
|
501
|
+ item->scene()->removeItem(item);
|
|
502
|
+ }
|
459
|
503
|
delete item;
|
460
|
504
|
}
|
461
|
505
|
selected_connection_item = NULL;
|
|
@@ -497,7 +541,7 @@ void Editor::createConnectionItem(Connection* connection, bool hide) {
|
497
|
541
|
item->setX(x);
|
498
|
542
|
item->setY(y);
|
499
|
543
|
scene->addItem(item);
|
500
|
|
- map->connection_items.append(item);
|
|
544
|
+ connection_items.append(item);
|
501
|
545
|
item->setVisible(!hide);
|
502
|
546
|
|
503
|
547
|
ConnectionPixmapItem *connection_edit_item = new ConnectionPixmapItem(pixmap, connection, x, y, map->getWidth(), map->getHeight());
|
|
@@ -512,6 +556,14 @@ void Editor::createConnectionItem(Connection* connection, bool hide) {
|
512
|
556
|
}
|
513
|
557
|
|
514
|
558
|
void Editor::displayMapBorder() {
|
|
559
|
+ for (QGraphicsPixmapItem* item : borderItems) {
|
|
560
|
+ if (item->scene()) {
|
|
561
|
+ item->scene()->removeItem(item);
|
|
562
|
+ }
|
|
563
|
+ delete item;
|
|
564
|
+ }
|
|
565
|
+ borderItems.clear();
|
|
566
|
+
|
515
|
567
|
QPixmap pixmap = map->renderBorder();
|
516
|
568
|
for (int y = -6; y < map->getHeight() + 6; y += 2)
|
517
|
569
|
for (int x = -6; x < map->getWidth() + 6; x += 2) {
|
|
@@ -525,18 +577,29 @@ void Editor::displayMapBorder() {
|
525
|
577
|
}
|
526
|
578
|
|
527
|
579
|
void Editor::displayMapGrid() {
|
|
580
|
+ for (QGraphicsLineItem* item : gridLines) {
|
|
581
|
+ if (item && item->scene()) {
|
|
582
|
+ item->scene()->removeItem(item);
|
|
583
|
+ }
|
|
584
|
+ delete item;
|
|
585
|
+ }
|
|
586
|
+ gridLines.clear();
|
|
587
|
+ ui->checkBox_ToggleGrid->disconnect();
|
|
588
|
+
|
528
|
589
|
int pixelWidth = map->getWidth() * 16;
|
529
|
590
|
int pixelHeight = map->getHeight() * 16;
|
530
|
591
|
for (int i = 0; i <= map->getWidth(); i++) {
|
531
|
592
|
int x = i * 16;
|
532
|
593
|
QGraphicsLineItem *line = scene->addLine(x, 0, x, pixelHeight);
|
533
|
594
|
line->setVisible(ui->checkBox_ToggleGrid->isChecked());
|
|
595
|
+ gridLines.append(line);
|
534
|
596
|
connect(ui->checkBox_ToggleGrid, &QCheckBox::toggled, [=](bool checked){line->setVisible(checked);});
|
535
|
597
|
}
|
536
|
598
|
for (int j = 0; j <= map->getHeight(); j++) {
|
537
|
599
|
int y = j * 16;
|
538
|
600
|
QGraphicsLineItem *line = scene->addLine(0, y, pixelWidth, y);
|
539
|
601
|
line->setVisible(ui->checkBox_ToggleGrid->isChecked());
|
|
602
|
+ gridLines.append(line);
|
540
|
603
|
connect(ui->checkBox_ToggleGrid, &QCheckBox::toggled, [=](bool checked){line->setVisible(checked);});
|
541
|
604
|
}
|
542
|
605
|
}
|
|
@@ -679,8 +742,11 @@ void Editor::removeCurrentConnection() {
|
679
|
742
|
connection_edit_items.removeOne(selected_connection_item);
|
680
|
743
|
removeMirroredConnection(selected_connection_item->connection);
|
681
|
744
|
|
682
|
|
- scene->removeItem(selected_connection_item);
|
683
|
|
- delete selected_connection_item;
|
|
745
|
+ if (selected_connection_item && selected_connection_item->scene()) {
|
|
746
|
+ selected_connection_item->scene()->removeItem(selected_connection_item);
|
|
747
|
+ delete selected_connection_item;
|
|
748
|
+ }
|
|
749
|
+
|
684
|
750
|
selected_connection_item = NULL;
|
685
|
751
|
setConnectionEditControlsEnabled(false);
|
686
|
752
|
ui->spinBox_ConnectionOffset->setValue(0);
|
|
@@ -737,6 +803,20 @@ void Editor::updateDiveEmergeMap(QString mapName, QString direction) {
|
737
|
803
|
ui->label_NumConnections->setText(QString::number(map->connections.length()));
|
738
|
804
|
}
|
739
|
805
|
|
|
806
|
+void Editor::updatePrimaryTileset(QString tilesetLabel)
|
|
807
|
+{
|
|
808
|
+ map->layout->tileset_primary_label = tilesetLabel;
|
|
809
|
+ map->layout->tileset_primary = project->getTileset(tilesetLabel);
|
|
810
|
+ emit tilesetChanged(map->name);
|
|
811
|
+}
|
|
812
|
+
|
|
813
|
+void Editor::updateSecondaryTileset(QString tilesetLabel)
|
|
814
|
+{
|
|
815
|
+ map->layout->tileset_secondary_label = tilesetLabel;
|
|
816
|
+ map->layout->tileset_secondary = project->getTileset(tilesetLabel);
|
|
817
|
+ emit tilesetChanged(map->name);
|
|
818
|
+}
|
|
819
|
+
|
740
|
820
|
void MetatilesPixmapItem::paintTileChanged(Map *map) {
|
741
|
821
|
draw();
|
742
|
822
|
}
|