Prevent paste exceeding object limit, warn when copying healspots
This commit is contained in:
parent
2051127815
commit
d9b37ecb0b
3 changed files with 19 additions and 12 deletions
|
@ -151,6 +151,7 @@ public:
|
||||||
void shouldReselectEvents();
|
void shouldReselectEvents();
|
||||||
void scaleMapView(int);
|
void scaleMapView(int);
|
||||||
void openInTextEditor(const QString &path, int lineNum = 0) const;
|
void openInTextEditor(const QString &path, int lineNum = 0) const;
|
||||||
|
bool eventLimitReached(QString event_type);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void openMapScripts() const;
|
void openMapScripts() const;
|
||||||
|
@ -176,7 +177,6 @@ private:
|
||||||
void updateEncounterFields(EncounterFields newFields);
|
void updateEncounterFields(EncounterFields newFields);
|
||||||
QString getMovementPermissionText(uint16_t collision, uint16_t elevation);
|
QString getMovementPermissionText(uint16_t collision, uint16_t elevation);
|
||||||
QString getMetatileDisplayMessage(uint16_t metatileId);
|
QString getMetatileDisplayMessage(uint16_t metatileId);
|
||||||
bool eventLimitReached(Map *, QString);
|
|
||||||
bool startDetachedProcess(const QString &command,
|
bool startDetachedProcess(const QString &command,
|
||||||
const QString &workingDirectory = QString(),
|
const QString &workingDirectory = QString(),
|
||||||
qint64 *pid = nullptr) const;
|
qint64 *pid = nullptr) const;
|
||||||
|
|
|
@ -2031,7 +2031,7 @@ void Editor::duplicateSelectedEvents() {
|
||||||
for (int i = 0; i < selected_events->length(); i++) {
|
for (int i = 0; i < selected_events->length(); i++) {
|
||||||
Event *original = selected_events->at(i)->event;
|
Event *original = selected_events->at(i)->event;
|
||||||
QString eventType = original->get("event_type");
|
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));
|
logWarn(QString("Skipping duplication, the map limit for events of type '%1' has been reached.").arg(eventType));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2045,7 +2045,7 @@ void Editor::duplicateSelectedEvents() {
|
||||||
}
|
}
|
||||||
|
|
||||||
DraggablePixmapItem* Editor::addNewEvent(QString event_type) {
|
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 *event = Event::createNewEvent(event_type, map->name, project);
|
||||||
event->put("map_name", map->name);
|
event->put("map_name", map->name);
|
||||||
if (event_type == EventType::HealLocation) {
|
if (event_type == EventType::HealLocation) {
|
||||||
|
@ -2061,7 +2061,7 @@ DraggablePixmapItem* Editor::addNewEvent(QString event_type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Currently only object events have an explicit limit
|
// 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 (project && map && !event_type.isEmpty()) {
|
||||||
if (Event::typeToGroup(event_type) == EventGroup::Object)
|
if (Event::typeToGroup(event_type) == EventGroup::Object)
|
||||||
|
|
|
@ -1516,6 +1516,7 @@ void MainWindow::copy() {
|
||||||
|
|
||||||
if (type == EventType::HealLocation) {
|
if (type == EventType::HealLocation) {
|
||||||
// no copy on heal locations
|
// no copy on heal locations
|
||||||
|
logWarn(QString("Copying events of type '%1' is not allowed.").arg(type));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1527,11 +1528,11 @@ void MainWindow::copy() {
|
||||||
|
|
||||||
eventsArray.append(eventJson);
|
eventsArray.append(eventJson);
|
||||||
}
|
}
|
||||||
|
if (!eventsArray.isEmpty()) {
|
||||||
copyObject["events"] = eventsArray;
|
copyObject["events"] = eventsArray;
|
||||||
setClipboardData(copyObject);
|
setClipboardData(copyObject);
|
||||||
logInfo("Copied currently selected events to clipboard");
|
logInfo("Copied currently selected events to clipboard");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1616,6 +1617,11 @@ void MainWindow::paste() {
|
||||||
// paste the event to the map
|
// paste the event to the map
|
||||||
QString type = event["event_type"].toString();
|
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);
|
Event *pasteEvent = Event::createNewEvent(type, editor->map->name, editor->project);
|
||||||
|
|
||||||
for (auto key : event.toObject().keys())
|
for (auto key : event.toObject().keys())
|
||||||
|
@ -1647,9 +1653,10 @@ void MainWindow::paste() {
|
||||||
newEvents.append(pasteEvent);
|
newEvents.append(pasteEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!newEvents.isEmpty()) {
|
||||||
editor->map->editHistory.push(new EventPaste(this->editor, editor->map, newEvents));
|
editor->map->editHistory.push(new EventPaste(this->editor, editor->map, newEvents));
|
||||||
updateObjects();
|
updateObjects();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue