Michał Zaremba пре 3 недеља
родитељ
комит
aaeb7fa6d5
1 измењених фајлова са 71 додато и 71 уклоњено
  1. 71 71
      mapeditor/inspector/inspector.cpp

+ 71 - 71
mapeditor/inspector/inspector.cpp

@@ -85,7 +85,7 @@ void Initializer::initialize(CGCreature * o)
 void Initializer::initialize(CGDwelling * o)
 {
 	if(!o) return;
-	
+
 	o->tempOwner = defaultPlayer;
 
 	if(o->ID == Obj::RANDOM_DWELLING || o->ID == Obj::RANDOM_DWELLING_LVL || o->ID == Obj::RANDOM_DWELLING_FACTION)
@@ -106,7 +106,7 @@ void Initializer::initialize(CGDwelling * o)
 void Initializer::initialize(CGGarrison * o)
 {
 	if(!o) return;
-	
+
 	o->tempOwner = defaultPlayer;
 	o->removableUnits = true;
 }
@@ -114,26 +114,26 @@ void Initializer::initialize(CGGarrison * o)
 void Initializer::initialize(CGShipyard * o)
 {
 	if(!o) return;
-	
+
 	o->tempOwner = defaultPlayer;
 }
 
 void Initializer::initialize(FlaggableMapObject * o)
 {
 	if(!o) return;
-	
+
 	o->tempOwner = defaultPlayer;
 }
 
 void Initializer::initialize(CGHeroPlaceholder * o)
 {
 	if(!o) return;
-	
+
 	o->tempOwner = defaultPlayer;
-	
+
 	if(!o->powerRank.has_value() && !o->heroType.has_value())
 		o->powerRank = 0;
-	
+
 	if(o->powerRank.has_value() && o->heroType.has_value())
 		o->powerRank.reset();
 }
@@ -142,7 +142,7 @@ void Initializer::initialize(CGHeroInstance * o)
 {
 	if(!o)
 		return;
-	
+
 	o->tempOwner = defaultPlayer;
 	if(o->ID == Obj::PRISON)
 	{
@@ -194,7 +194,7 @@ void Initializer::initialize(CGTownInstance * o)
 void Initializer::initialize(CGArtifact * o)
 {
 	if(!o) return;
-	
+
 	if(o->ID == Obj::SPELL_SCROLL)
 	{
 		std::vector<SpellID> out;
@@ -220,7 +220,7 @@ void Initializer::initialize(CGArtifact * o)
 void Initializer::initialize(CGMine * o)
 {
 	if(!o) return;
-	
+
 	o->tempOwner = defaultPlayer;
 	if(o->isAbandoned())
 	{
@@ -241,7 +241,7 @@ void Initializer::initialize(CGMine * o)
 void Inspector::updateProperties(CArmedInstance * o)
 {
 	if(!o) return;
-	
+
 	auto * delegate = new ArmyDelegate(*o);
 	addProperty(QObject::tr("Army"), PropertyEditorPlaceholder(), delegate, false);
 }
@@ -249,9 +249,9 @@ void Inspector::updateProperties(CArmedInstance * o)
 void Inspector::updateProperties(CGDwelling * o)
 {
 	if(!o) return;
-	
+
 	addProperty(QObject::tr("Owner"), o->tempOwner, new OwnerDelegate(controller), false);
-	
+
 	if (o->ID == Obj::RANDOM_DWELLING || o->ID == Obj::RANDOM_DWELLING_LVL)
 	{
 		auto * delegate = new PickObjectDelegate(controller, PickObjectDelegate::typedFilter<CGTownInstance>);
@@ -269,7 +269,7 @@ void Inspector::updateProperties(FlaggableMapObject * o)
 void Inspector::updateProperties(CGGarrison * o)
 {
 	if(!o) return;
-	
+
 	addProperty(QObject::tr("Owner"), o->tempOwner, new OwnerDelegate(controller), false);
 	addProperty(QObject::tr("Removable units"), o->removableUnits, false);
 }
@@ -277,30 +277,30 @@ void Inspector::updateProperties(CGGarrison * o)
 void Inspector::updateProperties(CGShipyard * o)
 {
 	if(!o) return;
-	
+
 	addProperty(QObject::tr("Owner"), o->tempOwner, new OwnerDelegate(controller), false);
 }
 
 void Inspector::updateProperties(CGHeroPlaceholder * o)
 {
 	if(!o) return;
-	
+
 	addProperty(QObject::tr("Owner"), o->tempOwner, new OwnerDelegate(controller), false);
-	
+
 	bool type = false;
 	if(o->heroType.has_value())
 		type = true;
 	else if(!o->powerRank.has_value())
 		assert(0); //one of values must be initialized
-	
+
 	{
 		auto * delegate = new InspectorDelegate;
 		delegate->options = {{QObject::tr("POWER RANK"), QVariant::fromValue(false)}, {QObject::tr("HERO TYPE"), QVariant::fromValue(true)}};
 		addProperty(QObject::tr("Placeholder type"), delegate->options[type].first, delegate, false);
 	}
-	
+
 	addProperty(QObject::tr("Power rank"), o->powerRank.has_value() ? o->powerRank.value() : 0, type);
-	
+
 	{
 		auto * delegate = new InspectorDelegate;
 		for(int i = 0; i < LIBRARY->heroh->objects.size(); ++i)
@@ -314,12 +314,12 @@ void Inspector::updateProperties(CGHeroPlaceholder * o)
 void Inspector::updateProperties(CGHeroInstance * o)
 {
 	if(!o) return;
-	
+
 	auto isPrison = o->ID == Obj::PRISON;
 	addProperty(QObject::tr("Owner"), o->tempOwner, new OwnerDelegate(controller, isPrison), isPrison); //field is not editable for prison
 	addProperty<int>(QObject::tr("Experience"), o->exp, false);
 	addProperty(QObject::tr("Hero class"), o->getHeroClassID().hasValue() ? o->getHeroClass()->getNameTranslated() : "", true);
-	
+
 	{ //Gender
 		auto * delegate = new InspectorDelegate;
 		delegate->options = {{QObject::tr("MALE"), QVariant::fromValue(static_cast<int>(EHeroGender::MALE))}, {QObject::tr("FEMALE"), QVariant::fromValue(static_cast<int>(EHeroGender::FEMALE))}};
@@ -328,12 +328,12 @@ void Inspector::updateProperties(CGHeroInstance * o)
 	addProperty(QObject::tr("Name"), o->getNameTranslated(), false);
 	addProperty(QObject::tr("Biography"), o->getBiographyTranslated(), new MessageDelegate, false);
 	addProperty(QObject::tr("Portrait"), PropertyEditorPlaceholder(), new PortraitDelegate(*o), false);
-	
+
 	auto * delegate = new HeroSkillsDelegate(*o);
 	addProperty(QObject::tr("Skills"), PropertyEditorPlaceholder(), delegate, false);
 	addProperty(QObject::tr("Spells"), PropertyEditorPlaceholder(), new HeroSpellDelegate(*o), false);
 	addProperty(QObject::tr("Artifacts"), PropertyEditorPlaceholder(), new HeroArtifactsDelegate(controller, *o), false);
-	
+
 	if(o->getHeroTypeID().hasValue() || o->ID == Obj::PRISON)
 	{ //Hero type
 		auto * delegate = new InspectorDelegate;
@@ -363,9 +363,9 @@ void Inspector::updateProperties(CGHeroInstance * o)
 void Inspector::updateProperties(CGTownInstance * o)
 {
 	if(!o) return;
-	
+
 	addProperty(QObject::tr("Town name"), o->getNameTranslated(), false);
-	
+
 	auto * delegate = new TownBuildingsDelegate(*o);
 	addProperty(QObject::tr("Buildings"), PropertyEditorPlaceholder(), delegate, false);
 	addProperty(QObject::tr("Spells"), PropertyEditorPlaceholder(), new TownSpellsDelegate(*o), false);
@@ -403,7 +403,7 @@ void Inspector::updateProperties(CGArtifact * o)
 void Inspector::updateProperties(CGMine * o)
 {
 	if(!o) return;
-	
+
 	addProperty(QObject::tr("Owner"), o->tempOwner, new OwnerDelegate(controller), false);
 	if(o->producedResource != GameResID::NONE)
 		addProperty(QObject::tr("Resource"), o->producedResource);
@@ -413,7 +413,7 @@ void Inspector::updateProperties(CGMine * o)
 void Inspector::updateProperties(CGResource * o)
 {
 	if(!o) return;
-	
+
 	addProperty(QObject::tr("Amount"), o->amount, false);
 	addProperty(QObject::tr("Message"), o->message, false);
 }
@@ -421,14 +421,14 @@ void Inspector::updateProperties(CGResource * o)
 void Inspector::updateProperties(CGSignBottle * o)
 {
 	if(!o) return;
-	
+
 	addProperty(QObject::tr("Message"), o->message, new MessageDelegate, false);
 }
 
 void Inspector::updateProperties(CGCreature * o)
 {
 	if(!o) return;
-	
+
 	addProperty(QObject::tr("Message"), o->message, false);
 	{ //Character
 		auto * delegate = new InspectorDelegate;
@@ -446,7 +446,7 @@ void Inspector::updateProperties(CGCreature * o)
 void Inspector::updateProperties(CRewardableObject * o)
 {
 	if(!o) return;
-		
+
 	auto * delegate = new RewardsDelegate(*controller.map(), *o);
 	addProperty(QObject::tr("Reward"), PropertyEditorPlaceholder(), delegate, false);
 }
@@ -454,14 +454,14 @@ void Inspector::updateProperties(CRewardableObject * o)
 void Inspector::updateProperties(CGPandoraBox * o)
 {
 	if(!o) return;
-	
+
 	addProperty(QObject::tr("Message"), o->message, new MessageDelegate, false);
 }
 
 void Inspector::updateProperties(CGEvent * o)
 {
 	if(!o) return;
-	
+
 	addProperty(QObject::tr("Remove after"), o->removeAfterVisit, false);
 	addProperty(QObject::tr("Human trigger"), o->humanActivate, false);
 	addProperty(QObject::tr("Cpu trigger"), o->computerActivate, false);
@@ -471,13 +471,13 @@ void Inspector::updateProperties(CGEvent * o)
 void Inspector::updateProperties(CGSeerHut * o)
 {
 	if(!o) return;
-	
+
 	addProperty(QObject::tr("First visit text"), o->getQuest().firstVisitText, new MessageDelegate, false);
 	addProperty(QObject::tr("Next visit text"), o->getQuest().nextVisitText, new MessageDelegate, false);
 	addProperty(QObject::tr("Completed text"), o->getQuest().completedText, new MessageDelegate, false);
 	addProperty(QObject::tr("Repeat quest"), o->getQuest().repeatedQuest, false);
 	addProperty(QObject::tr("Time limit"), o->getQuest().lastDay, false);
-	
+
 	{ //Quest
 		auto * delegate = new QuestDelegate(controller, o->getQuest());
 		addProperty(QObject::tr("Quest"), PropertyEditorPlaceholder(), delegate, false);
@@ -487,7 +487,7 @@ void Inspector::updateProperties(CGSeerHut * o)
 void Inspector::updateProperties(CGQuestGuard * o)
 {
 	if(!o) return;
-	
+
 	addProperty(QObject::tr("Reward"), PropertyEditorPlaceholder(), nullptr, true);
 	addProperty(QObject::tr("Repeat quest"), o->getQuest().repeatedQuest, true);
 }
@@ -497,20 +497,20 @@ void Inspector::updateProperties()
 	if(!obj)
 		return;
 	table->setRowCount(0); //cleanup table
-	
+
 	addProperty(QObject::tr("Identifier"), obj);
 	addProperty(QObject::tr("ID"), obj->ID.getNum());
 	addProperty(QObject::tr("SubID"), obj->subID);
 	addProperty(QObject::tr("InstanceName"), obj->instanceName);
-	
+
 	if(obj->ID != Obj::HERO_PLACEHOLDER && !dynamic_cast<CGHeroInstance*>(obj))
 	{
 		auto factory = LIBRARY->objtypeh->getHandlerFor(obj->ID, obj->subID);
 		addProperty(QObject::tr("IsStatic"), factory->isStaticObject());
 	}
-	
+
 	addProperty(QObject::tr("Owner"), obj->tempOwner, new OwnerDelegate(controller), true);
-	
+
 	UPDATE_OBJ_PROPERTIES(CArmedInstance);
 	UPDATE_OBJ_PROPERTIES(CGResource);
 	UPDATE_OBJ_PROPERTIES(CGArtifact);
@@ -529,7 +529,7 @@ void Inspector::updateProperties()
 	UPDATE_OBJ_PROPERTIES(CGEvent);
 	UPDATE_OBJ_PROPERTIES(CGSeerHut);
 	UPDATE_OBJ_PROPERTIES(CGQuestGuard);
-	
+
 	table->show();
 }
 
@@ -541,13 +541,13 @@ void Inspector::setProperty(const QString & key, const QTableWidgetItem * item)
 		setProperty(key, item->data(Qt::UserRole));
 		return;
 	}
-	
+
 	if(item->flags() & Qt::ItemIsUserCheckable)
 	{
 		setProperty(key, QVariant::fromValue(item->checkState() == Qt::Checked));
 		return;
 	}
-	
+
 	setProperty(key, item->text());
 }
 
@@ -555,10 +555,10 @@ void Inspector::setProperty(const QString & key, const QVariant & value)
 {
 	if(!obj)
 		return;
-	
+
 	if(key == QObject::tr("Owner"))
 		obj->tempOwner = PlayerColor(value.toInt());
-	
+
 	SET_PROPERTIES(CArmedInstance);
 	SET_PROPERTIES(CGTownInstance);
 	SET_PROPERTIES(CGArtifact);
@@ -597,7 +597,7 @@ void Inspector::setProperty(CRewardableObject * o, const QString & key, const QV
 void Inspector::setProperty(CGPandoraBox * o, const QString & key, const QVariant & value)
 {
 	if(!o) return;
-	
+
 	if(key == QObject::tr("Message"))
 		o->message = MetaString::createFromTextID(mapRegisterLocalizedString("map", *controller.map(),
 			TextIdentifier("guards", o->instanceName, "message"), value.toString().toStdString()));
@@ -606,13 +606,13 @@ void Inspector::setProperty(CGPandoraBox * o, const QString & key, const QVarian
 void Inspector::setProperty(CGEvent * o, const QString & key, const QVariant & value)
 {
 	if(!o) return;
-	
+
 	if(key == QObject::tr("Remove after"))
 		o->removeAfterVisit = value.toBool();
-	
+
 	if(key == QObject::tr("Human trigger"))
 		o->humanActivate = value.toBool();
-	
+
 	if(key == QObject::tr("Cpu trigger"))
 		o->computerActivate = value.toBool();
 }
@@ -620,7 +620,7 @@ void Inspector::setProperty(CGEvent * o, const QString & key, const QVariant & v
 void Inspector::setProperty(CGTownInstance * o, const QString & key, const QVariant & value)
 {
 	if(!o) return;
-	
+
 	if(key == QObject::tr("Town name"))
 		o->setNameTextId(mapRegisterLocalizedString("map", *controller.map(),
 			TextIdentifier("town", o->instanceName, "name"), value.toString().toStdString()));
@@ -632,7 +632,7 @@ void Inspector::setProperty(CGTownInstance * o, const QString & key, const QVari
 void Inspector::setProperty(CGSignBottle * o, const QString & key, const QVariant & value)
 {
 	if(!o) return;
-	
+
 	if(key == QObject::tr("Message"))
 		o->message = MetaString::createFromTextID(mapRegisterLocalizedString("map", *controller.map(),
 			TextIdentifier("sign", o->instanceName, "message"), value.toString().toStdString()));
@@ -641,7 +641,7 @@ void Inspector::setProperty(CGSignBottle * o, const QString & key, const QVarian
 void Inspector::setProperty(CGMine * o, const QString & key, const QVariant & value)
 {
 	if(!o) return;
-	
+
 	if(key == QObject::tr("Productivity"))
 		o->producedQuantity = value.toString().toInt();
 }
@@ -649,11 +649,11 @@ void Inspector::setProperty(CGMine * o, const QString & key, const QVariant & va
 void Inspector::setProperty(CGArtifact * o, const QString & key, const QVariant & value)
 {
 	if(!o) return;
-	
+
 	if(key == QObject::tr("Message"))
 		o->message = MetaString::createFromTextID(mapRegisterLocalizedString("map", *controller.map(),
 			TextIdentifier("guards", o->instanceName, "message"), value.toString().toStdString()));
-	
+
 	if(key == QObject::tr("Spell"))
 	{
 		o->setArtifactInstance(controller.map()->createScroll(SpellID(value.toInt())));
@@ -663,7 +663,7 @@ void Inspector::setProperty(CGArtifact * o, const QString & key, const QVariant
 void Inspector::setProperty(CGDwelling * o, const QString & key, const QVariant & value)
 {
 	if(!o) return;
-	
+
 	if(key == QObject::tr("Same as town"))
 	{
 		if (!o->randomizationInfo.has_value())
@@ -678,7 +678,7 @@ void Inspector::setProperty(CGDwelling * o, const QString & key, const QVariant
 void Inspector::setProperty(CGGarrison * o, const QString & key, const QVariant & value)
 {
 	if(!o) return;
-	
+
 	if(key == QObject::tr("Removable units"))
 		o->removableUnits = value.toBool();
 }
@@ -701,13 +701,13 @@ void Inspector::setProperty(CGHeroPlaceholder * o, const QString & key, const QV
 				o->powerRank = 0;
 			o->heroType.reset();
 		}
-		
+
 		updateProperties();
 	}
-	
+
 	if(key == QObject::tr("Power rank"))
 		o->powerRank = value.toInt();
-	
+
 	if(key == QObject::tr("Hero type"))
 	{
 		o->heroType = HeroTypeID(value.toInt());
@@ -717,21 +717,21 @@ void Inspector::setProperty(CGHeroPlaceholder * o, const QString & key, const QV
 void Inspector::setProperty(CGHeroInstance * o, const QString & key, const QVariant & value)
 {
 	if(!o) return;
-	
+
 	if(key == QObject::tr("Gender"))
 		o->gender = EHeroGender(value.toInt());
-	
+
 	if(key == QObject::tr("Name"))
 		o->nameCustomTextId = mapRegisterLocalizedString("map", *controller.map(),
 			TextIdentifier("hero", o->instanceName, "name"), value.toString().toStdString());
-	
+
 	if(key == QObject::tr("Biography"))
 		o->biographyCustomTextId = mapRegisterLocalizedString("map", *controller.map(),
 			TextIdentifier("hero", o->instanceName, "biography"), value.toString().toStdString());
-	
+
 	if(key == QObject::tr("Experience"))
 		o->exp = value.toString().toInt();
-	
+
 	if(key == QObject::tr("Hero type"))
 	{
 		for(auto const & t : LIBRARY->heroh->objects)
@@ -760,7 +760,7 @@ void Inspector::setProperty(CGShipyard * o, const QString & key, const QVariant
 void Inspector::setProperty(CGResource * o, const QString & key, const QVariant & value)
 {
 	if(!o) return;
-	
+
 	if(key == QObject::tr("Amount"))
 		o->amount = value.toString().toInt();
 }
@@ -768,7 +768,7 @@ void Inspector::setProperty(CGResource * o, const QString & key, const QVariant
 void Inspector::setProperty(CGCreature * o, const QString & key, const QVariant & value)
 {
 	if(!o) return;
-	
+
 	if(key == QObject::tr("Message"))
 		o->message = MetaString::createFromTextID(mapRegisterLocalizedString("map", *controller.map(),
 			TextIdentifier("monster", o->instanceName, "message"), value.toString().toStdString()));
@@ -785,7 +785,7 @@ void Inspector::setProperty(CGCreature * o, const QString & key, const QVariant
 void Inspector::setProperty(CGSeerHut * o, const QString & key, const QVariant & value)
 {
 	if(!o) return;
-	
+
 	if(key == QObject::tr("First visit text"))
 		o->getQuest().firstVisitText = MetaString::createFromTextID(mapRegisterLocalizedString("map", *controller.map(),
 			TextIdentifier("quest", o->instanceName, "firstVisit"), value.toString().toStdString()));
@@ -881,12 +881,12 @@ QTableWidgetItem * Inspector::addProperty(const PlayerColor & value)
 	auto str = QObject::tr("UNFLAGGABLE");
 	if(value == PlayerColor::NEUTRAL)
 		str = QObject::tr("neutral");
-	
+
 	MetaString playerStr;
 	playerStr.appendName(value);
 	if(value.isValidPlayer())
 		str = QString::fromStdString(playerStr.toString());
-	
+
 	auto * item = new QTableWidgetItem(str);
 	item->setFlags(Qt::NoItemFlags);
 	item->setData(Qt::UserRole, QVariant::fromValue(value.getNum()));
@@ -908,7 +908,7 @@ QTableWidgetItem * Inspector::addProperty(CGCreature::Character value)
 	auto * item = new QTableWidgetItem;
 	item->setFlags(Qt::NoItemFlags);
 	item->setData(Qt::UserRole, QVariant::fromValue(int(value)));
-	
+
 	for(const auto & i : characterIdentifiers)
 	{
 		if(i.second.toInt() == static_cast<int>(value))
@@ -917,7 +917,7 @@ QTableWidgetItem * Inspector::addProperty(CGCreature::Character value)
 			break;
 		}
 	}
-	
+
 	return item;
 }