mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:53:51 +00:00
Remove code duplication.
This commit is contained in:
parent
b11f5b2717
commit
1f902ff069
2 changed files with 20 additions and 38 deletions
|
@ -68,6 +68,19 @@ bool CSVRender::Cell::addObjects (int start, int end)
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVRender::Cell::recreatePathgrid()
|
||||||
|
{
|
||||||
|
const CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& pathgrids = mData.getPathgrids();
|
||||||
|
int pathgridIndex = pathgrids.searchId(mId);
|
||||||
|
if (pathgridIndex != -1)
|
||||||
|
{
|
||||||
|
mPathgridGeode->removeDrawable(mPathgridGeometry);
|
||||||
|
mPathgridGeometry = SceneUtil::PathgridGeometryFactory::get().create(
|
||||||
|
pathgrids.getRecord(pathgridIndex).get());
|
||||||
|
mPathgridGeode->addDrawable(mPathgridGeometry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CSVRender::Cell::Cell (CSMWorld::Data& data, osg::Group* rootNode, const std::string& id,
|
CSVRender::Cell::Cell (CSMWorld::Data& data, osg::Group* rootNode, const std::string& id,
|
||||||
bool deleted)
|
bool deleted)
|
||||||
: mData (data), mId (Misc::StringUtils::lowerCase (id)), mDeleted (deleted), mSubMode (0),
|
: mData (data), mId (Misc::StringUtils::lowerCase (id)), mDeleted (deleted), mSubMode (0),
|
||||||
|
@ -120,14 +133,7 @@ CSVRender::Cell::Cell (CSMWorld::Data& data, osg::Group* rootNode, const std::st
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& pathgrids = mData.getPathgrids();
|
recreatePathgrid();
|
||||||
int pathgridIndex = pathgrids.searchId(mId);
|
|
||||||
if (pathgridIndex != -1)
|
|
||||||
{
|
|
||||||
mPathgridGeometry = SceneUtil::PathgridGeometryFactory::get().create(
|
|
||||||
pathgrids.getRecord(pathgridIndex).get());
|
|
||||||
mPathgridGeode->addDrawable(mPathgridGeometry);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,9 +286,7 @@ bool CSVRender::Cell::referenceAdded (const QModelIndex& parent, int start, int
|
||||||
|
|
||||||
void CSVRender::Cell::pathgridAdded(const CSMWorld::Pathgrid& pathgrid)
|
void CSVRender::Cell::pathgridAdded(const CSMWorld::Pathgrid& pathgrid)
|
||||||
{
|
{
|
||||||
mPathgridGeode->removeDrawable(mPathgridGeometry);
|
recreatePathgrid();
|
||||||
mPathgridGeometry = SceneUtil::PathgridGeometryFactory::get().create(pathgrid);
|
|
||||||
mPathgridGeode->addDrawable(mPathgridGeometry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::Cell::pathgridRemoved()
|
void CSVRender::Cell::pathgridRemoved()
|
||||||
|
@ -292,41 +296,17 @@ void CSVRender::Cell::pathgridRemoved()
|
||||||
|
|
||||||
void CSVRender::Cell::pathgridDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
|
void CSVRender::Cell::pathgridDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
|
||||||
{
|
{
|
||||||
const CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& pathgrids = mData.getPathgrids();
|
recreatePathgrid();
|
||||||
int pathgridIndex = pathgrids.searchId(mId);
|
|
||||||
if (pathgridIndex != -1)
|
|
||||||
{
|
|
||||||
mPathgridGeode->removeDrawable(mPathgridGeometry);
|
|
||||||
mPathgridGeometry = SceneUtil::PathgridGeometryFactory::get().create(
|
|
||||||
pathgrids.getRecord(pathgridIndex).get());
|
|
||||||
mPathgridGeode->addDrawable(mPathgridGeometry);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::Cell::pathgridRowRemoved(const QModelIndex& parent, int start, int end)
|
void CSVRender::Cell::pathgridRowRemoved(const QModelIndex& parent, int start, int end)
|
||||||
{
|
{
|
||||||
const CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& pathgrids = mData.getPathgrids();
|
recreatePathgrid();
|
||||||
int pathgridIndex = pathgrids.searchId(mId);
|
|
||||||
if (pathgridIndex != -1)
|
|
||||||
{
|
|
||||||
mPathgridGeode->removeDrawable(mPathgridGeometry);
|
|
||||||
mPathgridGeometry = SceneUtil::PathgridGeometryFactory::get().create(
|
|
||||||
pathgrids.getRecord(pathgridIndex).get());
|
|
||||||
mPathgridGeode->addDrawable(mPathgridGeometry);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::Cell::pathgridRowAdded(const QModelIndex& parent, int start, int end)
|
void CSVRender::Cell::pathgridRowAdded(const QModelIndex& parent, int start, int end)
|
||||||
{
|
{
|
||||||
const CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& pathgrids = mData.getPathgrids();
|
recreatePathgrid();
|
||||||
int pathgridIndex = pathgrids.searchId(mId);
|
|
||||||
if (pathgridIndex != -1)
|
|
||||||
{
|
|
||||||
mPathgridGeode->removeDrawable(mPathgridGeometry);
|
|
||||||
mPathgridGeometry = SceneUtil::PathgridGeometryFactory::get().create(
|
|
||||||
pathgrids.getRecord(pathgridIndex).get());
|
|
||||||
mPathgridGeode->addDrawable(mPathgridGeometry);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::Cell::setSelection (int elementMask, Selection mode)
|
void CSVRender::Cell::setSelection (int elementMask, Selection mode)
|
||||||
|
|
|
@ -69,6 +69,8 @@ namespace CSVRender
|
||||||
/// \return Have any objects been added?
|
/// \return Have any objects been added?
|
||||||
bool addObjects (int start, int end);
|
bool addObjects (int start, int end);
|
||||||
|
|
||||||
|
void recreatePathgrid();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum Selection
|
enum Selection
|
||||||
|
|
Loading…
Reference in a new issue