1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-29 21:56:54 +02:00

map editor: option to set random town same as player faction

This commit is contained in:
godric3 2025-01-05 21:57:11 +01:00
parent 018503c5e8
commit 4b7792075d
2 changed files with 6 additions and 0 deletions
lib/mapObjects
mapeditor/inspector

@ -1134,6 +1134,7 @@ void CGTownInstance::serializeJsonOptions(JsonSerializeFormat & handler)
eventsHandler.syncSize(events, JsonNode::JsonType::DATA_VECTOR);
eventsHandler.serializeStruct(events);
}
handler.serializeId("alignmentToPlayer", alignmentToPlayer, PlayerColor::NEUTRAL);
}
const CFaction * CGTownInstance::getFaction() const

@ -364,6 +364,8 @@ void Inspector::updateProperties(CGTownInstance * o)
addProperty(QObject::tr("Buildings"), PropertyEditorPlaceholder(), delegate, false);
addProperty(QObject::tr("Spells"), PropertyEditorPlaceholder(), new TownSpellsDelegate(*o), false);
addProperty(QObject::tr("Events"), PropertyEditorPlaceholder(), new TownEventsDelegate(*o, controller), false);
if(o->ID == Obj::RANDOM_TOWN)
addProperty(QObject::tr("Same as player"), o->alignmentToPlayer, new OwnerDelegate(controller), false);
}
void Inspector::updateProperties(CGArtifact * o)
@ -612,6 +614,9 @@ void Inspector::setProperty(CGTownInstance * o, const QString & key, const QVari
if(key == QObject::tr("Town name"))
o->setNameTextId(mapRegisterLocalizedString("map", *controller.map(),
TextIdentifier("town", o->instanceName, "name"), value.toString().toStdString()));
if(key == QObject::tr("Same as player"))
o->alignmentToPlayer = PlayerColor(value.toInt());
}
void Inspector::setProperty(CGSignBottle * o, const QString & key, const QVariant & value)