mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:19:55 +00:00
Commit files that I thought wre in the previous commit. :-[ I'm
accustomed to the hg behavior of commiting all modified files by default.
This commit is contained in:
parent
18da95e4f8
commit
67c4b17581
8 changed files with 100 additions and 107 deletions
|
@ -7,8 +7,6 @@ set(LAUNCHER
|
|||
textslotmsgbox.cpp
|
||||
settingspage.cpp
|
||||
|
||||
settings/graphicssettings.cpp
|
||||
|
||||
utils/profilescombobox.cpp
|
||||
utils/textinputdialog.cpp
|
||||
utils/lineedit.cpp
|
||||
|
@ -24,8 +22,6 @@ set(LAUNCHER_HEADER
|
|||
textslotmsgbox.hpp
|
||||
settingspage.hpp
|
||||
|
||||
settings/graphicssettings.hpp
|
||||
|
||||
utils/profilescombobox.hpp
|
||||
utils/textinputdialog.hpp
|
||||
utils/lineedit.hpp
|
||||
|
|
|
@ -75,7 +75,7 @@ bool Launcher::DataFilesPage::loadSettings()
|
|||
QStringList profiles = mLauncherSettings.getContentLists();
|
||||
QString currentProfile = mLauncherSettings.getCurrentContentListName();
|
||||
|
||||
qDebug() << "current profile is: " << currentProfile;
|
||||
qDebug() << "The current profile is: " << currentProfile;
|
||||
|
||||
foreach (const QString &item, profiles)
|
||||
addProfile (item, false);
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#include <components/contentselector/model/naturalsort.hpp>
|
||||
|
||||
#include "settings/graphicssettings.hpp"
|
||||
#include <components/settings/settings.hpp>
|
||||
|
||||
QString getAspect(int x, int y)
|
||||
{
|
||||
|
@ -32,10 +32,10 @@ QString getAspect(int x, int y)
|
|||
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)
|
||||
, mCfgMgr(cfg)
|
||||
, mGraphicsSettings(graphicsSetting)
|
||||
, mEngineSettings(engineSettings)
|
||||
{
|
||||
setObjectName ("GraphicsPage");
|
||||
setupUi(this);
|
||||
|
@ -80,25 +80,26 @@ bool Launcher::GraphicsPage::loadSettings()
|
|||
if (!setupSDL())
|
||||
return false;
|
||||
|
||||
if (mGraphicsSettings.value(QString("Video/vsync")) == QLatin1String("true"))
|
||||
if (mEngineSettings.getBool("vsync", "Video"))
|
||||
vSyncCheckBox->setCheckState(Qt::Checked);
|
||||
|
||||
if (mGraphicsSettings.value(QString("Video/fullscreen")) == QLatin1String("true"))
|
||||
if (mEngineSettings.getBool("fullscreen", "Video"))
|
||||
fullScreenCheckBox->setCheckState(Qt::Checked);
|
||||
|
||||
if (mGraphicsSettings.value(QString("Video/window border")) == QLatin1String("true"))
|
||||
if (mEngineSettings.getBool("window border", "Video"))
|
||||
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)
|
||||
antiAliasingComboBox->setCurrentIndex(aaIndex);
|
||||
|
||||
QString width = mGraphicsSettings.value(QString("Video/resolution x"));
|
||||
QString height = mGraphicsSettings.value(QString("Video/resolution y"));
|
||||
QString resolution = width + QString(" x ") + height;
|
||||
QString screen = mGraphicsSettings.value(QString("Video/screen"));
|
||||
|
||||
screenComboBox->setCurrentIndex(screen.toInt());
|
||||
int width = mEngineSettings.getInt("resolution x", "Video");
|
||||
int height = mEngineSettings.getInt("resolution y", "Video");
|
||||
QString resolution = QString::number(width) + QString(" x ") + QString::number(height);
|
||||
screenComboBox->setCurrentIndex(mEngineSettings.getInt("screen", "Video"));
|
||||
|
||||
int resIndex = resolutionComboBox->findText(resolution, Qt::MatchStartsWith);
|
||||
|
||||
|
@ -107,9 +108,8 @@ bool Launcher::GraphicsPage::loadSettings()
|
|||
resolutionComboBox->setCurrentIndex(resIndex);
|
||||
} else {
|
||||
customRadioButton->toggle();
|
||||
customWidthSpinBox->setValue(width.toInt());
|
||||
customHeightSpinBox->setValue(height.toInt());
|
||||
|
||||
customWidthSpinBox->setValue(width);
|
||||
customHeightSpinBox->setValue(height);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -117,31 +117,29 @@ bool Launcher::GraphicsPage::loadSettings()
|
|||
|
||||
void Launcher::GraphicsPage::saveSettings()
|
||||
{
|
||||
vSyncCheckBox->checkState() ? mGraphicsSettings.setValue(QString("Video/vsync"), QString("true"))
|
||||
: mGraphicsSettings.setValue(QString("Video/vsync"), QString("false"));
|
||||
|
||||
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());
|
||||
mEngineSettings.setBool("vsync", "Video", vSyncCheckBox->checkState());
|
||||
mEngineSettings.setBool("fullscreen", "Video", fullScreenCheckBox->checkState());
|
||||
mEngineSettings.setBool("window border", "Video", windowBorderCheckBox->checkState());
|
||||
|
||||
// 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()) {
|
||||
QRegExp resolutionRe(QString("(\\d+) x (\\d+).*"));
|
||||
|
||||
if (resolutionRe.exactMatch(resolutionComboBox->currentText().simplified())) {
|
||||
mGraphicsSettings.setValue(QString("Video/resolution x"), resolutionRe.cap(1));
|
||||
mGraphicsSettings.setValue(QString("Video/resolution y"), resolutionRe.cap(2));
|
||||
// The atoi() call is safe because the pull down constrains the string values.
|
||||
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 {
|
||||
mGraphicsSettings.setValue(QString("Video/resolution x"), QString::number(customWidthSpinBox->value()));
|
||||
mGraphicsSettings.setValue(QString("Video/resolution y"), QString::number(customHeightSpinBox->value()));
|
||||
mEngineSettings.setInt("resolution x", "Video", customWidthSpinBox->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)
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
#include "ui_graphicspage.h"
|
||||
|
||||
#include <components/settings/settings.hpp>
|
||||
|
||||
namespace Files { struct ConfigurationManager; }
|
||||
|
||||
namespace Launcher
|
||||
|
@ -16,7 +18,7 @@ namespace Launcher
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GraphicsPage(Files::ConfigurationManager &cfg, GraphicsSettings &graphicsSettings, QWidget *parent = 0);
|
||||
GraphicsPage(Files::ConfigurationManager &cfg, Settings::Manager &engineSettings, QWidget *parent = 0);
|
||||
|
||||
void saveSettings();
|
||||
bool loadSettings();
|
||||
|
@ -30,7 +32,7 @@ namespace Launcher
|
|||
|
||||
private:
|
||||
Files::ConfigurationManager &mCfgMgr;
|
||||
GraphicsSettings &mGraphicsSettings;
|
||||
Settings::Manager &mEngineSettings;
|
||||
|
||||
QStringList getAvailableResolutions(int screen);
|
||||
QRect getMaximumResolution();
|
||||
|
|
|
@ -105,7 +105,7 @@ void Launcher::MainDialog::createPages()
|
|||
{
|
||||
mPlayPage = new PlayPage(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);
|
||||
|
||||
// Set the combobox of the play page to imitate the combobox on the datafilespage
|
||||
|
@ -381,55 +381,64 @@ bool Launcher::MainDialog::setupGameSettings()
|
|||
return true;
|
||||
}
|
||||
|
||||
void cfgError(const QString& title, const QString& msg) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(title);
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(msg);
|
||||
msgBox.exec();
|
||||
}
|
||||
|
||||
bool Launcher::MainDialog::setupGraphicsSettings()
|
||||
{
|
||||
mGraphicsSettings.setMultiValueEnabled(false);
|
||||
// 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.
|
||||
|
||||
QString userPath = QString::fromUtf8(mCfgMgr.getUserConfigPath().string().c_str());
|
||||
QString globalPath = QString::fromUtf8(mCfgMgr.getGlobalPath().string().c_str());
|
||||
// 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;
|
||||
|
||||
QFile localDefault(QString("settings-default.cfg"));
|
||||
QFile globalDefault(globalPath + QString("settings-default.cfg"));
|
||||
|
||||
if (!localDefault.exists() && !globalDefault.exists()) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Error reading OpenMW configuration file"));
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setText(tr("<br><b>Could not find settings-default.cfg</b><br><br> \
|
||||
// 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> \
|
||||
Reinstalling OpenMW may resolve the problem."));
|
||||
msgBox.exec();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
QStringList paths;
|
||||
paths.append(globalPath + QString("settings-default.cfg"));
|
||||
paths.append(QString("settings-default.cfg"));
|
||||
paths.append(userPath + QString("settings.cfg"));
|
||||
|
||||
foreach (const QString &path, paths) {
|
||||
qDebug() << "Loading config file:" << qPrintable(path);
|
||||
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();
|
||||
// Load the default settings, report any parsing errors.
|
||||
try {
|
||||
mEngineSettings.loadDefault(defaultPath);
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
|
@ -511,28 +520,17 @@ bool Launcher::MainDialog::writeSettings()
|
|||
file.close();
|
||||
|
||||
// Graphics settings
|
||||
file.setFileName(userPath + QString("settings.cfg"));
|
||||
|
||||
if (!file.open(QIODevice::ReadWrite | QIODevice::Text | QIODevice::Truncate)) {
|
||||
// File cannot be opened or created
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Error writing OpenMW configuration file"));
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
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();
|
||||
const std::string settingsPath = mCfgMgr.getUserConfigPath().string() + "settings.cfg";
|
||||
try {
|
||||
mEngineSettings.saveUser(settingsPath);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
std::string msg = "<br><b>Error writing settings.cfg</b><br><br>" +
|
||||
settingsPath + "<br><br>" + e.what();
|
||||
cfgError(tr("Error reading OpenMW configuration file"), tr(msg.c_str()));
|
||||
return false;
|
||||
}
|
||||
|
||||
QTextStream stream(&file);
|
||||
stream.setDevice(&file);
|
||||
stream.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||
|
||||
mGraphicsSettings.writeFile(stream);
|
||||
file.close();
|
||||
|
||||
// Launcher settings
|
||||
file.setFileName(userPath + QString(Config::LauncherSettings::sLauncherConfigFileName));
|
||||
|
||||
|
@ -549,6 +547,7 @@ bool Launcher::MainDialog::writeSettings()
|
|||
return false;
|
||||
}
|
||||
|
||||
QTextStream stream(&file);
|
||||
stream.setDevice(&file);
|
||||
stream.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <components/config/gamesettings.hpp>
|
||||
#include <components/config/launchersettings.hpp>
|
||||
|
||||
#include "settings/graphicssettings.hpp"
|
||||
#include <components/settings/settings.hpp>
|
||||
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
|
@ -93,7 +93,7 @@ namespace Launcher
|
|||
Files::ConfigurationManager mCfgMgr;
|
||||
|
||||
Config::GameSettings mGameSettings;
|
||||
GraphicsSettings mGraphicsSettings;
|
||||
Settings::Manager mEngineSettings;
|
||||
Config::LauncherSettings mLauncherSettings;
|
||||
|
||||
};
|
||||
|
|
|
@ -298,8 +298,8 @@ void OMW::Engine::setSkipMenu (bool skipMenu, bool newGame)
|
|||
std::string OMW::Engine::loadSettings (Settings::Manager & settings)
|
||||
{
|
||||
// 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";
|
||||
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))
|
||||
|
@ -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.");
|
||||
|
||||
// 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))
|
||||
settings.loadUser(settingspath);
|
||||
|
||||
|
|
|
@ -25,8 +25,6 @@ QStringList Config::LauncherSettings::subKeys(const QString &key)
|
|||
QMap<QString, QString> settings = SettingsBase::getSettings();
|
||||
QStringList keys = settings.uniqueKeys();
|
||||
|
||||
qDebug() << keys;
|
||||
|
||||
QRegExp keyRe("(.+)/");
|
||||
|
||||
QStringList result;
|
||||
|
|
Loading…
Reference in a new issue