Browse Source

map editor: dont suggest neutral owner for hero

godric3 1 year ago
parent
commit
da91e90a7b
2 changed files with 6 additions and 4 deletions
  1. 5 3
      mapeditor/inspector/inspector.cpp
  2. 1 1
      mapeditor/inspector/inspector.h

+ 5 - 3
mapeditor/inspector/inspector.cpp

@@ -298,7 +298,8 @@ void Inspector::updateProperties(CGHeroInstance * o)
 {
 	if(!o) return;
 	
-	addProperty("Owner", o->tempOwner, new OwnerDelegate(controller), o->ID == Obj::PRISON); //field is not editable for prison
+	auto isPrison = o->ID == Obj::PRISON;
+	addProperty("Owner", o->tempOwner, new OwnerDelegate(controller, isPrison), isPrison); //field is not editable for prison
 	addProperty<int>("Experience", o->exp, false);
 	addProperty("Hero class", o->type ? o->type->heroClass->getNameTranslated() : "", true);
 	
@@ -923,9 +924,10 @@ void InspectorDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
 	}
 }
 
-OwnerDelegate::OwnerDelegate(MapController & controller)
+OwnerDelegate::OwnerDelegate(MapController & controller, bool addNeutral)
 {
-	options.push_back({QObject::tr("neutral"), QVariant::fromValue(PlayerColor::NEUTRAL.getNum()) });
+	if(addNeutral)
+		options.push_back({QObject::tr("neutral"), QVariant::fromValue(PlayerColor::NEUTRAL.getNum()) });
 	for(int p = 0; p < controller.map()->players.size(); ++p)
 		if(controller.map()->players[p].canAnyonePlay())
 			options.push_back({QString::fromStdString(GameConstants::PLAYER_COLOR_NAMES[p]), QVariant::fromValue(PlayerColor(p).getNum()) });

+ 1 - 1
mapeditor/inspector/inspector.h

@@ -177,5 +177,5 @@ class OwnerDelegate : public InspectorDelegate
 {
 	Q_OBJECT
 public:
-	OwnerDelegate(MapController &);
+	OwnerDelegate(MapController & controller, bool addNeutral = true);
 };