forked from teamnwah/openmw-tes3coop
Merge branch 'editorfixes'
This commit is contained in:
commit
607445d40c
9 changed files with 116 additions and 15 deletions
|
@ -550,7 +550,12 @@ bool CSMFilter::Parser::parse (const std::string& filter, bool allowPredefined)
|
|||
if (allowPredefined)
|
||||
token = getNextToken();
|
||||
|
||||
if (!allowPredefined || token==Token (Token::Type_OneShot))
|
||||
if (allowPredefined && token==Token (Token::Type_EOS))
|
||||
{
|
||||
mFilter.reset();
|
||||
return true;
|
||||
}
|
||||
else if (!allowPredefined || token==Token (Token::Type_OneShot))
|
||||
{
|
||||
boost::shared_ptr<Node> node = parseImp (true, token!=Token (Token::Type_OneShot));
|
||||
|
||||
|
|
|
@ -174,6 +174,9 @@ namespace CSMWorld
|
|||
{ ColumnId_PcRank, "PC Rank" },
|
||||
{ ColumnId_Scope, "Scope" },
|
||||
{ ColumnId_ReferenceableId, "Referenceable ID" },
|
||||
{ ColumnId_CombatState, "Combat" },
|
||||
{ ColumnId_MagicState, "Magic" },
|
||||
{ ColumnId_StealthState, "Stealth" },
|
||||
|
||||
{ ColumnId_UseValue1, "Use value 1" },
|
||||
{ ColumnId_UseValue2, "Use value 2" },
|
||||
|
|
|
@ -167,6 +167,9 @@ namespace CSMWorld
|
|||
ColumnId_PcRank = 154,
|
||||
ColumnId_Scope = 155,
|
||||
ColumnId_ReferenceableId = 156,
|
||||
ColumnId_CombatState = 157,
|
||||
ColumnId_MagicState = 158,
|
||||
ColumnId_StealthState = 159,
|
||||
|
||||
// Allocated to a separate value range, so we don't get a collision should we ever need
|
||||
// to extend the number of use values.
|
||||
|
|
|
@ -15,7 +15,10 @@ namespace CSMWorld
|
|||
|
||||
void load (ESM::ESMReader& reader, bool base);
|
||||
|
||||
void load (const ESXRecordT& record, bool base);
|
||||
/// \param index Index at which the record can be found.
|
||||
/// Special values: -2 index unknown, -1 record does not exist yet and therefore
|
||||
/// does not have an index
|
||||
void load (const ESXRecordT& record, bool base, int index = -2);
|
||||
|
||||
bool tryDelete (const std::string& id);
|
||||
///< Try deleting \a id. If the id does not exist or can't be deleted the call is ignored.
|
||||
|
@ -56,17 +59,28 @@ namespace CSMWorld
|
|||
else
|
||||
{
|
||||
ESXRecordT record;
|
||||
IdAccessorT().getId (record) = id;
|
||||
|
||||
int index = this->searchId (id);
|
||||
|
||||
if (index==-1)
|
||||
IdAccessorT().getId (record) = id;
|
||||
else
|
||||
{
|
||||
record = this->getRecord (index).get();
|
||||
}
|
||||
|
||||
record.load (reader);
|
||||
|
||||
load (record, base);
|
||||
load (record, base, index);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename ESXRecordT, typename IdAccessorT>
|
||||
void IdCollection<ESXRecordT, IdAccessorT>::load (const ESXRecordT& record, bool base)
|
||||
void IdCollection<ESXRecordT, IdAccessorT>::load (const ESXRecordT& record, bool base,
|
||||
int index)
|
||||
{
|
||||
int index = this->searchId (IdAccessorT().getId (record));
|
||||
if (index==-2)
|
||||
index = this->searchId (IdAccessorT().getId (record));
|
||||
|
||||
if (index==-1)
|
||||
{
|
||||
|
|
|
@ -248,6 +248,15 @@ QVariant CSMWorld::CreatureRefIdAdapter::getData (const RefIdColumn *column, con
|
|||
if (column==mColumns.mOriginal)
|
||||
return QString::fromUtf8 (record.get().mOriginal.c_str());
|
||||
|
||||
if (column==mColumns.mCombat)
|
||||
return static_cast<int> (record.get().mData.mCombat);
|
||||
|
||||
if (column==mColumns.mMagic)
|
||||
return static_cast<int> (record.get().mData.mMagic);
|
||||
|
||||
if (column==mColumns.mStealth)
|
||||
return static_cast<int> (record.get().mData.mStealth);
|
||||
|
||||
std::map<const RefIdColumn *, unsigned int>::const_iterator iter =
|
||||
mColumns.mFlags.find (column);
|
||||
|
||||
|
@ -271,6 +280,12 @@ void CSMWorld::CreatureRefIdAdapter::setData (const RefIdColumn *column, RefIdDa
|
|||
record.get().mScale = value.toFloat();
|
||||
else if (column==mColumns.mOriginal)
|
||||
record.get().mOriginal = value.toString().toUtf8().constData();
|
||||
else if (column==mColumns.mCombat)
|
||||
record.get().mData.mCombat = value.toInt();
|
||||
else if (column==mColumns.mMagic)
|
||||
record.get().mData.mMagic = value.toInt();
|
||||
else if (column==mColumns.mStealth)
|
||||
record.get().mData.mStealth = value.toInt();
|
||||
else
|
||||
{
|
||||
std::map<const RefIdColumn *, unsigned int>::const_iterator iter =
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace CSMWorld
|
|||
BaseRefIdAdapter (UniversalId::Type type, const BaseColumns& base);
|
||||
|
||||
virtual std::string getId (const RecordBase& record) const;
|
||||
|
||||
|
||||
virtual void setId (RecordBase& record, const std::string& id);
|
||||
|
||||
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index)
|
||||
|
@ -57,7 +57,7 @@ namespace CSMWorld
|
|||
{
|
||||
(dynamic_cast<Record<RecordT>&> (record).get().mId) = id;
|
||||
}
|
||||
|
||||
|
||||
template<typename RecordT>
|
||||
std::string BaseRefIdAdapter<RecordT>::getId (const RecordBase& record) const
|
||||
{
|
||||
|
@ -631,6 +631,9 @@ namespace CSMWorld
|
|||
const RefIdColumn *mSoul;
|
||||
const RefIdColumn *mScale;
|
||||
const RefIdColumn *mOriginal;
|
||||
const RefIdColumn *mCombat;
|
||||
const RefIdColumn *mMagic;
|
||||
const RefIdColumn *mStealth;
|
||||
|
||||
CreatureColumns (const ActorColumns& actorColumns);
|
||||
};
|
||||
|
|
|
@ -175,6 +175,15 @@ CSMWorld::RefIdCollection::RefIdCollection()
|
|||
creatureColumns.mScale = &mColumns.back();
|
||||
mColumns.push_back (RefIdColumn (Columns::ColumnId_OriginalCreature, ColumnBase::Display_String));
|
||||
creatureColumns.mOriginal = &mColumns.back();
|
||||
mColumns.push_back (
|
||||
RefIdColumn (Columns::ColumnId_CombatState, ColumnBase::Display_Integer));
|
||||
creatureColumns.mCombat = &mColumns.back();
|
||||
mColumns.push_back (
|
||||
RefIdColumn (Columns::ColumnId_MagicState, ColumnBase::Display_Integer));
|
||||
creatureColumns.mMagic = &mColumns.back();
|
||||
mColumns.push_back (
|
||||
RefIdColumn (Columns::ColumnId_StealthState, ColumnBase::Display_Integer));
|
||||
creatureColumns.mStealth = &mColumns.back();
|
||||
|
||||
static const struct
|
||||
{
|
||||
|
|
|
@ -15,13 +15,18 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells()
|
|||
bool modified = false;
|
||||
bool setCamera = false;
|
||||
|
||||
const CSMWorld::IdCollection<CSMWorld::Cell>& cells = mDocument.getData().getCells();
|
||||
|
||||
{
|
||||
// remove
|
||||
std::map<CSMWorld::CellCoordinates, Cell *>::iterator iter (mCells.begin());
|
||||
|
||||
while (iter!=mCells.end())
|
||||
{
|
||||
if (!mSelection.has (iter->first))
|
||||
int index = cells.searchId (iter->first.getId (mWorldspace));
|
||||
|
||||
if (!mSelection.has (iter->first) || index==-1 ||
|
||||
cells.getRecord (index).mState==CSMWorld::RecordBase::State_Deleted)
|
||||
{
|
||||
delete iter->second;
|
||||
mCells.erase (iter++);
|
||||
|
@ -39,7 +44,10 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells()
|
|||
for (CSMWorld::CellSelection::Iterator iter (mSelection.begin()); iter!=mSelection.end();
|
||||
++iter)
|
||||
{
|
||||
if (mCells.find (*iter)==mCells.end())
|
||||
int index = cells.searchId (iter->getId (mWorldspace));
|
||||
|
||||
if (index!=0 && cells.getRecord (index).mState!=CSMWorld::RecordBase::State_Deleted &&
|
||||
mCells.find (*iter)==mCells.end())
|
||||
{
|
||||
if (setCamera)
|
||||
{
|
||||
|
@ -49,7 +57,7 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells()
|
|||
|
||||
mCells.insert (std::make_pair (*iter,
|
||||
new Cell (mDocument.getData(), getSceneManager(),
|
||||
iter->getId ("std::default"))));
|
||||
iter->getId (mWorldspace))));
|
||||
|
||||
modified = true;
|
||||
}
|
||||
|
@ -121,11 +129,19 @@ void CSVRender::PagedWorldspaceWidget::referenceAdded (const QModelIndex& parent
|
|||
flagAsModified();
|
||||
}
|
||||
|
||||
|
||||
|
||||
CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget* parent, CSMDoc::Document& document)
|
||||
: WorldspaceWidget (document, parent), mDocument (document)
|
||||
{}
|
||||
: WorldspaceWidget (document, parent), mDocument (document), mWorldspace ("std::default")
|
||||
{
|
||||
QAbstractItemModel *cells =
|
||||
document.getData().getTableModel (CSMWorld::UniversalId::Type_Cells);
|
||||
|
||||
connect (cells, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)),
|
||||
this, SLOT (cellDataChanged (const QModelIndex&, const QModelIndex&)));
|
||||
connect (cells, SIGNAL (rowsRemoved (const QModelIndex&, int, int)),
|
||||
this, SLOT (cellRemoved (const QModelIndex&, int, int)));
|
||||
connect (cells, SIGNAL (rowsInserted (const QModelIndex&, int, int)),
|
||||
this, SLOT (cellAdded (const QModelIndex&, int, int)));
|
||||
}
|
||||
|
||||
CSVRender::PagedWorldspaceWidget::~PagedWorldspaceWidget()
|
||||
{
|
||||
|
@ -219,4 +235,27 @@ CSVRender::WorldspaceWidget::dropRequirments CSVRender::PagedWorldspaceWidget::g
|
|||
default:
|
||||
return ignored;
|
||||
}
|
||||
}
|
||||
|
||||
void CSVRender::PagedWorldspaceWidget::cellDataChanged (const QModelIndex& topLeft,
|
||||
const QModelIndex& bottomRight)
|
||||
{
|
||||
/// \todo check if no selected cell is affected and do not update, if that is the case
|
||||
if (adjustCells())
|
||||
flagAsModified();
|
||||
}
|
||||
|
||||
void CSVRender::PagedWorldspaceWidget::cellRemoved (const QModelIndex& parent, int start,
|
||||
int end)
|
||||
{
|
||||
if (adjustCells())
|
||||
flagAsModified();
|
||||
}
|
||||
|
||||
void CSVRender::PagedWorldspaceWidget::cellAdded (const QModelIndex& index, int start,
|
||||
int end)
|
||||
{
|
||||
/// \todo check if no selected cell is affected and do not update, if that is the case
|
||||
if (adjustCells())
|
||||
flagAsModified();
|
||||
}
|
|
@ -17,6 +17,7 @@ namespace CSVRender
|
|||
CSMDoc::Document& mDocument;
|
||||
CSMWorld::CellSelection mSelection;
|
||||
std::map<CSMWorld::CellCoordinates, Cell *> mCells;
|
||||
std::string mWorldspace;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -60,6 +61,15 @@ namespace CSVRender
|
|||
signals:
|
||||
|
||||
void cellSelectionChanged (const CSMWorld::CellSelection& selection);
|
||||
|
||||
private slots:
|
||||
|
||||
virtual void cellDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
|
||||
|
||||
virtual void cellRemoved (const QModelIndex& parent, int start, int end);
|
||||
|
||||
virtual void cellAdded (const QModelIndex& index, int start, int end);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue