mirror of
https://github.com/huderlem/porymap.git
synced 2026-10-01 04:16:37 -05:00
fix multi event deletion crash, allow spinboxes to commit move history
This commit is contained in:
@@ -50,7 +50,6 @@ void PaintMetatile::undo() {
|
||||
}
|
||||
|
||||
bool PaintMetatile::mergeWith(const QUndoCommand *command) {
|
||||
// does an up merge
|
||||
const PaintMetatile *other = static_cast<const PaintMetatile *>(command);
|
||||
|
||||
if (this->map != other->map)
|
||||
@@ -312,6 +311,8 @@ bool EventMove::mergeWith(const QUndoCommand *command) {
|
||||
if (actionId != other->actionId)
|
||||
return false;
|
||||
|
||||
// TODO: check that same events as well?
|
||||
|
||||
this->deltaX += other->deltaX;
|
||||
this->deltaY += other->deltaY;
|
||||
|
||||
@@ -360,7 +361,6 @@ void EventCreate::redo() {
|
||||
}
|
||||
|
||||
void EventCreate::undo() {
|
||||
//
|
||||
map->removeEvent(event);
|
||||
|
||||
if (editor->scene->items().contains(event->pixmapItem)) {
|
||||
@@ -368,6 +368,8 @@ void EventCreate::undo() {
|
||||
}
|
||||
editor->selected_events->removeOne(event->pixmapItem);
|
||||
|
||||
editor->updateSelectedEvents();
|
||||
|
||||
map->objectsChanged();
|
||||
|
||||
QUndoCommand::undo();
|
||||
@@ -377,15 +379,18 @@ void EventCreate::undo() {
|
||||
************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
EventDelete::EventDelete(Editor *editor, Map *map, Event *event,
|
||||
EventDelete::EventDelete(Editor *editor, Map *map, QList<Event *> selectedEvents,
|
||||
QUndoCommand *parent) : QUndoCommand(parent) {
|
||||
//
|
||||
setText("Delete Event");
|
||||
if (selectedEvents.size() > 1) {
|
||||
setText("Delete Events");
|
||||
} else {
|
||||
setText("Delete Event");
|
||||
}
|
||||
|
||||
this->editor = editor;
|
||||
|
||||
this->map = map;
|
||||
this->event = event;
|
||||
this->selectedEvents = selectedEvents;
|
||||
}
|
||||
|
||||
EventDelete::~EventDelete() {}
|
||||
@@ -393,22 +398,25 @@ EventDelete::~EventDelete() {}
|
||||
void EventDelete::redo() {
|
||||
QUndoCommand::redo();
|
||||
|
||||
map->removeEvent(event);
|
||||
for (Event *event : selectedEvents) {
|
||||
map->removeEvent(event);
|
||||
|
||||
if (editor->scene->items().contains(event->pixmapItem)) {
|
||||
editor->scene->removeItem(event->pixmapItem);
|
||||
if (editor->scene->items().contains(event->pixmapItem)) {
|
||||
editor->scene->removeItem(event->pixmapItem);
|
||||
}
|
||||
editor->selected_events->removeOne(event->pixmapItem);
|
||||
}
|
||||
editor->selected_events->removeOne(event->pixmapItem);
|
||||
|
||||
map->objectsChanged();
|
||||
}
|
||||
|
||||
void EventDelete::undo() {
|
||||
//
|
||||
map->addEvent(event);
|
||||
for (Event *event : selectedEvents) {
|
||||
map->addEvent(event);
|
||||
|
||||
editor->project->loadEventPixmaps(map->getAllEvents());
|
||||
editor->addMapEvent(event);
|
||||
editor->project->loadEventPixmaps(map->getAllEvents());
|
||||
editor->addMapEvent(event);
|
||||
}
|
||||
|
||||
map->objectsChanged();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user