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/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 + + + + diff --git a/project.cpp b/project.cpp index b01d6aa5..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; @@ -864,7 +870,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++) { @@ -1010,6 +1016,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; @@ -1088,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; } @@ -1473,6 +1483,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: diff --git a/tileset.cpp b/tileset.cpp index 7538075c..df368170 100755 --- a/tileset.cpp +++ b/tileset.cpp @@ -53,11 +53,11 @@ 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(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);