1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 15:19:55 +00:00
openmw-tes3mp/apps/browser/main.cpp

49 lines
1.6 KiB
C++
Raw Normal View History

2017-01-11 14:04:53 +00:00
#include <QApplication>
#include <components/settings/settings.hpp>
#include <components/files/configurationmanager.hpp>
2017-04-27 03:40:41 +00:00
#include <apps/browser/netutils/QueryClient.hpp>
2017-01-12 02:46:48 +00:00
#include "MainWindow.hpp"
2017-01-11 14:04:53 +00:00
std::string loadSettings (Settings::Manager & settings)
{
Files::ConfigurationManager mCfgMgr;
// Create the settings manager and load default settings file
const std::string localdefault = (mCfgMgr.getLocalPath() / "tes3mp-client-default.cfg").string();
const std::string globaldefault = (mCfgMgr.getGlobalPath() / "tes3mp-client-default.cfg").string();
// prefer local
if (boost::filesystem::exists(localdefault))
settings.loadDefault(localdefault);
else if (boost::filesystem::exists(globaldefault))
settings.loadDefault(globaldefault);
else
throw std::runtime_error ("No default settings file found! Make sure the file \"tes3mp-client-default.cfg\" was properly installed.");
// load user settings if they exist
const std::string settingspath = (mCfgMgr.getUserConfigPath() / "tes3mp-client.cfg").string();
if (boost::filesystem::exists(settingspath))
settings.loadUser(settingspath);
return settingspath;
}
2017-01-11 14:04:53 +00:00
int main(int argc, char *argv[])
{
Settings::Manager mgr;
loadSettings(mgr);
std::string addr = mgr.getString("address", "Master");
int port = mgr.getInt("port", "Master");
2017-01-11 14:04:53 +00:00
// initialize resources, if needed
// Q_INIT_RESOURCE(resfile);
2017-04-27 03:40:41 +00:00
QueryClient::Get().SetServer(addr, port);
2017-01-11 14:04:53 +00:00
QApplication app(argc, argv);
2017-01-12 02:46:48 +00:00
MainWindow d;
2017-01-18 14:44:59 +00:00
d.show();
return app.exec();
}