NONE_MAP -> DYNAMIC_MAP

This commit is contained in:
GriffinR 2022-10-18 12:39:37 -04:00
parent 75788ed3f9
commit 0e0da77c07
5 changed files with 15 additions and 14 deletions

View file

@ -26,8 +26,9 @@ struct EventGraphics
bool inanimate;
};
static QString NONE_MAP_CONSTANT = "MAP_NONE";
static QString NONE_MAP_NAME = "None";
// The constant and displayed name of the special map value used by warps with multiple potential destinations
static QString DYNAMIC_MAP_CONSTANT = "MAP_DYNAMIC";
static QString DYNAMIC_MAP_NAME = "Dynamic";
class Project : public QObject
{

View file

@ -321,8 +321,8 @@ bool CloneObjectEvent::loadFromJson(QJsonObject json, Project *project) {
QString mapConstant = ParseUtil::jsonToQString(json["target_map"]);
if (project->mapConstantsToMapNames.contains(mapConstant)) {
this->setTargetMap(project->mapConstantsToMapNames.value(mapConstant));
} else if (mapConstant == NONE_MAP_CONSTANT) {
this->setTargetMap(NONE_MAP_NAME);
} else if (mapConstant == DYNAMIC_MAP_CONSTANT) {
this->setTargetMap(DYNAMIC_MAP_NAME);
} else {
logError(QString("Destination map constant '%1' is invalid").arg(mapConstant));
return false;
@ -431,8 +431,8 @@ bool WarpEvent::loadFromJson(QJsonObject json, Project *project) {
QString mapConstant = ParseUtil::jsonToQString(json["dest_map"]);
if (project->mapConstantsToMapNames.contains(mapConstant)) {
this->setDestinationMap(project->mapConstantsToMapNames.value(mapConstant));
} else if (mapConstant == NONE_MAP_CONSTANT) {
this->setDestinationMap(NONE_MAP_NAME);
} else if (mapConstant == DYNAMIC_MAP_CONSTANT) {
this->setDestinationMap(DYNAMIC_MAP_NAME);
} else {
logError(QString("Destination map constant '%1' is invalid for warp").arg(mapConstant));
return false;

View file

@ -1747,7 +1747,7 @@ void Editor::setConnectionMap(QString mapName) {
if (!selected_connection_item)
return;
if (mapName.isEmpty() || mapName == NONE_MAP_NAME) {
if (mapName.isEmpty() || mapName == DYNAMIC_MAP_NAME) {
removeCurrentConnection();
return;
}
@ -1899,7 +1899,7 @@ void Editor::updateDiveEmergeMap(QString mapName, QString direction) {
}
}
if (mapName.isEmpty() || mapName == NONE_MAP_NAME) {
if (mapName.isEmpty() || mapName == DYNAMIC_MAP_NAME) {
// Remove dive/emerge connection
if (connection) {
map->connections.removeOne(connection);

View file

@ -1762,9 +1762,9 @@ bool Project::readMapGroups() {
}
}
mapConstantsToMapNames.insert(NONE_MAP_CONSTANT, NONE_MAP_NAME);
mapNamesToMapConstants.insert(NONE_MAP_NAME, NONE_MAP_CONSTANT);
maps.append(NONE_MAP_NAME);
mapConstantsToMapNames.insert(DYNAMIC_MAP_CONSTANT, DYNAMIC_MAP_NAME);
mapNamesToMapConstants.insert(DYNAMIC_MAP_NAME, DYNAMIC_MAP_CONSTANT);
maps.append(DYNAMIC_MAP_NAME);
groupNames = groups;
groupedMapNames = groupedMaps;

View file

@ -85,14 +85,14 @@ void DraggablePixmapItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *) {
if (eventType == Event::Type::Warp) {
WarpEvent *warp = dynamic_cast<WarpEvent *>(this->event);
QString destMap = warp->getDestinationMap();
if (destMap != NONE_MAP_NAME) {
if (destMap != DYNAMIC_MAP_NAME) {
emit editor->warpEventDoubleClicked(destMap, warp->getDestinationWarpID(), Event::Group::Warp);
}
}
else if (eventType == Event::Type::CloneObject) {
CloneObjectEvent *clone = dynamic_cast<CloneObjectEvent *>(this->event);
QString destMap = clone->getTargetMap();
if (destMap != NONE_MAP_NAME) {
if (destMap != DYNAMIC_MAP_NAME) {
emit editor->warpEventDoubleClicked(destMap, clone->getTargetID(), Event::Group::Object);
}
}
@ -100,7 +100,7 @@ void DraggablePixmapItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *) {
SecretBaseEvent *base = dynamic_cast<SecretBaseEvent *>(this->event);
QString baseId = base->getBaseID();
QString destMap = editor->project->mapConstantsToMapNames.value("MAP_" + baseId.left(baseId.lastIndexOf("_")));
if (destMap != NONE_MAP_NAME) {
if (destMap != DYNAMIC_MAP_NAME) {
emit editor->warpEventDoubleClicked(destMap, 0, Event::Group::Warp);
}
}