1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-18 03:21:27 +02:00

Add spell scroll inspector

This commit is contained in:
nordsoft 2022-09-08 04:16:16 +04:00
parent 3f4fa8ec10
commit 50dbf9a254
3 changed files with 41 additions and 9 deletions

View File

@ -123,7 +123,7 @@ void Inspector::updateProperties(CArmedInstance * o)
{
if(!o) return;
auto * delegate = new InspectorDelegate;
auto * delegate = new InspectorDelegate();
delegate->options << "NEUTRAL";
for(int p = 0; p < map->players.size(); ++p)
if(map->players[p].canAnyonePlay())
@ -170,6 +170,24 @@ void Inspector::updateProperties(CGTownInstance * o)
void Inspector::updateProperties(CGArtifact * o)
{
if(!o) return;
addProperty("Message", o->message, false);
CArtifactInstance * instance = o->storedArtifact;
if(instance)
{
SpellID spellId = instance->getGivenSpellID();
if(spellId != -1)
{
auto * delegate = new InspectorDelegate;
for(auto spell : VLC->spellh->objects)
{
//if(map->isAllowedSpell(spell->id))
delegate->options << QString::fromStdString(spell->name);
}
addProperty("Spell", VLC->spellh->objects[spellId]->name, delegate, false);
}
}
}
void Inspector::updateProperties(CGMine * o)
@ -186,6 +204,7 @@ void Inspector::updateProperties(CGResource * o)
if(!o) return;
addProperty("Amount", o->amount, false);
addProperty("Message", o->message, false);
}
void Inspector::updateProperties(CGCreature * o)
@ -286,6 +305,21 @@ void Inspector::setProperty(CGMine * object, const QString & key, const QVariant
void Inspector::setProperty(CGArtifact * object, const QString & key, const QVariant & value)
{
if(!object) return;
if(key == "Message")
object->message = value.toString().toStdString();
if(object->storedArtifact && key == "Spell")
{
for(auto spell : VLC->spellh->objects)
{
if(spell->name == value.toString().toStdString())
{
object->storedArtifact = CArtifactInstance::createScroll(spell->getId());
break;
}
}
}
}
void Inspector::setProperty(CGDwelling * object, const QString & key, const QVariant & value)

View File

@ -131,8 +131,6 @@ class InspectorDelegate : public QStyledItemDelegate
public:
static InspectorDelegate * boolDelegate();
InspectorDelegate(const QStringList &);
using QStyledItemDelegate::QStyledItemDelegate;
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;

View File

@ -197,13 +197,13 @@
</property>
<property name="minimumSize">
<size>
<width>192</width>
<width>268</width>
<height>196</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>192</width>
<width>524287</width>
<height>524287</height>
</size>
</property>
@ -344,7 +344,7 @@
</font>
</property>
<property name="editTriggers">
<set>QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked</set>
<set>QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked</set>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
@ -668,7 +668,7 @@
<x>0</x>
<y>0</y>
<width>128</width>
<height>344</height>
<height>271</height>
</rect>
</property>
<property name="sizePolicy">
@ -711,7 +711,7 @@
<x>0</x>
<y>0</y>
<width>128</width>
<height>344</height>
<height>271</height>
</rect>
</property>
<property name="sizePolicy">
@ -730,7 +730,7 @@
<x>0</x>
<y>0</y>
<width>128</width>
<height>344</height>
<height>271</height>
</rect>
</property>
<property name="sizePolicy">