forked from mirror/openmw-tes3mp
Implements switch (--help and --resources), and copying defaultfilters.omwaddon.project. Seems to work.
This commit is contained in:
parent
3000386443
commit
a7002e8a09
6 changed files with 23 additions and 27 deletions
|
@ -6,8 +6,6 @@
|
||||||
#include <QLocalSocket>
|
#include <QLocalSocket>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include <boost/iostreams/concepts.hpp>
|
|
||||||
|
|
||||||
#include "model/doc/document.hpp"
|
#include "model/doc/document.hpp"
|
||||||
#include "model/world/data.hpp"
|
#include "model/world/data.hpp"
|
||||||
|
|
||||||
|
@ -231,9 +229,8 @@ bool CS::Editor::parseOptions (int argc, char** argv)
|
||||||
{
|
{
|
||||||
// Create a local alias for brevity
|
// Create a local alias for brevity
|
||||||
namespace bpo = boost::program_options;
|
namespace bpo = boost::program_options;
|
||||||
typedef std::vector<std::string> StringsVector;
|
|
||||||
|
|
||||||
bpo::options_description desc("Syntax: openmw <options>\nAllowed options");
|
bpo::options_description desc("Syntax: opencs <options>\nAllowed options");
|
||||||
|
|
||||||
desc.add_options()
|
desc.add_options()
|
||||||
("help", "print help message")
|
("help", "print help message")
|
||||||
|
@ -248,7 +245,7 @@ bool CS::Editor::parseOptions (int argc, char** argv)
|
||||||
bpo::store(valid_opts, variables);
|
bpo::store(valid_opts, variables);
|
||||||
bpo::notify(variables);
|
bpo::notify(variables);
|
||||||
|
|
||||||
// cfgMgr.readConfiguration(variables, desc);
|
mCfgMgr.readConfiguration(variables, desc);
|
||||||
|
|
||||||
bool run = true;
|
bool run = true;
|
||||||
|
|
||||||
|
@ -261,13 +258,7 @@ bool CS::Editor::parseOptions (int argc, char** argv)
|
||||||
if (!run)
|
if (!run)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
setResourceDir(variables["resources"].as<std::string>());
|
mDocumentManager.setResourceDir(variables["resources"].as<std::string>());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set resource dir
|
|
||||||
void CS::Editor::setResourceDir (const boost::filesystem::path& parResDir)
|
|
||||||
{
|
|
||||||
mResDir = boost::filesystem::system_complete(parResDir);
|
|
||||||
}
|
|
|
@ -67,14 +67,12 @@ namespace CS
|
||||||
|
|
||||||
void showSettings();
|
void showSettings();
|
||||||
bool parseOptions (int argc, char** argv);
|
bool parseOptions (int argc, char** argv);
|
||||||
void setResourceDir (const boost::filesystem::path& parResDir);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QString mIpcServerName;
|
QString mIpcServerName;
|
||||||
QLocalServer *mServer;
|
QLocalServer *mServer;
|
||||||
QLocalSocket *mClientSocket;
|
QLocalSocket *mClientSocket;
|
||||||
boost::filesystem::path mResDir;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2146,10 +2146,8 @@ void CSMDoc::Document::createBase()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMDoc::Document::Document (const Files::ConfigurationManager& configuration,
|
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_)
|
||||||
const std::vector<boost::filesystem::path>& files,
|
: mSavePath (savePath), mContentFiles (files), mTools (mData), mResDir(resDir),
|
||||||
const boost::filesystem::path& savePath, bool new_)
|
|
||||||
: mSavePath (savePath), mContentFiles (files), mTools (mData),
|
|
||||||
mProjectPath ((configuration.getUserPath() / "projects") /
|
mProjectPath ((configuration.getUserPath() / "projects") /
|
||||||
(savePath.filename().string() + ".project")),
|
(savePath.filename().string() + ".project")),
|
||||||
mSaving (*this, mProjectPath)
|
mSaving (*this, mProjectPath)
|
||||||
|
@ -2183,7 +2181,9 @@ CSMDoc::Document::Document (const Files::ConfigurationManager& configuration,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/// \todo create new project file with default filters
|
boost::filesystem::path filters = mResDir;
|
||||||
|
filters /= "defaultfilters.omwaddon.project";
|
||||||
|
boost::filesystem::copy_file(mResDir, mProjectPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,13 +43,14 @@ namespace CSMDoc
|
||||||
CSMTools::Tools mTools;
|
CSMTools::Tools mTools;
|
||||||
boost::filesystem::path mProjectPath;
|
boost::filesystem::path mProjectPath;
|
||||||
Saving mSaving;
|
Saving mSaving;
|
||||||
|
boost::filesystem::path mResDir;
|
||||||
|
|
||||||
// It is important that the undo stack is declared last, because on desctruction it fires a signal, that is connected to a slot, that is
|
// It is important that the undo stack is declared last, because on desctruction it fires a signal, that is connected to a slot, that is
|
||||||
// using other member variables. Unfortunately this connection is cut only in the QObject destructor, which is way too late.
|
// using other member variables. Unfortunately this connection is cut only in the QObject destructor, which is way too late.
|
||||||
QUndoStack mUndoStack;
|
QUndoStack mUndoStack;
|
||||||
|
|
||||||
// not implemented
|
// not implemented
|
||||||
Document (const Document&);
|
Document (const Files::ConfigurationManager& configuration, const std::vector< boost::filesystem::path >& files, const boost::filesystem::path& savePath, bool new_);
|
||||||
Document& operator= (const Document&);
|
Document& operator= (const Document&);
|
||||||
|
|
||||||
void load (const std::vector<boost::filesystem::path>::const_iterator& begin,
|
void load (const std::vector<boost::filesystem::path>::const_iterator& begin,
|
||||||
|
@ -70,9 +71,7 @@ namespace CSMDoc
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Document (const Files::ConfigurationManager& configuration,
|
Document (const Files::ConfigurationManager& configuration, const std::vector< boost::filesystem::path >& files, const boost::filesystem::path& savePath, const boost::filesystem::path& resDir, bool new_);
|
||||||
const std::vector<boost::filesystem::path>& files,
|
|
||||||
const boost::filesystem::path& savePath, bool new_);
|
|
||||||
|
|
||||||
~Document();
|
~Document();
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ CSMDoc::DocumentManager::~DocumentManager()
|
||||||
CSMDoc::Document *CSMDoc::DocumentManager::addDocument (const std::vector<boost::filesystem::path>& files, const boost::filesystem::path& savePath,
|
CSMDoc::Document *CSMDoc::DocumentManager::addDocument (const std::vector<boost::filesystem::path>& files, const boost::filesystem::path& savePath,
|
||||||
bool new_)
|
bool new_)
|
||||||
{
|
{
|
||||||
Document *document = new Document (mConfiguration, files, savePath, new_);
|
Document *document = new Document (mConfiguration, files, savePath, mResDir, new_);
|
||||||
|
|
||||||
mDocuments.push_back (document);
|
mDocuments.push_back (document);
|
||||||
|
|
||||||
|
@ -49,3 +49,8 @@ bool CSMDoc::DocumentManager::removeDocument (Document *document)
|
||||||
|
|
||||||
return mDocuments.empty();
|
return mDocuments.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSMDoc::DocumentManager::setResourceDir (const boost::filesystem::path& parResDir)
|
||||||
|
{
|
||||||
|
mResDir = boost::filesystem::system_complete(parResDir);
|
||||||
|
}
|
|
@ -29,8 +29,7 @@ namespace CSMDoc
|
||||||
|
|
||||||
~DocumentManager();
|
~DocumentManager();
|
||||||
|
|
||||||
Document *addDocument (const std::vector<boost::filesystem::path>& files,
|
Document *addDocument (const std::vector< boost::filesystem::path >& files, const boost::filesystem::path& savePath, bool new_);
|
||||||
const boost::filesystem::path& savePath, bool new_);
|
|
||||||
///< The ownership of the returned document is not transferred to the caller.
|
///< The ownership of the returned document is not transferred to the caller.
|
||||||
///
|
///
|
||||||
/// \param new_ Do not load the last content file in \a files and instead create in an
|
/// \param new_ Do not load the last content file in \a files and instead create in an
|
||||||
|
@ -38,6 +37,10 @@ namespace CSMDoc
|
||||||
|
|
||||||
bool removeDocument (Document *document);
|
bool removeDocument (Document *document);
|
||||||
///< \return last document removed?
|
///< \return last document removed?
|
||||||
|
void setResourceDir (const boost::filesystem::path& parResDir);
|
||||||
|
|
||||||
|
private:
|
||||||
|
boost::filesystem::path mResDir;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue