#include "saving.hpp" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "../world/data.hpp" #include "../world/idcollection.hpp" #include "document.hpp" #include "savingstages.hpp" #include "state.hpp" CSMDoc::Saving::Saving(Document& document, const std::filesystem::path& projectPath, ToUTF8::FromType encoding) : Operation(State_Saving, true, true) , mDocument(document) , mState(*this, projectPath, encoding) { // save project file appendStage(new OpenSaveStage(mDocument, mState, true)); appendStage(new WriteHeaderStage(mDocument, mState, true)); appendStage(new WriteCollectionStage>( mDocument.getData().getFilters(), mState, CSMWorld::Scope_Project)); appendStage(new WriteCollectionStage>( mDocument.getData().getDebugProfiles(), mState, CSMWorld::Scope_Project)); appendStage(new WriteCollectionStage>( mDocument.getData().getScripts(), mState, CSMWorld::Scope_Project)); appendStage(new WriteCollectionStage>( mDocument.getData().getSelectionGroups(), mState, CSMWorld::Scope_Project)); appendStage(new CloseSaveStage(mState)); // save content file appendStage(new OpenSaveStage(mDocument, mState, false)); appendStage(new WriteHeaderStage(mDocument, mState, false)); appendStage( new WriteCollectionStage>(mDocument.getData().getGlobals(), mState)); appendStage( new WriteCollectionStage>(mDocument.getData().getGmsts(), mState)); appendStage(new WriteCollectionStage>(mDocument.getData().getSkills(), mState)); appendStage(new WriteCollectionStage>(mDocument.getData().getClasses(), mState)); appendStage( new WriteCollectionStage>(mDocument.getData().getFactions(), mState)); appendStage(new WriteCollectionStage>(mDocument.getData().getRaces(), mState)); appendStage(new WriteCollectionStage>(mDocument.getData().getSounds(), mState)); appendStage( new WriteCollectionStage>(mDocument.getData().getScripts(), mState)); appendStage( new WriteCollectionStage>(mDocument.getData().getRegions(), mState)); appendStage( new WriteCollectionStage>(mDocument.getData().getBirthsigns(), mState)); appendStage(new WriteCollectionStage>(mDocument.getData().getSpells(), mState)); appendStage(new WriteCollectionStage>( mDocument.getData().getEnchantments(), mState)); appendStage( new WriteCollectionStage>(mDocument.getData().getBodyParts(), mState)); appendStage(new WriteCollectionStage>( mDocument.getData().getMagicEffects(), mState)); appendStage(new WriteCollectionStage>( mDocument.getData().getStartScripts(), mState)); appendStage(new WriteRefIdCollectionStage(mDocument, mState)); // Can reference creatures so needs to load after them for TESCS compatibility appendStage(new WriteCollectionStage>( mDocument.getData().getSoundGens(), mState)); appendStage(new CollectionReferencesStage(mDocument, mState)); appendStage(new WriteCellCollectionStage(mDocument, mState)); // Dialogue can reference objects, cells, and journals so must be written after these records for vanilla-compatible // files appendStage(new WriteDialogueCollectionStage(mDocument, mState, true)); appendStage(new WriteDialogueCollectionStage(mDocument, mState, false)); appendStage(new WritePathgridCollectionStage(mDocument, mState)); appendStage(new WriteLandTextureCollectionStage(mDocument, mState)); // references Land Textures appendStage(new WriteLandCollectionStage(mDocument, mState)); // close file and clean up appendStage(new CloseSaveStage(mState)); appendStage(new FinalSavingStage(mDocument, mState)); }