forked from teamnwah/openmw-tes3coop
Moved launcher settings stuff into components, so they can be reused in the wizard
This commit is contained in:
parent
3a37761d76
commit
095ff4e17a
11 changed files with 42 additions and 43 deletions
|
@ -6,9 +6,7 @@ set(LAUNCHER
|
||||||
playpage.cpp
|
playpage.cpp
|
||||||
textslotmsgbox.cpp
|
textslotmsgbox.cpp
|
||||||
|
|
||||||
settings/gamesettings.cpp
|
|
||||||
settings/graphicssettings.cpp
|
settings/graphicssettings.cpp
|
||||||
settings/launchersettings.cpp
|
|
||||||
|
|
||||||
utils/checkablemessagebox.cpp
|
utils/checkablemessagebox.cpp
|
||||||
utils/profilescombobox.cpp
|
utils/profilescombobox.cpp
|
||||||
|
@ -28,10 +26,7 @@ set(LAUNCHER_HEADER
|
||||||
playpage.hpp
|
playpage.hpp
|
||||||
textslotmsgbox.hpp
|
textslotmsgbox.hpp
|
||||||
|
|
||||||
settings/gamesettings.hpp
|
|
||||||
settings/graphicssettings.hpp
|
settings/graphicssettings.hpp
|
||||||
settings/launchersettings.hpp
|
|
||||||
settings/settingsbase.hpp
|
|
||||||
|
|
||||||
utils/checkablemessagebox.hpp
|
utils/checkablemessagebox.hpp
|
||||||
utils/profilescombobox.hpp
|
utils/profilescombobox.hpp
|
||||||
|
|
|
@ -9,18 +9,16 @@
|
||||||
#include <components/files/configurationmanager.hpp>
|
#include <components/files/configurationmanager.hpp>
|
||||||
|
|
||||||
#include <components/contentselector/model/esmfile.hpp>
|
#include <components/contentselector/model/esmfile.hpp>
|
||||||
|
|
||||||
#include <components/contentselector/model/naturalsort.hpp>
|
#include <components/contentselector/model/naturalsort.hpp>
|
||||||
|
#include <components/contentselector/view/contentselector.hpp>
|
||||||
|
|
||||||
|
#include <components/config/gamesettings.hpp>
|
||||||
|
#include <components/config/launchersettings.hpp>
|
||||||
|
|
||||||
#include "utils/textinputdialog.hpp"
|
#include "utils/textinputdialog.hpp"
|
||||||
#include "utils/profilescombobox.hpp"
|
#include "utils/profilescombobox.hpp"
|
||||||
|
|
||||||
#include "settings/gamesettings.hpp"
|
Launcher::DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, Config::GameSettings &gameSettings, Config::LauncherSettings &launcherSettings, QWidget *parent)
|
||||||
#include "settings/launchersettings.hpp"
|
|
||||||
|
|
||||||
#include "components/contentselector/view/contentselector.hpp"
|
|
||||||
|
|
||||||
Launcher::DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gameSettings, LauncherSettings &launcherSettings, QWidget *parent)
|
|
||||||
: mCfgMgr(cfg)
|
: mCfgMgr(cfg)
|
||||||
, mGameSettings(gameSettings)
|
, mGameSettings(gameSettings)
|
||||||
, mLauncherSettings(launcherSettings)
|
, mLauncherSettings(launcherSettings)
|
||||||
|
|
|
@ -14,12 +14,12 @@ class QMenu;
|
||||||
|
|
||||||
namespace Files { struct ConfigurationManager; }
|
namespace Files { struct ConfigurationManager; }
|
||||||
namespace ContentSelectorView { class ContentSelector; }
|
namespace ContentSelectorView { class ContentSelector; }
|
||||||
|
namespace Config { class GameSettings;
|
||||||
|
class LauncherSettings; }
|
||||||
|
|
||||||
namespace Launcher
|
namespace Launcher
|
||||||
{
|
{
|
||||||
class TextInputDialog;
|
class TextInputDialog;
|
||||||
class GameSettings;
|
|
||||||
class LauncherSettings;
|
|
||||||
class ProfilesComboBox;
|
class ProfilesComboBox;
|
||||||
|
|
||||||
class DataFilesPage : public QWidget
|
class DataFilesPage : public QWidget
|
||||||
|
@ -30,8 +30,8 @@ namespace Launcher
|
||||||
Ui::DataFilesPage ui;
|
Ui::DataFilesPage ui;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DataFilesPage (Files::ConfigurationManager &cfg, GameSettings &gameSettings,
|
explicit DataFilesPage (Files::ConfigurationManager &cfg, Config::GameSettings &gameSettings,
|
||||||
LauncherSettings &launcherSettings, QWidget *parent = 0);
|
Config::LauncherSettings &launcherSettings, QWidget *parent = 0);
|
||||||
|
|
||||||
QAbstractItemModel* profilesModel() const;
|
QAbstractItemModel* profilesModel() const;
|
||||||
|
|
||||||
|
@ -62,8 +62,8 @@ namespace Launcher
|
||||||
|
|
||||||
Files::ConfigurationManager &mCfgMgr;
|
Files::ConfigurationManager &mCfgMgr;
|
||||||
|
|
||||||
GameSettings &mGameSettings;
|
Config::GameSettings &mGameSettings;
|
||||||
LauncherSettings &mLauncherSettings;
|
Config::LauncherSettings &mLauncherSettings;
|
||||||
|
|
||||||
QString mDataLocal;
|
QString mDataLocal;
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,10 @@
|
||||||
#ifndef Q_MOC_RUN
|
#ifndef Q_MOC_RUN
|
||||||
#include <components/files/configurationmanager.hpp>
|
#include <components/files/configurationmanager.hpp>
|
||||||
#endif
|
#endif
|
||||||
#include "settings/gamesettings.hpp"
|
#include <components/config/gamesettings.hpp>
|
||||||
|
#include <components/config/launchersettings.hpp>
|
||||||
|
|
||||||
#include "settings/graphicssettings.hpp"
|
#include "settings/graphicssettings.hpp"
|
||||||
#include "settings/launchersettings.hpp"
|
|
||||||
|
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
|
|
||||||
|
@ -60,9 +61,9 @@ namespace Launcher
|
||||||
|
|
||||||
Files::ConfigurationManager mCfgMgr;
|
Files::ConfigurationManager mCfgMgr;
|
||||||
|
|
||||||
GameSettings mGameSettings;
|
Config::GameSettings mGameSettings;
|
||||||
GraphicsSettings mGraphicsSettings;
|
GraphicsSettings mGraphicsSettings;
|
||||||
LauncherSettings mLauncherSettings;
|
Config::LauncherSettings mLauncherSettings;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#ifndef GRAPHICSSETTINGS_HPP
|
#ifndef GRAPHICSSETTINGS_HPP
|
||||||
#define GRAPHICSSETTINGS_HPP
|
#define GRAPHICSSETTINGS_HPP
|
||||||
|
|
||||||
#include "settingsbase.hpp"
|
#include <components/config/settingsbase.hpp>
|
||||||
|
|
||||||
namespace Launcher
|
namespace Launcher
|
||||||
{
|
{
|
||||||
class GraphicsSettings : public SettingsBase<QMap<QString, QString> >
|
class GraphicsSettings : public Config::SettingsBase<QMap<QString, QString> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GraphicsSettings();
|
GraphicsSettings();
|
||||||
|
|
|
@ -75,8 +75,8 @@ add_component_dir (loadinglistener
|
||||||
)
|
)
|
||||||
|
|
||||||
add_component_dir (ogreinit
|
add_component_dir (ogreinit
|
||||||
ogreinit ogreplugin
|
ogreinit ogreplugin
|
||||||
)
|
)
|
||||||
|
|
||||||
set (ESM_UI ${CMAKE_SOURCE_DIR}/files/ui/contentselector.ui
|
set (ESM_UI ${CMAKE_SOURCE_DIR}/files/ui/contentselector.ui
|
||||||
)
|
)
|
||||||
|
@ -84,11 +84,16 @@ set (ESM_UI ${CMAKE_SOURCE_DIR}/files/ui/contentselector.ui
|
||||||
find_package(Qt4 COMPONENTS QtCore QtGui)
|
find_package(Qt4 COMPONENTS QtCore QtGui)
|
||||||
|
|
||||||
if(QT_QTGUI_LIBRARY AND QT_QTCORE_LIBRARY)
|
if(QT_QTGUI_LIBRARY AND QT_QTCORE_LIBRARY)
|
||||||
add_component_qt_dir (contentselector
|
add_component_qt_dir (contentselector
|
||||||
model/modelitem model/esmfile
|
model/modelitem model/esmfile
|
||||||
model/naturalsort model/contentmodel
|
model/naturalsort model/contentmodel
|
||||||
view/combobox view/contentselector
|
view/combobox view/contentselector
|
||||||
)
|
)
|
||||||
|
add_component_qt_dir (config
|
||||||
|
gamesettings
|
||||||
|
launchersettings
|
||||||
|
settingsbase
|
||||||
|
)
|
||||||
|
|
||||||
include(${QT_USE_FILE})
|
include(${QT_USE_FILE})
|
||||||
QT4_WRAP_UI(ESM_UI_HDR ${ESM_UI})
|
QT4_WRAP_UI(ESM_UI_HDR ${ESM_UI})
|
||||||
|
|
|
@ -27,16 +27,16 @@ namespace boost
|
||||||
#endif /* (BOOST_VERSION <= 104600) */
|
#endif /* (BOOST_VERSION <= 104600) */
|
||||||
|
|
||||||
|
|
||||||
Launcher::GameSettings::GameSettings(Files::ConfigurationManager &cfg)
|
Config::GameSettings::GameSettings(Files::ConfigurationManager &cfg)
|
||||||
: mCfgMgr(cfg)
|
: mCfgMgr(cfg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Launcher::GameSettings::~GameSettings()
|
Config::GameSettings::~GameSettings()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Launcher::GameSettings::validatePaths()
|
void Config::GameSettings::validatePaths()
|
||||||
{
|
{
|
||||||
if (mSettings.isEmpty() || !mDataDirs.isEmpty())
|
if (mSettings.isEmpty() || !mDataDirs.isEmpty())
|
||||||
return; // Don't re-validate paths if they are already parsed
|
return; // Don't re-validate paths if they are already parsed
|
||||||
|
@ -82,14 +82,14 @@ void Launcher::GameSettings::validatePaths()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Launcher::GameSettings::values(const QString &key, const QStringList &defaultValues)
|
QStringList Config::GameSettings::values(const QString &key, const QStringList &defaultValues)
|
||||||
{
|
{
|
||||||
if (!mSettings.values(key).isEmpty())
|
if (!mSettings.values(key).isEmpty())
|
||||||
return mSettings.values(key);
|
return mSettings.values(key);
|
||||||
return defaultValues;
|
return defaultValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Launcher::GameSettings::readFile(QTextStream &stream)
|
bool Config::GameSettings::readFile(QTextStream &stream)
|
||||||
{
|
{
|
||||||
QMap<QString, QString> cache;
|
QMap<QString, QString> cache;
|
||||||
QRegExp keyRe("^([^=]+)\\s*=\\s*(.+)$");
|
QRegExp keyRe("^([^=]+)\\s*=\\s*(.+)$");
|
||||||
|
@ -131,7 +131,7 @@ bool Launcher::GameSettings::readFile(QTextStream &stream)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Launcher::GameSettings::writeFile(QTextStream &stream)
|
bool Config::GameSettings::writeFile(QTextStream &stream)
|
||||||
{
|
{
|
||||||
// Iterate in reverse order to preserve insertion order
|
// Iterate in reverse order to preserve insertion order
|
||||||
QMapIterator<QString, QString> i(mSettings);
|
QMapIterator<QString, QString> i(mSettings);
|
||||||
|
@ -170,7 +170,7 @@ bool Launcher::GameSettings::writeFile(QTextStream &stream)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Launcher::GameSettings::hasMaster()
|
bool Config::GameSettings::hasMaster()
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
QStringList content = mSettings.values(QString("content"));
|
QStringList content = mSettings.values(QString("content"));
|
|
@ -14,7 +14,7 @@ namespace Files
|
||||||
struct ConfigurationManager;
|
struct ConfigurationManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Launcher
|
namespace Config
|
||||||
{
|
{
|
||||||
class GameSettings
|
class GameSettings
|
||||||
{
|
{
|
|
@ -7,15 +7,15 @@
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
Launcher::LauncherSettings::LauncherSettings()
|
Config::LauncherSettings::LauncherSettings()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Launcher::LauncherSettings::~LauncherSettings()
|
Config::LauncherSettings::~LauncherSettings()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Launcher::LauncherSettings::values(const QString &key, Qt::MatchFlags flags)
|
QStringList Config::LauncherSettings::values(const QString &key, Qt::MatchFlags flags)
|
||||||
{
|
{
|
||||||
QMap<QString, QString> settings = SettingsBase::getSettings();
|
QMap<QString, QString> settings = SettingsBase::getSettings();
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ QStringList Launcher::LauncherSettings::values(const QString &key, Qt::MatchFlag
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Launcher::LauncherSettings::subKeys(const QString &key)
|
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();
|
||||||
|
@ -60,7 +60,7 @@ QStringList Launcher::LauncherSettings::subKeys(const QString &key)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Launcher::LauncherSettings::writeFile(QTextStream &stream)
|
bool Config::LauncherSettings::writeFile(QTextStream &stream)
|
||||||
{
|
{
|
||||||
QString sectionPrefix;
|
QString sectionPrefix;
|
||||||
QRegExp sectionRe("([^/]+)/(.+)$");
|
QRegExp sectionRe("([^/]+)/(.+)$");
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "settingsbase.hpp"
|
#include "settingsbase.hpp"
|
||||||
|
|
||||||
namespace Launcher
|
namespace Config
|
||||||
{
|
{
|
||||||
class LauncherSettings : public SettingsBase<QMap<QString, QString> >
|
class LauncherSettings : public SettingsBase<QMap<QString, QString> >
|
||||||
{
|
{
|
|
@ -7,7 +7,7 @@
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
|
||||||
namespace Launcher
|
namespace Config
|
||||||
{
|
{
|
||||||
template <class Map>
|
template <class Map>
|
||||||
class SettingsBase
|
class SettingsBase
|
Loading…
Reference in a new issue