Convert magic effects Skills column in the nested tables to use enum delegates.

test
cc9cii 10 years ago
parent 0aff188d8d
commit befd6fe658

@ -75,6 +75,7 @@ bool CSMWorld::ColumnBase::isId (Display display)
Display_Video,
Display_Id,
Display_SkillImpact,
Display_None
};

@ -109,6 +109,7 @@ namespace CSMWorld
Display_SoundGeneratorType,
Display_School,
Display_Id,
Display_SkillImpact,
//top level columns that nest other columns
Display_NestedHeader

@ -270,6 +270,7 @@ namespace CSMWorld
{ ColumnId_LevelledItemChanceNone, "Chance None" },
{ ColumnId_PowerList, "Powers" },
{ ColumnId_SkillImpact, "Skills" },
{ ColumnId_UseValue1, "Use value 1" },
{ ColumnId_UseValue2, "Use value 2" },
@ -423,6 +424,17 @@ namespace
"Alteration", "Conjuration", "Destruction", "Illusion", "Mysticism", "Restoration", 0
};
// impact from magic effects
static const char *sSkills[] =
{
"Block", "Armorer", "MediumArmor", "HeavyArmor", "BluntWeapon",
"LongBlade", "Axe", "Spear", "Athletics", "Enchant",
"Destruction", "Alteration", "Illusion", "Conjuration", "Mysticism",
"Restoration", "Alchemy", "Unarmored", "Security", "Sneak",
"Acrobatics", "LightArmor", "ShortBlade", "Marksman", "Mercantile",
"Speechcraft", "HandToHand", 0
};
const char **getEnumNames (CSMWorld::Columns::ColumnId column)
{
switch (column)
@ -445,6 +457,7 @@ namespace
case CSMWorld::Columns::ColumnId_MeshType: return sMeshTypes;
case CSMWorld::Columns::ColumnId_SoundGeneratorType: return sSoundGeneratorType;
case CSMWorld::Columns::ColumnId_School: return sSchools;
case CSMWorld::Columns::ColumnId_SkillImpact: return sSkills;
default: return 0;
}

@ -260,6 +260,7 @@ namespace CSMWorld
ColumnId_LevelledItemChanceNone = 237,
ColumnId_PowerList = 238,
ColumnId_SkillImpact = 239, // impact from magic effects
// Allocated to a separate value range, so we don't get a collision should we ever need
// to extend the number of use values.

@ -195,7 +195,7 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
mSpells.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_EffectId, ColumnBase::Display_String/*, false*/)); // false means no edit
mSpells.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_Skill, ColumnBase::Display_String));
new NestedChildColumn (Columns::ColumnId_SkillImpact, ColumnBase::Display_SkillImpact));
mSpells.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_Attribute, ColumnBase::Display_Attribute)); // reuse attribute
mSpells.getNestableColumn(index)->addColumn(
@ -269,7 +269,7 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
mEnchantments.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_EffectId, ColumnBase::Display_String/*, false*/));
mEnchantments.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_Skill, ColumnBase::Display_String));
new NestedChildColumn (Columns::ColumnId_SkillImpact, ColumnBase::Display_SkillImpact));
mEnchantments.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_Attribute, ColumnBase::Display_Attribute)); // reuse attribute
mEnchantments.getNestableColumn(index)->addColumn(

@ -315,42 +315,7 @@ namespace CSMWorld
}
case 1:
{
switch (effect.mSkill)
{
// see ESM::Skill::SkillEnum in <component/esm/loadskil.hpp>
case ESM::Skill::Block:
case ESM::Skill::Armorer:
case ESM::Skill::MediumArmor:
case ESM::Skill::HeavyArmor:
case ESM::Skill::BluntWeapon:
case ESM::Skill::LongBlade:
case ESM::Skill::Axe:
case ESM::Skill::Spear:
case ESM::Skill::Athletics:
case ESM::Skill::Enchant:
case ESM::Skill::Destruction:
case ESM::Skill::Alteration:
case ESM::Skill::Illusion:
case ESM::Skill::Conjuration:
case ESM::Skill::Mysticism:
case ESM::Skill::Restoration:
case ESM::Skill::Alchemy:
case ESM::Skill::Unarmored:
case ESM::Skill::Security:
case ESM::Skill::Sneak:
case ESM::Skill::Acrobatics:
case ESM::Skill::LightArmor:
case ESM::Skill::ShortBlade:
case ESM::Skill::Marksman:
case ESM::Skill::Mercantile:
case ESM::Skill::Speechcraft:
case ESM::Skill::HandToHand:
{
return QString(ESM::Skill::sSkillNames[effect.mSkill].c_str());
}
case -1: return QString("N/A");
default: return QVariant();
}
return effect.mSkill;
}
case 2:
{
@ -396,21 +361,7 @@ namespace CSMWorld
}
case 1:
{
std::string skillName = value.toString().toStdString();
if ("N/A" == skillName)
{
effect.mSkill = -1;
break;
}
for (unsigned int i = 0; i < ESM::Skill::Length; ++i)
{
if (ESM::Skill::sSkillNames[i] == skillName)
{
effect.mSkill = static_cast<signed char>(i);
break;
}
}
effect.mSkill = static_cast<signed char>(value.toInt());
break;
}
case 2:

@ -83,7 +83,7 @@ CSMWorld::RefIdCollection::RefIdCollection()
mColumns.back().addColumn(
new NestedChildColumn (Columns::ColumnId_EffectId, ColumnBase::Display_String/*, false*/));
mColumns.back().addColumn(
new NestedChildColumn (Columns::ColumnId_Skill, ColumnBase::Display_String));
new NestedChildColumn (Columns::ColumnId_SkillImpact, ColumnBase::Display_SkillImpact));
mColumns.back().addColumn(
new NestedChildColumn (Columns::ColumnId_Attribute, ColumnBase::Display_Attribute)); // reuse attribute
mColumns.back().addColumn(

@ -84,7 +84,8 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager)
{ CSMWorld::ColumnBase::Display_MeshType, CSMWorld::Columns::ColumnId_MeshType, false },
{ CSMWorld::ColumnBase::Display_Gender, CSMWorld::Columns::ColumnId_Gender, true },
{ CSMWorld::ColumnBase::Display_SoundGeneratorType, CSMWorld::Columns::ColumnId_SoundGeneratorType, false },
{ CSMWorld::ColumnBase::Display_School, CSMWorld::Columns::ColumnId_School, true }
{ CSMWorld::ColumnBase::Display_School, CSMWorld::Columns::ColumnId_School, true },
{ CSMWorld::ColumnBase::Display_SkillImpact, CSMWorld::Columns::ColumnId_SkillImpact, true }
};
for (std::size_t i=0; i<sizeof (sMapping)/sizeof (Mapping); ++i)

@ -442,7 +442,8 @@ void CSVWorld::EditWidget::remake(int row)
mNestedModels.push_back(new CSMWorld::NestedTableProxyModel (mTable->index(row, i), display, dynamic_cast<CSMWorld::IdTree*>(mTable)));
NestedTable* table = new NestedTable(mDocument, mNestedModels.back(), this);
table->resizeColumnsToContents();
// FIXME: does not work well when enum delegates are used
//table->resizeColumnsToContents();
QLabel* label =

Loading…
Cancel
Save