1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 21:23:52 +00:00

Add creature/item levelled lists (non table items) to dialogue subview.

This commit is contained in:
cc9cii 2015-04-17 11:50:19 +10:00
parent a2d824bfa6
commit 32e73c3deb
4 changed files with 185 additions and 38 deletions

View file

@ -223,49 +223,51 @@ namespace CSMWorld
{ ColumnId_AreaSound, "Area Sound" }, { ColumnId_AreaSound, "Area Sound" },
{ ColumnId_BoltSound, "Bolt Sound" }, { ColumnId_BoltSound, "Bolt Sound" },
{ ColumnId_PathgridPoints, "Points"}, { ColumnId_PathgridPoints, "Points" },
{ ColumnId_PathgridIndex, "Index"}, { ColumnId_PathgridIndex, "Index" },
{ ColumnId_PathgridPosX, "X"}, { ColumnId_PathgridPosX, "X" },
{ ColumnId_PathgridPosY, "Y"}, { ColumnId_PathgridPosY, "Y" },
{ ColumnId_PathgridPosZ, "Z"}, { ColumnId_PathgridPosZ, "Z" },
{ ColumnId_PathgridEdges, "Edges"}, { ColumnId_PathgridEdges, "Edges" },
{ ColumnId_PathgridEdgeIndex, "Index"}, { ColumnId_PathgridEdgeIndex, "Index" },
{ ColumnId_PathgridEdge0, "Point 0"}, { ColumnId_PathgridEdge0, "Point 0" },
{ ColumnId_PathgridEdge1, "Point 1"}, { ColumnId_PathgridEdge1, "Point 1" },
{ ColumnId_RegionSounds, "Sounds"}, { ColumnId_RegionSounds, "Sounds" },
{ ColumnId_SoundName, "Name"}, { ColumnId_SoundName, "Name" },
{ ColumnId_SoundChance, "Chance"}, { ColumnId_SoundChance, "Chance" },
{ ColumnId_FactionReactions, "Reactions"}, { ColumnId_FactionReactions, "Reactions" },
//{ ColumnId_FactionID, "Faction ID"}, //{ ColumnId_FactionID, "Faction ID" },
{ ColumnId_FactionReaction, "Reaction"}, { ColumnId_FactionReaction, "Reaction" },
{ ColumnId_EffectList, "Effects"}, { ColumnId_EffectList, "Effects" },
{ ColumnId_EffectId, "Effect"}, { ColumnId_EffectId, "Effect" },
//{ ColumnId_EffectAttribute, "Attrib"}, //{ ColumnId_EffectAttribute, "Attrib" },
{ ColumnId_EffectRange, "Range"}, { ColumnId_EffectRange, "Range" },
{ ColumnId_EffectArea, "Area"}, { ColumnId_EffectArea, "Area" },
{ ColumnId_AiPackageList, "Ai Packages"}, { ColumnId_AiPackageList, "Ai Packages" },
{ ColumnId_AiPackage, "Package"}, { ColumnId_AiPackage, "Package" },
{ ColumnId_AiWanderDist, "Wander Dist"}, { ColumnId_AiWanderDist, "Wander Dist" },
{ ColumnId_AiDuration, "Duration"}, { ColumnId_AiDuration, "Duration" },
{ ColumnId_AiWanderToD, "Wander ToD"}, { ColumnId_AiWanderToD, "Wander ToD" },
{ ColumnId_AiWanderIdle, "Wander Idle"}, { ColumnId_AiWanderIdle, "Wander Idle" },
{ ColumnId_AiWanderRepeat, "Wander Repeat"}, { ColumnId_AiWanderRepeat, "Wander Repeat" },
{ ColumnId_AiActivateName, "Activate"}, { ColumnId_AiActivateName, "Activate" },
{ ColumnId_AiTargetId, "Target ID"}, { ColumnId_AiTargetId, "Target ID" },
{ ColumnId_AiTargetCell, "Target Cell"}, { ColumnId_AiTargetCell, "Target Cell" },
{ ColumnId_PartRefList, "Part Reference"}, { ColumnId_PartRefList, "Part Reference" },
{ ColumnId_PartRefType, "Type"}, { ColumnId_PartRefType, "Type" },
{ ColumnId_PartRefMale, "Male"}, { ColumnId_PartRefMale, "Male" },
{ ColumnId_PartRefFemale, "Female"}, { ColumnId_PartRefFemale, "Female" },
{ ColumnId_LevelledList,"Levelled List"}, { ColumnId_LevelledList,"Levelled List" },
{ ColumnId_LevelledItemId,"Item ID"}, { ColumnId_LevelledItemId,"Item ID" },
{ ColumnId_LevelledItemLevel,"Level"}, { ColumnId_LevelledItemLevel,"Level" },
{ ColumnId_LevelledItemType, "Type" },
{ ColumnId_LevelledItemChanceNone, "Chance None" },
{ ColumnId_UseValue1, "Use value 1" }, { ColumnId_UseValue1, "Use value 1" },
{ ColumnId_UseValue2, "Use value 2" }, { ColumnId_UseValue2, "Use value 2" },

View file

@ -256,6 +256,8 @@ namespace CSMWorld
ColumnId_LevelledList = 233, ColumnId_LevelledList = 233,
ColumnId_LevelledItemId = 234, ColumnId_LevelledItemId = 234,
ColumnId_LevelledItemLevel = 235, ColumnId_LevelledItemLevel = 235,
ColumnId_LevelledItemType = 236,
ColumnId_LevelledItemChanceNone = 237,
// Allocated to a separate value range, so we don't get a collision should we ever need // Allocated to a separate value range, so we don't get a collision should we ever need
// to extend the number of use values. // to extend the number of use values.

View file

@ -1829,9 +1829,11 @@ namespace CSMWorld
} }
}; };
struct LevListColumns : public BaseColumns struct LevListColumns : public BaseColumns
{ {
const RefIdColumn *mLevList; const RefIdColumn *mLevList;
const RefIdColumn *mNestedListLevList;
LevListColumns (const BaseColumns& base) : BaseColumns (base) {} LevListColumns (const BaseColumns& base) : BaseColumns (base) {}
}; };
@ -1863,7 +1865,7 @@ namespace CSMWorld
QVariant LevelledListRefIdAdapter<RecordT>::getData (const RefIdColumn *column, const RefIdData& data, QVariant LevelledListRefIdAdapter<RecordT>::getData (const RefIdColumn *column, const RefIdData& data,
int index) const int index) const
{ {
if (column==mLevList.mLevList) if (column==mLevList.mLevList || column == mLevList.mNestedListLevList)
return true; // to show nested tables in dialogue subview, see IdTree::hasChildren() return true; // to show nested tables in dialogue subview, see IdTree::hasChildren()
return BaseRefIdAdapter<RecordT>::getData (column, data, index); return BaseRefIdAdapter<RecordT>::getData (column, data, index);
@ -1877,6 +1879,133 @@ namespace CSMWorld
return; return;
} }
template <typename ESXRecordT>
class NestedListLevListRefIdAdapter : public NestedRefIdAdapterBase
{
UniversalId::Type mType;
// not implemented
NestedListLevListRefIdAdapter (const NestedListLevListRefIdAdapter&);
NestedListLevListRefIdAdapter& operator= (const NestedListLevListRefIdAdapter&);
public:
NestedListLevListRefIdAdapter(UniversalId::Type type)
:mType(type) {}
virtual ~NestedListLevListRefIdAdapter() {}
virtual void addNestedRow (const RefIdColumn *column,
RefIdData& data, int index, int position) const
{
throw std::logic_error ("cannot add a row to a fixed table");
}
virtual void removeNestedRow (const RefIdColumn *column,
RefIdData& data, int index, int rowToRemove) const
{
throw std::logic_error ("cannot remove a row to a fixed table");
}
virtual void setNestedTable (const RefIdColumn* column,
RefIdData& data, int index, const NestedTableWrapperBase& nestedTable) const
{
throw std::logic_error ("table operation not supported");
}
virtual NestedTableWrapperBase* nestedTable (const RefIdColumn* column,
const RefIdData& data, int index) const
{
throw std::logic_error ("table operation not supported");
}
virtual QVariant getNestedData (const RefIdColumn *column,
const RefIdData& data, int index, int subRowIndex, int subColIndex) const
{
const Record<ESXRecordT>& record =
static_cast<const Record<ESXRecordT>&> (data.getRecord (RefIdData::LocalIndex (index, mType)));
switch (subColIndex)
{
case 0:
{
if (mType == CSMWorld::UniversalId::Type_CreatureLevelledList &&
record.get().mFlags == 0x01)
{
return QString("All Levels");
}
else if(mType == CSMWorld::UniversalId::Type_ItemLevelledList &&
record.get().mFlags == 0x01)
{
return QString("Each");
}
else if(mType == CSMWorld::UniversalId::Type_ItemLevelledList &&
record.get().mFlags == 0x02)
{
return QString("All Levels");
}
else
throw std::runtime_error("unknown leveled list type");
}
case 1: return static_cast<int> (record.get().mChanceNone);
default:
throw std::runtime_error("Trying to access non-existing column in the nested table!");
}
}
virtual void setNestedData (const RefIdColumn *column,
RefIdData& data, int row, const QVariant& value, int subRowIndex, int subColIndex) const
{
Record<ESXRecordT>& record =
static_cast<Record<ESXRecordT>&> (data.getRecord (RefIdData::LocalIndex (row, mType)));
ESXRecordT leveled = record.get();
switch(subColIndex)
{
case 0:
{
if (mType == CSMWorld::UniversalId::Type_CreatureLevelledList &&
value.toString().toStdString() == "All Levels")
{
leveled.mFlags = 0x01;
break;
}
else if(mType == CSMWorld::UniversalId::Type_ItemLevelledList &&
value.toString().toStdString() == "Each")
{
leveled.mFlags = 0x01;
break;
}
else if(mType == CSMWorld::UniversalId::Type_ItemLevelledList &&
value.toString().toStdString() == "All Levels")
{
leveled.mFlags = 0x02;
break;
}
else
return; // return without saving
}
case 1: leveled.mChanceNone = static_cast<unsigned char>(value.toInt()); break;
default:
throw std::runtime_error("Trying to access non-existing column in the nested table!");
}
record.setModified (leveled);
}
virtual int getNestedColumnsCount(const RefIdColumn *column, const RefIdData& data) const
{
return 2;
}
virtual int getNestedRowsCount(const RefIdColumn *column, const RefIdData& data, int index) const
{
return 1; // fixed at size 1
}
};
template <typename ESXRecordT> template <typename ESXRecordT>
class NestedLevListRefIdAdapter : public NestedRefIdAdapterBase class NestedLevListRefIdAdapter : public NestedRefIdAdapterBase
{ {

View file

@ -503,6 +503,20 @@ CSMWorld::RefIdCollection::RefIdCollection()
mColumns.back().addColumn( mColumns.back().addColumn(
new RefIdColumn (Columns::ColumnId_LevelledItemLevel, CSMWorld::ColumnBase::Display_Integer)); new RefIdColumn (Columns::ColumnId_LevelledItemLevel, CSMWorld::ColumnBase::Display_Integer));
// Nested list
mColumns.push_back(RefIdColumn (Columns::ColumnId_LevelledList,
ColumnBase::Display_NestedHeader, ColumnBase::Flag_Dialogue | ColumnBase::Flag_Dialogue_List));
levListColumns.mNestedListLevList = &mColumns.back();
std::map<UniversalId::Type, NestedRefIdAdapterBase*> nestedListLevListMap;
nestedListLevListMap.insert(std::make_pair(UniversalId::Type_CreatureLevelledList,
new NestedListLevListRefIdAdapter<ESM::CreatureLevList> (UniversalId::Type_CreatureLevelledList)));
nestedListLevListMap.insert(std::make_pair(UniversalId::Type_ItemLevelledList,
new NestedListLevListRefIdAdapter<ESM::ItemLevList> (UniversalId::Type_ItemLevelledList)));
mNestedAdapters.push_back (std::make_pair(&mColumns.back(), nestedListLevListMap));
mColumns.back().addColumn(
new RefIdColumn (Columns::ColumnId_LevelledItemType, CSMWorld::ColumnBase::Display_String));
mColumns.back().addColumn(
new RefIdColumn (Columns::ColumnId_LevelledItemChanceNone, CSMWorld::ColumnBase::Display_Integer));
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)));