forked from mirror/openmw-tes3mp
Convert clothing/armour part reference type column in the nested tables to use enum delegates.
This commit is contained in:
parent
e00d7f72ac
commit
e241fb0104
6 changed files with 25 additions and 30 deletions
|
@ -78,6 +78,7 @@ bool CSMWorld::ColumnBase::isId (Display display)
|
|||
Display_SkillImpact,
|
||||
Display_EffectRange,
|
||||
Display_EffectId,
|
||||
Display_PartRefType,
|
||||
|
||||
Display_None
|
||||
};
|
||||
|
|
|
@ -112,6 +112,7 @@ namespace CSMWorld
|
|||
Display_SkillImpact,
|
||||
Display_EffectRange,
|
||||
Display_EffectId,
|
||||
Display_PartRefType,
|
||||
|
||||
//top level columns that nest other columns
|
||||
Display_NestedHeader
|
||||
|
|
|
@ -476,6 +476,17 @@ namespace
|
|||
"SummonBonewolf", "SummonCreature04", "SummonCreature05", 0
|
||||
};
|
||||
|
||||
// see ESM::PartReferenceType in <component/esm/loadarmo.hpp>
|
||||
static const char *sPartRefType[] =
|
||||
{
|
||||
"Head", "Hair", "Neck", "Cuirass", "Groin",
|
||||
"Skirt", "Right Hand", "Left Hand", "Right Wrist", "Left Wrist",
|
||||
"Shield", "Right Forearm", "Left Forearm", "Right Upperarm", "Left Upperarm",
|
||||
"Right Foot", "Left Foot", "Right Ankle", "Left Ankle", "Right Knee",
|
||||
"Left Knee", "Right Leg", "Left Leg", "Right Pauldron", "Left Pauldron",
|
||||
"Weapon", "Tail", 0
|
||||
};
|
||||
|
||||
const char **getEnumNames (CSMWorld::Columns::ColumnId column)
|
||||
{
|
||||
switch (column)
|
||||
|
@ -501,6 +512,7 @@ namespace
|
|||
case CSMWorld::Columns::ColumnId_SkillImpact: return sSkills;
|
||||
case CSMWorld::Columns::ColumnId_EffectRange: return sEffectRange;
|
||||
case CSMWorld::Columns::ColumnId_EffectId: return sEffectId;
|
||||
case CSMWorld::Columns::ColumnId_PartRefType: return sPartRefType;
|
||||
|
||||
default: return 0;
|
||||
}
|
||||
|
|
|
@ -1665,15 +1665,6 @@ namespace CSMWorld
|
|||
}
|
||||
};
|
||||
|
||||
static const char *sPartRefs[ESM::PRT_Count] =
|
||||
{
|
||||
"Head", "Hair", "Neck", "Cuirass", "Groin",
|
||||
"Skirt", "Right Hand", "Left Hand", "Right Wrist", "Left Wrist",
|
||||
"Shield", "Right Forearm", "Left Forearm", "Right Upperarm", "Left Upperarm",
|
||||
"Right Foot", "Left Foot", "Right Ankle", "Left Ankle", "Right Knee",
|
||||
"Left Knee", "Right Leg", "Left Leg", "Right Pauldron", "Left Pauldron",
|
||||
"Weapon", "Tail"
|
||||
};
|
||||
|
||||
template <typename ESXRecordT>
|
||||
class BodyPartRefIdAdapter : public NestedRefIdAdapterBase
|
||||
|
@ -1767,7 +1758,13 @@ namespace CSMWorld
|
|||
|
||||
switch (subColIndex)
|
||||
{
|
||||
case 0: return QString(sPartRefs[content.mPart]);
|
||||
case 0:
|
||||
{
|
||||
if (content.mPart >=0 && content.mPart < ESM::PRT_Count)
|
||||
return content.mPart;
|
||||
else
|
||||
throw std::runtime_error("Part Reference Type unexpected value");
|
||||
}
|
||||
case 1: return QString(content.mMale.c_str());
|
||||
case 2: return QString(content.mFemale.c_str());
|
||||
default:
|
||||
|
@ -1788,24 +1785,7 @@ namespace CSMWorld
|
|||
|
||||
switch(subColIndex)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
std::string part = value.toString().toStdString();
|
||||
bool found = false;
|
||||
for (unsigned int i = 0; i < ESM::PRT_Count; ++i)
|
||||
{
|
||||
if (part == sPartRefs[i])
|
||||
{
|
||||
list.at(subRowIndex).mPart = static_cast<unsigned char>(i);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
return; // return without saving
|
||||
else
|
||||
break;
|
||||
}
|
||||
case 0: list.at(subRowIndex).mPart = static_cast<unsigned char>(value.toInt()); break;
|
||||
case 1: list.at(subRowIndex).mMale = value.toString().toStdString(); break;
|
||||
case 2: list.at(subRowIndex).mFemale = value.toString().toStdString(); break;
|
||||
default:
|
||||
|
|
|
@ -480,7 +480,7 @@ CSMWorld::RefIdCollection::RefIdCollection()
|
|||
new BodyPartRefIdAdapter<ESM::Clothing> (UniversalId::Type_Clothing)));
|
||||
mNestedAdapters.push_back (std::make_pair(&mColumns.back(), partMap));
|
||||
mColumns.back().addColumn(
|
||||
new RefIdColumn (Columns::ColumnId_PartRefType, CSMWorld::ColumnBase::Display_String));
|
||||
new RefIdColumn (Columns::ColumnId_PartRefType, CSMWorld::ColumnBase::Display_PartRefType));
|
||||
mColumns.back().addColumn(
|
||||
new RefIdColumn (Columns::ColumnId_PartRefMale, CSMWorld::ColumnBase::Display_String));
|
||||
mColumns.back().addColumn(
|
||||
|
|
|
@ -87,7 +87,8 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager)
|
|||
{ CSMWorld::ColumnBase::Display_School, CSMWorld::Columns::ColumnId_School, true },
|
||||
{ CSMWorld::ColumnBase::Display_SkillImpact, CSMWorld::Columns::ColumnId_SkillImpact, true },
|
||||
{ CSMWorld::ColumnBase::Display_EffectRange, CSMWorld::Columns::ColumnId_EffectRange, false },
|
||||
{ CSMWorld::ColumnBase::Display_EffectId, CSMWorld::Columns::ColumnId_EffectId, false }
|
||||
{ CSMWorld::ColumnBase::Display_EffectId, CSMWorld::Columns::ColumnId_EffectId, false },
|
||||
{ CSMWorld::ColumnBase::Display_PartRefType, CSMWorld::Columns::ColumnId_PartRefType, false }
|
||||
};
|
||||
|
||||
for (std::size_t i=0; i<sizeof (sMapping)/sizeof (Mapping); ++i)
|
||||
|
|
Loading…
Reference in a new issue