|
|
|
@ -7,28 +7,6 @@
|
|
|
|
|
|
|
|
|
|
MainDialog::MainDialog()
|
|
|
|
|
{
|
|
|
|
|
// Create the settings manager and load default settings file
|
|
|
|
|
const std::string localdefault = mCfgMgr.getLocalPath().string() + "/settings-default.cfg";
|
|
|
|
|
const std::string globaldefault = mCfgMgr.getGlobalPath().string() + "/settings-default.cfg";
|
|
|
|
|
|
|
|
|
|
// prefer local
|
|
|
|
|
if (boost::filesystem::exists(localdefault))
|
|
|
|
|
mSettings.loadDefault(localdefault);
|
|
|
|
|
else if (boost::filesystem::exists(globaldefault))
|
|
|
|
|
mSettings.loadDefault(globaldefault);
|
|
|
|
|
else
|
|
|
|
|
throw std::runtime_error ("No default settings file found! Make sure the file \"settings-default.cfg\" was properly installed.");
|
|
|
|
|
|
|
|
|
|
// load user settings if they exist, otherwise just load the default settings as user settings
|
|
|
|
|
const std::string settingspath = mCfgMgr.getUserPath().string() + "/settings.cfg";
|
|
|
|
|
if (boost::filesystem::exists(settingspath))
|
|
|
|
|
mSettings.loadUser(settingspath);
|
|
|
|
|
else if (boost::filesystem::exists(localdefault))
|
|
|
|
|
mSettings.loadUser(localdefault);
|
|
|
|
|
else if (boost::filesystem::exists(globaldefault))
|
|
|
|
|
mSettings.loadUser(globaldefault);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QWidget *centralWidget = new QWidget(this);
|
|
|
|
|
setCentralWidget(centralWidget);
|
|
|
|
|
|
|
|
|
@ -72,22 +50,22 @@ MainDialog::MainDialog()
|
|
|
|
|
// Install the stylesheet font
|
|
|
|
|
QFile file;
|
|
|
|
|
QFontDatabase fontDatabase;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const QStringList fonts = fontDatabase.families();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check if the font is installed
|
|
|
|
|
if (!fonts.contains("EB Garamond")) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString font = QString::fromStdString((mCfgMgr.getGlobalDataPath() / "resources/mygui/EBGaramond-Regular.ttf").string());
|
|
|
|
|
file.setFileName(font);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!file.exists()) {
|
|
|
|
|
font = QString::fromStdString((mCfgMgr.getLocalPath() / "resources/mygui/EBGaramond-Regular.ttf").string());
|
|
|
|
|
font = QString::fromStdString((mCfgMgr.getLocalPath() / "resources/mygui/EBGaramond-Regular.ttf").string());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fontDatabase.addApplicationFont(font);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Load the stylesheet
|
|
|
|
|
QString config = QString::fromStdString((mCfgMgr.getGlobalDataPath() / "resources/launcher.qss").string());
|
|
|
|
|
file.setFileName(config);
|
|
|
|
@ -101,7 +79,6 @@ MainDialog::MainDialog()
|
|
|
|
|
qApp->setStyleSheet(styleSheet);
|
|
|
|
|
file.close();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect(buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
|
|
|
|
connect(buttonBox, SIGNAL(accepted()), this, SLOT(play()));
|
|
|
|
|
|
|
|
|
@ -172,6 +149,53 @@ void MainDialog::createPages()
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool MainDialog::setup()
|
|
|
|
|
{
|
|
|
|
|
// Create the settings manager and load default settings file
|
|
|
|
|
const std::string localdefault = (mCfgMgr.getLocalPath() / "settings-default.cfg").string();
|
|
|
|
|
const std::string globaldefault = (mCfgMgr.getGlobalPath() / "settings-default.cfg").string();
|
|
|
|
|
|
|
|
|
|
// prefer local
|
|
|
|
|
if (boost::filesystem::exists(localdefault)) {
|
|
|
|
|
mSettings.loadDefault(localdefault);
|
|
|
|
|
} else if (boost::filesystem::exists(globaldefault)) {
|
|
|
|
|
mSettings.loadDefault(globaldefault);
|
|
|
|
|
} else {
|
|
|
|
|
QMessageBox msgBox;
|
|
|
|
|
msgBox.setWindowTitle("Error reading OpenMW configuration file");
|
|
|
|
|
msgBox.setIcon(QMessageBox::Critical);
|
|
|
|
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
|
|
|
|
msgBox.setText(tr("<br><b>Could not find %0</b><br><br> \
|
|
|
|
|
The problem may be due to an incomplete installation of OpenMW.<br> \
|
|
|
|
|
Reinstalling OpenMW may resolve the problem.").arg(QString::fromStdString(globaldefault)));
|
|
|
|
|
msgBox.exec();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// load user settings if they exist, otherwise just load the default settings as user settings
|
|
|
|
|
const std::string settingspath = (mCfgMgr.getUserPath() / "settings.cfg").string();
|
|
|
|
|
|
|
|
|
|
if (boost::filesystem::exists(settingspath))
|
|
|
|
|
mSettings.loadUser(settingspath);
|
|
|
|
|
else if (boost::filesystem::exists(localdefault))
|
|
|
|
|
mSettings.loadUser(localdefault);
|
|
|
|
|
else if (boost::filesystem::exists(globaldefault))
|
|
|
|
|
mSettings.loadUser(globaldefault);
|
|
|
|
|
|
|
|
|
|
// Setup the Graphics page
|
|
|
|
|
if (!mGraphicsPage->setupOgre()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Setup the Data Files page
|
|
|
|
|
if (!mDataFilesPage->setupDataFiles()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainDialog::profileChanged(int index)
|
|
|
|
|
{
|
|
|
|
|
// Just to be sure, should always have a selection
|
|
|
|
@ -204,7 +228,8 @@ void MainDialog::closeEvent(QCloseEvent *event)
|
|
|
|
|
mGraphicsPage->writeConfig();
|
|
|
|
|
|
|
|
|
|
// Save user settings
|
|
|
|
|
const std::string settingspath = mCfgMgr.getUserPath().string() + "/settings.cfg";
|
|
|
|
|
const std::string settingspath = (mCfgMgr.getUserPath() / "settings.cfg").string();
|
|
|
|
|
qDebug() << QString::fromStdString(settingspath);
|
|
|
|
|
mSettings.saveUser(settingspath);
|
|
|
|
|
|
|
|
|
|
event->accept();
|
|
|
|
@ -248,7 +273,7 @@ void MainDialog::play()
|
|
|
|
|
if (!info.isExecutable()) {
|
|
|
|
|
QMessageBox msgBox;
|
|
|
|
|
msgBox.setWindowTitle("Error starting OpenMW");
|
|
|
|
|
msgBox.setIcon(QMessageBox::Critical);
|
|
|
|
|
msgBox.setIcon(QMessageBox::Warning);
|
|
|
|
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
|
|
|
|
msgBox.setText(tr("<br><b>Could not start OpenMW</b><br><br> \
|
|
|
|
|
The OpenMW application is not executable.<br> \
|
|
|
|
@ -272,6 +297,7 @@ void MainDialog::play()
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
close();
|
|
|
|
|
qApp->quit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|