diff --git a/CHANGELOG.md b/CHANGELOG.md index 48006ea7..56cbae12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d - Overhauled the region map editor, adding support for tilemaps, and significant customization. Also now supports pokefirered. - Metatiles are always rendered accurately with 3 layers, and the unused layer is not assumed to be transparent. - `object_event_graphics_info.h` can now be parsed correctly if it uses structs with attributes. +- The selection is no longer reset when pasting events. The newly pasted events are selected instead. - Palette editor ui is updated a bit to allow hex and rgb value input. ### Fixed @@ -34,6 +35,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d - Fix cursor tile and player view outlines not updating immediately when toggled in Collision view. - Fix selected space not updating while painting in Collision view. - Fix the map music dropdown being empty when importing a map from Advance Map. +- Fix object events added by pasting ignoring the map event limit. - Fixed a bug where saving the tileset editor would reselect the main editor's first selected metatile. ## [4.5.0] - 2021-12-26 diff --git a/include/editor.h b/include/editor.h index 11efabda..c44fd960 100644 --- a/include/editor.h +++ b/include/editor.h @@ -151,6 +151,7 @@ public: void shouldReselectEvents(); void scaleMapView(int); void openInTextEditor(const QString &path, int lineNum = 0) const; + bool eventLimitReached(QString event_type); public slots: void openMapScripts() const; @@ -176,7 +177,6 @@ private: void updateEncounterFields(EncounterFields newFields); QString getMovementPermissionText(uint16_t collision, uint16_t elevation); QString getMetatileDisplayMessage(uint16_t metatileId); - bool eventLimitReached(Map *, QString); bool startDetachedProcess(const QString &command, const QString &workingDirectory = QString(), qint64 *pid = nullptr) const; diff --git a/src/editor.cpp b/src/editor.cpp index d15b3bbc..f4890106 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -2031,7 +2031,7 @@ void Editor::duplicateSelectedEvents() { for (int i = 0; i < selected_events->length(); i++) { Event *original = selected_events->at(i)->event; QString eventType = original->get("event_type"); - if (eventLimitReached(map, eventType)) { + if (eventLimitReached(eventType)) { logWarn(QString("Skipping duplication, the map limit for events of type '%1' has been reached.").arg(eventType)); continue; } @@ -2045,7 +2045,7 @@ void Editor::duplicateSelectedEvents() { } DraggablePixmapItem* Editor::addNewEvent(QString event_type) { - if (project && map && !event_type.isEmpty() && !eventLimitReached(map, event_type)) { + if (project && map && !event_type.isEmpty() && !eventLimitReached(event_type)) { Event *event = Event::createNewEvent(event_type, map->name, project); event->put("map_name", map->name); if (event_type == EventType::HealLocation) { @@ -2061,7 +2061,7 @@ DraggablePixmapItem* Editor::addNewEvent(QString event_type) { } // Currently only object events have an explicit limit -bool Editor::eventLimitReached(Map *map, QString event_type) +bool Editor::eventLimitReached(QString event_type) { if (project && map && !event_type.isEmpty()) { if (Event::typeToGroup(event_type) == EventGroup::Object) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 71089327..79580bfd 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1520,6 +1520,7 @@ void MainWindow::copy() { if (type == EventType::HealLocation) { // no copy on heal locations + logWarn(QString("Copying events of type '%1' is not allowed.").arg(type)); continue; } @@ -1531,11 +1532,11 @@ void MainWindow::copy() { eventsArray.append(eventJson); } - - copyObject["events"] = eventsArray; - setClipboardData(copyObject); - logInfo("Copied currently selected events to clipboard"); - + if (!eventsArray.isEmpty()) { + copyObject["events"] = eventsArray; + setClipboardData(copyObject); + logInfo("Copied currently selected events to clipboard"); + } break; } } @@ -1620,6 +1621,11 @@ void MainWindow::paste() { // paste the event to the map QString type = event["event_type"].toString(); + if (editor->eventLimitReached(type)) { + logWarn(QString("Skipping paste, the map limit for events of type '%1' has been reached.").arg(type)); + continue; + } + Event *pasteEvent = Event::createNewEvent(type, editor->map->name, editor->project); for (auto key : event.toObject().keys()) @@ -1651,9 +1657,10 @@ void MainWindow::paste() { newEvents.append(pasteEvent); } - editor->map->editHistory.push(new EventPaste(this->editor, editor->map, newEvents)); - updateObjects(); - + if (!newEvents.isEmpty()) { + updateObjects(); + editor->map->editHistory.push(new EventPaste(this->editor, editor->map, newEvents)); + } break; } }