mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-04 03:40:14 +00:00
Removed command line handling. Maybe zini will let me to implement it later. Implemented switch to handle resources directory. TODO: check for defaultfilters on data path.
This commit is contained in:
parent
a7002e8a09
commit
4e26a61db3
@ -41,13 +41,14 @@ CS::Editor::Editor()
|
|||||||
void CS::Editor::setupDataFiles()
|
void CS::Editor::setupDataFiles()
|
||||||
{
|
{
|
||||||
boost::program_options::variables_map variables;
|
boost::program_options::variables_map variables;
|
||||||
boost::program_options::options_description desc;
|
boost::program_options::options_description desc("Syntax: opencs <options>\nAllowed options");
|
||||||
|
|
||||||
desc.add_options()
|
desc.add_options()
|
||||||
("data", boost::program_options::value<Files::PathContainer>()->default_value(Files::PathContainer(), "data")->multitoken())
|
("data", boost::program_options::value<Files::PathContainer>()->default_value(Files::PathContainer(), "data")->multitoken())
|
||||||
("data-local", boost::program_options::value<std::string>()->default_value(""))
|
("data-local", boost::program_options::value<std::string>()->default_value(""))
|
||||||
("fs-strict", boost::program_options::value<bool>()->implicit_value(true)->default_value(false))
|
("fs-strict", boost::program_options::value<bool>()->implicit_value(true)->default_value(false))
|
||||||
("encoding", boost::program_options::value<std::string>()->default_value("win1252"));
|
("encoding", boost::program_options::value<std::string>()->default_value("win1252"))
|
||||||
|
("resources", boost::program_options::value<std::string>()->default_value("resources"), "set resources directory");
|
||||||
|
|
||||||
boost::program_options::notify(variables);
|
boost::program_options::notify(variables);
|
||||||
|
|
||||||
@ -87,6 +88,9 @@ void CS::Editor::setupDataFiles()
|
|||||||
|
|
||||||
dataDirs.insert (dataDirs.end(), dataLocal.begin(), dataLocal.end());
|
dataDirs.insert (dataDirs.end(), dataLocal.begin(), dataLocal.end());
|
||||||
|
|
||||||
|
// Setting Resources directory.
|
||||||
|
mDocumentManager.setResourceDir(variables["resources"].as<std::string>());
|
||||||
|
|
||||||
for (Files::PathContainer::const_iterator iter = dataDirs.begin(); iter != dataDirs.end(); ++iter)
|
for (Files::PathContainer::const_iterator iter = dataDirs.begin(); iter != dataDirs.end(); ++iter)
|
||||||
{
|
{
|
||||||
QString path = QString::fromStdString(iter->string());
|
QString path = QString::fromStdString(iter->string());
|
||||||
@ -208,13 +212,8 @@ void CS::Editor::connectToIPCServer()
|
|||||||
mClientSocket->close();
|
mClientSocket->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
int CS::Editor::run(int argc, char** argv)
|
int CS::Editor::run()
|
||||||
{
|
{
|
||||||
if (!parseOptions(argc, argv) )
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mLocal.empty())
|
if (mLocal.empty())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@ -224,41 +223,3 @@ int CS::Editor::run(int argc, char** argv)
|
|||||||
|
|
||||||
return QApplication::exec();
|
return QApplication::exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CS::Editor::parseOptions (int argc, char** argv)
|
|
||||||
{
|
|
||||||
// Create a local alias for brevity
|
|
||||||
namespace bpo = boost::program_options;
|
|
||||||
|
|
||||||
bpo::options_description desc("Syntax: opencs <options>\nAllowed options");
|
|
||||||
|
|
||||||
desc.add_options()
|
|
||||||
("help", "print help message")
|
|
||||||
|
|
||||||
("resources", bpo::value<std::string>()->default_value("resources"), "set resources directory");
|
|
||||||
|
|
||||||
bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv).options(desc).allow_unregistered().run();
|
|
||||||
|
|
||||||
bpo::variables_map variables;
|
|
||||||
|
|
||||||
// Runtime options override settings from all configs
|
|
||||||
bpo::store(valid_opts, variables);
|
|
||||||
bpo::notify(variables);
|
|
||||||
|
|
||||||
mCfgMgr.readConfiguration(variables, desc);
|
|
||||||
|
|
||||||
bool run = true;
|
|
||||||
|
|
||||||
if (variables.count ("help"))
|
|
||||||
{
|
|
||||||
std::cout << desc << std::endl;
|
|
||||||
run = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!run)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
mDocumentManager.setResourceDir(variables["resources"].as<std::string>());
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
@ -50,7 +50,7 @@ namespace CS
|
|||||||
bool makeIPCServer();
|
bool makeIPCServer();
|
||||||
void connectToIPCServer();
|
void connectToIPCServer();
|
||||||
|
|
||||||
int run(int argc, char** argv);
|
int run();
|
||||||
///< \return error status
|
///< \return error status
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@ -66,7 +66,6 @@ namespace CS
|
|||||||
void showStartup();
|
void showStartup();
|
||||||
|
|
||||||
void showSettings();
|
void showSettings();
|
||||||
bool parseOptions (int argc, char** argv);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -45,5 +45,5 @@ int main(int argc, char *argv[])
|
|||||||
// return 0;
|
// return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return editor.run(argc, argv);
|
return editor.run();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user