forked from teamnwah/openmw-tes3coop
added sound parameter columns to sonud table
This commit is contained in:
parent
8bf569d58a
commit
dd5940b395
2 changed files with 63 additions and 0 deletions
|
@ -506,6 +506,66 @@ namespace CSMWorld
|
|||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename ESXRecordT>
|
||||
struct SoundParamColumn : public Column<ESXRecordT>
|
||||
{
|
||||
enum Type
|
||||
{
|
||||
Type_Volume,
|
||||
Type_MinRange,
|
||||
Type_MaxRange
|
||||
};
|
||||
|
||||
Type mType;
|
||||
|
||||
SoundParamColumn (Type type)
|
||||
: Column<ESXRecordT> (
|
||||
type==Type_Volume ? "Volume" : (type==Type_MinRange ? "Min Range" : "Max Range"),
|
||||
ColumnBase::Display_Integer),
|
||||
mType (type)
|
||||
{}
|
||||
|
||||
virtual QVariant get (const Record<ESXRecordT>& record) const
|
||||
{
|
||||
int value = 0;
|
||||
|
||||
switch (mType)
|
||||
{
|
||||
case Type_Volume: value = record.get().mData.mVolume; break;
|
||||
case Type_MinRange: value = record.get().mData.mMinRange; break;
|
||||
case Type_MaxRange: value = record.get().mData.mMaxRange; break;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
virtual void set (Record<ESXRecordT>& record, const QVariant& data)
|
||||
{
|
||||
int value = data.toInt();
|
||||
|
||||
if (value<0)
|
||||
value = 0;
|
||||
else if (value>255)
|
||||
value = 255;
|
||||
|
||||
ESXRecordT record2 = record.get();
|
||||
|
||||
switch (mType)
|
||||
{
|
||||
case Type_Volume: record2.mData.mVolume = static_cast<unsigned char> (value); break;
|
||||
case Type_MinRange: record2.mData.mMinRange = static_cast<unsigned char> (value); break;
|
||||
case Type_MaxRange: record2.mData.mMaxRange = static_cast<unsigned char> (value); break;
|
||||
}
|
||||
|
||||
record.setModified (record2);
|
||||
}
|
||||
|
||||
virtual bool isEditable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -79,6 +79,9 @@ CSMWorld::Data::Data()
|
|||
|
||||
mSounds.addColumn (new StringIdColumn<ESM::Sound>);
|
||||
mSounds.addColumn (new RecordStateColumn<ESM::Sound>);
|
||||
mSounds.addColumn (new SoundParamColumn<ESM::Sound> (SoundParamColumn<ESM::Sound>::Type_Volume));
|
||||
mSounds.addColumn (new SoundParamColumn<ESM::Sound> (SoundParamColumn<ESM::Sound>::Type_MinRange));
|
||||
mSounds.addColumn (new SoundParamColumn<ESM::Sound> (SoundParamColumn<ESM::Sound>::Type_MaxRange));
|
||||
|
||||
addModel (new IdTable (&mGlobals), UniversalId::Type_Globals, UniversalId::Type_Global);
|
||||
addModel (new IdTable (&mGmsts), UniversalId::Type_Gmsts, UniversalId::Type_Gmst);
|
||||
|
|
Loading…
Reference in a new issue