2013-09-15 12:48:57 +02:00
|
|
|
#include "saving.hpp"
|
|
|
|
|
2013-09-16 12:51:57 +02:00
|
|
|
#include "../world/data.hpp"
|
|
|
|
#include "../world/idcollection.hpp"
|
2013-09-15 12:48:57 +02:00
|
|
|
|
2013-09-16 12:51:57 +02:00
|
|
|
#include "state.hpp"
|
2013-09-15 12:48:57 +02:00
|
|
|
#include "savingstages.hpp"
|
2013-09-16 12:51:57 +02:00
|
|
|
#include "document.hpp"
|
2013-09-15 12:48:57 +02:00
|
|
|
|
2014-05-12 10:32:57 +02:00
|
|
|
CSMDoc::Saving::Saving (Document& document, const boost::filesystem::path& projectPath,
|
|
|
|
ToUTF8::FromType encoding)
|
|
|
|
: Operation (State_Saving, true, true), mDocument (document), mState (*this, projectPath, encoding)
|
2013-09-15 12:48:57 +02:00
|
|
|
{
|
2013-09-27 11:36:06 +02:00
|
|
|
// save project file
|
|
|
|
appendStage (new OpenSaveStage (mDocument, mState, true));
|
2013-09-15 12:48:57 +02:00
|
|
|
|
2013-09-27 11:36:06 +02:00
|
|
|
appendStage (new WriteHeaderStage (mDocument, mState, true));
|
|
|
|
|
2014-08-10 21:03:45 +02:00
|
|
|
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Filter> > (
|
2014-08-06 10:03:04 +02:00
|
|
|
mDocument.getData().getFilters(), mState, CSMWorld::Scope_Project));
|
2013-09-27 13:56:40 +02:00
|
|
|
|
2014-08-15 12:08:29 +02:00
|
|
|
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::DebugProfile> > (
|
|
|
|
mDocument.getData().getDebugProfiles(), mState, CSMWorld::Scope_Project));
|
|
|
|
|
2014-09-14 11:41:28 +02:00
|
|
|
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Script> > (
|
|
|
|
mDocument.getData().getScripts(), mState, CSMWorld::Scope_Project));
|
|
|
|
|
2013-09-27 11:36:06 +02:00
|
|
|
appendStage (new CloseSaveStage (mState));
|
|
|
|
|
|
|
|
// save content file
|
|
|
|
appendStage (new OpenSaveStage (mDocument, mState, false));
|
|
|
|
|
|
|
|
appendStage (new WriteHeaderStage (mDocument, mState, false));
|
2013-09-15 15:31:44 +02:00
|
|
|
|
2013-09-16 12:51:57 +02:00
|
|
|
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Global> >
|
2013-09-24 13:17:28 +02:00
|
|
|
(mDocument.getData().getGlobals(), mState));
|
2013-09-15 15:31:44 +02:00
|
|
|
|
2013-09-16 14:17:04 +02:00
|
|
|
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::GameSetting> >
|
2013-09-24 13:17:28 +02:00
|
|
|
(mDocument.getData().getGmsts(), mState));
|
2013-09-16 14:17:04 +02:00
|
|
|
|
|
|
|
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Skill> >
|
2013-09-24 13:17:28 +02:00
|
|
|
(mDocument.getData().getSkills(), mState));
|
2013-09-16 14:17:04 +02:00
|
|
|
|
|
|
|
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Class> >
|
2013-09-24 13:17:28 +02:00
|
|
|
(mDocument.getData().getClasses(), mState));
|
2013-09-16 14:17:04 +02:00
|
|
|
|
|
|
|
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Faction> >
|
2013-09-24 13:17:28 +02:00
|
|
|
(mDocument.getData().getFactions(), mState));
|
2013-09-16 14:17:04 +02:00
|
|
|
|
|
|
|
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Race> >
|
2013-09-24 13:17:28 +02:00
|
|
|
(mDocument.getData().getRaces(), mState));
|
2013-09-16 14:17:04 +02:00
|
|
|
|
|
|
|
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Sound> >
|
2013-09-24 13:17:28 +02:00
|
|
|
(mDocument.getData().getSounds(), mState));
|
2013-09-16 14:17:04 +02:00
|
|
|
|
|
|
|
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Script> >
|
2013-09-24 13:17:28 +02:00
|
|
|
(mDocument.getData().getScripts(), mState));
|
2013-09-16 14:17:04 +02:00
|
|
|
|
|
|
|
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Region> >
|
2013-09-24 13:17:28 +02:00
|
|
|
(mDocument.getData().getRegions(), mState));
|
2013-09-16 14:17:04 +02:00
|
|
|
|
|
|
|
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::BirthSign> >
|
2013-09-24 13:17:28 +02:00
|
|
|
(mDocument.getData().getBirthsigns(), mState));
|
2013-09-16 14:17:04 +02:00
|
|
|
|
|
|
|
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Spell> >
|
2013-09-24 13:17:28 +02:00
|
|
|
(mDocument.getData().getSpells(), mState));
|
2013-09-16 14:17:04 +02:00
|
|
|
|
2014-06-30 20:40:34 +02:00
|
|
|
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Enchantment> >
|
|
|
|
(mDocument.getData().getEnchantments(), mState));
|
|
|
|
|
2014-07-01 12:37:22 +02:00
|
|
|
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::BodyPart> >
|
|
|
|
(mDocument.getData().getBodyParts(), mState));
|
|
|
|
|
2014-09-23 12:18:18 +02:00
|
|
|
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::SoundGenerator> >
|
|
|
|
(mDocument.getData().getSoundGens(), mState));
|
|
|
|
|
2014-09-26 13:05:51 +02:00
|
|
|
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::MagicEffect> >
|
|
|
|
(mDocument.getData().getMagicEffects(), mState));
|
|
|
|
|
2015-03-03 16:11:00 +01:00
|
|
|
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::StartScript> >
|
|
|
|
(mDocument.getData().getStartScripts(), mState));
|
|
|
|
|
2013-09-24 13:53:19 +02:00
|
|
|
appendStage (new WriteRefIdCollectionStage (mDocument, mState));
|
|
|
|
|
2014-05-27 12:39:26 +02:00
|
|
|
appendStage (new CollectionReferencesStage (mDocument, mState));
|
2013-09-15 12:48:57 +02:00
|
|
|
|
2014-05-29 18:08:40 +02:00
|
|
|
appendStage (new WriteCellCollectionStage (mDocument, mState));
|
2014-05-27 12:39:26 +02:00
|
|
|
|
2015-08-22 12:57:39 +02:00
|
|
|
// Dialogue can reference objects and cells so must be written after these records for vanilla-compatible files
|
2014-10-10 15:29:21 +02:00
|
|
|
|
2015-08-22 12:57:39 +02:00
|
|
|
appendStage (new WriteDialogueCollectionStage (mDocument, mState, false));
|
|
|
|
|
|
|
|
appendStage (new WriteDialogueCollectionStage (mDocument, mState, true));
|
|
|
|
|
|
|
|
appendStage (new WritePathgridCollectionStage (mDocument, mState));
|
2015-03-13 08:01:48 +11:00
|
|
|
|
|
|
|
appendStage (new WriteLandTextureCollectionStage (mDocument, mState));
|
|
|
|
|
2015-08-22 12:57:39 +02:00
|
|
|
// references Land Textures
|
|
|
|
appendStage (new WriteLandCollectionStage (mDocument, mState));
|
|
|
|
|
2014-05-27 12:39:26 +02:00
|
|
|
// close file and clean up
|
2013-09-15 15:00:41 +02:00
|
|
|
appendStage (new CloseSaveStage (mState));
|
|
|
|
|
2013-09-15 12:48:57 +02:00
|
|
|
appendStage (new FinalSavingStage (mDocument, mState));
|
2015-03-11 10:54:45 -04:00
|
|
|
}
|