forked from teamnwah/openmw-tes3coop
merge from saving
Merge branch 'saving' of https://github.com/zinnschlag/openmw into esxSelector Conflicts: apps/launcher/datafilespage.cpp apps/opencs/editor.cpp apps/opencs/view/doc/filedialog.cpp apps/opencs/view/doc/filedialog.hppactorid
commit
9ce4a04a2d
@ -0,0 +1,74 @@
|
||||
|
||||
#include "saving.hpp"
|
||||
|
||||
#include "../world/data.hpp"
|
||||
#include "../world/idcollection.hpp"
|
||||
|
||||
#include "state.hpp"
|
||||
#include "savingstages.hpp"
|
||||
#include "document.hpp"
|
||||
|
||||
CSMDoc::Saving::Saving (Document& document, const boost::filesystem::path& projectPath)
|
||||
: Operation (State_Saving, true, true), mDocument (document), mState (*this, projectPath)
|
||||
{
|
||||
// save project file
|
||||
appendStage (new OpenSaveStage (mDocument, mState, true));
|
||||
|
||||
appendStage (new WriteHeaderStage (mDocument, mState, true));
|
||||
|
||||
appendStage (new WriteFilterStage (mDocument, mState, CSMFilter::Filter::Scope_Project));
|
||||
|
||||
appendStage (new CloseSaveStage (mState));
|
||||
|
||||
// save content file
|
||||
appendStage (new OpenSaveStage (mDocument, mState, false));
|
||||
|
||||
appendStage (new WriteHeaderStage (mDocument, mState, false));
|
||||
|
||||
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Global> >
|
||||
(mDocument.getData().getGlobals(), mState));
|
||||
|
||||
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));
|
||||
|
||||
/// \todo deal with info records for topcis and journals
|
||||
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Dialogue> >
|
||||
(mDocument.getData().getTopics(), mState));
|
||||
|
||||
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Dialogue> >
|
||||
(mDocument.getData().getJournals(), mState));
|
||||
|
||||
appendStage (new WriteRefIdCollectionStage (mDocument, mState));
|
||||
|
||||
|
||||
appendStage (new CloseSaveStage (mState));
|
||||
|
||||
appendStage (new FinalSavingStage (mDocument, mState));
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
#ifndef CSM_DOC_SAVING_H
|
||||
#define CSM_DOC_SAVING_H
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include "operation.hpp"
|
||||
#include "savingstate.hpp"
|
||||
|
||||
namespace CSMDoc
|
||||
{
|
||||
class Document;
|
||||
|
||||
class Saving : public Operation
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Document& mDocument;
|
||||
SavingState mState;
|
||||
|
||||
public:
|
||||
|
||||
Saving (Document& document, const boost::filesystem::path& projectPath);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,161 @@
|
||||
|
||||
#include "savingstages.hpp"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <QUndoStack>
|
||||
|
||||
#include "document.hpp"
|
||||
#include "savingstate.hpp"
|
||||
|
||||
CSMDoc::OpenSaveStage::OpenSaveStage (Document& document, SavingState& state, bool projectFile)
|
||||
: mDocument (document), mState (state), mProjectFile (projectFile)
|
||||
{}
|
||||
|
||||
int CSMDoc::OpenSaveStage::setup()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CSMDoc::OpenSaveStage::perform (int stage, std::vector<std::string>& messages)
|
||||
{
|
||||
mState.start (mDocument, mProjectFile);
|
||||
|
||||
mState.getStream().open ((mProjectFile ? mState.getPath() : mState.getTmpPath()).string().c_str());
|
||||
|
||||
if (!mState.getStream().is_open())
|
||||
throw std::runtime_error ("failed to open stream for saving");
|
||||
}
|
||||
|
||||
|
||||
CSMDoc::WriteHeaderStage::WriteHeaderStage (Document& document, SavingState& state, bool simple)
|
||||
: mDocument (document), mState (state), mSimple (simple)
|
||||
{}
|
||||
|
||||
int CSMDoc::WriteHeaderStage::setup()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CSMDoc::WriteHeaderStage::perform (int stage, std::vector<std::string>& messages)
|
||||
{
|
||||
mState.getWriter().setVersion();
|
||||
|
||||
mState.getWriter().clearMaster();
|
||||
|
||||
mState.getWriter().setFormat (0);
|
||||
|
||||
if (mSimple)
|
||||
{
|
||||
mState.getWriter().setAuthor ("");
|
||||
mState.getWriter().setDescription ("");
|
||||
mState.getWriter().setRecordCount (0);
|
||||
}
|
||||
else
|
||||
{
|
||||
mState.getWriter().setAuthor (mDocument.getData().getAuthor());
|
||||
mState.getWriter().setDescription (mDocument.getData().getDescription());
|
||||
mState.getWriter().setRecordCount (
|
||||
mDocument.getData().count (CSMWorld::RecordBase::State_Modified) +
|
||||
mDocument.getData().count (CSMWorld::RecordBase::State_ModifiedOnly) +
|
||||
mDocument.getData().count (CSMWorld::RecordBase::State_Deleted));
|
||||
|
||||
/// \todo refine dependency list (at least remove redundant dependencies)
|
||||
std::vector<boost::filesystem::path> dependencies = mDocument.getContentFiles();
|
||||
std::vector<boost::filesystem::path>::const_iterator end (--dependencies.end());
|
||||
|
||||
for (std::vector<boost::filesystem::path>::const_iterator iter (dependencies.begin());
|
||||
iter!=end; ++iter)
|
||||
{
|
||||
std::string name = iter->filename().string();
|
||||
uint64_t size = boost::filesystem::file_size (*iter);
|
||||
|
||||
mState.getWriter().addMaster (name, size);
|
||||
}
|
||||
}
|
||||
|
||||
mState.getWriter().save (mState.getStream());
|
||||
}
|
||||
|
||||
|
||||
CSMDoc::WriteRefIdCollectionStage::WriteRefIdCollectionStage (Document& document, SavingState& state)
|
||||
: mDocument (document), mState (state)
|
||||
{}
|
||||
|
||||
int CSMDoc::WriteRefIdCollectionStage::setup()
|
||||
{
|
||||
return mDocument.getData().getReferenceables().getSize();
|
||||
}
|
||||
|
||||
void CSMDoc::WriteRefIdCollectionStage::perform (int stage, std::vector<std::string>& messages)
|
||||
{
|
||||
mDocument.getData().getReferenceables().save (stage, mState.getWriter());
|
||||
}
|
||||
|
||||
|
||||
CSMDoc::WriteFilterStage::WriteFilterStage (Document& document, SavingState& state,
|
||||
CSMFilter::Filter::Scope scope)
|
||||
: WriteCollectionStage<CSMWorld::IdCollection<CSMFilter::Filter> > (document.getData().getFilters(),
|
||||
state),
|
||||
mDocument (document), mScope (scope)
|
||||
{}
|
||||
|
||||
void CSMDoc::WriteFilterStage::perform (int stage, std::vector<std::string>& messages)
|
||||
{
|
||||
const CSMWorld::Record<CSMFilter::Filter>& record =
|
||||
mDocument.getData().getFilters().getRecord (stage);
|
||||
|
||||
if (record.get().mScope==mScope)
|
||||
WriteCollectionStage<CSMWorld::IdCollection<CSMFilter::Filter> >::perform (stage, messages);
|
||||
}
|
||||
|
||||
|
||||
CSMDoc::CloseSaveStage::CloseSaveStage (SavingState& state)
|
||||
: mState (state)
|
||||
{}
|
||||
|
||||
int CSMDoc::CloseSaveStage::setup()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CSMDoc::CloseSaveStage::perform (int stage, std::vector<std::string>& messages)
|
||||
{
|
||||
mState.getStream().close();
|
||||
|
||||
if (!mState.getStream())
|
||||
throw std::runtime_error ("saving failed");
|
||||
}
|
||||
|
||||
|
||||
CSMDoc::FinalSavingStage::FinalSavingStage (Document& document, SavingState& state)
|
||||
: mDocument (document), mState (state)
|
||||
{}
|
||||
|
||||
int CSMDoc::FinalSavingStage::setup()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CSMDoc::FinalSavingStage::perform (int stage, std::vector<std::string>& messages)
|
||||
{
|
||||
if (mState.hasError())
|
||||
{
|
||||
mState.getWriter().close();
|
||||
mState.getStream().close();
|
||||
|
||||
if (boost::filesystem::exists (mState.getTmpPath()))
|
||||
boost::filesystem::remove (mState.getTmpPath());
|
||||
}
|
||||
else if (!mState.isProjectFile())
|
||||
{
|
||||
if (boost::filesystem::exists (mState.getPath()))
|
||||
boost::filesystem::remove (mState.getPath());
|
||||
|
||||
boost::filesystem::rename (mState.getTmpPath(), mState.getPath());
|
||||
|
||||
mDocument.getUndoStack().setClean();
|
||||
}
|
||||
}
|
@ -0,0 +1,172 @@
|
||||
#ifndef CSM_DOC_SAVINGSTAGES_H
|
||||
#define CSM_DOC_SAVINGSTAGES_H
|
||||
|
||||
#include "stage.hpp"
|
||||
|
||||
#include "savingstate.hpp"
|
||||
|
||||
#include "../world/record.hpp"
|
||||
#include "../world/idcollection.hpp"
|
||||
|
||||
#include "../filter/filter.hpp"
|
||||
|
||||
namespace CSMDoc
|
||||
{
|
||||
class Document;
|
||||
class SavingState;
|
||||
|
||||
class OpenSaveStage : public Stage
|
||||
{
|
||||
Document& mDocument;
|
||||
SavingState& mState;
|
||||
bool mProjectFile;
|
||||
|
||||
public:
|
||||
|
||||
OpenSaveStage (Document& document, SavingState& state, bool projectFile);
|
||||
///< \param projectFile Saving the project file instead of the content file.
|
||||
|
||||
virtual int setup();
|
||||
///< \return number of steps
|
||||
|
||||
virtual void perform (int stage, std::vector<std::string>& messages);
|
||||
///< Messages resulting from this stage will be appended to \a messages.
|
||||
};
|
||||
|
||||
class WriteHeaderStage : public Stage
|
||||
{
|
||||
Document& mDocument;
|
||||
SavingState& mState;
|
||||
bool mSimple;
|
||||
|
||||
public:
|
||||
|
||||
WriteHeaderStage (Document& document, SavingState& state, bool simple);
|
||||
///< \param simple Simplified header (used for project files).
|
||||
|
||||
virtual int setup();
|
||||
///< \return number of steps
|
||||
|
||||
virtual void perform (int stage, std::vector<std::string>& messages);
|
||||
///< Messages resulting from this stage will be appended to \a messages.
|
||||
};
|
||||
|
||||
|
||||
template<class CollectionT>
|
||||
class WriteCollectionStage : public Stage
|
||||
{
|
||||
const CollectionT& mCollection;
|
||||
SavingState& mState;
|
||||
|
||||
public:
|
||||
|
||||
WriteCollectionStage (const CollectionT& collection, SavingState& state);
|
||||
|
||||
virtual int setup();
|
||||
///< \return number of steps
|
||||
|
||||
virtual void perform (int stage, std::vector<std::string>& messages);
|
||||
///< Messages resulting from this stage will be appended to \a messages.
|
||||
};
|
||||
|
||||
template<class CollectionT>
|
||||
WriteCollectionStage<CollectionT>::WriteCollectionStage (const CollectionT& collection,
|
||||
SavingState& state)
|
||||
: mCollection (collection), mState (state)
|
||||
{}
|
||||
|
||||
template<class CollectionT>
|
||||
int WriteCollectionStage<CollectionT>::setup()
|
||||
{
|
||||
return mCollection.getSize();
|
||||
}
|
||||
|
||||
template<class CollectionT>
|
||||
void WriteCollectionStage<CollectionT>::perform (int stage, std::vector<std::string>& messages)
|
||||
{
|
||||
CSMWorld::RecordBase::State state = mCollection.getRecord (stage).mState;
|
||||
|
||||
if (state==CSMWorld::RecordBase::State_Modified ||
|
||||
state==CSMWorld::RecordBase::State_ModifiedOnly)
|
||||
{
|
||||
std::string type;
|
||||
for (int i=0; i<4; ++i)
|
||||
/// \todo make endianess agnostic (change ESMWriter interface?)
|
||||
type += reinterpret_cast<const char *> (&mCollection.getRecord (stage).mModified.sRecordId)[i];
|
||||
|
||||
mState.getWriter().startRecord (type);
|
||||
mState.getWriter().writeHNCString ("NAME", mCollection.getId (stage));
|
||||
mCollection.getRecord (stage).mModified.save (mState.getWriter());
|
||||
mState.getWriter().endRecord (type);
|
||||
}
|
||||
else if (state==CSMWorld::RecordBase::State_Deleted)
|
||||
{
|
||||
/// \todo write record with delete flag
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class WriteRefIdCollectionStage : public Stage
|
||||
{
|
||||
Document& mDocument;
|
||||
SavingState& mState;
|
||||
|
||||
public:
|
||||
|
||||
WriteRefIdCollectionStage (Document& document, SavingState& state);
|
||||
|
||||
virtual int setup();
|
||||
///< \return number of steps
|
||||
|
||||
virtual void perform (int stage, std::vector<std::string>& messages);
|
||||
///< Messages resulting from this stage will be appended to \a messages.
|
||||
};
|
||||
|
||||
|
||||
class WriteFilterStage : public WriteCollectionStage<CSMWorld::IdCollection<CSMFilter::Filter> >
|
||||
{
|
||||
Document& mDocument;
|
||||
CSMFilter::Filter::Scope mScope;
|
||||
|
||||
public:
|
||||
|
||||
WriteFilterStage (Document& document, SavingState& state, CSMFilter::Filter::Scope scope);
|
||||
|
||||
virtual void perform (int stage, std::vector<std::string>& messages);
|
||||
///< Messages resulting from this stage will be appended to \a messages.
|
||||
};
|
||||
|
||||
|
||||
class CloseSaveStage : public Stage
|
||||
{
|
||||
SavingState& mState;
|
||||
|
||||
public:
|
||||
|
||||
CloseSaveStage (SavingState& state);
|
||||
|
||||
virtual int setup();
|
||||
///< \return number of steps
|
||||
|
||||
virtual void perform (int stage, std::vector<std::string>& messages);
|
||||
///< Messages resulting from this stage will be appended to \a messages.
|
||||
};
|
||||
|
||||
class FinalSavingStage : public Stage
|
||||
{
|
||||
Document& mDocument;
|
||||
SavingState& mState;
|
||||
|
||||
public:
|
||||
|
||||
FinalSavingStage (Document& document, SavingState& state);
|
||||
|
||||
virtual int setup();
|
||||
///< \return number of steps
|
||||
|
||||
virtual void perform (int stage, std::vector<std::string>& messages);
|
||||
///< Messages resulting from this stage will be appended to \a messages.
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,65 @@
|
||||
|
||||
#include "savingstate.hpp"
|
||||
|
||||
#include "operation.hpp"
|
||||
#include "document.hpp"
|
||||
|
||||
CSMDoc::SavingState::SavingState (Operation& operation, const boost::filesystem::path& projectPath)
|
||||
: mOperation (operation),
|
||||
/// \todo set encoding properly, once config implementation has been fixed.
|
||||
mEncoder (ToUTF8::calculateEncoding ("win1252")),
|
||||
mProjectPath (projectPath), mProjectFile (false)
|
||||
{
|
||||
mWriter.setEncoder (&mEncoder);
|
||||
}
|
||||
|
||||
bool CSMDoc::SavingState::hasError() const
|
||||
{
|
||||
return mOperation.hasError();
|
||||
}
|
||||
|
||||
void CSMDoc::SavingState::start (Document& document, bool project)
|
||||
{
|
||||
mProjectFile = project;
|
||||
|
||||
if (mStream.is_open())
|
||||
mStream.close();
|
||||
|
||||
mStream.clear();
|
||||
|
||||
if (project)
|
||||
mPath = mProjectPath;
|
||||
else
|
||||
mPath = document.getSavePath();
|
||||
|
||||
boost::filesystem::path file (mPath.filename().string() + ".tmp");
|
||||
|
||||
mTmpPath = mPath.parent_path();
|
||||
|
||||
mTmpPath /= file;
|
||||
}
|
||||
|
||||
const boost::filesystem::path& CSMDoc::SavingState::getPath() const
|
||||
{
|
||||
return mPath;
|
||||
}
|
||||
|
||||
const boost::filesystem::path& CSMDoc::SavingState::getTmpPath() const
|
||||
{
|
||||
return mTmpPath;
|
||||
}
|
||||
|
||||
std::ofstream& CSMDoc::SavingState::getStream()
|
||||
{
|
||||
return mStream;
|
||||
}
|
||||
|
||||
ESM::ESMWriter& CSMDoc::SavingState::getWriter()
|
||||
{
|
||||
return mWriter;
|
||||
}
|
||||
|
||||
bool CSMDoc::SavingState::isProjectFile() const
|
||||
{
|
||||
return mProjectFile;
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
#ifndef CSM_DOC_SAVINGSTATE_H
|
||||
#define CSM_DOC_SAVINGSTATE_H
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <components/esm/esmwriter.hpp>
|
||||
|
||||
namespace CSMDoc
|
||||
{
|
||||
class Operation;
|
||||
class Document;
|
||||
|
||||
class SavingState
|
||||
{
|
||||
Operation& mOperation;
|
||||
boost::filesystem::path mPath;
|
||||
boost::filesystem::path mTmpPath;
|
||||
ToUTF8::Utf8Encoder mEncoder;
|
||||
std::ofstream mStream;
|
||||
ESM::ESMWriter mWriter;
|
||||
boost::filesystem::path mProjectPath;
|
||||
bool mProjectFile;
|
||||
|
||||
public:
|
||||
|
||||
SavingState (Operation& operation, const boost::filesystem::path& projectPath);
|
||||
|
||||
bool hasError() const;
|
||||
|
||||
void start (Document& document, bool project);
|
||||
///< \param project Save project file instead of content file.
|
||||
|
||||
const boost::filesystem::path& getPath() const;
|
||||
|
||||
const boost::filesystem::path& getTmpPath() const;
|
||||
|
||||
std::ofstream& getStream();
|
||||
|
||||
ESM::ESMWriter& getWriter();
|
||||
|
||||
bool isProjectFile() const;
|
||||
///< Currently saving project file? (instead of content file)
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,4 @@
|
||||
|
||||
#include "stage.hpp"
|
||||
|
||||
CSMDoc::Stage::~Stage() {}
|
@ -1,4 +0,0 @@
|
||||
|
||||
#include "stage.hpp"
|
||||
|
||||
CSMTools::Stage::~Stage() {}
|
@ -1,7 +0,0 @@
|
||||
|
||||
#include "verifier.hpp"
|
||||
|
||||
#include "../doc/state.hpp"
|
||||
|
||||
CSMTools::Verifier::Verifier() : Operation (CSMDoc::State_Verifying)
|
||||
{}
|
@ -1,17 +0,0 @@
|
||||
#ifndef CSM_TOOLS_VERIFIER_H
|
||||
#define CSM_TOOLS_VERIFIER_H
|
||||
|
||||
#include "operation.hpp"
|
||||
|
||||
namespace CSMTools
|
||||
{
|
||||
class Verifier : public Operation
|
||||
{
|
||||
public:
|
||||
|
||||
Verifier();
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -1,6 +1,31 @@
|
||||
|
||||
#include "collectionbase.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "columnbase.hpp"
|
||||
|
||||
CSMWorld::CollectionBase::CollectionBase() {}
|
||||
|
||||
CSMWorld::CollectionBase::~CollectionBase() {}
|
||||
|
||||
int CSMWorld::CollectionBase::searchColumnIndex (Columns::ColumnId id) const
|
||||
{
|
||||
int columns = getColumns();
|
||||
|
||||
for (int i=0; i<columns; ++i)
|
||||
if (getColumn (i).mColumnId==id)
|
||||
return i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int CSMWorld::CollectionBase::findColumnIndex (Columns::ColumnId id) const
|
||||
{
|
||||
int index = searchColumnIndex (id);
|
||||
|
||||
if (index==-1)
|
||||
throw std::logic_error ("invalid column index");
|
||||
|
||||
return index;
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
|
||||
#include "dialoguecreator.hpp"
|
||||
|
||||
#include <components/esm/loaddial.hpp>
|
||||
|
||||
#include "../../model/world/data.hpp"
|
||||
#include "../../model/world/commands.hpp"
|
||||
#include "../../model/world/columns.hpp"
|
||||
#include "../../model/world/idtable.hpp"
|
||||
|
||||
void CSVWorld::DialogueCreator::configureCreateCommand (CSMWorld::CreateCommand& command) const
|
||||
{
|
||||
int index =
|
||||
dynamic_cast<CSMWorld::IdTable&> (*getData().getTableModel (getCollectionId())).
|
||||
findColumnIndex (CSMWorld::Columns::ColumnId_DialogueType);
|
||||
|
||||
command.addValue (index, mType);
|
||||
}
|
||||
|
||||
CSVWorld::DialogueCreator::DialogueCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
||||
const CSMWorld::UniversalId& id, int type)
|
||||
: GenericCreator (data, undoStack, id), mType (type)
|
||||
{}
|
||||
|
||||
CSVWorld::Creator *CSVWorld::TopicCreatorFactory::makeCreator (CSMWorld::Data& data,
|
||||
QUndoStack& undoStack, const CSMWorld::UniversalId& id) const
|
||||
{
|
||||
return new DialogueCreator (data, undoStack, id, ESM::Dialogue::Topic);
|
||||
}
|
||||
|
||||
CSVWorld::Creator *CSVWorld::JournalCreatorFactory::makeCreator (CSMWorld::Data& data,
|
||||
QUndoStack& undoStack, const CSMWorld::UniversalId& id) const
|
||||
{
|
||||
return new DialogueCreator (data, undoStack, id, ESM::Dialogue::Journal);
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
#ifndef CSV_WORLD_DIALOGUECREATOR_H
|
||||
#define CSV_WORLD_DIALOGUECREATOR_H
|
||||
|
||||
#include "genericcreator.hpp"
|
||||
|
||||
namespace CSVWorld
|
||||
{
|
||||
class DialogueCreator : public GenericCreator
|
||||
{
|
||||
int mType;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void configureCreateCommand (CSMWorld::CreateCommand& command) const;
|
||||
|
||||
public:
|
||||
|
||||
DialogueCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
||||
const CSMWorld::UniversalId& id, int type);
|
||||
};
|
||||
|
||||
class TopicCreatorFactory : public CreatorFactoryBase
|
||||
{
|
||||
public:
|
||||
|
||||
virtual Creator *makeCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
||||
const CSMWorld::UniversalId& id) const;
|
||||
///< The ownership of the returned Creator is transferred to the caller.
|
||||
};
|
||||
|
||||
class JournalCreatorFactory : public CreatorFactoryBase
|
||||
{
|
||||
public:
|
||||
|
||||
virtual Creator *makeCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
||||
const CSMWorld::UniversalId& id) const;
|
||||
///< The ownership of the returned Creator is transferred to the caller.
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,35 @@
|
||||
#ifndef CONTENTLOADER_HPP
|
||||
#define CONTENTLOADER_HPP
|
||||
|
||||
#include <iosfwd>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include "components/loadinglistener/loadinglistener.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
|
||||
struct ContentLoader
|
||||
{
|
||||
ContentLoader(Loading::Listener& listener)
|
||||
: mListener(listener)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~ContentLoader()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void load(const boost::filesystem::path& filepath, int& index)
|
||||
{
|
||||
std::cout << "Loading content file " << filepath.string() << std::endl;
|
||||
mListener.setLabel(filepath.string());
|
||||
}
|
||||
|
||||
protected:
|
||||
Loading::Listener& mListener;
|
||||
};
|
||||
|
||||
} /* namespace MWWorld */
|
||||
|
||||
#endif /* CONTENTLOADER_HPP */
|
@ -0,0 +1,31 @@
|
||||
#include "esmloader.hpp"
|
||||
#include "esmstore.hpp"
|
||||
|
||||
#include "components/to_utf8/to_utf8.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
|
||||
EsmLoader::EsmLoader(MWWorld::ESMStore& store, std::vector<ESM::ESMReader>& readers,
|
||||
ToUTF8::Utf8Encoder* encoder, Loading::Listener& listener)
|
||||
: ContentLoader(listener)
|
||||
, mStore(store)
|
||||
, mEsm(readers)
|
||||
, mEncoder(encoder)
|
||||
{
|
||||
}
|
||||
|
||||
void EsmLoader::load(const boost::filesystem::path& filepath, int& index)
|
||||
{
|
||||
ContentLoader::load(filepath.filename(), index);
|
||||
|
||||
ESM::ESMReader lEsm;
|
||||
lEsm.setEncoder(mEncoder);
|
||||
lEsm.setIndex(index);
|
||||
lEsm.setGlobalReaderList(&mEsm);
|
||||
lEsm.open(filepath.string());
|
||||
mEsm[index] = lEsm;
|
||||
mStore.load(mEsm[index], &mListener);
|
||||
}
|
||||
|
||||
} /* namespace MWWorld */
|
@ -0,0 +1,34 @@
|
||||
#ifndef ESMLOADER_HPP
|
||||
#define ESMLOADER_HPP
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "contentloader.hpp"
|
||||
#include "components/esm/esmreader.hpp"
|
||||
|
||||
namespace ToUTF8
|
||||
{
|
||||
class Utf8Encoder;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
|
||||
class ESMStore;
|
||||
|
||||
struct EsmLoader : public ContentLoader
|
||||
{
|
||||
EsmLoader(MWWorld::ESMStore& store, std::vector<ESM::ESMReader>& readers,
|
||||
ToUTF8::Utf8Encoder* encoder, Loading::Listener& listener);
|
||||
|
||||
void load(const boost::filesystem::path& filepath, int& index);
|
||||
|
||||
private:
|
||||
std::vector<ESM::ESMReader>& mEsm;
|
||||
MWWorld::ESMStore& mStore;
|
||||
ToUTF8::Utf8Encoder* mEncoder;
|
||||
};
|
||||
|
||||
} /* namespace MWWorld */
|
||||
|
||||
#endif // ESMLOADER_HPP
|
@ -0,0 +1,17 @@
|
||||
#include "omwloader.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
|
||||
OmwLoader::OmwLoader(Loading::Listener& listener)
|
||||
: ContentLoader(listener)
|
||||
{
|
||||
}
|
||||
|
||||
void OmwLoader::load(const boost::filesystem::path& filepath, int& index)
|
||||
{
|
||||
ContentLoader::load(filepath.filename(), index);
|
||||
}
|
||||
|
||||
} /* namespace MWWorld */
|
||||
|
@ -0,0 +1,21 @@
|
||||
#ifndef OMWLOADER_HPP
|
||||
#define OMWLOADER_HPP
|
||||
|
||||
#include "contentloader.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief Placeholder for real OpenMW content loader
|
||||
*/
|
||||
struct OmwLoader : public ContentLoader
|
||||
{
|
||||
OmwLoader(Loading::Listener& listener);
|
||||
|
||||
void load(const boost::filesystem::path& filepath, int& index);
|
||||
};
|
||||
|
||||
} /* namespace MWWorld */
|
||||
|
||||
#endif /* OMWLOADER_HPP */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue