From da91e90a7b6e86023898012586557b09fe22db69 Mon Sep 17 00:00:00 2001 From: godric3 Date: Thu, 29 Feb 2024 22:38:31 +0100 Subject: [PATCH] map editor: dont suggest neutral owner for hero --- mapeditor/inspector/inspector.cpp | 8 +++++--- mapeditor/inspector/inspector.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mapeditor/inspector/inspector.cpp b/mapeditor/inspector/inspector.cpp index ec6e4e996..5ae80af4d 100644 --- a/mapeditor/inspector/inspector.cpp +++ b/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("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()) }); diff --git a/mapeditor/inspector/inspector.h b/mapeditor/inspector/inspector.h index 97acd3e91..1bb962555 100644 --- a/mapeditor/inspector/inspector.h +++ b/mapeditor/inspector/inspector.h @@ -177,5 +177,5 @@ class OwnerDelegate : public InspectorDelegate { Q_OBJECT public: - OwnerDelegate(MapController &); + OwnerDelegate(MapController & controller, bool addNeutral = true); }; \ No newline at end of file