diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 7094f8799e..86f44d2b2a 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -27,6 +27,7 @@ opencs_units (model/world opencs_units_noqt (model/world universalid record commands columnbase scriptcontext cell refidcollection refidadapter refiddata refidadapterimp ref collectionbase refcollection columns infocollection tablemimedata cellcoordinates cellselection resources resourcesmanager scope + pathgrid ) opencs_hdrs_noqt (model/world diff --git a/apps/opencs/model/doc/saving.cpp b/apps/opencs/model/doc/saving.cpp index 12c4b359be..163d5991fe 100644 --- a/apps/opencs/model/doc/saving.cpp +++ b/apps/opencs/model/doc/saving.cpp @@ -78,6 +78,9 @@ CSMDoc::Saving::Saving (Document& document, const boost::filesystem::path& proje appendStage (new WriteCollectionStage > (mDocument.getData().getMagicEffects(), mState)); + appendStage (new WriteCollectionStage > + (mDocument.getData().getPathgrids(), mState)); + appendStage (new WriteDialogueCollectionStage (mDocument, mState, false)); appendStage (new WriteDialogueCollectionStage (mDocument, mState, true)); diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index 41382fe482..ccf86c5b86 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -250,6 +250,10 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc Columns::ColumnId_NegativeLight, ESM::MagicEffect::NegativeLight)); mMagicEffects.addColumn (new DescriptionColumn); + mPathgrids.addColumn (new StringIdColumn); + mPathgrids.addColumn (new RecordStateColumn); + mPathgrids.addColumn (new FixedRecordTypeColumn (UniversalId::Type_Pathgrid)); + mRefs.addColumn (new StringIdColumn (true)); mRefs.addColumn (new RecordStateColumn); mRefs.addColumn (new FixedRecordTypeColumn (UniversalId::Type_Reference)); @@ -322,6 +326,7 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc addModel (new IdTable (&mBodyParts), UniversalId::Type_BodyPart); addModel (new IdTable (&mSoundGens), UniversalId::Type_SoundGen); addModel (new IdTable (&mMagicEffects), UniversalId::Type_MagicEffect); + addModel (new IdTable (&mPathgrids), UniversalId::Type_Pathgrid); addModel (new IdTable (&mReferenceables, IdTable::Feature_Preview), UniversalId::Type_Referenceable); addModel (new IdTable (&mRefs, IdTable::Feature_ViewCell | IdTable::Feature_Preview), UniversalId::Type_Reference); @@ -590,6 +595,16 @@ CSMWorld::IdCollection& CSMWorld::Data::getMagicEffects() return mMagicEffects; } +const CSMWorld::IdCollection& CSMWorld::Data::getPathgrids() const +{ + return mPathgrids; +} + +CSMWorld::IdCollection& CSMWorld::Data::getPathgrids() +{ + return mPathgrids; +} + const CSMWorld::Resources& CSMWorld::Data::getResources (const UniversalId& id) const { return mResourcesManager.get (id.getType()); @@ -678,6 +693,7 @@ bool CSMWorld::Data::continueLoading (CSMDoc::Stage::Messages& messages) case ESM::REC_BODY: mBodyParts.load (*mReader, mBase); break; case ESM::REC_SNDG: mSoundGens.load (*mReader, mBase); break; case ESM::REC_MGEF: mMagicEffects.load (*mReader, mBase); break; + case ESM::REC_PGRD: mPathgrids.load (*mReader, mBase); break; case ESM::REC_CELL: { @@ -852,7 +868,8 @@ int CSMWorld::Data::count (RecordBase::State state) const count (state, mBodyParts) + count (state, mSoundGens) + count (state, mMagicEffects) + - count (state, mReferenceables); + count (state, mReferenceables) + + count (state, mPathgrids); } void CSMWorld::Data::setDescription (const std::string& description) diff --git a/apps/opencs/model/world/data.hpp b/apps/opencs/model/world/data.hpp index 6862ab51a3..cae16128c3 100644 --- a/apps/opencs/model/world/data.hpp +++ b/apps/opencs/model/world/data.hpp @@ -38,6 +38,7 @@ #include "refidcollection.hpp" #include "refcollection.hpp" #include "infocollection.hpp" +#include "pathgrid.hpp" class QAbstractItemModel; @@ -73,6 +74,7 @@ namespace CSMWorld IdCollection mEnchantments; IdCollection mBodyParts; IdCollection mMagicEffects; + IdCollection mPathgrids; IdCollection mDebugProfiles; IdCollection mSoundGens; InfoCollection mTopicInfos; @@ -207,6 +209,10 @@ namespace CSMWorld IdCollection& getMagicEffects(); + const IdCollection& getPathgrids() const; + + IdCollection& getPathgrids(); + /// Throws an exception, if \a id does not match a resources list. const Resources& getResources (const UniversalId& id) const; diff --git a/apps/opencs/model/world/pathgrid.cpp b/apps/opencs/model/world/pathgrid.cpp new file mode 100644 index 0000000000..6226e361a6 --- /dev/null +++ b/apps/opencs/model/world/pathgrid.cpp @@ -0,0 +1,20 @@ + +#include "pathgrid.hpp" + +#include + +void CSMWorld::Pathgrid::load (ESM::ESMReader &esm) +{ + ESM::Pathgrid::load (esm); + + if (mCell.empty()) + { + std::ostringstream stream; + + stream << "#" << mData.mX << " " << mData.mY; + + mId = stream.str(); + } + else + mId = mCell; +} diff --git a/apps/opencs/model/world/pathgrid.hpp b/apps/opencs/model/world/pathgrid.hpp new file mode 100644 index 0000000000..4e4525232a --- /dev/null +++ b/apps/opencs/model/world/pathgrid.hpp @@ -0,0 +1,24 @@ +#ifndef CSM_WOLRD_PATHGRID_H +#define CSM_WOLRD_PATHGRID_H + +#include +#include + +#include + +namespace CSMWorld +{ + /// \brief Wrapper for Pathgrid record + /// + /// \attention The mData.mX and mData.mY fields of the ESM::Pathgrid struct are not used. + /// Exterior cell coordinates are encoded in the pathgrid ID. + struct Pathgrid : public ESM::Pathgrid + { + std::string mId; + + void load (ESM::ESMReader &esm); + + }; +} + +#endif \ No newline at end of file diff --git a/apps/opencs/model/world/universalid.cpp b/apps/opencs/model/world/universalid.cpp index 9f85cca142..f2ed87d61a 100644 --- a/apps/opencs/model/world/universalid.cpp +++ b/apps/opencs/model/world/universalid.cpp @@ -54,6 +54,7 @@ namespace { CSMWorld::UniversalId::Class_Transient, CSMWorld::UniversalId::Type_RunLog, "Run Log", 0 }, { CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_SoundGens, "Sound Generators", 0 }, { CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_MagicEffects, "Magic Effects", 0 }, + { CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Pathgrids, "Pathgrids", 0 }, { CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0, 0 } // end marker }; @@ -116,6 +117,7 @@ namespace { CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_DebugProfile, "Debug Profile", 0 }, { CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_SoundGen, "Sound Generator", 0 }, { CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_MagicEffect, "Magic Effect", 0 }, + { CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Pathgrid, "Pathgrid", 0 }, { CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0, 0 } // end marker }; diff --git a/apps/opencs/model/world/universalid.hpp b/apps/opencs/model/world/universalid.hpp index b244d9e169..ce2d021d09 100644 --- a/apps/opencs/model/world/universalid.hpp +++ b/apps/opencs/model/world/universalid.hpp @@ -126,6 +126,8 @@ namespace CSMWorld Type_SoundGen, Type_MagicEffects, Type_MagicEffect, + Type_Pathgrids, + Type_Pathgrid, Type_RunLog }; diff --git a/components/esm/loadpgrd.cpp b/components/esm/loadpgrd.cpp index 974e928d90..7fdc9a43ca 100644 --- a/components/esm/loadpgrd.cpp +++ b/components/esm/loadpgrd.cpp @@ -115,4 +115,14 @@ void Pathgrid::save(ESMWriter &esm) const } } + void Pathgrid::blank() + { + mCell.clear(); + mData.mX = 0; + mData.mY = 0; + mData.mS1 = 0; + mData.mS2 = 0; + mPoints.clear(); + mEdges.clear(); + } } diff --git a/components/esm/loadpgrd.hpp b/components/esm/loadpgrd.hpp index 60a7369917..256b86cdad 100644 --- a/components/esm/loadpgrd.hpp +++ b/components/esm/loadpgrd.hpp @@ -53,6 +53,8 @@ struct Pathgrid void load(ESMReader &esm); void save(ESMWriter &esm) const; + + void blank(); }; } #endif