Convert AI package type and AI wander repeat columns in the nested tables to use enum delegate

test
cc9cii 10 years ago
parent e241fb0104
commit f88be67556

@ -79,6 +79,8 @@ bool CSMWorld::ColumnBase::isId (Display display)
Display_EffectRange,
Display_EffectId,
Display_PartRefType,
Display_AiPackageType,
Display_YesNo,
Display_None
};

@ -113,6 +113,8 @@ namespace CSMWorld
Display_EffectRange,
Display_EffectId,
Display_PartRefType,
Display_AiPackageType,
Display_YesNo,
//top level columns that nest other columns
Display_NestedHeader

@ -248,7 +248,7 @@ namespace CSMWorld
{ ColumnId_EffectArea, "Area" },
{ ColumnId_AiPackageList, "Ai Packages" },
{ ColumnId_AiPackage, "Package" },
{ ColumnId_AiPackageType, "Package" },
{ ColumnId_AiWanderDist, "Wander Dist" },
{ ColumnId_AiDuration, "Duration" },
{ ColumnId_AiWanderToD, "Wander ToD" },
@ -487,6 +487,17 @@ namespace
"Weapon", "Tail", 0
};
// see the enums in <component/esm/aipackage.hpp>
static const char *sAiPackageType[] =
{
"AI Wander", "AI Travel", "AI Follow", "AI Escort", "AI Activate", 0
};
static const char *sAiWanderRepeat[] =
{
"No", "Yes", 0
};
const char **getEnumNames (CSMWorld::Columns::ColumnId column)
{
switch (column)
@ -513,6 +524,8 @@ namespace
case CSMWorld::Columns::ColumnId_EffectRange: return sEffectRange;
case CSMWorld::Columns::ColumnId_EffectId: return sEffectId;
case CSMWorld::Columns::ColumnId_PartRefType: return sPartRefType;
case CSMWorld::Columns::ColumnId_AiPackageType: return sAiPackageType;
case CSMWorld::Columns::ColumnId_AiWanderRepeat: return sAiWanderRepeat;
default: return 0;
}

@ -237,7 +237,7 @@ namespace CSMWorld
ColumnId_EffectArea = 218,
ColumnId_AiPackageList = 219,
ColumnId_AiPackage = 220,
ColumnId_AiPackageType = 220,
ColumnId_AiWanderDist = 221,
ColumnId_AiDuration = 222,
ColumnId_AiWanderToD = 223,

@ -1318,34 +1318,13 @@ namespace CSMWorld
switch(subColIndex)
{
case 0:
list.at(subRowIndex).mCellName = std::string(value.toString().toUtf8().constData());
break;
case 1:
list.at(subRowIndex).mPos.pos[0] = value.toFloat();
break;
case 2:
list.at(subRowIndex).mPos.pos[1] = value.toFloat();
break;
case 3:
list.at(subRowIndex).mPos.pos[2] = value.toFloat();
break;
case 4:
list.at(subRowIndex).mPos.rot[0] = value.toFloat();
break;
case 5:
list.at(subRowIndex).mPos.rot[1] = value.toFloat();
break;
case 6:
list.at(subRowIndex).mPos.rot[2] = value.toFloat();
break;
case 0: list.at(subRowIndex).mCellName = std::string(value.toString().toUtf8().constData()); break;
case 1: list.at(subRowIndex).mPos.pos[0] = value.toFloat(); break;
case 2: list.at(subRowIndex).mPos.pos[1] = value.toFloat(); break;
case 3: list.at(subRowIndex).mPos.pos[2] = value.toFloat(); break;
case 4: list.at(subRowIndex).mPos.rot[0] = value.toFloat(); break;
case 5: list.at(subRowIndex).mPos.rot[1] = value.toFloat(); break;
case 6: list.at(subRowIndex).mPos.rot[2] = value.toFloat(); break;
default:
throw std::runtime_error("Trying to access non-existing column in the nested table!");
}
@ -1461,13 +1440,13 @@ namespace CSMWorld
case 0:
switch (content.mType)
{
case ESM::AI_Wander: return QString("AI Wander");
case ESM::AI_Travel: return QString("AI Travel");
case ESM::AI_Follow: return QString("AI Follow");
case ESM::AI_Escort: return QString("AI Escort");
case ESM::AI_Activate: return QString("AI Activate");
case ESM::AI_Wander: return 0;
case ESM::AI_Travel: return 1;
case ESM::AI_Follow: return 2;
case ESM::AI_Escort: return 3;
case ESM::AI_Activate: return 4;
case ESM::AI_CNDT:
default: return QString("None");
default: return QVariant();
}
case 1: // wander dist
if (content.mType == ESM::AI_Wander)
@ -1494,7 +1473,7 @@ namespace CSMWorld
return QVariant();
case 5: // wander repeat
if (content.mType == ESM::AI_Wander)
return QString(content.mWander.mShouldRepeat ? "Yes" : "No");
return content.mWander.mShouldRepeat;
else
return QVariant();
case 6: // activate name
@ -1554,18 +1533,14 @@ namespace CSMWorld
switch(subColIndex)
{
case 0: // ai package type
if ("AI Wander" == value.toString().toStdString())
content.mType = ESM::AI_Wander;
else if ("AI Travel" == value.toString().toStdString())
content.mType = ESM::AI_Travel;
else if ("AI Follow" == value.toString().toStdString())
content.mType = ESM::AI_Follow;
else if ("AI Escort" == value.toString().toStdString())
content.mType = ESM::AI_Escort;
else if ("AI Activate" == value.toString().toStdString())
content.mType = ESM::AI_Activate;
else
content.mType = ESM::AI_CNDT;
switch (value.toInt())
{
case 0: content.mType = ESM::AI_Wander;
case 1: content.mType = ESM::AI_Travel;
case 2: content.mType = ESM::AI_Follow;
case 3: content.mType = ESM::AI_Escort;
case 4: content.mType = ESM::AI_Activate;
}
break; // always save
case 1:
@ -1592,12 +1567,8 @@ namespace CSMWorld
case 5:
if (content.mType == ESM::AI_Wander)
{
if ("Yes" == value.toString().toStdString())
content.mWander.mShouldRepeat = 1;
if ("No" == value.toString().toStdString())
content.mWander.mShouldRepeat = 0;
else
return; // return without saving
content.mWander.mShouldRepeat = static_cast<unsigned char>(value.toInt());
break;
}
case 6: // NAME32
if (content.mType == ESM::AI_Activate)

@ -188,7 +188,7 @@ CSMWorld::RefIdCollection::RefIdCollection()
new ActorAiRefIdAdapter<ESM::Creature> (UniversalId::Type_Creature)));
mNestedAdapters.push_back (std::make_pair(&mColumns.back(), aiMap));
mColumns.back().addColumn(
new RefIdColumn (Columns::ColumnId_AiPackage, CSMWorld::ColumnBase::Display_String));
new RefIdColumn (Columns::ColumnId_AiPackageType, CSMWorld::ColumnBase::Display_AiPackageType));
mColumns.back().addColumn(
new RefIdColumn (Columns::ColumnId_AiWanderDist, CSMWorld::ColumnBase::Display_Integer));
mColumns.back().addColumn(
@ -198,7 +198,7 @@ CSMWorld::RefIdCollection::RefIdCollection()
mColumns.back().addColumn(
new RefIdColumn (Columns::ColumnId_AiWanderIdle, CSMWorld::ColumnBase::Display_Integer));
mColumns.back().addColumn(
new RefIdColumn (Columns::ColumnId_AiWanderRepeat, CSMWorld::ColumnBase::Display_String));
new RefIdColumn (Columns::ColumnId_AiWanderRepeat, CSMWorld::ColumnBase::Display_YesNo));
mColumns.back().addColumn(
new RefIdColumn (Columns::ColumnId_AiActivateName, CSMWorld::ColumnBase::Display_String));
mColumns.back().addColumn(

@ -88,7 +88,9 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager)
{ 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_PartRefType, CSMWorld::Columns::ColumnId_PartRefType, false }
{ CSMWorld::ColumnBase::Display_PartRefType, CSMWorld::Columns::ColumnId_PartRefType, false },
{ CSMWorld::ColumnBase::Display_AiPackageType, CSMWorld::Columns::ColumnId_AiPackageType, false },
{ CSMWorld::ColumnBase::Display_YesNo, CSMWorld::Columns::ColumnId_AiWanderRepeat, false }
};
for (std::size_t i=0; i<sizeof (sMapping)/sizeof (Mapping); ++i)

Loading…
Cancel
Save