mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-12 03:45:51 -05:00
Merge branch 'master' of https://github.com/huderlem/porymap into fix-json
This commit is contained in:
@@ -340,6 +340,10 @@ void Map::setBorderDimensions(int newWidth, int newHeight, bool setNewBlockdata,
|
||||
emit mapChanged(this);
|
||||
}
|
||||
|
||||
void Map::openScript(QString label) {
|
||||
emit openScriptRequested(label);
|
||||
}
|
||||
|
||||
bool Map::getBlock(int x, int y, Block *out) {
|
||||
if (isWithinBounds(x, y)) {
|
||||
int i = y * getWidth() + x;
|
||||
@@ -474,37 +478,51 @@ QList<Event *> Map::getAllEvents() const {
|
||||
return all_events;
|
||||
}
|
||||
|
||||
QStringList Map::eventScriptLabels(const QString &event_group_type) const {
|
||||
QStringList Map::eventScriptLabels(Event::Group group) const {
|
||||
QStringList scriptLabels;
|
||||
if (event_group_type.isEmpty()) {
|
||||
for (const auto *event : getAllEvents())
|
||||
scriptLabels << event->get("script_label");
|
||||
|
||||
if (group == Event::Group::None) {
|
||||
ScriptTracker scriptTracker;
|
||||
for (Event *event : this->getAllEvents()) {
|
||||
event->accept(&scriptTracker);
|
||||
}
|
||||
scriptLabels = scriptTracker.getScripts();
|
||||
} else {
|
||||
for (const auto *event : events.value(event_group_type))
|
||||
scriptLabels << event->get("script_label");
|
||||
ScriptTracker scriptTracker;
|
||||
for (Event *event : events.value(group)) {
|
||||
event->accept(&scriptTracker);
|
||||
}
|
||||
scriptLabels = scriptTracker.getScripts();
|
||||
}
|
||||
|
||||
scriptLabels.removeAll("");
|
||||
scriptLabels.removeDuplicates();
|
||||
if (scriptLabels.contains("0x0"))
|
||||
scriptLabels.move(scriptLabels.indexOf("0x0"), scriptLabels.count() - 1);
|
||||
if (scriptLabels.contains("NULL"))
|
||||
scriptLabels.move(scriptLabels.indexOf("NULL"), scriptLabels.count() - 1);
|
||||
scriptLabels.prepend("0x0");
|
||||
scriptLabels.prepend("NULL");
|
||||
|
||||
return scriptLabels;
|
||||
}
|
||||
|
||||
void Map::removeEvent(Event *event) {
|
||||
for (QString key : events.keys()) {
|
||||
for (Event::Group key : events.keys()) {
|
||||
events[key].removeAll(event);
|
||||
}
|
||||
}
|
||||
|
||||
void Map::addEvent(Event *event) {
|
||||
events[event->get("event_group_type")].append(event);
|
||||
event->setMap(this);
|
||||
events[event->getEventGroup()].append(event);
|
||||
if (!ownedEvents.contains(event)) ownedEvents.append(event);
|
||||
}
|
||||
|
||||
void Map::modify() {
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void Map::clean() {
|
||||
this->hasUnsavedDataChanges = false;
|
||||
}
|
||||
|
||||
bool Map::hasUnsavedChanges() {
|
||||
return !editHistory.isClean() || hasUnsavedDataChanges || !isPersistedToFile;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user