mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:23:52 +00:00
Add Region sounds table to dialogue subview.
This commit is contained in:
parent
5da2f53bec
commit
88bc62e054
7 changed files with 156 additions and 6 deletions
|
@ -99,6 +99,7 @@ namespace CSMWorld
|
||||||
Display_NestedDestinationsList,
|
Display_NestedDestinationsList,
|
||||||
Display_PathgridPointList,
|
Display_PathgridPointList,
|
||||||
Display_PathgridEdgeList,
|
Display_PathgridEdgeList,
|
||||||
|
Display_RegionSoundList,
|
||||||
|
|
||||||
Display_EnchantmentType,
|
Display_EnchantmentType,
|
||||||
Display_BodyPartType,
|
Display_BodyPartType,
|
||||||
|
|
|
@ -2355,6 +2355,52 @@ namespace CSMWorld
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename ESXRecordT>
|
||||||
|
struct RegionSoundListColumn : public Column<ESXRecordT>
|
||||||
|
{
|
||||||
|
RegionSoundListColumn ()
|
||||||
|
: Column<ESXRecordT> (Columns::ColumnId_RegionSounds,
|
||||||
|
ColumnBase::Display_RegionSoundList, ColumnBase::Flag_Dialogue)
|
||||||
|
{}
|
||||||
|
|
||||||
|
virtual QVariant get (const Record<ESXRecordT>& record) const
|
||||||
|
{
|
||||||
|
return true; // required by IdTree::hasChildren()
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool isEditable() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
struct RegionSoundNameColumn : public NestableColumn
|
||||||
|
{
|
||||||
|
RegionSoundNameColumn ()
|
||||||
|
: NestableColumn (Columns::ColumnId_SoundName,
|
||||||
|
ColumnBase::Display_String, ColumnBase::Flag_Dialogue)
|
||||||
|
{}
|
||||||
|
|
||||||
|
virtual bool isEditable() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct RegionSoundChanceColumn : public NestableColumn
|
||||||
|
{
|
||||||
|
RegionSoundChanceColumn ()
|
||||||
|
: NestableColumn (Columns::ColumnId_SoundChance,
|
||||||
|
ColumnBase::Display_Integer, ColumnBase::Flag_Dialogue)
|
||||||
|
{}
|
||||||
|
|
||||||
|
virtual bool isEditable() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -233,6 +233,10 @@ namespace CSMWorld
|
||||||
{ ColumnId_PathgridEdge0, "Point 0"},
|
{ ColumnId_PathgridEdge0, "Point 0"},
|
||||||
{ ColumnId_PathgridEdge1, "Point 1"},
|
{ ColumnId_PathgridEdge1, "Point 1"},
|
||||||
|
|
||||||
|
{ ColumnId_RegionSounds, "Sounds"},
|
||||||
|
{ ColumnId_SoundName, "Name"},
|
||||||
|
{ ColumnId_SoundChance, "Chance"},
|
||||||
|
|
||||||
{ ColumnId_UseValue1, "Use value 1" },
|
{ ColumnId_UseValue1, "Use value 1" },
|
||||||
{ ColumnId_UseValue2, "Use value 2" },
|
{ ColumnId_UseValue2, "Use value 2" },
|
||||||
{ ColumnId_UseValue3, "Use value 3" },
|
{ ColumnId_UseValue3, "Use value 3" },
|
||||||
|
|
|
@ -222,6 +222,10 @@ namespace CSMWorld
|
||||||
ColumnId_PathgridEdge0 = 206,
|
ColumnId_PathgridEdge0 = 206,
|
||||||
ColumnId_PathgridEdge1 = 207,
|
ColumnId_PathgridEdge1 = 207,
|
||||||
|
|
||||||
|
ColumnId_RegionSounds = 208,
|
||||||
|
ColumnId_SoundName = 209,
|
||||||
|
ColumnId_SoundChance = 210,
|
||||||
|
|
||||||
// Allocated to a separate value range, so we don't get a collision should we ever need
|
// Allocated to a separate value range, so we don't get a collision should we ever need
|
||||||
// to extend the number of use values.
|
// to extend the number of use values.
|
||||||
ColumnId_UseValue1 = 0x10000,
|
ColumnId_UseValue1 = 0x10000,
|
||||||
|
|
|
@ -140,6 +140,12 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
|
||||||
mRegions.addColumn (new NameColumn<ESM::Region>);
|
mRegions.addColumn (new NameColumn<ESM::Region>);
|
||||||
mRegions.addColumn (new MapColourColumn<ESM::Region>);
|
mRegions.addColumn (new MapColourColumn<ESM::Region>);
|
||||||
mRegions.addColumn (new SleepListColumn<ESM::Region>);
|
mRegions.addColumn (new SleepListColumn<ESM::Region>);
|
||||||
|
// see idadapterimpl.hpp and columnimp.hpp
|
||||||
|
RegionSoundListColumn<ESM::Region> *soundList = new RegionSoundListColumn<ESM::Region> ();
|
||||||
|
mRegions.addColumn (soundList);
|
||||||
|
mRegions.addAdapter (std::make_pair(soundList, new RegionSoundListAdapter<ESM::Region> ()));
|
||||||
|
mRegions.getNestableColumn(mRegions.getColumns()-1)->addColumn(new RegionSoundNameColumn ());
|
||||||
|
mRegions.getNestableColumn(mRegions.getColumns()-1)->addColumn(new RegionSoundChanceColumn ());
|
||||||
|
|
||||||
mBirthsigns.addColumn (new StringIdColumn<ESM::BirthSign>);
|
mBirthsigns.addColumn (new StringIdColumn<ESM::BirthSign>);
|
||||||
mBirthsigns.addColumn (new RecordStateColumn<ESM::BirthSign>);
|
mBirthsigns.addColumn (new RecordStateColumn<ESM::BirthSign>);
|
||||||
|
@ -339,7 +345,7 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
|
||||||
addModel (new IdTable (&mRaces), UniversalId::Type_Race);
|
addModel (new IdTable (&mRaces), UniversalId::Type_Race);
|
||||||
addModel (new IdTable (&mSounds), UniversalId::Type_Sound);
|
addModel (new IdTable (&mSounds), UniversalId::Type_Sound);
|
||||||
addModel (new IdTable (&mScripts), UniversalId::Type_Script);
|
addModel (new IdTable (&mScripts), UniversalId::Type_Script);
|
||||||
addModel (new IdTable (&mRegions), UniversalId::Type_Region);
|
addModel (new IdTree (&mRegions, &mRegions), UniversalId::Type_Region);
|
||||||
addModel (new IdTable (&mBirthsigns), UniversalId::Type_Birthsign);
|
addModel (new IdTable (&mBirthsigns), UniversalId::Type_Birthsign);
|
||||||
addModel (new IdTable (&mSpells), UniversalId::Type_Spell);
|
addModel (new IdTable (&mSpells), UniversalId::Type_Spell);
|
||||||
addModel (new IdTable (&mTopics), UniversalId::Type_Topic);
|
addModel (new IdTable (&mTopics), UniversalId::Type_Topic);
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "../doc/stage.hpp"
|
#include "../doc/stage.hpp"
|
||||||
|
|
||||||
#include "idcollection.hpp"
|
#include "idcollection.hpp"
|
||||||
|
#include "nestedidcollection.hpp"
|
||||||
#include "universalid.hpp"
|
#include "universalid.hpp"
|
||||||
#include "cell.hpp"
|
#include "cell.hpp"
|
||||||
#include "land.hpp"
|
#include "land.hpp"
|
||||||
|
@ -72,7 +73,7 @@ namespace CSMWorld
|
||||||
IdCollection<ESM::Race> mRaces;
|
IdCollection<ESM::Race> mRaces;
|
||||||
IdCollection<ESM::Sound> mSounds;
|
IdCollection<ESM::Sound> mSounds;
|
||||||
IdCollection<ESM::Script> mScripts;
|
IdCollection<ESM::Script> mScripts;
|
||||||
IdCollection<ESM::Region> mRegions;
|
NestedIdCollection<ESM::Region> mRegions;
|
||||||
IdCollection<ESM::BirthSign> mBirthsigns;
|
IdCollection<ESM::BirthSign> mBirthsigns;
|
||||||
IdCollection<ESM::Spell> mSpells;
|
IdCollection<ESM::Spell> mSpells;
|
||||||
IdCollection<ESM::Dialogue> mTopics;
|
IdCollection<ESM::Dialogue> mTopics;
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
#include <components/esm/loadpgrd.hpp>
|
#include <components/esm/loadpgrd.hpp>
|
||||||
|
#include <components/esm/loadregn.hpp>
|
||||||
|
|
||||||
#include "idadapter.hpp"
|
#include "idadapter.hpp"
|
||||||
#include "nestedtablewrapper.hpp"
|
#include "nestedtablewrapper.hpp"
|
||||||
|
@ -127,7 +128,7 @@ namespace CSMWorld
|
||||||
case 1: return point.mX;
|
case 1: return point.mX;
|
||||||
case 2: return point.mY;
|
case 2: return point.mY;
|
||||||
case 3: return point.mZ;
|
case 3: return point.mZ;
|
||||||
default: throw std::logic_error("Pathgrid point subcolumn index out of range");
|
default: throw std::runtime_error("Pathgrid point subcolumn index out of range");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +143,7 @@ namespace CSMWorld
|
||||||
case 1: point.mX = value.toInt(); break;
|
case 1: point.mX = value.toInt(); break;
|
||||||
case 2: point.mY = value.toInt(); break;
|
case 2: point.mY = value.toInt(); break;
|
||||||
case 3: point.mZ = value.toInt(); break;
|
case 3: point.mZ = value.toInt(); break;
|
||||||
default: throw std::logic_error("Pathgrid point subcolumn index out of range");
|
default: throw std::runtime_error("Pathgrid point subcolumn index out of range");
|
||||||
}
|
}
|
||||||
|
|
||||||
pathgrid.mPoints[subRowIndex] = point;
|
pathgrid.mPoints[subRowIndex] = point;
|
||||||
|
@ -223,7 +224,7 @@ namespace CSMWorld
|
||||||
case 0: return subRowIndex;
|
case 0: return subRowIndex;
|
||||||
case 1: return edge.mV0;
|
case 1: return edge.mV0;
|
||||||
case 2: return edge.mV1;
|
case 2: return edge.mV1;
|
||||||
default: throw std::logic_error("Pathgrid edge subcolumn index out of range");
|
default: throw std::runtime_error("Pathgrid edge subcolumn index out of range");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +239,7 @@ namespace CSMWorld
|
||||||
case 0: break;
|
case 0: break;
|
||||||
case 1: edge.mV0 = value.toInt(); break;
|
case 1: edge.mV0 = value.toInt(); break;
|
||||||
case 2: edge.mV1 = value.toInt(); break;
|
case 2: edge.mV1 = value.toInt(); break;
|
||||||
default: throw std::logic_error("Pathgrid edge subcolumn index out of range");
|
default: throw std::runtime_error("Pathgrid edge subcolumn index out of range");
|
||||||
}
|
}
|
||||||
|
|
||||||
pathgrid.mEdges[subRowIndex] = edge;
|
pathgrid.mEdges[subRowIndex] = edge;
|
||||||
|
@ -256,6 +257,93 @@ namespace CSMWorld
|
||||||
return static_cast<int>(record.get().mEdges.size());
|
return static_cast<int>(record.get().mEdges.size());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename ESXRecordT>
|
||||||
|
class RegionSoundListAdapter : public NestedIdAdapter<ESXRecordT>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RegionSoundListAdapter () {}
|
||||||
|
|
||||||
|
virtual void addNestedRow(Record<ESXRecordT>& record, int position) const
|
||||||
|
{
|
||||||
|
ESXRecordT region = record.get();
|
||||||
|
|
||||||
|
std::vector<ESXRecordT::SoundRef>& soundList = region.mSoundList;
|
||||||
|
|
||||||
|
// blank row
|
||||||
|
ESXRecordT::SoundRef soundRef;
|
||||||
|
soundRef.mSound.assign("");
|
||||||
|
soundRef.mChance = 0;
|
||||||
|
|
||||||
|
soundList.insert(soundList.begin()+position, soundRef);
|
||||||
|
|
||||||
|
record.setModified (region);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void removeNestedRow(Record<ESXRecordT>& record, int rowToRemove) const
|
||||||
|
{
|
||||||
|
ESXRecordT region = record.get();
|
||||||
|
|
||||||
|
std::vector<ESXRecordT::SoundRef>& soundList = region.mSoundList;
|
||||||
|
|
||||||
|
if (rowToRemove < 0 || rowToRemove >= static_cast<int> (soundList.size()))
|
||||||
|
throw std::runtime_error ("index out of range");
|
||||||
|
|
||||||
|
soundList.erase(soundList.begin()+rowToRemove);
|
||||||
|
|
||||||
|
record.setModified (region);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void setNestedTable(Record<ESXRecordT>& record, const NestedTableWrapperBase& nestedTable) const
|
||||||
|
{
|
||||||
|
record.get().mSoundList =
|
||||||
|
static_cast<const NestedTableWrapper<std::vector<ESM::Region::SoundRef> >&>(nestedTable).mNestedTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual NestedTableWrapperBase* nestedTable(const Record<ESXRecordT>& record) const
|
||||||
|
{
|
||||||
|
// deleted by dtor of NestedTableStoring
|
||||||
|
return new NestedTableWrapper<std::vector<ESM::Region::SoundRef> >(record.get().mSoundList);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual QVariant getNestedData(const Record<ESXRecordT>& record, int subRowIndex, int subColIndex) const
|
||||||
|
{
|
||||||
|
ESXRecordT::SoundRef soundRef = record.get().mSoundList[subRowIndex];
|
||||||
|
switch (subColIndex)
|
||||||
|
{
|
||||||
|
case 0: return QString(soundRef.mSound.toString().c_str());
|
||||||
|
case 1: return soundRef.mChance;
|
||||||
|
default: throw std::runtime_error("Region sounds subcolumn index out of range");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void setNestedData(Record<ESXRecordT>& record, const QVariant& value,
|
||||||
|
int subRowIndex, int subColIndex) const
|
||||||
|
{
|
||||||
|
ESXRecordT region = record.get();
|
||||||
|
ESXRecordT::SoundRef soundRef = region.mSoundList[subRowIndex];
|
||||||
|
switch (subColIndex)
|
||||||
|
{
|
||||||
|
case 0: soundRef.mSound.assign(value.toString().toUtf8().constData()); break;
|
||||||
|
case 1: soundRef.mChance = static_cast<unsigned char>(value.toInt()); break;
|
||||||
|
default: throw std::runtime_error("Region sounds subcolumn index out of range");
|
||||||
|
}
|
||||||
|
|
||||||
|
region.mSoundList[subRowIndex] = soundRef;
|
||||||
|
|
||||||
|
record.setModified (region);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int getNestedColumnsCount(const Record<ESXRecordT>& record) const
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int getNestedRowsCount(const Record<ESXRecordT>& record) const
|
||||||
|
{
|
||||||
|
return static_cast<int>(record.get().mSoundList.size());
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // CSM_WOLRD_IDADAPTERIMP_H
|
#endif // CSM_WOLRD_IDADAPTERIMP_H
|
||||||
|
|
Loading…
Reference in a new issue