mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-14 06:40:40 +00:00
Merge pull request #2094 from Capostrophic/editor
Cherry-pick cc9cii's minor editor improvements
This commit is contained in:
commit
db74eb4466
@ -221,7 +221,11 @@ std::string CSMWorld::IdTable::getId(int row) const
|
|||||||
///This method can return only indexes to the top level table cells
|
///This method can return only indexes to the top level table cells
|
||||||
QModelIndex CSMWorld::IdTable::getModelIndex (const std::string& id, int column) const
|
QModelIndex CSMWorld::IdTable::getModelIndex (const std::string& id, int column) const
|
||||||
{
|
{
|
||||||
return index(mIdCollection->getIndex (id), column);
|
int row = mIdCollection->searchId (id);
|
||||||
|
if (row != -1)
|
||||||
|
return index(row, column);
|
||||||
|
|
||||||
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMWorld::IdTable::setRecord (const std::string& id, const RecordBase& record, CSMWorld::UniversalId::Type type)
|
void CSMWorld::IdTable::setRecord (const std::string& id, const RecordBase& record, CSMWorld::UniversalId::Type type)
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
#include "refcollection.hpp"
|
#include "refcollection.hpp"
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
#include <components/debug/debuglog.hpp>
|
|
||||||
#include <components/misc/stringops.hpp>
|
#include <components/misc/stringops.hpp>
|
||||||
#include <components/esm/loadcell.hpp>
|
#include <components/esm/loadcell.hpp>
|
||||||
|
|
||||||
@ -32,40 +29,31 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
|
|||||||
|
|
||||||
if (cell.get().isExterior())
|
if (cell.get().isExterior())
|
||||||
{
|
{
|
||||||
// ignoring moved references sub-record; instead calculate cell from coordinates
|
// Autocalculate the cell index from coordinates first
|
||||||
std::pair<int, int> index = ref.getCellIndex();
|
std::pair<int, int> index = ref.getCellIndex();
|
||||||
|
|
||||||
std::ostringstream stream;
|
ref.mCell = "#" + std::to_string(index.first) + " " + std::to_string(index.second);
|
||||||
stream << "#" << index.first << " " << index.second;
|
|
||||||
|
|
||||||
ref.mCell = stream.str();
|
// Handle non-base moved references
|
||||||
|
if (!base && mref.mRefNum.mIndex != 0)
|
||||||
if (!base && // don't try to update base records
|
|
||||||
mref.mRefNum.mIndex != 0) // MVRF tag found
|
|
||||||
{
|
{
|
||||||
// there is a requirement for a placeholder where the original object was
|
// Moved references must have a link back to their original cell
|
||||||
//
|
// See discussion: https://forum.openmw.org/viewtopic.php?f=6&t=577&start=30
|
||||||
// see the forum discussions here for more details:
|
|
||||||
// https://forum.openmw.org/viewtopic.php?f=6&t=577&start=30
|
|
||||||
ref.mOriginalCell = cell2.mId;
|
ref.mOriginalCell = cell2.mId;
|
||||||
|
|
||||||
// It is not always possibe to ignore moved references sub-record and
|
// Some mods may move references outside of the bounds, which often happens they are deleted.
|
||||||
// calculate from coordinates. Some mods may place the ref in positions
|
// This results in nonsensical autocalculated cell IDs, so we must use the record target cell.
|
||||||
// outside normal bounds, resulting in non sensical cell id's. This often
|
|
||||||
// happens if the moved ref was deleted.
|
// Log a warning if the record target cell is different
|
||||||
//
|
|
||||||
// Use the target cell from the MVRF tag but if different output an error
|
|
||||||
// message
|
|
||||||
if (index.first != mref.mTarget[0] || index.second != mref.mTarget[1])
|
if (index.first != mref.mTarget[0] || index.second != mref.mTarget[1])
|
||||||
{
|
{
|
||||||
Log(Debug::Warning) << "Warning: the Position of moved ref "
|
std::string indexCell = ref.mCell;
|
||||||
<< ref.mRefID << " does not match the target cell";
|
ref.mCell = "#" + std::to_string(mref.mTarget[0]) + " " + std::to_string(mref.mTarget[1]);
|
||||||
Log(Debug::Warning) << "Position: #" << index.first << " " << index.second
|
|
||||||
<<", Target #"<< mref.mTarget[0] << " " << mref.mTarget[1];
|
|
||||||
|
|
||||||
stream.clear();
|
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Cell, mCells.getId (cellIndex));
|
||||||
stream << "#" << mref.mTarget[0] << " " << mref.mTarget[1];
|
messages.add(id, "The position of the moved reference " + ref.mRefID + " (cell " + indexCell + ")"
|
||||||
ref.mCell = stream.str(); // overwrite
|
" does not match the target cell (" + ref.mCell + ")",
|
||||||
|
std::string(), CSMDoc::Message::Severity_Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,7 +75,7 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
|
|||||||
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Cell,
|
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Cell,
|
||||||
mCells.getId (cellIndex));
|
mCells.getId (cellIndex));
|
||||||
|
|
||||||
messages.add (id, "Attempt to delete a non-existing reference");
|
messages.add (id, "Attempt to delete a non-existent reference");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +128,5 @@ void CSMWorld::RefCollection::load (ESM::ESMReader& reader, int cellIndex, bool
|
|||||||
|
|
||||||
std::string CSMWorld::RefCollection::getNewId()
|
std::string CSMWorld::RefCollection::getNewId()
|
||||||
{
|
{
|
||||||
std::ostringstream stream;
|
return "ref#" + std::to_string(mNextId++);
|
||||||
stream << "ref#" << mNextId++;
|
|
||||||
return stream.str();
|
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,11 @@ QModelIndex CSMWorld::ResourceTable::parent (const QModelIndex& index) const
|
|||||||
|
|
||||||
QModelIndex CSMWorld::ResourceTable::getModelIndex (const std::string& id, int column) const
|
QModelIndex CSMWorld::ResourceTable::getModelIndex (const std::string& id, int column) const
|
||||||
{
|
{
|
||||||
return index (mResources->getIndex (id), column);
|
int row = mResources->searchId(id);
|
||||||
|
if (row != -1)
|
||||||
|
return index (row, column);
|
||||||
|
|
||||||
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
int CSMWorld::ResourceTable::searchColumnIndex (Columns::ColumnId id) const
|
int CSMWorld::ResourceTable::searchColumnIndex (Columns::ColumnId id) const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user