1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 15:35:23 +00:00

Added check to load custom filters set when present.

This commit is contained in:
Marek Kochanowicz 2013-10-19 18:43:47 +02:00
parent 4e26a61db3
commit 184456892b
2 changed files with 28 additions and 19 deletions

View File

@ -8,10 +8,11 @@
#include "model/doc/document.hpp"
#include "model/world/data.hpp"
#include <iostream>
CS::Editor::Editor()
: mDocumentManager (mCfgMgr), mViewManager (mDocumentManager)
: mDocumentManager (mCfgMgr), mViewManager (mDocumentManager)
{
mIpcServerName = "org.openmw.OpenCS";
@ -32,23 +33,23 @@ CS::Editor::Editor()
connect (&mFileDialog, SIGNAL(openFiles()), this, SLOT(openFiles()));
connect (&mFileDialog, SIGNAL(createNewFile (const boost::filesystem::path&)),
this, SLOT(createNewFile (const boost::filesystem::path&)));
this, SLOT(createNewFile (const boost::filesystem::path&)));
connect (&mNewGame, SIGNAL (createRequest (const boost::filesystem::path&)),
this, SLOT (createNewGame (const boost::filesystem::path&)));
this, SLOT (createNewGame (const boost::filesystem::path&)));
}
void CS::Editor::setupDataFiles()
{
boost::program_options::variables_map variables;
boost::program_options::options_description desc("Syntax: opencs <options>\nAllowed options");
desc.add_options()
("data", boost::program_options::value<Files::PathContainer>()->default_value(Files::PathContainer(), "data")->multitoken())
("data-local", boost::program_options::value<std::string>()->default_value(""))
("fs-strict", boost::program_options::value<bool>()->implicit_value(true)->default_value(false))
("encoding", boost::program_options::value<std::string>()->default_value("win1252"))
("resources", boost::program_options::value<std::string>()->default_value("resources"), "set resources directory");
("resources", boost::program_options::value<std::string>()->default_value("resources"));
boost::program_options::notify(variables);
@ -58,7 +59,7 @@ void CS::Editor::setupDataFiles()
if (!variables["data"].empty()) {
dataDirs = Files::PathContainer(variables["data"].as<Files::PathContainer>());
}
std::string local = variables["data-local"].as<std::string>();
if (!local.empty()) {
dataLocal.push_back(Files::PathContainer::value_type(local));
@ -83,12 +84,12 @@ void CS::Editor::setupDataFiles()
}
// Set the charset for reading the esm/esp files
// QString encoding = QString::fromStdString(variables["encoding"].as<std::string>());
// QString encoding = QString::fromStdString(variables["encoding"].as<std::string>());
//mFileDialog.setEncoding(encoding);
dataDirs.insert (dataDirs.end(), dataLocal.begin(), dataLocal.end());
// Setting Resources directory.
// Adding Resources directory. First check if there is a file defaultfilters in the user path.
mDocumentManager.setResourceDir(variables["resources"].as<std::string>());
for (Files::PathContainer::const_iterator iter = dataDirs.begin(); iter != dataDirs.end(); ++iter)
@ -222,4 +223,4 @@ int CS::Editor::run()
QApplication::setQuitOnLastWindowClosed (true);
return QApplication::exec();
}
}

View File

@ -9,7 +9,7 @@
#endif
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)
{
assert (begin!=end);
@ -2147,10 +2147,10 @@ void CSMDoc::Document::createBase()
}
CSMDoc::Document::Document (const Files::ConfigurationManager& configuration, const std::vector< boost::filesystem::path >& files, const boost::filesystem::path& savePath, const boost::filesystem::path& resDir, bool new_)
: mSavePath (savePath), mContentFiles (files), mTools (mData), mResDir(resDir),
mProjectPath ((configuration.getUserPath() / "projects") /
(savePath.filename().string() + ".project")),
mSaving (*this, mProjectPath)
: mSavePath (savePath), mContentFiles (files), mTools (mData), mResDir(resDir),
mProjectPath ((configuration.getUserPath() / "projects") /
(savePath.filename().string() + ".project")),
mSaving (*this, mProjectPath)
{
if (files.empty())
throw std::runtime_error ("Empty content file sequence");
@ -2181,9 +2181,17 @@ CSMDoc::Document::Document (const Files::ConfigurationManager& configuration, co
}
else
{
boost::filesystem::path filters = mResDir;
filters /= "defaultfilters.omwaddon.project";
boost::filesystem::copy_file(mResDir, mProjectPath);
boost::filesystem::path locCustomFiltersPath (configuration.getUserPath());
locCustomFiltersPath /= "defaultfilters.omwaddon.project";
if (boost::filesystem::exists(locCustomFiltersPath))
{
boost::filesystem::copy(locCustomFiltersPath, mProjectPath);
} else {
boost::filesystem::path filters(mResDir);
filters /= "defaultfilters.omwaddon.project";
boost::filesystem::copy_file(filters, mProjectPath);
}
getData().loadFile (mProjectPath, false, true);
}
}
@ -2198,7 +2206,7 @@ CSMDoc::Document::Document (const Files::ConfigurationManager& configuration, co
connect (&mSaving, SIGNAL (progress (int, int, int)), this, SLOT (progress (int, int, int)));
connect (&mSaving, SIGNAL (done (int)), this, SLOT (operationDone (int)));
connect (&mSaving, SIGNAL (reportMessage (const QString&, int)),
this, SLOT (reportMessage (const QString&, int)));
this, SLOT (reportMessage (const QString&, int)));
}
CSMDoc::Document::~Document()