added missing magic effect table columns

pull/318/head
Marc Zinnschlag 10 years ago
parent e47f9c7268
commit ff530a2e19

@ -102,7 +102,8 @@ namespace CSMWorld
Display_Video,
Display_Colour,
Display_ScriptLines, // console context
Display_SoundGeneratorType
Display_SoundGeneratorType,
Display_School
};
int mColumnId;

@ -1,7 +1,9 @@
#ifndef CSM_WOLRD_COLUMNIMP_H
#define CSM_WOLRD_COLUMNIMP_H
#include <cassert>
#include <sstream>
#include <stdexcept>
#include <boost/lexical_cast.hpp>
@ -2064,6 +2066,205 @@ namespace CSMWorld
}
};
template<typename ESXRecordT>
struct BaseCostColumn : public Column<ESXRecordT>
{
BaseCostColumn() : Column<ESXRecordT> (Columns::ColumnId_BaseCost, ColumnBase::Display_Float) {}
virtual QVariant get (const Record<ESXRecordT>& record) const
{
return record.get().mData.mBaseCost;
}
virtual void set (Record<ESXRecordT>& record, const QVariant& data)
{
ESXRecordT record2 = record.get();
record2.mData.mBaseCost = data.toFloat();
record.setModified (record2);
}
virtual bool isEditable() const
{
return true;
}
};
template<typename ESXRecordT>
struct SchoolColumn : public Column<ESXRecordT>
{
SchoolColumn()
: Column<ESXRecordT> (Columns::ColumnId_School, ColumnBase::Display_School)
{}
virtual QVariant get (const Record<ESXRecordT>& record) const
{
return record.get().mData.mSchool;
}
virtual void set (Record<ESXRecordT>& record, const QVariant& data)
{
ESXRecordT record2 = record.get();
record2.mData.mSchool = data.toInt();
record.setModified (record2);
}
virtual bool isEditable() const
{
return true;
}
};
template<typename ESXRecordT>
struct EffectTextureColumn : public Column<ESXRecordT>
{
EffectTextureColumn (Columns::ColumnId columnId)
: Column<ESXRecordT> (columnId, ColumnBase::Display_Texture)
{
assert (this->mColumnId==Columns::ColumnId_Icon ||
this->mColumnId==Columns::ColumnId_Particle);
}
virtual QVariant get (const Record<ESXRecordT>& record) const
{
return QString::fromUtf8 (
(this->mColumnId==Columns::ColumnId_Icon ?
record.get().mIcon : record.get().mParticle).c_str());
}
virtual void set (Record<ESXRecordT>& record, const QVariant& data)
{
ESXRecordT record2 = record.get();
(this->mColumnId==Columns::ColumnId_Icon ?
record2.mIcon : record2.mParticle)
= data.toString().toUtf8().constData();
record.setModified (record2);
}
virtual bool isEditable() const
{
return true;
}
};
template<typename ESXRecordT>
struct EffectObjectColumn : public Column<ESXRecordT>
{
EffectObjectColumn (Columns::ColumnId columnId)
: Column<ESXRecordT> (columnId, columnId==Columns::ColumnId_BoltObject ? ColumnBase::Display_Weapon : ColumnBase::Display_Static)
{
assert (this->mColumnId==Columns::ColumnId_CastingObject ||
this->mColumnId==Columns::ColumnId_HitObject ||
this->mColumnId==Columns::ColumnId_AreaObject ||
this->mColumnId==Columns::ColumnId_BoltObject);
}
virtual QVariant get (const Record<ESXRecordT>& record) const
{
const std::string *string = 0;
switch (this->mColumnId)
{
case Columns::ColumnId_CastingObject: string = &record.get().mCasting; break;
case Columns::ColumnId_HitObject: string = &record.get().mHit; break;
case Columns::ColumnId_AreaObject: string = &record.get().mArea; break;
case Columns::ColumnId_BoltObject: string = &record.get().mBolt; break;
}
if (!string)
throw std::logic_error ("Unsupported column ID");
return QString::fromUtf8 (string->c_str());
}
virtual void set (Record<ESXRecordT>& record, const QVariant& data)
{
std::string *string = 0;
ESXRecordT record2 = record.get();
switch (this->mColumnId)
{
case Columns::ColumnId_CastingObject: string = &record2.mCasting; break;
case Columns::ColumnId_HitObject: string = &record2.mHit; break;
case Columns::ColumnId_AreaObject: string = &record2.mArea; break;
case Columns::ColumnId_BoltObject: string = &record2.mBolt; break;
}
if (!string)
throw std::logic_error ("Unsupported column ID");
*string = data.toString().toUtf8().constData();
record.setModified (record2);
}
virtual bool isEditable() const
{
return true;
}
};
template<typename ESXRecordT>
struct EffectSoundColumn : public Column<ESXRecordT>
{
EffectSoundColumn (Columns::ColumnId columnId)
: Column<ESXRecordT> (columnId, ColumnBase::Display_Sound)
{
assert (this->mColumnId==Columns::ColumnId_CastingSound ||
this->mColumnId==Columns::ColumnId_HitSound ||
this->mColumnId==Columns::ColumnId_AreaSound ||
this->mColumnId==Columns::ColumnId_BoltSound);
}
virtual QVariant get (const Record<ESXRecordT>& record) const
{
const std::string *string = 0;
switch (this->mColumnId)
{
case Columns::ColumnId_CastingSound: string = &record.get().mCastSound; break;
case Columns::ColumnId_HitSound: string = &record.get().mHitSound; break;
case Columns::ColumnId_AreaSound: string = &record.get().mAreaSound; break;
case Columns::ColumnId_BoltSound: string = &record.get().mBoltSound; break;
}
if (!string)
throw std::logic_error ("Unsupported column ID");
return QString::fromUtf8 (string->c_str());
}
virtual void set (Record<ESXRecordT>& record, const QVariant& data)
{
std::string *string = 0;
ESXRecordT record2 = record.get();
switch (this->mColumnId)
{
case Columns::ColumnId_CastingSound: string = &record2.mCastSound; break;
case Columns::ColumnId_HitSound: string = &record2.mHitSound; break;
case Columns::ColumnId_AreaSound: string = &record2.mAreaSound; break;
case Columns::ColumnId_BoltSound: string = &record2.mBoltSound; break;
}
if (!string)
throw std::logic_error ("Unsupported column ID");
*string = data.toString().toUtf8().constData();
record.setModified (record2);
}
virtual bool isEditable() const
{
return true;
}
};
}
#endif

@ -190,6 +190,17 @@ namespace CSMWorld
{ ColumnId_SoundGeneratorType, "Sound Generator Type" },
{ ColumnId_AllowSpellmaking, "Allow Spellmaking" },
{ ColumnId_AllowEnchanting, "Allow Enchanting" },
{ ColumnId_BaseCost, "Base Cost" },
{ ColumnId_School, "School" },
{ ColumnId_Particle, "Particle" },
{ ColumnId_CastingObject, "Casting Object" },
{ ColumnId_HitObject, "Hit Object" },
{ ColumnId_AreaObject, "Area Object" },
{ ColumnId_BoltObject, "Bolt Object" },
{ ColumnId_CastingSound, "Casting Sound" },
{ ColumnId_HitSound, "Hit Sound" },
{ ColumnId_AreaSound, "Area Sound" },
{ ColumnId_BoltSound, "Bolt Sound" },
{ ColumnId_UseValue1, "Use value 1" },
{ ColumnId_UseValue2, "Use value 2" },
@ -337,6 +348,11 @@ namespace
"Land", 0
};
static const char *sSchools[] =
{
"Alteration", "Conjuration", "Destruction", "Illusion", "Mysticism", "Restoration", 0
};
const char **getEnumNames (CSMWorld::Columns::ColumnId column)
{
switch (column)
@ -358,6 +374,7 @@ namespace
case CSMWorld::Columns::ColumnId_BodyPartType: return sBodyPartTypes;
case CSMWorld::Columns::ColumnId_MeshType: return sMeshTypes;
case CSMWorld::Columns::ColumnId_SoundGeneratorType: return sSoundGeneratorType;
case CSMWorld::Columns::ColumnId_School: return sSchools;
default: return 0;
}

@ -183,7 +183,17 @@ namespace CSMWorld
ColumnId_SoundGeneratorType = 171,
ColumnId_AllowSpellmaking = 172,
ColumnId_AllowEnchanting = 173,
ColumnId_BaseCost = 174,
ColumnId_School = 175,
ColumnId_Particle = 176,
ColumnId_CastingObject = 177,
ColumnId_HitObject = 178,
ColumnId_AreaObject = 179,
ColumnId_BoltObject = 180,
ColumnId_CastingSound = 177,
ColumnId_HitSound = 178,
ColumnId_AreaSound = 179,
ColumnId_BoltSound = 180,
// 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,

@ -230,7 +230,18 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
mMagicEffects.addColumn (new StringIdColumn<ESM::MagicEffect>);
mMagicEffects.addColumn (new RecordStateColumn<ESM::MagicEffect>);
mMagicEffects.addColumn (new FixedRecordTypeColumn<ESM::MagicEffect> (UniversalId::Type_MagicEffect));
mMagicEffects.addColumn (new SchoolColumn<ESM::MagicEffect>);
mMagicEffects.addColumn (new BaseCostColumn<ESM::MagicEffect>);
mMagicEffects.addColumn (new EffectTextureColumn<ESM::MagicEffect> (Columns::ColumnId_Icon));
mMagicEffects.addColumn (new EffectTextureColumn<ESM::MagicEffect> (Columns::ColumnId_Particle));
mMagicEffects.addColumn (new EffectObjectColumn<ESM::MagicEffect> (Columns::ColumnId_CastingObject));
mMagicEffects.addColumn (new EffectObjectColumn<ESM::MagicEffect> (Columns::ColumnId_HitObject));
mMagicEffects.addColumn (new EffectObjectColumn<ESM::MagicEffect> (Columns::ColumnId_AreaObject));
mMagicEffects.addColumn (new EffectObjectColumn<ESM::MagicEffect> (Columns::ColumnId_BoltObject));
mMagicEffects.addColumn (new EffectSoundColumn<ESM::MagicEffect> (Columns::ColumnId_CastingSound));
mMagicEffects.addColumn (new EffectSoundColumn<ESM::MagicEffect> (Columns::ColumnId_HitSound));
mMagicEffects.addColumn (new EffectSoundColumn<ESM::MagicEffect> (Columns::ColumnId_AreaSound));
mMagicEffects.addColumn (new EffectSoundColumn<ESM::MagicEffect> (Columns::ColumnId_BoltSound));
mMagicEffects.addColumn (new FlagColumn<ESM::MagicEffect> (
Columns::ColumnId_AllowSpellmaking, ESM::MagicEffect::AllowSpellmaking));
mMagicEffects.addColumn (new FlagColumn<ESM::MagicEffect> (

@ -82,7 +82,8 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager)
{ CSMWorld::ColumnBase::Display_BodyPartType, CSMWorld::Columns::ColumnId_BodyPartType, false },
{ 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_SoundGeneratorType, CSMWorld::Columns::ColumnId_SoundGeneratorType, false },
{ CSMWorld::ColumnBase::Display_School, CSMWorld::Columns::ColumnId_School, true }
};
for (std::size_t i=0; i<sizeof (sMapping)/sizeof (Mapping); ++i)

Loading…
Cancel
Save