mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-31 12:45:36 +00:00
Feat(CS): Add undo stack as a member of CSVRender::Cell
This commit is contained in:
parent
b5d118f5ee
commit
c941245cd0
4 changed files with 15 additions and 7 deletions
|
@ -1,6 +1,7 @@
|
||||||
#include "cell.hpp"
|
#include "cell.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <qundostack.h>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
@ -171,8 +172,10 @@ void CSVRender::Cell::unloadLand()
|
||||||
mCellBorder.reset();
|
mCellBorder.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVRender::Cell::Cell(CSMWorld::Data& data, osg::Group* rootNode, const std::string& id, bool deleted)
|
CSVRender::Cell::Cell(
|
||||||
|
CSMWorld::Data& data, QUndoStack& undoStack, osg::Group* rootNode, const std::string& id, bool deleted)
|
||||||
: mData(data)
|
: mData(data)
|
||||||
|
, mUndoStack(undoStack)
|
||||||
, mId(ESM::RefId::stringRefId(id))
|
, mId(ESM::RefId::stringRefId(id))
|
||||||
, mDeleted(deleted)
|
, mDeleted(deleted)
|
||||||
, mSubMode(0)
|
, mSubMode(0)
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
#include <osg/Vec3d>
|
#include <osg/Vec3d>
|
||||||
#include <osg/ref_ptr>
|
#include <osg/ref_ptr>
|
||||||
|
|
||||||
|
#include <QUndoStack>
|
||||||
|
|
||||||
#include "../../model/world/cellcoordinates.hpp"
|
#include "../../model/world/cellcoordinates.hpp"
|
||||||
#include "instancedragmodes.hpp"
|
#include "instancedragmodes.hpp"
|
||||||
#include <components/esm/refid.hpp>
|
#include <components/esm/refid.hpp>
|
||||||
|
@ -46,6 +48,7 @@ namespace CSVRender
|
||||||
class Cell
|
class Cell
|
||||||
{
|
{
|
||||||
CSMWorld::Data& mData;
|
CSMWorld::Data& mData;
|
||||||
|
QUndoStack& mUndoStack;
|
||||||
ESM::RefId mId;
|
ESM::RefId mId;
|
||||||
osg::ref_ptr<osg::Group> mCellNode;
|
osg::ref_ptr<osg::Group> mCellNode;
|
||||||
std::map<std::string, Object*, Misc::StringUtils::CiComp> mObjects;
|
std::map<std::string, Object*, Misc::StringUtils::CiComp> mObjects;
|
||||||
|
@ -89,7 +92,8 @@ namespace CSVRender
|
||||||
public:
|
public:
|
||||||
/// \note Deleted covers both cells that are deleted and cells that don't exist in
|
/// \note Deleted covers both cells that are deleted and cells that don't exist in
|
||||||
/// the first place.
|
/// the first place.
|
||||||
Cell(CSMWorld::Data& data, osg::Group* rootNode, const std::string& id, bool deleted = false);
|
Cell(CSMWorld::Data& data, QUndoStack& undoStack, osg::Group* rootNode, const std::string& id,
|
||||||
|
bool deleted = false);
|
||||||
|
|
||||||
~Cell();
|
~Cell();
|
||||||
|
|
||||||
|
|
|
@ -86,8 +86,8 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells()
|
||||||
{
|
{
|
||||||
modified = true;
|
modified = true;
|
||||||
|
|
||||||
auto cell = std::make_unique<Cell>(
|
auto cell = std::make_unique<Cell>(mDocument.getData(), mDocument.getUndoStack(), mRootNode,
|
||||||
mDocument.getData(), mRootNode, iter->first.getId(mWorldspace), deleted);
|
iter->first.getId(mWorldspace), deleted);
|
||||||
|
|
||||||
delete iter->second;
|
delete iter->second;
|
||||||
iter->second = cell.release();
|
iter->second = cell.release();
|
||||||
|
@ -465,7 +465,8 @@ void CSVRender::PagedWorldspaceWidget::addCellToScene(const CSMWorld::CellCoordi
|
||||||
|
|
||||||
bool deleted = index == -1 || cells.getRecord(index).mState == CSMWorld::RecordBase::State_Deleted;
|
bool deleted = index == -1 || cells.getRecord(index).mState == CSMWorld::RecordBase::State_Deleted;
|
||||||
|
|
||||||
auto cell = std::make_unique<Cell>(mDocument.getData(), mRootNode, coordinates.getId(mWorldspace), deleted);
|
auto cell = std::make_unique<Cell>(
|
||||||
|
mDocument.getData(), mDocument.getUndoStack(), mRootNode, coordinates.getId(mWorldspace), deleted);
|
||||||
EditMode* editMode = getEditMode();
|
EditMode* editMode = getEditMode();
|
||||||
cell->setSubMode(editMode->getSubMode(), editMode->getInteractionMask());
|
cell->setSubMode(editMode->getSubMode(), editMode->getInteractionMask());
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget(
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
|
||||||
mCell = std::make_unique<Cell>(document.getData(), mRootNode, mCellId);
|
mCell = std::make_unique<Cell>(document.getData(), document.getUndoStack(), mRootNode, mCellId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::UnpagedWorldspaceWidget::cellDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
|
void CSVRender::UnpagedWorldspaceWidget::cellDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
|
||||||
|
@ -127,7 +127,7 @@ bool CSVRender::UnpagedWorldspaceWidget::handleDrop(
|
||||||
|
|
||||||
mCellId = universalIdData.begin()->getId();
|
mCellId = universalIdData.begin()->getId();
|
||||||
|
|
||||||
mCell = std::make_unique<Cell>(getDocument().getData(), mRootNode, mCellId);
|
mCell = std::make_unique<Cell>(getDocument().getData(), getDocument().getUndoStack(), mRootNode, mCellId);
|
||||||
mCamPositionSet = false;
|
mCamPositionSet = false;
|
||||||
mOrbitCamControl->reset();
|
mOrbitCamControl->reset();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue