forked from teamnwah/openmw-tes3coop
Add Spells and Enchantment magic effects table to dialogue subview. The numbers are not yet converted to strings.
This commit is contained in:
parent
49fd5afdf6
commit
a460409555
6 changed files with 200 additions and 106 deletions
|
@ -2265,97 +2265,6 @@ namespace CSMWorld
|
|||
}
|
||||
};
|
||||
|
||||
template<typename ESXRecordT>
|
||||
struct PathgridPointListColumn : public Column<ESXRecordT>
|
||||
{
|
||||
PathgridPointListColumn ()
|
||||
: Column<ESXRecordT> (Columns::ColumnId_PathgridPoints,
|
||||
ColumnBase::Display_PathgridPointList, ColumnBase::Flag_Dialogue)
|
||||
{}
|
||||
|
||||
virtual QVariant get (const Record<ESXRecordT>& record) const
|
||||
{
|
||||
return true; // required by IdTree::hasChildren()
|
||||
}
|
||||
|
||||
virtual bool isEditable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct PathgridIndexColumn : public NestableColumn
|
||||
{
|
||||
PathgridIndexColumn()
|
||||
: NestableColumn (Columns::ColumnId_PathgridIndex,
|
||||
ColumnBase::Display_Integer, ColumnBase::Flag_Dialogue)
|
||||
{}
|
||||
|
||||
virtual bool isEditable() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
struct PathgridPointColumn : public NestableColumn
|
||||
{
|
||||
PathgridPointColumn(int index)
|
||||
: NestableColumn (Columns::ColumnId_PathgridPosX+index,
|
||||
ColumnBase::Display_Integer, ColumnBase::Flag_Dialogue)
|
||||
{}
|
||||
|
||||
virtual bool isEditable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename ESXRecordT>
|
||||
struct PathgridEdgeListColumn : public Column<ESXRecordT>
|
||||
{
|
||||
PathgridEdgeListColumn ()
|
||||
: Column<ESXRecordT> (Columns::ColumnId_PathgridEdges,
|
||||
ColumnBase::Display_PathgridEdgeList, ColumnBase::Flag_Dialogue)
|
||||
{}
|
||||
|
||||
virtual QVariant get (const Record<ESXRecordT>& record) const
|
||||
{
|
||||
return true; // required by IdTree::hasChildren()
|
||||
}
|
||||
|
||||
virtual bool isEditable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct PathgridEdgeIndexColumn : public NestableColumn
|
||||
{
|
||||
PathgridEdgeIndexColumn()
|
||||
: NestableColumn (Columns::ColumnId_PathgridEdgeIndex,
|
||||
ColumnBase::Display_Integer, ColumnBase::Flag_Dialogue)
|
||||
{}
|
||||
|
||||
virtual bool isEditable() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
struct PathgridEdgeColumn : public NestableColumn
|
||||
{
|
||||
PathgridEdgeColumn (int index)
|
||||
: NestableColumn (Columns::ColumnId_PathgridEdge0+index,
|
||||
ColumnBase::Display_Integer, ColumnBase::Flag_Dialogue)
|
||||
{}
|
||||
|
||||
virtual bool isEditable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename ESXRecordT>
|
||||
struct NestedParentColumn : public Column<ESXRecordT>
|
||||
{
|
||||
|
@ -2389,13 +2298,16 @@ namespace CSMWorld
|
|||
|
||||
struct NestedIntegerColumn : public NestableColumn
|
||||
{
|
||||
NestedIntegerColumn (Columns::ColumnId id)
|
||||
bool mIsEditable;
|
||||
|
||||
NestedIntegerColumn (Columns::ColumnId id, bool isEditable = true)
|
||||
: NestableColumn (id, ColumnBase::Display_Integer, ColumnBase::Flag_Dialogue)
|
||||
, mIsEditable(isEditable)
|
||||
{}
|
||||
|
||||
virtual bool isEditable() const
|
||||
{
|
||||
return true;
|
||||
return mIsEditable;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -241,6 +241,12 @@ namespace CSMWorld
|
|||
//{ ColumnId_FactionID, "Faction ID"},
|
||||
{ ColumnId_FactionReaction, "Reaction"},
|
||||
|
||||
{ ColumnId_EffectList, "Effects"},
|
||||
{ ColumnId_EffectId, "ID"},
|
||||
{ ColumnId_EffectAttribute, "Attrib"},
|
||||
{ ColumnId_EffectRange, "Range"},
|
||||
{ ColumnId_EffectArea, "Area"},
|
||||
|
||||
{ ColumnId_UseValue1, "Use value 1" },
|
||||
{ ColumnId_UseValue2, "Use value 2" },
|
||||
{ ColumnId_UseValue3, "Use value 3" },
|
||||
|
|
|
@ -230,6 +230,12 @@ namespace CSMWorld
|
|||
//ColumnId_FactionID = 212,
|
||||
ColumnId_FactionReaction = 213,
|
||||
|
||||
ColumnId_EffectList = 214,
|
||||
ColumnId_EffectId = 215,
|
||||
ColumnId_EffectAttribute = 216,
|
||||
ColumnId_EffectRange = 217,
|
||||
ColumnId_EffectArea = 218,
|
||||
|
||||
// Allocated to a separate value range, so we don't get a collision should we ever need
|
||||
// to extend the number of use values.
|
||||
ColumnId_UseValue1 = 0x10000,
|
||||
|
|
|
@ -189,6 +189,27 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
|
|||
mSpells.addColumn (new FlagColumn<ESM::Spell> (Columns::ColumnId_AutoCalc, 0x1));
|
||||
mSpells.addColumn (new FlagColumn<ESM::Spell> (Columns::ColumnId_StarterSpell, 0x2));
|
||||
mSpells.addColumn (new FlagColumn<ESM::Spell> (Columns::ColumnId_AlwaysSucceeds, 0x4));
|
||||
// Spell effects
|
||||
NestedParentColumn<ESM::Spell> *spellEffect =
|
||||
new NestedParentColumn<ESM::Spell> (Columns::ColumnId_EffectList);
|
||||
mSpells.addColumn (spellEffect);
|
||||
mSpells.addAdapter (std::make_pair(spellEffect, new EffectsListAdapter<ESM::Spell> ()));
|
||||
mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn(
|
||||
new NestedIntegerColumn (Columns::ColumnId_EffectId));
|
||||
mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn(
|
||||
new NestedIntegerColumn (Columns::ColumnId_Skill));
|
||||
mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn(
|
||||
new NestedIntegerColumn (Columns::ColumnId_EffectAttribute));
|
||||
mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn(
|
||||
new NestedIntegerColumn (Columns::ColumnId_EffectRange));
|
||||
mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn(
|
||||
new NestedIntegerColumn (Columns::ColumnId_EffectArea));
|
||||
mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn(
|
||||
new NestedIntegerColumn (Columns::ColumnId_Duration)); // reuse from light
|
||||
mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn(
|
||||
new NestedIntegerColumn (Columns::ColumnId_MinRange)); // reuse from sound
|
||||
mSpells.getNestableColumn(mSpells.getColumns()-1)->addColumn(
|
||||
new NestedIntegerColumn (Columns::ColumnId_MaxRange)); // reuse from sound
|
||||
|
||||
mTopics.addColumn (new StringIdColumn<ESM::Dialogue>);
|
||||
mTopics.addColumn (new RecordStateColumn<ESM::Dialogue>);
|
||||
|
@ -242,6 +263,27 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
|
|||
mEnchantments.addColumn (new CostColumn<ESM::Enchantment>);
|
||||
mEnchantments.addColumn (new ChargesColumn2<ESM::Enchantment>);
|
||||
mEnchantments.addColumn (new AutoCalcColumn<ESM::Enchantment>);
|
||||
// Enchantment effects
|
||||
NestedParentColumn<ESM::Enchantment> *enchantmentEffect =
|
||||
new NestedParentColumn<ESM::Enchantment> (Columns::ColumnId_EffectList);
|
||||
mEnchantments.addColumn (enchantmentEffect);
|
||||
mEnchantments.addAdapter (std::make_pair(enchantmentEffect, new EffectsListAdapter<ESM::Enchantment> ()));
|
||||
mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn(
|
||||
new NestedIntegerColumn (Columns::ColumnId_EffectId));
|
||||
mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn(
|
||||
new NestedIntegerColumn (Columns::ColumnId_Skill));
|
||||
mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn(
|
||||
new NestedIntegerColumn (Columns::ColumnId_EffectAttribute));
|
||||
mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn(
|
||||
new NestedIntegerColumn (Columns::ColumnId_EffectRange));
|
||||
mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn(
|
||||
new NestedIntegerColumn (Columns::ColumnId_EffectArea));
|
||||
mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn(
|
||||
new NestedIntegerColumn (Columns::ColumnId_Duration)); // reuse from light
|
||||
mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn(
|
||||
new NestedIntegerColumn (Columns::ColumnId_MinRange)); // reuse from sound
|
||||
mEnchantments.getNestableColumn(mEnchantments.getColumns()-1)->addColumn(
|
||||
new NestedIntegerColumn (Columns::ColumnId_MaxRange)); // reuse from sound
|
||||
|
||||
mBodyParts.addColumn (new StringIdColumn<ESM::BodyPart>);
|
||||
mBodyParts.addColumn (new RecordStateColumn<ESM::BodyPart>);
|
||||
|
@ -289,23 +331,32 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
|
|||
mPathgrids.addColumn (new FixedRecordTypeColumn<Pathgrid> (UniversalId::Type_Pathgrid));
|
||||
|
||||
// new object deleted in dtor of Collection<T,A>
|
||||
PathgridPointListColumn<Pathgrid> *pointList = new PathgridPointListColumn<Pathgrid> ();
|
||||
NestedParentColumn<Pathgrid> *pointList =
|
||||
new NestedParentColumn<Pathgrid> (Columns::ColumnId_PathgridPoints);
|
||||
mPathgrids.addColumn (pointList);
|
||||
// new object deleted in dtor of SubCellCollection<T,A>
|
||||
mPathgrids.addAdapter (std::make_pair(pointList, new PathgridPointListAdapter<Pathgrid> ()));
|
||||
// new objects deleted in dtor of NestableColumn
|
||||
// WARNING: The order of the columns below are assumed in PathgridPointListAdapter
|
||||
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn(new PathgridIndexColumn ());
|
||||
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn(new PathgridPointColumn (0));
|
||||
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn(new PathgridPointColumn (1));
|
||||
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn(new PathgridPointColumn (2));
|
||||
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn(
|
||||
new NestedIntegerColumn (Columns::ColumnId_PathgridIndex, false));
|
||||
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn(
|
||||
new NestedIntegerColumn (Columns::ColumnId_PathgridPosX));
|
||||
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn(
|
||||
new NestedIntegerColumn (Columns::ColumnId_PathgridPosY));
|
||||
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn(
|
||||
new NestedIntegerColumn (Columns::ColumnId_PathgridPosZ));
|
||||
|
||||
PathgridEdgeListColumn<Pathgrid> *edgeList = new PathgridEdgeListColumn<Pathgrid> ();
|
||||
NestedParentColumn<Pathgrid> *edgeList =
|
||||
new NestedParentColumn<Pathgrid> (Columns::ColumnId_PathgridEdges);
|
||||
mPathgrids.addColumn (edgeList);
|
||||
mPathgrids.addAdapter (std::make_pair(edgeList, new PathgridEdgeListAdapter<Pathgrid> ()));
|
||||
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn(new PathgridEdgeIndexColumn ());
|
||||
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn(new PathgridEdgeColumn (0));
|
||||
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn(new PathgridEdgeColumn (1));
|
||||
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn(
|
||||
new NestedIntegerColumn (Columns::ColumnId_PathgridEdgeIndex, false));
|
||||
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn(
|
||||
new NestedIntegerColumn (Columns::ColumnId_PathgridEdge0));
|
||||
mPathgrids.getNestableColumn(mPathgrids.getColumns()-1)->addColumn(
|
||||
new NestedIntegerColumn (Columns::ColumnId_PathgridEdge1));
|
||||
|
||||
mStartScripts.addColumn (new StringIdColumn<ESM::StartScript>);
|
||||
mStartScripts.addColumn (new RecordStateColumn<ESM::StartScript>);
|
||||
|
@ -373,13 +424,13 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
|
|||
addModel (new IdTable (&mScripts), UniversalId::Type_Script);
|
||||
addModel (new IdTree (&mRegions, &mRegions), UniversalId::Type_Region);
|
||||
addModel (new IdTree (&mBirthsigns, &mBirthsigns), UniversalId::Type_Birthsign);
|
||||
addModel (new IdTable (&mSpells), UniversalId::Type_Spell);
|
||||
addModel (new IdTree (&mSpells, &mSpells), UniversalId::Type_Spell);
|
||||
addModel (new IdTable (&mTopics), UniversalId::Type_Topic);
|
||||
addModel (new IdTable (&mJournals), UniversalId::Type_Journal);
|
||||
addModel (new IdTable (&mTopicInfos, IdTable::Feature_ReorderWithinTopic), UniversalId::Type_TopicInfo);
|
||||
addModel (new IdTable (&mJournalInfos, IdTable::Feature_ReorderWithinTopic), UniversalId::Type_JournalInfo);
|
||||
addModel (new IdTable (&mCells, IdTable::Feature_ViewId), UniversalId::Type_Cell);
|
||||
addModel (new IdTable (&mEnchantments), UniversalId::Type_Enchantment);
|
||||
addModel (new IdTree (&mEnchantments, &mEnchantments), UniversalId::Type_Enchantment);
|
||||
addModel (new IdTable (&mBodyParts), UniversalId::Type_BodyPart);
|
||||
addModel (new IdTable (&mSoundGens), UniversalId::Type_SoundGen);
|
||||
addModel (new IdTable (&mMagicEffects), UniversalId::Type_MagicEffect);
|
||||
|
|
|
@ -75,10 +75,10 @@ namespace CSMWorld
|
|||
IdCollection<ESM::Script> mScripts;
|
||||
NestedIdCollection<ESM::Region> mRegions;
|
||||
NestedIdCollection<ESM::BirthSign> mBirthsigns;
|
||||
IdCollection<ESM::Spell> mSpells;
|
||||
NestedIdCollection<ESM::Spell> mSpells;
|
||||
IdCollection<ESM::Dialogue> mTopics;
|
||||
IdCollection<ESM::Dialogue> mJournals;
|
||||
IdCollection<ESM::Enchantment> mEnchantments;
|
||||
NestedIdCollection<ESM::Enchantment> mEnchantments;
|
||||
IdCollection<ESM::BodyPart> mBodyParts;
|
||||
IdCollection<ESM::MagicEffect> mMagicEffects;
|
||||
SubCellCollection<Pathgrid> mPathgrids;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <components/esm/loadpgrd.hpp>
|
||||
#include <components/esm/loadregn.hpp>
|
||||
#include <components/esm/loadfact.hpp>
|
||||
#include <components/esm/effectlist.hpp>
|
||||
|
||||
#include "idadapter.hpp"
|
||||
#include "nestedtablewrapper.hpp"
|
||||
|
@ -583,6 +584,124 @@ namespace CSMWorld
|
|||
return static_cast<int>(record.get().mPowers.mList.size());
|
||||
}
|
||||
};
|
||||
|
||||
template<typename ESXRecordT>
|
||||
class EffectsListAdapter : public NestedIdAdapter<ESXRecordT>
|
||||
{
|
||||
public:
|
||||
EffectsListAdapter () {}
|
||||
|
||||
virtual void addNestedRow(Record<ESXRecordT>& record, int position) const
|
||||
{
|
||||
ESXRecordT magic = record.get();
|
||||
|
||||
std::vector<ESM::ENAMstruct>& effectsList = magic.mEffects.mList;
|
||||
|
||||
// blank row
|
||||
ESM::ENAMstruct effect;
|
||||
effect.mEffectID = 0;
|
||||
effect.mSkill = 0;
|
||||
effect.mAttribute = 0;
|
||||
effect.mRange = 0;
|
||||
effect.mArea = 0;
|
||||
effect.mDuration = 0;
|
||||
effect.mMagnMin = 0;
|
||||
effect.mMagnMax = 0;
|
||||
|
||||
effectsList.insert(effectsList.begin()+position, effect);
|
||||
|
||||
record.setModified (magic);
|
||||
}
|
||||
|
||||
virtual void removeNestedRow(Record<ESXRecordT>& record, int rowToRemove) const
|
||||
{
|
||||
ESXRecordT magic = record.get();
|
||||
|
||||
std::vector<ESM::ENAMstruct>& effectsList = magic.mEffects.mList;
|
||||
|
||||
if (rowToRemove < 0 || rowToRemove >= static_cast<int> (effectsList.size()))
|
||||
throw std::runtime_error ("index out of range");
|
||||
|
||||
effectsList.erase(effectsList.begin()+rowToRemove);
|
||||
|
||||
record.setModified (magic);
|
||||
}
|
||||
|
||||
virtual void setNestedTable(Record<ESXRecordT>& record, const NestedTableWrapperBase& nestedTable) const
|
||||
{
|
||||
record.get().mEffects.mList =
|
||||
static_cast<const NestedTableWrapper<std::vector<ESM::ENAMstruct> >&>(nestedTable).mNestedTable;
|
||||
}
|
||||
|
||||
virtual NestedTableWrapperBase* nestedTable(const Record<ESXRecordT>& record) const
|
||||
{
|
||||
// deleted by dtor of NestedTableStoring
|
||||
return new NestedTableWrapper<std::vector<ESM::ENAMstruct> >(record.get().mEffects.mList);
|
||||
}
|
||||
|
||||
virtual QVariant getNestedData(const Record<ESXRecordT>& record, int subRowIndex, int subColIndex) const
|
||||
{
|
||||
ESXRecordT magic = record.get();
|
||||
|
||||
std::vector<ESM::ENAMstruct>& effectsList = magic.mEffects.mList;
|
||||
|
||||
if (subRowIndex < 0 || subRowIndex >= static_cast<int> (effectsList.size()))
|
||||
throw std::runtime_error ("index out of range");
|
||||
|
||||
ESM::ENAMstruct effect = effectsList[subRowIndex];
|
||||
switch (subColIndex)
|
||||
{
|
||||
case 0: return effect.mEffectID;
|
||||
case 1: return effect.mSkill;
|
||||
case 2: return effect.mAttribute;
|
||||
case 3: return effect.mRange;
|
||||
case 4: return effect.mArea;
|
||||
case 5: return effect.mDuration;
|
||||
case 6: return effect.mMagnMin;
|
||||
case 7: return effect.mMagnMax;
|
||||
default: throw std::runtime_error("Magic Effects subcolumn index out of range");
|
||||
}
|
||||
}
|
||||
|
||||
virtual void setNestedData(Record<ESXRecordT>& record, const QVariant& value,
|
||||
int subRowIndex, int subColIndex) const
|
||||
{
|
||||
ESXRecordT magic = record.get();
|
||||
|
||||
std::vector<ESM::ENAMstruct>& effectsList = magic.mEffects.mList;
|
||||
|
||||
if (subRowIndex < 0 || subRowIndex >= static_cast<int> (effectsList.size()))
|
||||
throw std::runtime_error ("index out of range");
|
||||
|
||||
ESM::ENAMstruct effect = effectsList[subRowIndex];
|
||||
switch (subColIndex)
|
||||
{
|
||||
case 0: effect.mEffectID = static_cast<short>(value.toInt()); break;
|
||||
case 1: effect.mSkill = static_cast<signed char>(value.toInt()); break;
|
||||
case 2: effect.mAttribute = static_cast<signed char>(value.toInt()); break;
|
||||
case 3: effect.mRange = value.toInt(); break;
|
||||
case 4: effect.mArea = value.toInt(); break;
|
||||
case 5: effect.mDuration = value.toInt(); break;
|
||||
case 6: effect.mMagnMin = value.toInt(); break;
|
||||
case 7: effect.mMagnMax = value.toInt(); break;
|
||||
default: throw std::runtime_error("Magic Effects subcolumn index out of range");
|
||||
}
|
||||
|
||||
magic.mEffects.mList[subRowIndex] = effect;
|
||||
|
||||
record.setModified (magic);
|
||||
}
|
||||
|
||||
virtual int getNestedColumnsCount(const Record<ESXRecordT>& record) const
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
virtual int getNestedRowsCount(const Record<ESXRecordT>& record) const
|
||||
{
|
||||
return static_cast<int>(record.get().mEffects.mList.size());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // CSM_WOLRD_IDADAPTERIMP_H
|
||||
|
|
Loading…
Reference in a new issue