Fix warp map destinations (both loading and saving)
This commit is contained in:
parent
d7756865a9
commit
0e268f9ede
3 changed files with 20 additions and 11 deletions
|
@ -504,7 +504,7 @@ void MainWindow::updateSelectedObjects() {
|
||||||
field_labels["property"] = "Property";
|
field_labels["property"] = "Property";
|
||||||
field_labels["sight_radius"] = "Sight Radius";
|
field_labels["sight_radius"] = "Sight Radius";
|
||||||
field_labels["destination_warp"] = "Destination Warp";
|
field_labels["destination_warp"] = "Destination Warp";
|
||||||
field_labels["destination_map"] = "Destination Map";
|
field_labels["destination_map_name"] = "Destination Map";
|
||||||
field_labels["coord_unknown1"] = "Unknown 1";
|
field_labels["coord_unknown1"] = "Unknown 1";
|
||||||
field_labels["coord_unknown2"] = "Unknown 2";
|
field_labels["coord_unknown2"] = "Unknown 2";
|
||||||
field_labels["type"] = "Type";
|
field_labels["type"] = "Type";
|
||||||
|
@ -542,7 +542,7 @@ void MainWindow::updateSelectedObjects() {
|
||||||
}
|
}
|
||||||
else if (event_type == "warp") {
|
else if (event_type == "warp") {
|
||||||
fields << "destination_warp";
|
fields << "destination_warp";
|
||||||
fields << "destination_map";
|
fields << "destination_map_name";
|
||||||
}
|
}
|
||||||
else if (event_type == "trap") {
|
else if (event_type == "trap") {
|
||||||
fields << "script_label";
|
fields << "script_label";
|
||||||
|
@ -568,7 +568,7 @@ void MainWindow::updateSelectedObjects() {
|
||||||
combo->setEditable(true);
|
combo->setEditable(true);
|
||||||
|
|
||||||
QString value = item->event->get(key);
|
QString value = item->event->get(key);
|
||||||
if (key == "destination_map") {
|
if (key == "destination_map_name") {
|
||||||
if (!editor->project->mapNames->contains(value)) {
|
if (!editor->project->mapNames->contains(value)) {
|
||||||
combo->addItem(value);
|
combo->addItem(value);
|
||||||
}
|
}
|
||||||
|
|
24
project.cpp
24
project.cpp
|
@ -517,13 +517,15 @@ void Project::readMapGroups() {
|
||||||
} else if (macro == ".4byte") {
|
} else if (macro == ".4byte") {
|
||||||
if (group != -1) {
|
if (group != -1) {
|
||||||
for (int j = 1; j < params.length(); j++) {
|
for (int j = 1; j < params.length(); j++) {
|
||||||
|
QString mapName = params.value(j);
|
||||||
QStringList *list = groupedMaps->value(group);
|
QStringList *list = groupedMaps->value(group);
|
||||||
list->append(params.value(j));
|
list->append(mapName);
|
||||||
maps->append(params.value(j));
|
maps->append(mapName);
|
||||||
|
|
||||||
// Build the mapping between map constants and map names.
|
// Build the mapping and reverse mapping between map constants and map names.
|
||||||
QString mapConstant = Map::mapConstantFromName(params.value(j));
|
QString mapConstant = Map::mapConstantFromName(mapName);
|
||||||
mapConstantsToMapNames.insert(mapConstant, params.value(j));
|
mapConstantsToMapNames.insert(mapConstant, mapName);
|
||||||
|
mapNamesToMapConstants.insert(mapName, mapConstant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -855,10 +857,16 @@ void Project::readMapEvents(Map *map) {
|
||||||
warp->put("y", command.value(i++));
|
warp->put("y", command.value(i++));
|
||||||
warp->put("elevation", command.value(i++));
|
warp->put("elevation", command.value(i++));
|
||||||
warp->put("destination_warp", command.value(i++));
|
warp->put("destination_warp", command.value(i++));
|
||||||
warp->put("destination_map", command.value(i++));
|
|
||||||
|
|
||||||
warp->put("event_type", "warp");
|
// Ensure the warp destination map constant is valid before adding it to the warps.
|
||||||
map->events["warp"].append(warp);
|
QString mapConstant = command.value(i++);
|
||||||
|
if (mapConstantsToMapNames.contains(mapConstant)) {
|
||||||
|
warp->put("destination_map_name", mapConstantsToMapNames[mapConstant]);
|
||||||
|
warp->put("event_type", "warp");
|
||||||
|
map->events["warp"].append(warp);
|
||||||
|
} else {
|
||||||
|
qDebug() << QString("Destination map constant '%1' is invalid for warp").arg(mapConstant);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ public:
|
||||||
QList<QStringList*> *groupedMapNames = NULL;
|
QList<QStringList*> *groupedMapNames = NULL;
|
||||||
QStringList *mapNames = NULL;
|
QStringList *mapNames = NULL;
|
||||||
QMap<QString, QString> mapConstantsToMapNames;
|
QMap<QString, QString> mapConstantsToMapNames;
|
||||||
|
QMap<QString, QString> mapNamesToMapConstants;
|
||||||
|
|
||||||
QMap<QString, Map*> *map_cache;
|
QMap<QString, Map*> *map_cache;
|
||||||
Map* loadMap(QString);
|
Map* loadMap(QString);
|
||||||
|
|
Loading…
Reference in a new issue