mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 09:45:36 +00:00
load and save pathgrid records
This commit is contained in:
parent
ff530a2e19
commit
d64127106b
10 changed files with 88 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -78,6 +78,9 @@ CSMDoc::Saving::Saving (Document& document, const boost::filesystem::path& proje
|
|||
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::MagicEffect> >
|
||||
(mDocument.getData().getMagicEffects(), mState));
|
||||
|
||||
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<CSMWorld::Pathgrid> >
|
||||
(mDocument.getData().getPathgrids(), mState));
|
||||
|
||||
appendStage (new WriteDialogueCollectionStage (mDocument, mState, false));
|
||||
|
||||
appendStage (new WriteDialogueCollectionStage (mDocument, mState, true));
|
||||
|
|
|
@ -250,6 +250,10 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
|
|||
Columns::ColumnId_NegativeLight, ESM::MagicEffect::NegativeLight));
|
||||
mMagicEffects.addColumn (new DescriptionColumn<ESM::MagicEffect>);
|
||||
|
||||
mPathgrids.addColumn (new StringIdColumn<Pathgrid>);
|
||||
mPathgrids.addColumn (new RecordStateColumn<Pathgrid>);
|
||||
mPathgrids.addColumn (new FixedRecordTypeColumn<Pathgrid> (UniversalId::Type_Pathgrid));
|
||||
|
||||
mRefs.addColumn (new StringIdColumn<CellRef> (true));
|
||||
mRefs.addColumn (new RecordStateColumn<CellRef>);
|
||||
mRefs.addColumn (new FixedRecordTypeColumn<CellRef> (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<ESM::MagicEffect>& CSMWorld::Data::getMagicEffects()
|
|||
return mMagicEffects;
|
||||
}
|
||||
|
||||
const CSMWorld::IdCollection<CSMWorld::Pathgrid>& CSMWorld::Data::getPathgrids() const
|
||||
{
|
||||
return mPathgrids;
|
||||
}
|
||||
|
||||
CSMWorld::IdCollection<CSMWorld::Pathgrid>& 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)
|
||||
|
|
|
@ -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<ESM::Enchantment> mEnchantments;
|
||||
IdCollection<ESM::BodyPart> mBodyParts;
|
||||
IdCollection<ESM::MagicEffect> mMagicEffects;
|
||||
IdCollection<Pathgrid> mPathgrids;
|
||||
IdCollection<ESM::DebugProfile> mDebugProfiles;
|
||||
IdCollection<ESM::SoundGenerator> mSoundGens;
|
||||
InfoCollection mTopicInfos;
|
||||
|
@ -207,6 +209,10 @@ namespace CSMWorld
|
|||
|
||||
IdCollection<ESM::MagicEffect>& getMagicEffects();
|
||||
|
||||
const IdCollection<Pathgrid>& getPathgrids() const;
|
||||
|
||||
IdCollection<Pathgrid>& getPathgrids();
|
||||
|
||||
/// Throws an exception, if \a id does not match a resources list.
|
||||
const Resources& getResources (const UniversalId& id) const;
|
||||
|
||||
|
|
20
apps/opencs/model/world/pathgrid.cpp
Normal file
20
apps/opencs/model/world/pathgrid.cpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
|
||||
#include "pathgrid.hpp"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
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;
|
||||
}
|
24
apps/opencs/model/world/pathgrid.hpp
Normal file
24
apps/opencs/model/world/pathgrid.hpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#ifndef CSM_WOLRD_PATHGRID_H
|
||||
#define CSM_WOLRD_PATHGRID_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include <components/esm/loadpgrd.hpp>
|
||||
|
||||
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
|
|
@ -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
|
||||
};
|
||||
|
|
|
@ -126,6 +126,8 @@ namespace CSMWorld
|
|||
Type_SoundGen,
|
||||
Type_MagicEffects,
|
||||
Type_MagicEffect,
|
||||
Type_Pathgrids,
|
||||
Type_Pathgrid,
|
||||
Type_RunLog
|
||||
};
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,8 @@ struct Pathgrid
|
|||
|
||||
void load(ESMReader &esm);
|
||||
void save(ESMWriter &esm) const;
|
||||
|
||||
void blank();
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue