From b3a30c91ae3d62903b853bf58fa22019751996b7 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Sat, 15 Sep 2018 15:25:34 -0500 Subject: [PATCH 1/5] Properly read dynamically-set warps that use MAP_NONE as their destination --- editor.cpp | 5 ++++- project.cpp | 9 +++++++++ project.h | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/editor.cpp b/editor.cpp index 375c4ebf..cc550aaa 100755 --- a/editor.cpp +++ b/editor.cpp @@ -1700,7 +1700,10 @@ void DraggablePixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *) { void DraggablePixmapItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *) { if (this->event->get("event_type") == EventType::Warp) { - emit editor->warpEventDoubleClicked(this->event->get("destination_map_name"), this->event->get("destination_warp")); + QString destMap = this->event->get("destination_map_name"); + if (destMap != NONE_MAP_NAME) { + emit editor->warpEventDoubleClicked(this->event->get("destination_map_name"), this->event->get("destination_warp")); + } } } diff --git a/project.cpp b/project.cpp index b01d6aa5..fa886dec 100755 --- a/project.cpp +++ b/project.cpp @@ -1010,6 +1010,10 @@ void Project::readMapGroups() { } } + mapConstantsToMapNames->insert(NONE_MAP_CONSTANT, NONE_MAP_NAME); + mapNamesToMapConstants->insert(NONE_MAP_NAME, NONE_MAP_CONSTANT); + maps->append(NONE_MAP_NAME); + groupNames = groups; groupedMapNames = groupedMaps; mapNames = maps; @@ -1473,6 +1477,11 @@ void Project::readMapEvents(Map *map) { warp->put("event_group_type", "warp_event_group"); warp->put("event_type", EventType::Warp); map->events["warp_event_group"].append(warp); + } else if (mapConstant == NONE_MAP_CONSTANT) { + warp->put("destination_map_name", NONE_MAP_NAME); + warp->put("event_group_type", "warp_event_group"); + warp->put("event_type", EventType::Warp); + map->events["warp_event_group"].append(warp); } else { qDebug() << QString("Destination map constant '%1' is invalid for warp").arg(mapConstant); } diff --git a/project.h b/project.h index 454cb676..fb630f38 100755 --- a/project.h +++ b/project.h @@ -9,6 +9,9 @@ #include #include +static QString NONE_MAP_CONSTANT = "MAP_NONE"; +static QString NONE_MAP_NAME = "None"; + class Project { public: From 23f2016e2663c93824762af8ce616193a0a2fa6a Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Sun, 16 Sep 2018 11:21:53 -0500 Subject: [PATCH 2/5] Update tileset image palette processing, to accompany RGB-indexed images, rather than greyscale --- project.cpp | 2 +- tileset.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/project.cpp b/project.cpp index fa886dec..06190b8b 100755 --- a/project.cpp +++ b/project.cpp @@ -864,7 +864,7 @@ void Project::loadTilesetAssets(Tileset* tileset) { int green = (word >> 5) & 0x1f; int blue = (word >> 10) & 0x1f; QRgb color = qRgb(red * 8, green * 8, blue * 8); - palette.prepend(color); + palette.append(color); } } else { for (int j = 0; j < 16; j++) { diff --git a/tileset.cpp b/tileset.cpp index 7538075c..8409a358 100755 --- a/tileset.cpp +++ b/tileset.cpp @@ -55,9 +55,9 @@ QImage Metatile::getMetatileImage(int tile, Tileset *primaryTileset, Tileset *se // The top layer of the metatile has its last color displayed at transparent. if (layer > 0) { - QColor color(tile_image.color(15)); + QColor color(tile_image.color(0)); color.setAlpha(0); - tile_image.setColor(15, color.rgba()); + tile_image.setColor(0, color.rgba()); } QPoint origin = QPoint(x*8, y*8); From 43eeffcf759fbc6420fba3851043e7f34d2d6d17 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Sun, 16 Sep 2018 11:57:16 -0500 Subject: [PATCH 3/5] Fix comment --- tileset.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tileset.cpp b/tileset.cpp index 8409a358..df368170 100755 --- a/tileset.cpp +++ b/tileset.cpp @@ -53,7 +53,7 @@ QImage Metatile::getMetatileImage(int tile, Tileset *primaryTileset, Tileset *se qDebug() << "Tile is referring to invalid palette number: " << tile_.palette; } - // The top layer of the metatile has its last color displayed at transparent. + // The top layer of the metatile has its first color displayed at transparent. if (layer > 0) { QColor color(tile_image.color(0)); color.setAlpha(0); From ef657628fa27ca8b067400cfd75dc6f33321828f Mon Sep 17 00:00:00 2001 From: Diegoisawesome Date: Mon, 17 Sep 2018 14:23:25 -0500 Subject: [PATCH 4/5] Fix segfault if metatile count != metatile attrs count --- project.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/project.cpp b/project.cpp index 06190b8b..b3b625ba 100755 --- a/project.cpp +++ b/project.cpp @@ -835,7 +835,13 @@ void Project::loadTilesetAssets(Tileset* tileset) { //qDebug() << metatile_attrs_path; if (attrs_file.open(QIODevice::ReadOnly)) { QByteArray data = attrs_file.readAll(); - int num_metatiles = data.length() / 2; + int num_metatiles = tileset->metatiles->count(); + int num_metatileAttrs = data.length() / 2; + if (num_metatiles != num_metatileAttrs) { + qDebug() << QString("Metatile count %1 does not match metatile attribute count %2").arg(num_metatiles).arg(num_metatileAttrs); + if (num_metatiles > num_metatileAttrs) + num_metatiles = num_metatileAttrs; + } for (int i = 0; i < num_metatiles; i++) { uint16_t word = data[i*2] & 0xff; word += (data[i*2 + 1] & 0xff) << 8; @@ -1092,7 +1098,7 @@ QMap Project::getTilesets() { // Advance to command specifying whether or not it is a secondary tileset i += 2; if (commands->at(i).at(0) != ".byte") { - qDebug() << "Unexpected command found for secondary tileset flag. Expected '.byte', but found: " << commands->at(i).at(0); + qDebug() << "Unexpected command found for secondary tileset flag in tileset" << tilesetLabel << ". Expected '.byte', but found: " << commands->at(i).at(0); continue; } From 3b61b1af0b0f1b592503f7fcf4cab371067e19a4 Mon Sep 17 00:00:00 2001 From: Diegoisawesome Date: Tue, 18 Sep 2018 00:05:29 -0500 Subject: [PATCH 5/5] Visual tweaks --- mainwindow.ui | 541 +++++++++++++++++++++++++------------------------- 1 file changed, 265 insertions(+), 276 deletions(-) diff --git a/mainwindow.ui b/mainwindow.ui index 936ccaf2..36600ee5 100755 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -115,19 +115,19 @@ - 0 + 3 - 0 + 3 - 0 + 3 - 0 + 3 - 0 + 6 @@ -379,7 +379,7 @@ 0 0 469 - 620 + 608 @@ -490,16 +490,16 @@ - 0 + 3 - 0 + 3 - 0 + 3 - 0 + 3 @@ -533,19 +533,19 @@ - 0 + 3 - 0 + 3 - 0 + 3 - 0 + 3 - 0 + 3 @@ -605,100 +605,6 @@ - - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 6 - - - QLayout::SetDefaultConstraint - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - Border - - - - - - - - 0 - 0 - - - - - 16777215 - 48 - - - - <html><head/><body><p>The border is a 2x2 metatile which is repeated outside of the map layout's boundary. Draw on this border area to modify it.</p></body></html> - - - QFrame::StyledPanel - - - QFrame::Sunken - - - Qt::ScrollBarAsNeeded - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 40 - 20 - - - - - - - @@ -727,110 +633,136 @@ - 6 + 0 QLayout::SetDefaultConstraint + + 0 + - 2 + 0 + + + 0 - 2 + 0 - - - - 0 - 0 - - - + + Selection - - - - - - true - - - - - 0 - 0 - 275 - 86 - + + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::NoFrame + + + QFrame::Plain + + + true + + + + + 0 + 0 + 324 + 77 + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - + + + @@ -867,8 +799,8 @@ 0 0 - 325 - 405 + 307 + 387 @@ -893,6 +825,9 @@ 0 + + 0 + @@ -958,6 +893,84 @@ + + + + Border + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 16777215 + 48 + + + + <html><head/><body><p>The border is a 2x2 metatile which is repeated outside of the map layout's boundary. Draw on this border area to modify it.</p></body></html> + + + QFrame::StyledPanel + + + QFrame::Sunken + + + Qt::ScrollBarAsNeeded + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + @@ -1205,6 +1218,18 @@ + + 3 + + + 3 + + + 3 + + + 3 + @@ -1269,8 +1294,8 @@ 0 0 - 420 - 584 + 432 + 596 @@ -1385,6 +1410,12 @@ + + + 0 + 0 + + Open Map Scripts @@ -1393,19 +1424,6 @@ - - - - Qt::Horizontal - - - - 20 - 20 - - - - @@ -1708,7 +1726,7 @@ Qt::Horizontal - QSizePolicy::Maximum + QSizePolicy::Expanding @@ -1730,26 +1748,13 @@ <html><head/><body><p>If enabled, connections will automatically be updated on the connected map.</p></body></html> - Mirror + Mirror to Connecting Maps true - - - - Qt::Horizontal - - - - 40 - 20 - - - - @@ -1773,9 +1778,9 @@ QFrame::Raised - + - 4 + 6 4 @@ -1789,49 +1794,6 @@ 4 - - - - <html><head/><body><p>The direction of the connection.</p></body></html> - - - - up - - - - - right - - - - - down - - - - - left - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - @@ -1869,6 +1831,33 @@ + + + + <html><head/><body><p>The direction of the connection.</p></body></html> + + + + up + + + + + right + + + + + down + + + + + left + + + +