mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-28 21:06:41 +00:00
added cell rendering in unpaged worldspaces
This commit is contained in:
parent
74ed9cbb2d
commit
a6626b94c8
4 changed files with 117 additions and 7 deletions
|
@ -21,6 +21,8 @@ void CSVRender::UnpagedWorldspaceWidget::update()
|
||||||
setDefaultAmbient (colour);
|
setDefaultAmbient (colour);
|
||||||
|
|
||||||
/// \todo deal with mSunlight and mFog/mForDensity
|
/// \todo deal with mSunlight and mFog/mForDensity
|
||||||
|
|
||||||
|
flagAsModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget (const std::string& cellId, CSMDoc::Document& document, QWidget* parent)
|
CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget (const std::string& cellId, CSMDoc::Document& document, QWidget* parent)
|
||||||
|
@ -29,12 +31,17 @@ CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget (const std::string&
|
||||||
mCellsModel = &dynamic_cast<CSMWorld::IdTable&> (
|
mCellsModel = &dynamic_cast<CSMWorld::IdTable&> (
|
||||||
*document.getData().getTableModel (CSMWorld::UniversalId::Type_Cells));
|
*document.getData().getTableModel (CSMWorld::UniversalId::Type_Cells));
|
||||||
|
|
||||||
|
mReferenceablesModel = &dynamic_cast<CSMWorld::IdTable&> (
|
||||||
|
*document.getData().getTableModel (CSMWorld::UniversalId::Type_Referenceables));
|
||||||
|
|
||||||
connect (mCellsModel, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)),
|
connect (mCellsModel, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)),
|
||||||
this, SLOT (cellDataChanged (const QModelIndex&, const QModelIndex&)));
|
this, SLOT (cellDataChanged (const QModelIndex&, const QModelIndex&)));
|
||||||
connect (mCellsModel, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)),
|
connect (mCellsModel, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)),
|
||||||
this, SLOT (cellRowsAboutToBeRemoved (const QModelIndex&, int, int)));
|
this, SLOT (cellRowsAboutToBeRemoved (const QModelIndex&, int, int)));
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
|
||||||
|
mCell.reset (new Cell (document.getData(), getSceneManager(), mCellId));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::UnpagedWorldspaceWidget::cellDataChanged (const QModelIndex& topLeft,
|
void CSVRender::UnpagedWorldspaceWidget::cellDataChanged (const QModelIndex& topLeft,
|
||||||
|
@ -72,6 +79,62 @@ void CSVRender::UnpagedWorldspaceWidget::handleDrop (const std::vector< CSMWorld
|
||||||
mCellId = data.begin()->getId();
|
mCellId = data.begin()->getId();
|
||||||
update();
|
update();
|
||||||
emit cellChanged(*data.begin());
|
emit cellChanged(*data.begin());
|
||||||
|
|
||||||
|
/// \todo replace mCell
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVRender::UnpagedWorldspaceWidget::referenceableDataChanged (const QModelIndex& topLeft,
|
||||||
|
const QModelIndex& bottomRight)
|
||||||
|
{
|
||||||
|
if (mCell.get())
|
||||||
|
if (mCell.get()->referenceableDataChanged (topLeft, bottomRight))
|
||||||
|
flagAsModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVRender::UnpagedWorldspaceWidget::referenceableAboutToBeRemoved (
|
||||||
|
const QModelIndex& parent, int start, int end)
|
||||||
|
{
|
||||||
|
if (mCell.get())
|
||||||
|
if (mCell.get()->referenceableAboutToBeRemoved (parent, start, end))
|
||||||
|
flagAsModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVRender::UnpagedWorldspaceWidget::referenceableAdded (const QModelIndex& parent,
|
||||||
|
int start, int end)
|
||||||
|
{
|
||||||
|
if (mCell.get())
|
||||||
|
{
|
||||||
|
QModelIndex topLeft = mReferenceablesModel->index (start, 0);
|
||||||
|
QModelIndex bottomRight =
|
||||||
|
mReferenceablesModel->index (end, mReferenceablesModel->columnCount());
|
||||||
|
|
||||||
|
if (mCell.get()->referenceableDataChanged (topLeft, bottomRight))
|
||||||
|
flagAsModified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVRender::UnpagedWorldspaceWidget::referenceDataChanged (const QModelIndex& topLeft,
|
||||||
|
const QModelIndex& bottomRight)
|
||||||
|
{
|
||||||
|
if (mCell.get())
|
||||||
|
if (mCell.get()->referenceDataChanged (topLeft, bottomRight))
|
||||||
|
flagAsModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVRender::UnpagedWorldspaceWidget::referenceAboutToBeRemoved (const QModelIndex& parent,
|
||||||
|
int start, int end)
|
||||||
|
{
|
||||||
|
if (mCell.get())
|
||||||
|
if (mCell.get()->referenceAboutToBeRemoved (parent, start, end))
|
||||||
|
flagAsModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVRender::UnpagedWorldspaceWidget::referenceAdded (const QModelIndex& parent, int start,
|
||||||
|
int end)
|
||||||
|
{
|
||||||
|
if (mCell.get())
|
||||||
|
if (mCell.get()->referenceAdded (parent, start, end))
|
||||||
|
flagAsModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVRender::WorldspaceWidget::dropRequirments CSVRender::UnpagedWorldspaceWidget::getDropRequirements (CSVRender::WorldspaceWidget::dropType type) const
|
CSVRender::WorldspaceWidget::dropRequirments CSVRender::UnpagedWorldspaceWidget::getDropRequirements (CSVRender::WorldspaceWidget::dropType type) const
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
#define OPENCS_VIEW_UNPAGEDWORLDSPACEWIDGET_H
|
#define OPENCS_VIEW_UNPAGEDWORLDSPACEWIDGET_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "worldspacewidget.hpp"
|
#include "worldspacewidget.hpp"
|
||||||
|
#include "cell.hpp"
|
||||||
|
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
|
|
||||||
|
@ -25,6 +27,8 @@ namespace CSVRender
|
||||||
|
|
||||||
std::string mCellId;
|
std::string mCellId;
|
||||||
CSMWorld::IdTable *mCellsModel;
|
CSMWorld::IdTable *mCellsModel;
|
||||||
|
CSMWorld::IdTable *mReferenceablesModel;
|
||||||
|
std::auto_ptr<Cell> mCell;
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
|
@ -37,6 +41,21 @@ namespace CSVRender
|
||||||
|
|
||||||
virtual void handleDrop(const std::vector<CSMWorld::UniversalId>& data);
|
virtual void handleDrop(const std::vector<CSMWorld::UniversalId>& data);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
virtual void referenceableDataChanged (const QModelIndex& topLeft,
|
||||||
|
const QModelIndex& bottomRight);
|
||||||
|
|
||||||
|
virtual void referenceableAboutToBeRemoved (const QModelIndex& parent, int start, int end);
|
||||||
|
|
||||||
|
virtual void referenceableAdded (const QModelIndex& index, int start, int end);
|
||||||
|
|
||||||
|
virtual void referenceDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
|
||||||
|
|
||||||
|
virtual void referenceAboutToBeRemoved (const QModelIndex& parent, int start, int end);
|
||||||
|
|
||||||
|
virtual void referenceAdded (const QModelIndex& index, int start, int end);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void cellDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
|
void cellDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
|
||||||
|
|
|
@ -10,15 +10,30 @@
|
||||||
#include "../world/scenetoolmode.hpp"
|
#include "../world/scenetoolmode.hpp"
|
||||||
#include <apps/opencs/model/world/universalid.hpp>
|
#include <apps/opencs/model/world/universalid.hpp>
|
||||||
|
|
||||||
CSVRender::WorldspaceWidget::WorldspaceWidget (const CSMDoc::Document& document, QWidget* parent)
|
CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidget* parent)
|
||||||
: SceneWidget (parent), mDocument(document)
|
: SceneWidget (parent), mDocument(document)
|
||||||
{
|
{
|
||||||
Ogre::Entity* ent = getSceneManager()->createEntity("cube", Ogre::SceneManager::PT_CUBE);
|
|
||||||
ent->setMaterialName("BaseWhite");
|
|
||||||
|
|
||||||
getSceneManager()->getRootSceneNode()->attachObject(ent);
|
|
||||||
|
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
|
QAbstractItemModel *referenceables =
|
||||||
|
document.getData().getTableModel (CSMWorld::UniversalId::Type_Referenceables);
|
||||||
|
|
||||||
|
connect (referenceables, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)),
|
||||||
|
this, SLOT (referenceableDataChanged (const QModelIndex&, const QModelIndex&)));
|
||||||
|
connect (referenceables, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)),
|
||||||
|
this, SLOT (referenceableAboutToBeRemoved (const QModelIndex&, int, int)));
|
||||||
|
connect (referenceables, SIGNAL (rowsInserted (const QModelIndex&, int, int)),
|
||||||
|
this, SLOT (referenceableAdded (const QModelIndex&, int, int)));
|
||||||
|
|
||||||
|
QAbstractItemModel *references =
|
||||||
|
document.getData().getTableModel (CSMWorld::UniversalId::Type_References);
|
||||||
|
|
||||||
|
connect (references, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)),
|
||||||
|
this, SLOT (referenceDataChanged (const QModelIndex&, const QModelIndex&)));
|
||||||
|
connect (references, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)),
|
||||||
|
this, SLOT (referenceAboutToBeRemoved (const QModelIndex&, int, int)));
|
||||||
|
connect (references, SIGNAL (rowsInserted (const QModelIndex&, int, int)),
|
||||||
|
this, SLOT (referenceAdded (const QModelIndex&, int, int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::WorldspaceWidget::selectNavigationMode (const std::string& mode)
|
void CSVRender::WorldspaceWidget::selectNavigationMode (const std::string& mode)
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace CSVRender
|
||||||
ignored //either mixed cells, or not cells
|
ignored //either mixed cells, or not cells
|
||||||
};
|
};
|
||||||
|
|
||||||
WorldspaceWidget (const CSMDoc::Document& document, QWidget *parent = 0);
|
WorldspaceWidget (CSMDoc::Document& document, QWidget *parent = 0);
|
||||||
|
|
||||||
CSVWorld::SceneToolMode *makeNavigationSelector (CSVWorld::SceneToolbar *parent);
|
CSVWorld::SceneToolMode *makeNavigationSelector (CSVWorld::SceneToolbar *parent);
|
||||||
///< \attention The created tool is not added to the toolbar (via addTool). Doing that
|
///< \attention The created tool is not added to the toolbar (via addTool). Doing that
|
||||||
|
@ -79,6 +79,19 @@ namespace CSVRender
|
||||||
|
|
||||||
void selectNavigationMode (const std::string& mode);
|
void selectNavigationMode (const std::string& mode);
|
||||||
|
|
||||||
|
virtual void referenceableDataChanged (const QModelIndex& topLeft,
|
||||||
|
const QModelIndex& bottomRight) {}
|
||||||
|
|
||||||
|
virtual void referenceableAboutToBeRemoved (const QModelIndex& parent, int start, int end) {}
|
||||||
|
|
||||||
|
virtual void referenceableAdded (const QModelIndex& index, int start, int end) {}
|
||||||
|
|
||||||
|
virtual void referenceDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight) {}
|
||||||
|
|
||||||
|
virtual void referenceAboutToBeRemoved (const QModelIndex& parent, int start, int end) {}
|
||||||
|
|
||||||
|
virtual void referenceAdded (const QModelIndex& index, int start, int end) {}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void closeRequest();
|
void closeRequest();
|
||||||
|
|
Loading…
Reference in a new issue