Commit files that I thought wre in the previous commit. :-[ I'm

accustomed to the hg behavior of commiting all modified files by
default.
openmw-38
cfcohen 9 years ago
parent 18da95e4f8
commit 67c4b17581

@ -7,8 +7,6 @@ set(LAUNCHER
textslotmsgbox.cpp textslotmsgbox.cpp
settingspage.cpp settingspage.cpp
settings/graphicssettings.cpp
utils/profilescombobox.cpp utils/profilescombobox.cpp
utils/textinputdialog.cpp utils/textinputdialog.cpp
utils/lineedit.cpp utils/lineedit.cpp
@ -24,8 +22,6 @@ set(LAUNCHER_HEADER
textslotmsgbox.hpp textslotmsgbox.hpp
settingspage.hpp settingspage.hpp
settings/graphicssettings.hpp
utils/profilescombobox.hpp utils/profilescombobox.hpp
utils/textinputdialog.hpp utils/textinputdialog.hpp
utils/lineedit.hpp utils/lineedit.hpp

@ -75,7 +75,7 @@ bool Launcher::DataFilesPage::loadSettings()
QStringList profiles = mLauncherSettings.getContentLists(); QStringList profiles = mLauncherSettings.getContentLists();
QString currentProfile = mLauncherSettings.getCurrentContentListName(); QString currentProfile = mLauncherSettings.getCurrentContentListName();
qDebug() << "current profile is: " << currentProfile; qDebug() << "The current profile is: " << currentProfile;
foreach (const QString &item, profiles) foreach (const QString &item, profiles)
addProfile (item, false); addProfile (item, false);

@ -18,7 +18,7 @@
#include <components/contentselector/model/naturalsort.hpp> #include <components/contentselector/model/naturalsort.hpp>
#include "settings/graphicssettings.hpp" #include <components/settings/settings.hpp>
QString getAspect(int x, int y) QString getAspect(int x, int y)
{ {
@ -32,10 +32,10 @@ QString getAspect(int x, int y)
return QString(QString::number(xaspect) + ":" + QString::number(yaspect)); return QString(QString::number(xaspect) + ":" + QString::number(yaspect));
} }
Launcher::GraphicsPage::GraphicsPage(Files::ConfigurationManager &cfg, GraphicsSettings &graphicsSetting, QWidget *parent) Launcher::GraphicsPage::GraphicsPage(Files::ConfigurationManager &cfg, Settings::Manager &engineSettings, QWidget *parent)
: QWidget(parent) : QWidget(parent)
, mCfgMgr(cfg) , mCfgMgr(cfg)
, mGraphicsSettings(graphicsSetting) , mEngineSettings(engineSettings)
{ {
setObjectName ("GraphicsPage"); setObjectName ("GraphicsPage");
setupUi(this); setupUi(this);
@ -80,25 +80,26 @@ bool Launcher::GraphicsPage::loadSettings()
if (!setupSDL()) if (!setupSDL())
return false; return false;
if (mGraphicsSettings.value(QString("Video/vsync")) == QLatin1String("true")) if (mEngineSettings.getBool("vsync", "Video"))
vSyncCheckBox->setCheckState(Qt::Checked); vSyncCheckBox->setCheckState(Qt::Checked);
if (mGraphicsSettings.value(QString("Video/fullscreen")) == QLatin1String("true")) if (mEngineSettings.getBool("fullscreen", "Video"))
fullScreenCheckBox->setCheckState(Qt::Checked); fullScreenCheckBox->setCheckState(Qt::Checked);
if (mGraphicsSettings.value(QString("Video/window border")) == QLatin1String("true")) if (mEngineSettings.getBool("window border", "Video"))
windowBorderCheckBox->setCheckState(Qt::Checked); windowBorderCheckBox->setCheckState(Qt::Checked);
int aaIndex = antiAliasingComboBox->findText(mGraphicsSettings.value(QString("Video/antialiasing"))); // aaValue is the actual value (0, 1, 2, 4, 8, 16)
int aaValue = mEngineSettings.getInt("antialiasing", "Video");
// aaIndex is the index into the allowed values in the pull down.
int aaIndex = antiAliasingComboBox->findText(QString::number(aaValue));
if (aaIndex != -1) if (aaIndex != -1)
antiAliasingComboBox->setCurrentIndex(aaIndex); antiAliasingComboBox->setCurrentIndex(aaIndex);
QString width = mGraphicsSettings.value(QString("Video/resolution x")); int width = mEngineSettings.getInt("resolution x", "Video");
QString height = mGraphicsSettings.value(QString("Video/resolution y")); int height = mEngineSettings.getInt("resolution y", "Video");
QString resolution = width + QString(" x ") + height; QString resolution = QString::number(width) + QString(" x ") + QString::number(height);
QString screen = mGraphicsSettings.value(QString("Video/screen")); screenComboBox->setCurrentIndex(mEngineSettings.getInt("screen", "Video"));
screenComboBox->setCurrentIndex(screen.toInt());
int resIndex = resolutionComboBox->findText(resolution, Qt::MatchStartsWith); int resIndex = resolutionComboBox->findText(resolution, Qt::MatchStartsWith);
@ -107,9 +108,8 @@ bool Launcher::GraphicsPage::loadSettings()
resolutionComboBox->setCurrentIndex(resIndex); resolutionComboBox->setCurrentIndex(resIndex);
} else { } else {
customRadioButton->toggle(); customRadioButton->toggle();
customWidthSpinBox->setValue(width.toInt()); customWidthSpinBox->setValue(width);
customHeightSpinBox->setValue(height.toInt()); customHeightSpinBox->setValue(height);
} }
return true; return true;
@ -117,31 +117,29 @@ bool Launcher::GraphicsPage::loadSettings()
void Launcher::GraphicsPage::saveSettings() void Launcher::GraphicsPage::saveSettings()
{ {
vSyncCheckBox->checkState() ? mGraphicsSettings.setValue(QString("Video/vsync"), QString("true")) mEngineSettings.setBool("vsync", "Video", vSyncCheckBox->checkState());
: mGraphicsSettings.setValue(QString("Video/vsync"), QString("false")); mEngineSettings.setBool("fullscreen", "Video", fullScreenCheckBox->checkState());
mEngineSettings.setBool("window border", "Video", windowBorderCheckBox->checkState());
fullScreenCheckBox->checkState() ? mGraphicsSettings.setValue(QString("Video/fullscreen"), QString("true"))
: mGraphicsSettings.setValue(QString("Video/fullscreen"), QString("false"));
windowBorderCheckBox->checkState() ? mGraphicsSettings.setValue(QString("Video/window border"), QString("true"))
: mGraphicsSettings.setValue(QString("Video/window border"), QString("false"));
mGraphicsSettings.setValue(QString("Video/antialiasing"), antiAliasingComboBox->currentText());
// The atoi() call is safe because the pull down constrains the string values.
int aaValue = atoi(antiAliasingComboBox->currentText().toLatin1().data());
mEngineSettings.setInt("antialiasing", "Video", aaValue);
if (standardRadioButton->isChecked()) { if (standardRadioButton->isChecked()) {
QRegExp resolutionRe(QString("(\\d+) x (\\d+).*")); QRegExp resolutionRe(QString("(\\d+) x (\\d+).*"));
if (resolutionRe.exactMatch(resolutionComboBox->currentText().simplified())) { if (resolutionRe.exactMatch(resolutionComboBox->currentText().simplified())) {
mGraphicsSettings.setValue(QString("Video/resolution x"), resolutionRe.cap(1)); // The atoi() call is safe because the pull down constrains the string values.
mGraphicsSettings.setValue(QString("Video/resolution y"), resolutionRe.cap(2)); int width = atoi(resolutionRe.cap(1).toLatin1().data());
int height = atoi(resolutionRe.cap(2).toLatin1().data());
mEngineSettings.setInt("resolution x", "Video", width);
mEngineSettings.setInt("resolution y", "Video", height);
} }
} else { } else {
mGraphicsSettings.setValue(QString("Video/resolution x"), QString::number(customWidthSpinBox->value())); mEngineSettings.setInt("resolution x", "Video", customWidthSpinBox->value());
mGraphicsSettings.setValue(QString("Video/resolution y"), QString::number(customHeightSpinBox->value())); mEngineSettings.setInt("resolution y", "Video", customHeightSpinBox->value());
} }
mGraphicsSettings.setValue(QString("Video/screen"), QString::number(screenComboBox->currentIndex())); mEngineSettings.setInt("screen", "Video", screenComboBox->currentIndex());
} }
QStringList Launcher::GraphicsPage::getAvailableResolutions(int screen) QStringList Launcher::GraphicsPage::getAvailableResolutions(int screen)

@ -5,6 +5,8 @@
#include "ui_graphicspage.h" #include "ui_graphicspage.h"
#include <components/settings/settings.hpp>
namespace Files { struct ConfigurationManager; } namespace Files { struct ConfigurationManager; }
namespace Launcher namespace Launcher
@ -16,7 +18,7 @@ namespace Launcher
Q_OBJECT Q_OBJECT
public: public:
GraphicsPage(Files::ConfigurationManager &cfg, GraphicsSettings &graphicsSettings, QWidget *parent = 0); GraphicsPage(Files::ConfigurationManager &cfg, Settings::Manager &engineSettings, QWidget *parent = 0);
void saveSettings(); void saveSettings();
bool loadSettings(); bool loadSettings();
@ -30,7 +32,7 @@ namespace Launcher
private: private:
Files::ConfigurationManager &mCfgMgr; Files::ConfigurationManager &mCfgMgr;
GraphicsSettings &mGraphicsSettings; Settings::Manager &mEngineSettings;
QStringList getAvailableResolutions(int screen); QStringList getAvailableResolutions(int screen);
QRect getMaximumResolution(); QRect getMaximumResolution();

@ -105,7 +105,7 @@ void Launcher::MainDialog::createPages()
{ {
mPlayPage = new PlayPage(this); mPlayPage = new PlayPage(this);
mDataFilesPage = new DataFilesPage(mCfgMgr, mGameSettings, mLauncherSettings, this); mDataFilesPage = new DataFilesPage(mCfgMgr, mGameSettings, mLauncherSettings, this);
mGraphicsPage = new GraphicsPage(mCfgMgr, mGraphicsSettings, this); mGraphicsPage = new GraphicsPage(mCfgMgr, mEngineSettings, this);
mSettingsPage = new SettingsPage(mCfgMgr, mGameSettings, mLauncherSettings, this); mSettingsPage = new SettingsPage(mCfgMgr, mGameSettings, mLauncherSettings, this);
// Set the combobox of the play page to imitate the combobox on the datafilespage // Set the combobox of the play page to imitate the combobox on the datafilespage
@ -381,55 +381,64 @@ bool Launcher::MainDialog::setupGameSettings()
return true; return true;
} }
bool Launcher::MainDialog::setupGraphicsSettings() void cfgError(const QString& title, const QString& msg) {
{
mGraphicsSettings.setMultiValueEnabled(false);
QString userPath = QString::fromUtf8(mCfgMgr.getUserConfigPath().string().c_str());
QString globalPath = QString::fromUtf8(mCfgMgr.getGlobalPath().string().c_str());
QFile localDefault(QString("settings-default.cfg"));
QFile globalDefault(globalPath + QString("settings-default.cfg"));
if (!localDefault.exists() && !globalDefault.exists()) {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setWindowTitle(tr("Error reading OpenMW configuration file")); msgBox.setWindowTitle(title);
msgBox.setIcon(QMessageBox::Critical); msgBox.setIcon(QMessageBox::Critical);
msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setText(tr("<br><b>Could not find settings-default.cfg</b><br><br> \ msgBox.setText(msg);
msgBox.exec();
}
bool Launcher::MainDialog::setupGraphicsSettings()
{
// This method is almost a copy of OMW::Engine::loadSettings(). They should definitely
// remain consistent, and possibly be merged into a shared component. At the very least
// the filenames should be in the CfgMgr component.
// 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";
std::string defaultPath;
// Prefer the settings-default.cfg in the current directory.
if (boost::filesystem::exists(localDefault))
defaultPath = localDefault;
else if (boost::filesystem::exists(globalDefault))
defaultPath = globalDefault;
// Something's very wrong if we can't find the file at all.
else {
cfgError(tr("Error reading OpenMW configuration file"),
tr("<br><b>Could not find settings-default.cfg</b><br><br> \
The problem may be due to an incomplete installation of OpenMW.<br> \ The problem may be due to an incomplete installation of OpenMW.<br> \
Reinstalling OpenMW may resolve the problem.")); Reinstalling OpenMW may resolve the problem."));
msgBox.exec();
return false; return false;
} }
// Load the default settings, report any parsing errors.
QStringList paths; try {
paths.append(globalPath + QString("settings-default.cfg")); mEngineSettings.loadDefault(defaultPath);
paths.append(QString("settings-default.cfg")); }
paths.append(userPath + QString("settings.cfg")); catch (std::exception& e) {
std::string msg = "<br><b>Error reading settings-default.cfg</b><br><br>" +
foreach (const QString &path, paths) { defaultPath + "<br><br>" + e.what();
qDebug() << "Loading config file:" << qPrintable(path); cfgError(tr("Error reading OpenMW configuration file"), tr(msg.c_str()));
QFile file(path);
if (file.exists()) {
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QMessageBox msgBox;
msgBox.setWindowTitle(tr("Error opening OpenMW configuration file"));
msgBox.setIcon(QMessageBox::Critical);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setText(tr("<br><b>Could not open %0 for reading</b><br><br> \
Please make sure you have the right permissions \
and try again.<br>").arg(file.fileName()));
msgBox.exec();
return false; return false;
} }
QTextStream stream(&file);
stream.setCodec(QTextCodec::codecForName("UTF-8"));
mGraphicsSettings.readFile(stream); // Load user settings if they exist
const std::string userPath = mCfgMgr.getUserConfigPath().string() + "settings.cfg";
// User settings are not required to exist, so if they don't we're done.
if (!boost::filesystem::exists(userPath)) return true;
try {
mEngineSettings.loadUser(userPath);
} }
file.close(); catch (std::exception& e) {
std::string msg = "<br><b>Error reading settings-default.cfg</b><br><br>" +
defaultPath + "<br><br>" + e.what();
cfgError(tr("Error reading OpenMW configuration file"), tr(msg.c_str()));
return false;
} }
return true; return true;
@ -511,28 +520,17 @@ bool Launcher::MainDialog::writeSettings()
file.close(); file.close();
// Graphics settings // Graphics settings
file.setFileName(userPath + QString("settings.cfg")); const std::string settingsPath = mCfgMgr.getUserConfigPath().string() + "settings.cfg";
try {
if (!file.open(QIODevice::ReadWrite | QIODevice::Text | QIODevice::Truncate)) { mEngineSettings.saveUser(settingsPath);
// File cannot be opened or created }
QMessageBox msgBox; catch (std::exception& e) {
msgBox.setWindowTitle(tr("Error writing OpenMW configuration file")); std::string msg = "<br><b>Error writing settings.cfg</b><br><br>" +
msgBox.setIcon(QMessageBox::Critical); settingsPath + "<br><br>" + e.what();
msgBox.setStandardButtons(QMessageBox::Ok); cfgError(tr("Error reading OpenMW configuration file"), tr(msg.c_str()));
msgBox.setText(tr("<br><b>Could not open or create %0 for writing</b><br><br> \
Please make sure you have the right permissions \
and try again.<br>").arg(file.fileName()));
msgBox.exec();
return false; return false;
} }
QTextStream stream(&file);
stream.setDevice(&file);
stream.setCodec(QTextCodec::codecForName("UTF-8"));
mGraphicsSettings.writeFile(stream);
file.close();
// Launcher settings // Launcher settings
file.setFileName(userPath + QString(Config::LauncherSettings::sLauncherConfigFileName)); file.setFileName(userPath + QString(Config::LauncherSettings::sLauncherConfigFileName));
@ -549,6 +547,7 @@ bool Launcher::MainDialog::writeSettings()
return false; return false;
} }
QTextStream stream(&file);
stream.setDevice(&file); stream.setDevice(&file);
stream.setCodec(QTextCodec::codecForName("UTF-8")); stream.setCodec(QTextCodec::codecForName("UTF-8"));

@ -13,7 +13,7 @@
#include <components/config/gamesettings.hpp> #include <components/config/gamesettings.hpp>
#include <components/config/launchersettings.hpp> #include <components/config/launchersettings.hpp>
#include "settings/graphicssettings.hpp" #include <components/settings/settings.hpp>
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
@ -93,7 +93,7 @@ namespace Launcher
Files::ConfigurationManager mCfgMgr; Files::ConfigurationManager mCfgMgr;
Config::GameSettings mGameSettings; Config::GameSettings mGameSettings;
GraphicsSettings mGraphicsSettings; Settings::Manager mEngineSettings;
Config::LauncherSettings mLauncherSettings; Config::LauncherSettings mLauncherSettings;
}; };

@ -298,8 +298,8 @@ void OMW::Engine::setSkipMenu (bool skipMenu, bool newGame)
std::string OMW::Engine::loadSettings (Settings::Manager & settings) std::string OMW::Engine::loadSettings (Settings::Manager & settings)
{ {
// Create the settings manager and load default settings file // Create the settings manager and load default settings file
const std::string localdefault = mCfgMgr.getLocalPath().string() + "/settings-default.cfg"; const std::string localdefault = mCfgMgr.getLocalPath().string() + "settings-default.cfg";
const std::string globaldefault = mCfgMgr.getGlobalPath().string() + "/settings-default.cfg"; const std::string globaldefault = mCfgMgr.getGlobalPath().string() + "settings-default.cfg";
// prefer local // prefer local
if (boost::filesystem::exists(localdefault)) if (boost::filesystem::exists(localdefault))
@ -310,7 +310,7 @@ std::string OMW::Engine::loadSettings (Settings::Manager & settings)
throw std::runtime_error ("No default settings file found! Make sure the file \"settings-default.cfg\" was properly installed."); 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 // load user settings if they exist
const std::string settingspath = mCfgMgr.getUserConfigPath().string() + "/settings.cfg"; const std::string settingspath = mCfgMgr.getUserConfigPath().string() + "settings.cfg";
if (boost::filesystem::exists(settingspath)) if (boost::filesystem::exists(settingspath))
settings.loadUser(settingspath); settings.loadUser(settingspath);

@ -25,8 +25,6 @@ QStringList Config::LauncherSettings::subKeys(const QString &key)
QMap<QString, QString> settings = SettingsBase::getSettings(); QMap<QString, QString> settings = SettingsBase::getSettings();
QStringList keys = settings.uniqueKeys(); QStringList keys = settings.uniqueKeys();
qDebug() << keys;
QRegExp keyRe("(.+)/"); QRegExp keyRe("(.+)/");
QStringList result; QStringList result;

Loading…
Cancel
Save