mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 21:49:55 +00:00
Add race spells table to dialogue subview.
This commit is contained in:
parent
9c75dad1ac
commit
f939648736
6 changed files with 110 additions and 7 deletions
|
@ -187,7 +187,7 @@ namespace CSMWorld
|
|||
{ ColumnId_MeshType, "Mesh Type" },
|
||||
|
||||
{ ColumnId_ActorInventory, "Inventory" },
|
||||
{ ColumnId_ActorSpells, "Spells" },
|
||||
{ ColumnId_SpellList, "Spells" },
|
||||
{ ColumnId_SpellId, "ID"},
|
||||
|
||||
{ ColumnId_NpcDestinations, "Destinations" },
|
||||
|
|
|
@ -179,7 +179,7 @@ namespace CSMWorld
|
|||
ColumnId_BodyPartType = 164,
|
||||
ColumnId_MeshType = 165,
|
||||
ColumnId_ActorInventory = 166,
|
||||
ColumnId_ActorSpells = 167,
|
||||
ColumnId_SpellList = 167,
|
||||
ColumnId_SpellId = 168,
|
||||
ColumnId_NpcDestinations = 169,
|
||||
ColumnId_DestinationCell = 170,
|
||||
|
|
|
@ -129,6 +129,13 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
|
|||
mRaces.addColumn (new WeightHeightColumn<ESM::Race> (true, false));
|
||||
mRaces.addColumn (new WeightHeightColumn<ESM::Race> (false, true));
|
||||
mRaces.addColumn (new WeightHeightColumn<ESM::Race> (false, false));
|
||||
// Race spells
|
||||
NestedParentColumn<ESM::Race> *raceSpells =
|
||||
new NestedParentColumn<ESM::Race> (Columns::ColumnId_SpellList);
|
||||
mRaces.addColumn (raceSpells);
|
||||
mRaces.addAdapter (std::make_pair(raceSpells, new SpellListAdapter<ESM::Race> ()));
|
||||
mRaces.getNestableColumn(mRaces.getColumns()-1)->addColumn(
|
||||
new NestedStringColumn (Columns::ColumnId_SpellId));
|
||||
|
||||
mSounds.addColumn (new StringIdColumn<ESM::Sound>);
|
||||
mSounds.addColumn (new RecordStateColumn<ESM::Sound>);
|
||||
|
@ -354,7 +361,7 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
|
|||
addModel (new IdTable (&mSkills), UniversalId::Type_Skill);
|
||||
addModel (new IdTable (&mClasses), UniversalId::Type_Class);
|
||||
addModel (new IdTree (&mFactions, &mFactions), UniversalId::Type_Faction);
|
||||
addModel (new IdTable (&mRaces), UniversalId::Type_Race);
|
||||
addModel (new IdTree (&mRaces, &mRaces), UniversalId::Type_Race);
|
||||
addModel (new IdTable (&mSounds), UniversalId::Type_Sound);
|
||||
addModel (new IdTable (&mScripts), UniversalId::Type_Script);
|
||||
addModel (new IdTree (&mRegions, &mRegions), UniversalId::Type_Region);
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace CSMWorld
|
|||
IdCollection<ESM::Skill> mSkills;
|
||||
IdCollection<ESM::Class> mClasses;
|
||||
NestedIdCollection<ESM::Faction> mFactions;
|
||||
IdCollection<ESM::Race> mRaces;
|
||||
NestedIdCollection<ESM::Race> mRaces;
|
||||
IdCollection<ESM::Sound> mSounds;
|
||||
IdCollection<ESM::Script> mScripts;
|
||||
NestedIdCollection<ESM::Region> mRegions;
|
||||
|
|
|
@ -487,6 +487,102 @@ namespace CSMWorld
|
|||
return static_cast<int>(record.get().mSoundList.size());
|
||||
}
|
||||
};
|
||||
|
||||
template<typename ESXRecordT>
|
||||
class SpellListAdapter : public NestedIdAdapter<ESXRecordT>
|
||||
{
|
||||
public:
|
||||
SpellListAdapter () {}
|
||||
|
||||
virtual void addNestedRow(Record<ESXRecordT>& record, int position) const
|
||||
{
|
||||
ESXRecordT raceOrBthSgn = record.get();
|
||||
|
||||
std::vector<std::string>& spells = raceOrBthSgn.mPowers.mList;
|
||||
|
||||
// blank row
|
||||
std::string spell = "";
|
||||
|
||||
spells.insert(spells.begin()+position, spell);
|
||||
|
||||
record.setModified (raceOrBthSgn);
|
||||
}
|
||||
|
||||
virtual void removeNestedRow(Record<ESXRecordT>& record, int rowToRemove) const
|
||||
{
|
||||
ESXRecordT raceOrBthSgn = record.get();
|
||||
|
||||
std::vector<std::string>& spells = raceOrBthSgn.mPowers.mList;
|
||||
|
||||
if (rowToRemove < 0 || rowToRemove >= static_cast<int> (spells.size()))
|
||||
throw std::runtime_error ("index out of range");
|
||||
|
||||
spells.erase(spells.begin()+rowToRemove);
|
||||
|
||||
record.setModified (raceOrBthSgn);
|
||||
}
|
||||
|
||||
virtual void setNestedTable(Record<ESXRecordT>& record, const NestedTableWrapperBase& nestedTable) const
|
||||
{
|
||||
record.get().mPowers.mList =
|
||||
static_cast<const NestedTableWrapper<std::vector<std::string> >&>(nestedTable).mNestedTable;
|
||||
}
|
||||
|
||||
virtual NestedTableWrapperBase* nestedTable(const Record<ESXRecordT>& record) const
|
||||
{
|
||||
// deleted by dtor of NestedTableStoring
|
||||
return new NestedTableWrapper<std::vector<std::string> >(record.get().mPowers.mList);
|
||||
}
|
||||
|
||||
virtual QVariant getNestedData(const Record<ESXRecordT>& record, int subRowIndex, int subColIndex) const
|
||||
{
|
||||
ESXRecordT raceOrBthSgn = record.get();
|
||||
|
||||
std::vector<std::string>& spells = raceOrBthSgn.mPowers.mList;
|
||||
|
||||
if (subRowIndex < 0 || subRowIndex >= static_cast<int> (spells.size()))
|
||||
throw std::runtime_error ("index out of range");
|
||||
|
||||
std::string spell = spells[subRowIndex];
|
||||
switch (subColIndex)
|
||||
{
|
||||
case 0: return QString(spell.c_str());
|
||||
default: throw std::runtime_error("Spells subcolumn index out of range");
|
||||
}
|
||||
}
|
||||
|
||||
virtual void setNestedData(Record<ESXRecordT>& record, const QVariant& value,
|
||||
int subRowIndex, int subColIndex) const
|
||||
{
|
||||
ESXRecordT raceOrBthSgn = record.get();
|
||||
|
||||
std::vector<std::string>& spells = raceOrBthSgn.mPowers.mList;
|
||||
|
||||
if (subRowIndex < 0 || subRowIndex >= static_cast<int> (spells.size()))
|
||||
throw std::runtime_error ("index out of range");
|
||||
|
||||
std::string spell = spells[subRowIndex];
|
||||
switch (subColIndex)
|
||||
{
|
||||
case 0: spell = value.toString().toUtf8().constData(); break;
|
||||
default: throw std::runtime_error("Spells subcolumn index out of range");
|
||||
}
|
||||
|
||||
raceOrBthSgn.mPowers.mList[subRowIndex] = spell;
|
||||
|
||||
record.setModified (raceOrBthSgn);
|
||||
}
|
||||
|
||||
virtual int getNestedColumnsCount(const Record<ESXRecordT>& record) const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
virtual int getNestedRowsCount(const Record<ESXRecordT>& record) const
|
||||
{
|
||||
return static_cast<int>(record.get().mPowers.mList.size());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // CSM_WOLRD_IDADAPTERIMP_H
|
||||
|
|
|
@ -106,7 +106,7 @@ CSMWorld::RefIdCollection::RefIdCollection()
|
|||
new RefIdColumn (Columns::ColumnId_ItemCount, CSMWorld::ColumnBase::Display_Integer));
|
||||
|
||||
// Nested table
|
||||
mColumns.push_back(RefIdColumn (Columns::ColumnId_ActorSpells, ColumnBase::Display_NestedSpellList, ColumnBase::Flag_Dialogue));
|
||||
mColumns.push_back(RefIdColumn (Columns::ColumnId_SpellList, ColumnBase::Display_NestedSpellList, ColumnBase::Flag_Dialogue));
|
||||
actorsColumns.mSpells = &mColumns.back();
|
||||
mColumns.back().addColumn(
|
||||
new RefIdColumn (Columns::ColumnId_SpellId, CSMWorld::ColumnBase::Display_String));
|
||||
|
|
Loading…
Reference in a new issue