mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
map editor: fix owner selection
This commit is contained in:
parent
cb841e2e02
commit
51386db347
@ -233,7 +233,7 @@ void Inspector::updateProperties(CGDwelling * o)
|
||||
{
|
||||
if(!o) return;
|
||||
|
||||
addProperty("Owner", o->tempOwner, false);
|
||||
addProperty("Owner", o->tempOwner, new OwnerDelegate(controller), false);
|
||||
|
||||
if (o->ID == Obj::RANDOM_DWELLING || o->ID == Obj::RANDOM_DWELLING_LVL)
|
||||
{
|
||||
@ -245,15 +245,15 @@ void Inspector::updateProperties(CGDwelling * o)
|
||||
void Inspector::updateProperties(CGLighthouse * o)
|
||||
{
|
||||
if(!o) return;
|
||||
|
||||
addProperty("Owner", o->tempOwner, false);
|
||||
|
||||
addProperty("Owner", o->tempOwner, new OwnerDelegate(controller), false);
|
||||
}
|
||||
|
||||
void Inspector::updateProperties(CGGarrison * o)
|
||||
{
|
||||
if(!o) return;
|
||||
|
||||
addProperty("Owner", o->tempOwner, false);
|
||||
addProperty("Owner", o->tempOwner, new OwnerDelegate(controller), false);
|
||||
addProperty("Removable units", o->removableUnits, false);
|
||||
}
|
||||
|
||||
@ -261,14 +261,14 @@ void Inspector::updateProperties(CGShipyard * o)
|
||||
{
|
||||
if(!o) return;
|
||||
|
||||
addProperty("Owner", o->tempOwner, false);
|
||||
addProperty("Owner", o->tempOwner, new OwnerDelegate(controller), false);
|
||||
}
|
||||
|
||||
void Inspector::updateProperties(CGHeroPlaceholder * o)
|
||||
{
|
||||
if(!o) return;
|
||||
|
||||
addProperty("Owner", o->tempOwner, false);
|
||||
addProperty("Owner", o->tempOwner, new OwnerDelegate(controller), false);
|
||||
|
||||
bool type = false;
|
||||
if(o->heroType.has_value())
|
||||
@ -298,7 +298,7 @@ void Inspector::updateProperties(CGHeroInstance * o)
|
||||
{
|
||||
if(!o) return;
|
||||
|
||||
addProperty("Owner", o->tempOwner, o->ID == Obj::PRISON); //field is not editable for prison
|
||||
addProperty("Owner", o->tempOwner, new OwnerDelegate(controller), o->ID == Obj::PRISON); //field is not editable for prison
|
||||
addProperty<int>("Experience", o->exp, false);
|
||||
addProperty("Hero class", o->type ? o->type->heroClass->getNameTranslated() : "", true);
|
||||
|
||||
@ -368,7 +368,7 @@ void Inspector::updateProperties(CGMine * o)
|
||||
{
|
||||
if(!o) return;
|
||||
|
||||
addProperty("Owner", o->tempOwner, false);
|
||||
addProperty("Owner", o->tempOwner, new OwnerDelegate(controller), false);
|
||||
addProperty("Resource", o->producedResource);
|
||||
addProperty("Productivity", o->producedQuantity);
|
||||
}
|
||||
@ -474,12 +474,7 @@ void Inspector::updateProperties()
|
||||
addProperty("IsStatic", factory->isStaticObject());
|
||||
}
|
||||
|
||||
auto * delegate = new InspectorDelegate();
|
||||
delegate->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())
|
||||
delegate->options.push_back({QString::fromStdString(GameConstants::PLAYER_COLOR_NAMES[p]), QVariant::fromValue(PlayerColor(p).getNum())});
|
||||
addProperty("Owner", obj->tempOwner, delegate, true);
|
||||
addProperty("Owner", obj->tempOwner, new OwnerDelegate(controller), true);
|
||||
|
||||
UPDATE_OBJ_PROPERTIES(CArmedInstance);
|
||||
UPDATE_OBJ_PROPERTIES(CGResource);
|
||||
@ -927,3 +922,11 @@ void InspectorDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||
QStyledItemDelegate::setModelData(editor, model, index);
|
||||
}
|
||||
}
|
||||
|
||||
OwnerDelegate::OwnerDelegate(MapController & controller)
|
||||
{
|
||||
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()) });
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ protected:
|
||||
{
|
||||
itemKey = keyItems[key];
|
||||
table->setItem(table->row(itemKey), 1, itemValue);
|
||||
table->setItemDelegateForRow(table->row(itemKey), delegate);
|
||||
table->setItemDelegateForRow(table->row(itemKey), delegate);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -138,7 +138,7 @@ protected:
|
||||
table->setRowCount(row + 1);
|
||||
table->setItem(row, 0, itemKey);
|
||||
table->setItem(row, 1, itemValue);
|
||||
table->setItemDelegateForRow(row, delegate);
|
||||
table->setItemDelegateForRow(row, delegate);
|
||||
++row;
|
||||
}
|
||||
itemKey->setFlags(restricted ? Qt::NoItemFlags : Qt::ItemIsEnabled);
|
||||
@ -171,3 +171,11 @@ public:
|
||||
|
||||
QList<std::pair<QString, QVariant>> options;
|
||||
};
|
||||
|
||||
|
||||
class OwnerDelegate : public InspectorDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
OwnerDelegate(MapController &);
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user