mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:23:52 +00:00
Add the remaining Race data for editing with dialogue subview. Should resolve Bug #2546.
This commit is contained in:
parent
7494340b66
commit
0ecfd9119f
8 changed files with 241 additions and 1 deletions
|
@ -84,6 +84,7 @@ bool CSMWorld::ColumnBase::isId (Display display)
|
|||
Display_InfoCondFunc,
|
||||
Display_InfoCondVar,
|
||||
Display_InfoCondComp,
|
||||
Display_RaceSkill,
|
||||
|
||||
Display_None
|
||||
};
|
||||
|
|
|
@ -119,6 +119,7 @@ namespace CSMWorld
|
|||
Display_InfoCondFunc,
|
||||
Display_InfoCondVar,
|
||||
Display_InfoCondComp,
|
||||
Display_RaceSkill,
|
||||
|
||||
//top level columns that nest other columns
|
||||
Display_NestedHeader
|
||||
|
|
|
@ -296,6 +296,13 @@ namespace CSMWorld
|
|||
{ ColumnId_NpcGold, "Gold" },
|
||||
{ ColumnId_NpcPersistence, "Persistent" },
|
||||
|
||||
{ ColumnId_RaceAttributes, "Attributes" },
|
||||
{ ColumnId_RaceMaleValue, "Male" },
|
||||
{ ColumnId_RaceFemaleValue, "Female" },
|
||||
{ ColumnId_RaceSkillBonus, "Skill Bonus" },
|
||||
{ ColumnId_RaceSkill, "Skills" },
|
||||
{ ColumnId_RaceBonus, "Bonus" },
|
||||
|
||||
{ ColumnId_UseValue1, "Use value 1" },
|
||||
{ ColumnId_UseValue2, "Use value 2" },
|
||||
{ ColumnId_UseValue3, "Use value 3" },
|
||||
|
@ -566,6 +573,7 @@ namespace
|
|||
// FIXME: don't have dynamic value enum delegate, use Display_String for now
|
||||
//case CSMWorld::Columns::ColumnId_InfoCond: return sInfoCond;
|
||||
case CSMWorld::Columns::ColumnId_InfoCondComp: return sInfoCondComp;
|
||||
case CSMWorld::Columns::ColumnId_RaceSkill: return sSkills;
|
||||
|
||||
default: return 0;
|
||||
}
|
||||
|
|
|
@ -287,6 +287,13 @@ namespace CSMWorld
|
|||
ColumnId_NpcGold = 260,
|
||||
ColumnId_NpcPersistence = 261,
|
||||
|
||||
ColumnId_RaceAttributes = 262,
|
||||
ColumnId_RaceMaleValue = 263,
|
||||
ColumnId_RaceFemaleValue = 264,
|
||||
ColumnId_RaceSkillBonus = 265,
|
||||
ColumnId_RaceSkill = 266,
|
||||
ColumnId_RaceBonus = 267,
|
||||
|
||||
// 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,
|
||||
|
|
|
@ -136,6 +136,24 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
|
|||
mRaces.addAdapter (std::make_pair(&mRaces.getColumn(index), new SpellListAdapter<ESM::Race> ()));
|
||||
mRaces.getNestableColumn(index)->addColumn(
|
||||
new NestedChildColumn (Columns::ColumnId_SpellId, ColumnBase::Display_String));
|
||||
// Race attributes
|
||||
mRaces.addColumn (new NestedParentColumn<ESM::Race> (Columns::ColumnId_RaceAttributes));
|
||||
index = mRaces.getColumns()-1;
|
||||
mRaces.addAdapter (std::make_pair(&mRaces.getColumn(index), new RaceAttributeAdapter()));
|
||||
mRaces.getNestableColumn(index)->addColumn(
|
||||
new NestedChildColumn (Columns::ColumnId_RaceAttributes, ColumnBase::Display_String, false));
|
||||
mRaces.getNestableColumn(index)->addColumn(
|
||||
new NestedChildColumn (Columns::ColumnId_RaceMaleValue, ColumnBase::Display_Integer));
|
||||
mRaces.getNestableColumn(index)->addColumn(
|
||||
new NestedChildColumn (Columns::ColumnId_RaceFemaleValue, ColumnBase::Display_Integer));
|
||||
// Race skill bonus
|
||||
mRaces.addColumn (new NestedParentColumn<ESM::Race> (Columns::ColumnId_RaceSkillBonus));
|
||||
index = mRaces.getColumns()-1;
|
||||
mRaces.addAdapter (std::make_pair(&mRaces.getColumn(index), new RaceSkillsBonusAdapter()));
|
||||
mRaces.getNestableColumn(index)->addColumn(
|
||||
new NestedChildColumn (Columns::ColumnId_RaceSkill, ColumnBase::Display_RaceSkill));
|
||||
mRaces.getNestableColumn(index)->addColumn(
|
||||
new NestedChildColumn (Columns::ColumnId_RaceBonus, ColumnBase::Display_Integer));
|
||||
|
||||
mSounds.addColumn (new StringIdColumn<ESM::Sound>);
|
||||
mSounds.addColumn (new RecordStateColumn<ESM::Sound>);
|
||||
|
|
|
@ -880,4 +880,157 @@ namespace CSMWorld
|
|||
{
|
||||
return static_cast<int>(record.get().mSelects.size());
|
||||
}
|
||||
|
||||
RaceAttributeAdapter::RaceAttributeAdapter () {}
|
||||
|
||||
void RaceAttributeAdapter::addRow(Record<ESM::Race>& record, int position) const
|
||||
{
|
||||
// Do nothing, this table cannot be changed by the user
|
||||
}
|
||||
|
||||
void RaceAttributeAdapter::removeRow(Record<ESM::Race>& record, int rowToRemove) const
|
||||
{
|
||||
// Do nothing, this table cannot be changed by the user
|
||||
}
|
||||
|
||||
void RaceAttributeAdapter::setTable(Record<ESM::Race>& record,
|
||||
const NestedTableWrapperBase& nestedTable) const
|
||||
{
|
||||
ESM::Race race = record.get();
|
||||
|
||||
race.mData =
|
||||
static_cast<const NestedTableWrapper<std::vector<ESM::Race::RADTstruct> >&>(nestedTable).mNestedTable.at(0);
|
||||
|
||||
record.setModified (race);
|
||||
}
|
||||
|
||||
NestedTableWrapperBase* RaceAttributeAdapter::table(const Record<ESM::Race>& record) const
|
||||
{
|
||||
std::vector<typename ESM::Race::RADTstruct> wrap;
|
||||
wrap.push_back(record.get().mData);
|
||||
// deleted by dtor of NestedTableStoring
|
||||
return new NestedTableWrapper<std::vector<ESM::Race::RADTstruct> >(wrap);
|
||||
}
|
||||
|
||||
QVariant RaceAttributeAdapter::getData(const Record<ESM::Race>& record,
|
||||
int subRowIndex, int subColIndex) const
|
||||
{
|
||||
ESM::Race race = record.get();
|
||||
|
||||
if (subRowIndex < 0 || subRowIndex >= ESM::Attribute::Length)
|
||||
throw std::runtime_error ("index out of range");
|
||||
|
||||
switch (subColIndex)
|
||||
{
|
||||
case 0: return QString(ESM::Attribute::sAttributeNames[subRowIndex].c_str());
|
||||
case 1: return race.mData.mAttributeValues[subRowIndex].mMale;
|
||||
case 2: return race.mData.mAttributeValues[subRowIndex].mFemale;
|
||||
default: throw std::runtime_error("Race Attribute subcolumn index out of range");
|
||||
}
|
||||
}
|
||||
|
||||
void RaceAttributeAdapter::setData(Record<ESM::Race>& record,
|
||||
const QVariant& value, int subRowIndex, int subColIndex) const
|
||||
{
|
||||
ESM::Race race = record.get();
|
||||
|
||||
if (subRowIndex < 0 || subRowIndex >= ESM::Attribute::Length)
|
||||
throw std::runtime_error ("index out of range");
|
||||
|
||||
switch (subColIndex)
|
||||
{
|
||||
case 0: return; // throw an exception here?
|
||||
case 1: race.mData.mAttributeValues[subRowIndex].mMale = value.toInt(); break;
|
||||
case 2: race.mData.mAttributeValues[subRowIndex].mFemale = value.toInt(); break;
|
||||
default: throw std::runtime_error("Race Attribute subcolumn index out of range");
|
||||
}
|
||||
|
||||
record.setModified (race);
|
||||
}
|
||||
|
||||
int RaceAttributeAdapter::getColumnsCount(const Record<ESM::Race>& record) const
|
||||
{
|
||||
return 3; // attrib, male, female
|
||||
}
|
||||
|
||||
int RaceAttributeAdapter::getRowsCount(const Record<ESM::Race>& record) const
|
||||
{
|
||||
return ESM::Attribute::Length; // there are 8 attributes
|
||||
}
|
||||
|
||||
RaceSkillsBonusAdapter::RaceSkillsBonusAdapter () {}
|
||||
|
||||
void RaceSkillsBonusAdapter::addRow(Record<ESM::Race>& record, int position) const
|
||||
{
|
||||
// Do nothing, this table cannot be changed by the user
|
||||
}
|
||||
|
||||
void RaceSkillsBonusAdapter::removeRow(Record<ESM::Race>& record, int rowToRemove) const
|
||||
{
|
||||
// Do nothing, this table cannot be changed by the user
|
||||
}
|
||||
|
||||
void RaceSkillsBonusAdapter::setTable(Record<ESM::Race>& record,
|
||||
const NestedTableWrapperBase& nestedTable) const
|
||||
{
|
||||
ESM::Race race = record.get();
|
||||
|
||||
race.mData =
|
||||
static_cast<const NestedTableWrapper<std::vector<ESM::Race::RADTstruct> >&>(nestedTable).mNestedTable.at(0);
|
||||
|
||||
record.setModified (race);
|
||||
}
|
||||
|
||||
NestedTableWrapperBase* RaceSkillsBonusAdapter::table(const Record<ESM::Race>& record) const
|
||||
{
|
||||
std::vector<typename ESM::Race::RADTstruct> wrap;
|
||||
wrap.push_back(record.get().mData);
|
||||
// deleted by dtor of NestedTableStoring
|
||||
return new NestedTableWrapper<std::vector<ESM::Race::RADTstruct> >(wrap);
|
||||
}
|
||||
|
||||
QVariant RaceSkillsBonusAdapter::getData(const Record<ESM::Race>& record,
|
||||
int subRowIndex, int subColIndex) const
|
||||
{
|
||||
ESM::Race race = record.get();
|
||||
|
||||
if (subRowIndex < 0 || subRowIndex >= static_cast<int>(sizeof(race.mData.mBonus)/sizeof(race.mData.mBonus[0])))
|
||||
throw std::runtime_error ("index out of range");
|
||||
|
||||
switch (subColIndex)
|
||||
{
|
||||
case 0: return race.mData.mBonus[subRowIndex].mSkill; // can be -1
|
||||
case 1: return race.mData.mBonus[subRowIndex].mBonus;
|
||||
default: throw std::runtime_error("Race skill bonus subcolumn index out of range");
|
||||
}
|
||||
}
|
||||
|
||||
void RaceSkillsBonusAdapter::setData(Record<ESM::Race>& record,
|
||||
const QVariant& value, int subRowIndex, int subColIndex) const
|
||||
{
|
||||
ESM::Race race = record.get();
|
||||
|
||||
if (subRowIndex < 0 || subRowIndex >= static_cast<int>(sizeof(race.mData.mBonus)/sizeof(race.mData.mBonus[0])))
|
||||
throw std::runtime_error ("index out of range");
|
||||
|
||||
switch (subColIndex)
|
||||
{
|
||||
case 0: race.mData.mBonus[subRowIndex].mSkill = value.toInt(); break; // can be -1
|
||||
case 1: race.mData.mBonus[subRowIndex].mBonus = value.toInt(); break;
|
||||
default: throw std::runtime_error("Race skill bonus subcolumn index out of range");
|
||||
}
|
||||
|
||||
record.setModified (race);
|
||||
}
|
||||
|
||||
int RaceSkillsBonusAdapter::getColumnsCount(const Record<ESM::Race>& record) const
|
||||
{
|
||||
return 2; // skill, bonus
|
||||
}
|
||||
|
||||
int RaceSkillsBonusAdapter::getRowsCount(const Record<ESM::Race>& record) const
|
||||
{
|
||||
// there are 7 skill bonuses
|
||||
return static_cast<int>(sizeof(record.get().mData.mBonus)/sizeof(record.get().mData.mBonus[0]));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <components/esm/loadmgef.hpp> // for converting magic effect id to string & back
|
||||
#include <components/esm/loadskil.hpp> // for converting skill names
|
||||
#include <components/esm/attr.hpp> // for converting attributes
|
||||
#include <components/esm/loadrace.hpp>
|
||||
|
||||
#include "nestedcolumnadapter.hpp"
|
||||
#include "nestedtablewrapper.hpp"
|
||||
|
@ -437,6 +438,56 @@ namespace CSMWorld
|
|||
|
||||
virtual int getRowsCount(const Record<Info>& record) const;
|
||||
};
|
||||
|
||||
class RaceAttributeAdapter : public NestedColumnAdapter<ESM::Race>
|
||||
{
|
||||
public:
|
||||
RaceAttributeAdapter ();
|
||||
|
||||
virtual void addRow(Record<ESM::Race>& record, int position) const;
|
||||
|
||||
virtual void removeRow(Record<ESM::Race>& record, int rowToRemove) const;
|
||||
|
||||
virtual void setTable(Record<ESM::Race>& record,
|
||||
const NestedTableWrapperBase& nestedTable) const;
|
||||
|
||||
virtual NestedTableWrapperBase* table(const Record<ESM::Race>& record) const;
|
||||
|
||||
virtual QVariant getData(const Record<ESM::Race>& record,
|
||||
int subRowIndex, int subColIndex) const;
|
||||
|
||||
virtual void setData(Record<ESM::Race>& record,
|
||||
const QVariant& value, int subRowIndex, int subColIndex) const;
|
||||
|
||||
virtual int getColumnsCount(const Record<ESM::Race>& record) const;
|
||||
|
||||
virtual int getRowsCount(const Record<ESM::Race>& record) const;
|
||||
};
|
||||
|
||||
class RaceSkillsBonusAdapter : public NestedColumnAdapter<ESM::Race>
|
||||
{
|
||||
public:
|
||||
RaceSkillsBonusAdapter ();
|
||||
|
||||
virtual void addRow(Record<ESM::Race>& record, int position) const;
|
||||
|
||||
virtual void removeRow(Record<ESM::Race>& record, int rowToRemove) const;
|
||||
|
||||
virtual void setTable(Record<ESM::Race>& record,
|
||||
const NestedTableWrapperBase& nestedTable) const;
|
||||
|
||||
virtual NestedTableWrapperBase* table(const Record<ESM::Race>& record) const;
|
||||
|
||||
virtual QVariant getData(const Record<ESM::Race>& record,
|
||||
int subRowIndex, int subColIndex) const;
|
||||
|
||||
virtual void setData(Record<ESM::Race>& record,
|
||||
const QVariant& value, int subRowIndex, int subColIndex) const;
|
||||
|
||||
virtual int getColumnsCount(const Record<ESM::Race>& record) const;
|
||||
|
||||
virtual int getRowsCount(const Record<ESM::Race>& record) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // CSM_WOLRD_NESTEDCOLADAPTERIMP_H
|
||||
|
|
|
@ -92,7 +92,8 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager)
|
|||
{ CSMWorld::ColumnBase::Display_AiPackageType, CSMWorld::Columns::ColumnId_AiPackageType, false },
|
||||
{ CSMWorld::ColumnBase::Display_YesNo, CSMWorld::Columns::ColumnId_AiWanderRepeat, false },
|
||||
{ CSMWorld::ColumnBase::Display_InfoCondFunc, CSMWorld::Columns::ColumnId_InfoCondFunc, false },
|
||||
{ CSMWorld::ColumnBase::Display_InfoCondComp, CSMWorld::Columns::ColumnId_InfoCondComp, false }
|
||||
{ CSMWorld::ColumnBase::Display_InfoCondComp, CSMWorld::Columns::ColumnId_InfoCondComp, false },
|
||||
{ CSMWorld::ColumnBase::Display_RaceSkill, CSMWorld::Columns::ColumnId_RaceSkill, true },
|
||||
};
|
||||
|
||||
for (std::size_t i=0; i<sizeof (sMapping)/sizeof (Mapping); ++i)
|
||||
|
|
Loading…
Reference in a new issue