mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-31 18:45:36 +00:00
added changed reference tracking for cells
This commit is contained in:
parent
e0b6bf6aeb
commit
f4334da42e
3 changed files with 51 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
|||
#ifndef CSM_WOLRD_CELL_H
|
||||
#define CSM_WOLRD_CELL_H
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include <components/esm/loadcell.hpp>
|
||||
|
@ -16,8 +16,11 @@ namespace CSMWorld
|
|||
{
|
||||
std::string mId;
|
||||
|
||||
void load (ESM::ESMReader &esm);
|
||||
/// These are the references modified by the edited content file. These are stored in
|
||||
/// mModified only.
|
||||
std::set<std::string> mTouchedRefs;
|
||||
|
||||
void load (ESM::ESMReader &esm);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "columnbase.hpp"
|
||||
#include "columns.hpp"
|
||||
#include "info.hpp"
|
||||
#include "cell.hpp"
|
||||
|
||||
namespace CSMWorld
|
||||
{
|
||||
|
@ -87,6 +88,45 @@ namespace CSMWorld
|
|||
}
|
||||
};
|
||||
|
||||
/// \brief Specialisation that takes care of the modified reference tracking
|
||||
template<>
|
||||
struct RecordStateColumn<Cell> : public Column<Cell>
|
||||
{
|
||||
RecordStateColumn<Cell>()
|
||||
: Column<Cell> (Columns::ColumnId_Modification, ColumnBase::Display_RecordState)
|
||||
{}
|
||||
|
||||
virtual QVariant get (const Record<Cell>& record) const
|
||||
{
|
||||
if (record.mState==Record<Cell>::State_Erased)
|
||||
return static_cast<int> (Record<Cell>::State_Deleted);
|
||||
|
||||
if (!record.mModified.mTouchedRefs.empty() &&
|
||||
!record.mState==Record<Cell>::State_Deleted &&
|
||||
!record.mState==Record<Cell>::State_ModifiedOnly)
|
||||
{
|
||||
static_cast<int> (Record<Cell>::State_Modified);
|
||||
}
|
||||
|
||||
return static_cast<int> (record.mState);
|
||||
}
|
||||
|
||||
virtual void set (Record<Cell>& record, const QVariant& data)
|
||||
{
|
||||
record.mState = static_cast<RecordBase::State> (data.toInt());
|
||||
}
|
||||
|
||||
virtual bool isEditable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool isUserEditable() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename ESXRecordT>
|
||||
struct FixedRecordTypeColumn : public Column<ESXRecordT>
|
||||
{
|
||||
|
|
|
@ -53,6 +53,8 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
|
|||
}
|
||||
else
|
||||
{
|
||||
cell.mModified.mTouchedRefs.insert (Misc::StringUtils::lowerCase (
|
||||
mCells.getId (cellIndex)));
|
||||
record.mState = RecordBase::State_Deleted;
|
||||
setRecord (index, record);
|
||||
}
|
||||
|
@ -60,6 +62,10 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!base)
|
||||
cell.mModified.mTouchedRefs.insert (Misc::StringUtils::lowerCase (
|
||||
mCells.getId (cellIndex)));
|
||||
|
||||
if (iter==cache.end())
|
||||
{
|
||||
// new reference
|
||||
|
|
Loading…
Reference in a new issue