forked from teamnwah/openmw-tes3coop
load project files
This commit is contained in:
parent
62148b3247
commit
e7c48cbe58
3 changed files with 34 additions and 4 deletions
|
@ -1,6 +1,9 @@
|
||||||
#include "document.hpp"
|
#include "document.hpp"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
void CSMDoc::Document::load (const std::vector<boost::filesystem::path>::const_iterator& begin,
|
void CSMDoc::Document::load (const std::vector<boost::filesystem::path>::const_iterator& begin,
|
||||||
const std::vector<boost::filesystem::path>::const_iterator& end, bool lastAsModified)
|
const std::vector<boost::filesystem::path>::const_iterator& end, bool lastAsModified)
|
||||||
{
|
{
|
||||||
|
@ -12,10 +15,10 @@ void CSMDoc::Document::load (const std::vector<boost::filesystem::path>::const_i
|
||||||
--end2;
|
--end2;
|
||||||
|
|
||||||
for (std::vector<boost::filesystem::path>::const_iterator iter (begin); iter!=end2; ++iter)
|
for (std::vector<boost::filesystem::path>::const_iterator iter (begin); iter!=end2; ++iter)
|
||||||
getData().loadFile (*iter, true);
|
getData().loadFile (*iter, true, false);
|
||||||
|
|
||||||
if (lastAsModified)
|
if (lastAsModified)
|
||||||
getData().loadFile (*end2, false);
|
getData().loadFile (*end2, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMDoc::Document::addGmsts()
|
void CSMDoc::Document::addGmsts()
|
||||||
|
@ -2164,6 +2167,18 @@ CSMDoc::Document::Document (const std::vector<boost::filesystem::path>& files,
|
||||||
mData.setDescription ("");
|
mData.setDescription ("");
|
||||||
mData.setAuthor ("");
|
mData.setAuthor ("");
|
||||||
}
|
}
|
||||||
|
/// \todo un-outcomment the else, once loading an existing content file works properly again.
|
||||||
|
// else
|
||||||
|
{
|
||||||
|
if (boost::filesystem::exists (projectPath))
|
||||||
|
{
|
||||||
|
getData().loadFile (projectPath, false, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/// \todo create new project file with default filters
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
addOptionalGmsts();
|
addOptionalGmsts();
|
||||||
addOptionalGlobals();
|
addOptionalGlobals();
|
||||||
|
|
|
@ -386,7 +386,7 @@ void CSMWorld::Data::merge()
|
||||||
mGlobals.merge();
|
mGlobals.merge();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMWorld::Data::loadFile (const boost::filesystem::path& path, bool base)
|
void CSMWorld::Data::loadFile (const boost::filesystem::path& path, bool base, bool project)
|
||||||
{
|
{
|
||||||
ESM::ESMReader reader;
|
ESM::ESMReader reader;
|
||||||
|
|
||||||
|
@ -449,6 +449,19 @@ void CSMWorld::Data::loadFile (const boost::filesystem::path& path, bool base)
|
||||||
case ESM::REC_STAT: mReferenceables.load (reader, base, UniversalId::Type_Static); break;
|
case ESM::REC_STAT: mReferenceables.load (reader, base, UniversalId::Type_Static); break;
|
||||||
case ESM::REC_WEAP: mReferenceables.load (reader, base, UniversalId::Type_Weapon); break;
|
case ESM::REC_WEAP: mReferenceables.load (reader, base, UniversalId::Type_Weapon); break;
|
||||||
|
|
||||||
|
case ESM::REC_FILT:
|
||||||
|
|
||||||
|
if (project)
|
||||||
|
{
|
||||||
|
mFilters.load (reader, base);
|
||||||
|
mFilters.setData (mFilters.getSize()-1,
|
||||||
|
mFilters.findColumnIndex (CSMWorld::Columns::ColumnId_Scope),
|
||||||
|
static_cast<int> (CSMFilter::Filter::Scope_Project));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// fall through (filter record in a content file is an error with format 0)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
/// \todo throw an exception instead, once all records are implemented
|
/// \todo throw an exception instead, once all records are implemented
|
||||||
|
|
|
@ -145,8 +145,10 @@ namespace CSMWorld
|
||||||
void merge();
|
void merge();
|
||||||
///< Merge modified into base.
|
///< Merge modified into base.
|
||||||
|
|
||||||
void loadFile (const boost::filesystem::path& path, bool base);
|
void loadFile (const boost::filesystem::path& path, bool base, bool project);
|
||||||
///< Merging content of a file into base or modified.
|
///< Merging content of a file into base or modified.
|
||||||
|
///
|
||||||
|
/// \param project load project file instead of content file
|
||||||
|
|
||||||
bool hasId (const std::string& id) const;
|
bool hasId (const std::string& id) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue