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