mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-24 18:09:44 +00:00
parent
e5038cbece
commit
a2d4957d2a
6 changed files with 124 additions and 2 deletions
|
@ -37,10 +37,13 @@ CSMTools::MergeOperation::MergeOperation (CSMDoc::Document& document, ToUTF8::Fr
|
||||||
appendStage (new MergeIdCollectionStage<CSMWorld::Info, CSMWorld::InfoCollection> (mState, &CSMWorld::Data::getJournalInfos));
|
appendStage (new MergeIdCollectionStage<CSMWorld::Info, CSMWorld::InfoCollection> (mState, &CSMWorld::Data::getJournalInfos));
|
||||||
appendStage (new MergeRefIdsStage (mState));
|
appendStage (new MergeRefIdsStage (mState));
|
||||||
appendStage (new MergeReferencesStage (mState));
|
appendStage (new MergeReferencesStage (mState));
|
||||||
|
appendStage (new MergeReferencesStage (mState));
|
||||||
|
appendStage (new ListLandTexturesMergeStage (mState));
|
||||||
|
appendStage (new MergeLandTexturesStage (mState));
|
||||||
|
|
||||||
appendStage (new FinishMergedDocumentStage (mState, encoding));
|
appendStage (new FinishMergedDocumentStage (mState, encoding));
|
||||||
|
|
||||||
/// \todo Land, LandTextures
|
/// \todo Land
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMTools::MergeOperation::setTarget (std::auto_ptr<CSMDoc::Document> document)
|
void CSMTools::MergeOperation::setTarget (std::auto_ptr<CSMDoc::Document> document)
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
|
||||||
#include "mergestages.hpp"
|
#include "mergestages.hpp"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
#include <components/misc/stringops.hpp>
|
#include <components/misc/stringops.hpp>
|
||||||
|
|
||||||
#include "mergestate.hpp"
|
#include "mergestate.hpp"
|
||||||
|
@ -104,3 +106,80 @@ void CSMTools::MergeReferencesStage::perform (int stage, CSMDoc::Messages& messa
|
||||||
mState.mTarget->getData().getReferences().appendRecord (newRecord);
|
mState.mTarget->getData().getReferences().appendRecord (newRecord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CSMTools::ListLandTexturesMergeStage::ListLandTexturesMergeStage (MergeState& state)
|
||||||
|
: mState (state)
|
||||||
|
{}
|
||||||
|
|
||||||
|
int CSMTools::ListLandTexturesMergeStage::setup()
|
||||||
|
{
|
||||||
|
return mState.mSource.getData().getLand().getSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMTools::ListLandTexturesMergeStage::perform (int stage, CSMDoc::Messages& messages)
|
||||||
|
{
|
||||||
|
const CSMWorld::Record<CSMWorld::Land>& record =
|
||||||
|
mState.mSource.getData().getLand().getRecord (stage);
|
||||||
|
|
||||||
|
if (!record.isDeleted())
|
||||||
|
{
|
||||||
|
ESM::Land& land = *record.get().mLand;
|
||||||
|
|
||||||
|
// make sure record is loaded
|
||||||
|
land.loadData (ESM::Land::DATA_VHGT | ESM::Land::DATA_VNML |
|
||||||
|
ESM::Land::DATA_VCLR | ESM::Land::DATA_VTEX | ESM::Land::DATA_WNAM);
|
||||||
|
|
||||||
|
if (land.mLandData)
|
||||||
|
{
|
||||||
|
// list texture indices
|
||||||
|
std::pair<uint16_t, int> key;
|
||||||
|
key.second = land.mPlugin;
|
||||||
|
|
||||||
|
for (int i=0; i<ESM::Land::LAND_NUM_TEXTURES; ++i)
|
||||||
|
{
|
||||||
|
key.first = land.mLandData->mTextures[i];
|
||||||
|
|
||||||
|
mState.mTextureIndices[key] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CSMTools::MergeLandTexturesStage::MergeLandTexturesStage (MergeState& state)
|
||||||
|
: mState (state), mNext (mState.mTextureIndices.end())
|
||||||
|
{}
|
||||||
|
|
||||||
|
int CSMTools::MergeLandTexturesStage::setup()
|
||||||
|
{
|
||||||
|
mNext = mState.mTextureIndices.begin();
|
||||||
|
return mState.mTextureIndices.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMTools::MergeLandTexturesStage::perform (int stage, CSMDoc::Messages& messages)
|
||||||
|
{
|
||||||
|
mNext->second = stage;
|
||||||
|
|
||||||
|
std::ostringstream stream;
|
||||||
|
stream << mNext->first.first << "_" << mNext->first.second;
|
||||||
|
|
||||||
|
int index = mState.mSource.getData().getLandTextures().searchId (stream.str());
|
||||||
|
|
||||||
|
if (index!=-1)
|
||||||
|
{
|
||||||
|
CSMWorld::LandTexture texture =
|
||||||
|
mState.mSource.getData().getLandTextures().getRecord (index).get();
|
||||||
|
|
||||||
|
texture.mIndex = mNext->second;
|
||||||
|
texture.mId = stream.str();
|
||||||
|
|
||||||
|
CSMWorld::Record<CSMWorld::LandTexture> newRecord (
|
||||||
|
CSMWorld::RecordBase::State_ModifiedOnly, 0, &texture);
|
||||||
|
|
||||||
|
mState.mTarget->getData().getLandTextures().appendRecord (newRecord);
|
||||||
|
}
|
||||||
|
/// \todo deal with missing textures (either abort merge or report and make sure OpenMW can deal with missing textures)
|
||||||
|
|
||||||
|
++mNext;
|
||||||
|
}
|
||||||
|
|
|
@ -115,6 +115,37 @@ namespace CSMTools
|
||||||
virtual void perform (int stage, CSMDoc::Messages& messages);
|
virtual void perform (int stage, CSMDoc::Messages& messages);
|
||||||
///< Messages resulting from this stage will be appended to \a messages.
|
///< Messages resulting from this stage will be appended to \a messages.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ListLandTexturesMergeStage : public CSMDoc::Stage
|
||||||
|
{
|
||||||
|
MergeState& mState;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
ListLandTexturesMergeStage (MergeState& state);
|
||||||
|
|
||||||
|
virtual int setup();
|
||||||
|
///< \return number of steps
|
||||||
|
|
||||||
|
virtual void perform (int stage, CSMDoc::Messages& messages);
|
||||||
|
///< Messages resulting from this stage will be appended to \a messages.
|
||||||
|
};
|
||||||
|
|
||||||
|
class MergeLandTexturesStage : public CSMDoc::Stage
|
||||||
|
{
|
||||||
|
MergeState& mState;
|
||||||
|
std::map<std::pair<uint16_t, int>, int>::iterator mNext;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
MergeLandTexturesStage (MergeState& state);
|
||||||
|
|
||||||
|
virtual int setup();
|
||||||
|
///< \return number of steps
|
||||||
|
|
||||||
|
virtual void perform (int stage, CSMDoc::Messages& messages);
|
||||||
|
///< Messages resulting from this stage will be appended to \a messages.
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef CSM_TOOLS_MERGESTATE_H
|
#ifndef CSM_TOOLS_MERGESTATE_H
|
||||||
#define CSM_TOOLS_MERGESTATE_H
|
#define CSM_TOOLS_MERGESTATE_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
@ -13,7 +15,7 @@ namespace CSMTools
|
||||||
std::auto_ptr<CSMDoc::Document> mTarget;
|
std::auto_ptr<CSMDoc::Document> mTarget;
|
||||||
CSMDoc::Document& mSource;
|
CSMDoc::Document& mSource;
|
||||||
bool mCompleted;
|
bool mCompleted;
|
||||||
std::map<std::pair<int, int>, int> mTextureIndices; // (texture, content file) -> new texture
|
std::map<std::pair<uint16_t, int>, int> mTextureIndices; // (texture, content file) -> new texture
|
||||||
|
|
||||||
MergeState (CSMDoc::Document& source) : mSource (source), mCompleted (false) {}
|
MergeState (CSMDoc::Document& source) : mSource (source), mCompleted (false) {}
|
||||||
};
|
};
|
||||||
|
|
|
@ -878,6 +878,11 @@ const CSMWorld::IdCollection<CSMWorld::LandTexture>& CSMWorld::Data::getLandText
|
||||||
return mLandTextures;
|
return mLandTextures;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CSMWorld::IdCollection<CSMWorld::LandTexture>& CSMWorld::Data::getLandTextures()
|
||||||
|
{
|
||||||
|
return mLandTextures;
|
||||||
|
}
|
||||||
|
|
||||||
const CSMWorld::IdCollection<ESM::SoundGenerator>& CSMWorld::Data::getSoundGens() const
|
const CSMWorld::IdCollection<ESM::SoundGenerator>& CSMWorld::Data::getSoundGens() const
|
||||||
{
|
{
|
||||||
return mSoundGens;
|
return mSoundGens;
|
||||||
|
|
|
@ -226,6 +226,8 @@ namespace CSMWorld
|
||||||
|
|
||||||
const IdCollection<CSMWorld::LandTexture>& getLandTextures() const;
|
const IdCollection<CSMWorld::LandTexture>& getLandTextures() const;
|
||||||
|
|
||||||
|
IdCollection<CSMWorld::LandTexture>& getLandTextures();
|
||||||
|
|
||||||
const IdCollection<ESM::SoundGenerator>& getSoundGens() const;
|
const IdCollection<ESM::SoundGenerator>& getSoundGens() const;
|
||||||
|
|
||||||
IdCollection<ESM::SoundGenerator>& getSoundGens();
|
IdCollection<ESM::SoundGenerator>& getSoundGens();
|
||||||
|
|
Loading…
Reference in a new issue