mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-04 03:45:33 +00:00
failed attempt on switch adding.
This commit is contained in:
parent
ef617d408b
commit
3000386443
3 changed files with 58 additions and 3 deletions
|
@ -6,6 +6,8 @@
|
|||
#include <QLocalSocket>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <boost/iostreams/concepts.hpp>
|
||||
|
||||
#include "model/doc/document.hpp"
|
||||
#include "model/world/data.hpp"
|
||||
|
||||
|
@ -208,8 +210,13 @@ void CS::Editor::connectToIPCServer()
|
|||
mClientSocket->close();
|
||||
}
|
||||
|
||||
int CS::Editor::run()
|
||||
int CS::Editor::run(int argc, char** argv)
|
||||
{
|
||||
if (!parseOptions(argc, argv) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mLocal.empty())
|
||||
return 1;
|
||||
|
||||
|
@ -219,3 +226,48 @@ int CS::Editor::run()
|
|||
|
||||
return QApplication::exec();
|
||||
}
|
||||
|
||||
bool CS::Editor::parseOptions (int argc, char** argv)
|
||||
{
|
||||
// Create a local alias for brevity
|
||||
namespace bpo = boost::program_options;
|
||||
typedef std::vector<std::string> StringsVector;
|
||||
|
||||
bpo::options_description desc("Syntax: openmw <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);
|
||||
|
||||
// cfgMgr.readConfiguration(variables, desc);
|
||||
|
||||
bool run = true;
|
||||
|
||||
if (variables.count ("help"))
|
||||
{
|
||||
std::cout << desc << std::endl;
|
||||
run = false;
|
||||
}
|
||||
|
||||
if (!run)
|
||||
return false;
|
||||
|
||||
setResourceDir(variables["resources"].as<std::string>());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Set resource dir
|
||||
void CS::Editor::setResourceDir (const boost::filesystem::path& parResDir)
|
||||
{
|
||||
mResDir = boost::filesystem::system_complete(parResDir);
|
||||
}
|
|
@ -50,7 +50,7 @@ namespace CS
|
|||
bool makeIPCServer();
|
||||
void connectToIPCServer();
|
||||
|
||||
int run();
|
||||
int run(int argc, char** argv);
|
||||
///< \return error status
|
||||
|
||||
private slots:
|
||||
|
@ -66,12 +66,15 @@ namespace CS
|
|||
void showStartup();
|
||||
|
||||
void showSettings();
|
||||
bool parseOptions (int argc, char** argv);
|
||||
void setResourceDir (const boost::filesystem::path& parResDir);
|
||||
|
||||
private:
|
||||
|
||||
QString mIpcServerName;
|
||||
QLocalServer *mServer;
|
||||
QLocalSocket *mClientSocket;
|
||||
boost::filesystem::path mResDir;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -45,5 +45,5 @@ int main(int argc, char *argv[])
|
|||
// return 0;
|
||||
}
|
||||
|
||||
return editor.run();
|
||||
return editor.run(argc, argv);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue