mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 06:53:53 +00:00
added missing columns for container record
This commit is contained in:
parent
28f2a7d2b4
commit
d794a62d19
3 changed files with 80 additions and 1 deletions
|
@ -170,4 +170,54 @@ void CSMWorld::ClothingRefIdAdapter::setData (const RefIdColumn *column, RefIdDa
|
||||||
record.get().mData.mType = value.toInt();
|
record.get().mData.mType = value.toInt();
|
||||||
else
|
else
|
||||||
EnchantableRefIdAdapter<ESM::Clothing>::setData (column, data, index, value);
|
EnchantableRefIdAdapter<ESM::Clothing>::setData (column, data, index, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
CSMWorld::ContainerRefIdAdapter::ContainerRefIdAdapter (const NameColumns& columns,
|
||||||
|
const RefIdColumn *weight, const RefIdColumn *organic, const RefIdColumn *respawn)
|
||||||
|
: NameRefIdAdapter<ESM::Container> (UniversalId::Type_Container, columns), mWeight (weight),
|
||||||
|
mOrganic (organic), mRespawn (respawn)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QVariant CSMWorld::ContainerRefIdAdapter::getData (const RefIdColumn *column, const RefIdData& data,
|
||||||
|
int index) const
|
||||||
|
{
|
||||||
|
const Record<ESM::Container>& record = static_cast<const Record<ESM::Container>&> (
|
||||||
|
data.getRecord (RefIdData::LocalIndex (index, UniversalId::Type_Container)));
|
||||||
|
|
||||||
|
if (column==mWeight)
|
||||||
|
return record.get().mWeight;
|
||||||
|
|
||||||
|
if (column==mOrganic)
|
||||||
|
return (record.get().mFlags & ESM::Container::Organic)!=0;
|
||||||
|
|
||||||
|
if (column==mRespawn)
|
||||||
|
return (record.get().mFlags & ESM::Container::Respawn)!=0;
|
||||||
|
|
||||||
|
return NameRefIdAdapter<ESM::Container>::getData (column, data, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMWorld::ContainerRefIdAdapter::setData (const RefIdColumn *column, RefIdData& data, int index,
|
||||||
|
const QVariant& value) const
|
||||||
|
{
|
||||||
|
Record<ESM::Container>& record = static_cast<Record<ESM::Container>&> (
|
||||||
|
data.getRecord (RefIdData::LocalIndex (index, UniversalId::Type_Container)));
|
||||||
|
|
||||||
|
if (column==mWeight)
|
||||||
|
record.get().mWeight = value.toFloat();
|
||||||
|
else if (column==mOrganic)
|
||||||
|
{
|
||||||
|
if (value.toInt())
|
||||||
|
record.get().mFlags |= ESM::Container::Organic;
|
||||||
|
else
|
||||||
|
record.get().mFlags &= ~ESM::Container::Organic;
|
||||||
|
}
|
||||||
|
else if (column==mRespawn)
|
||||||
|
{
|
||||||
|
if (value.toInt())
|
||||||
|
record.get().mFlags |= ESM::Container::Respawn;
|
||||||
|
else
|
||||||
|
record.get().mFlags &= ~ESM::Container::Respawn;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
NameRefIdAdapter<ESM::Container>::setData (column, data, index, value);
|
||||||
}
|
}
|
|
@ -596,6 +596,26 @@ namespace CSMWorld
|
||||||
const QVariant& value) const;
|
const QVariant& value) const;
|
||||||
///< If the data type does not match an exception is thrown.
|
///< If the data type does not match an exception is thrown.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ContainerRefIdAdapter : public NameRefIdAdapter<ESM::Container>
|
||||||
|
{
|
||||||
|
const RefIdColumn *mWeight;
|
||||||
|
const RefIdColumn *mOrganic;
|
||||||
|
const RefIdColumn *mRespawn;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
ContainerRefIdAdapter (const NameColumns& columns, const RefIdColumn *weight,
|
||||||
|
const RefIdColumn *organic, const RefIdColumn *respawn);
|
||||||
|
|
||||||
|
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index)
|
||||||
|
const;
|
||||||
|
|
||||||
|
virtual void setData (const RefIdColumn *column, RefIdData& data, int index,
|
||||||
|
const QVariant& value) const;
|
||||||
|
///< If the data type does not match an exception is thrown.
|
||||||
|
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -151,6 +151,15 @@ CSMWorld::RefIdCollection::RefIdCollection()
|
||||||
mColumns.push_back (RefIdColumn ("Clothing Type", ColumnBase::Display_ClothingType));
|
mColumns.push_back (RefIdColumn ("Clothing Type", ColumnBase::Display_ClothingType));
|
||||||
const RefIdColumn *clothingType = &mColumns.back();
|
const RefIdColumn *clothingType = &mColumns.back();
|
||||||
|
|
||||||
|
mColumns.push_back (RefIdColumn ("Weight Capacity", ColumnBase::Display_Float));
|
||||||
|
const RefIdColumn *weightCapacity = &mColumns.back();
|
||||||
|
|
||||||
|
mColumns.push_back (RefIdColumn ("Organic Container", ColumnBase::Display_Boolean));
|
||||||
|
const RefIdColumn *organic = &mColumns.back();
|
||||||
|
|
||||||
|
mColumns.push_back (RefIdColumn ("Respawn", ColumnBase::Display_Boolean));
|
||||||
|
const RefIdColumn *respawn = &mColumns.back();
|
||||||
|
|
||||||
mAdapters.insert (std::make_pair (UniversalId::Type_Activator,
|
mAdapters.insert (std::make_pair (UniversalId::Type_Activator,
|
||||||
new NameRefIdAdapter<ESM::Activator> (UniversalId::Type_Activator, nameColumns)));
|
new NameRefIdAdapter<ESM::Activator> (UniversalId::Type_Activator, nameColumns)));
|
||||||
mAdapters.insert (std::make_pair (UniversalId::Type_Potion,
|
mAdapters.insert (std::make_pair (UniversalId::Type_Potion,
|
||||||
|
@ -164,7 +173,7 @@ CSMWorld::RefIdCollection::RefIdCollection()
|
||||||
mAdapters.insert (std::make_pair (UniversalId::Type_Clothing,
|
mAdapters.insert (std::make_pair (UniversalId::Type_Clothing,
|
||||||
new ClothingRefIdAdapter (enchantableColumns, clothingType)));
|
new ClothingRefIdAdapter (enchantableColumns, clothingType)));
|
||||||
mAdapters.insert (std::make_pair (UniversalId::Type_Container,
|
mAdapters.insert (std::make_pair (UniversalId::Type_Container,
|
||||||
new NameRefIdAdapter<ESM::Container> (UniversalId::Type_Container, nameColumns)));
|
new ContainerRefIdAdapter (nameColumns, weightCapacity, organic, respawn)));
|
||||||
mAdapters.insert (std::make_pair (UniversalId::Type_Creature,
|
mAdapters.insert (std::make_pair (UniversalId::Type_Creature,
|
||||||
new ActorRefIdAdapter<ESM::Creature> (UniversalId::Type_Creature, actorsColumns)));
|
new ActorRefIdAdapter<ESM::Creature> (UniversalId::Type_Creature, actorsColumns)));
|
||||||
mAdapters.insert (std::make_pair (UniversalId::Type_Door,
|
mAdapters.insert (std::make_pair (UniversalId::Type_Door,
|
||||||
|
|
Loading…
Reference in a new issue