2013-02-11 15:01:00 +01:00
|
|
|
#ifndef LAUNCHERSETTINGS_HPP
|
|
|
|
#define LAUNCHERSETTINGS_HPP
|
|
|
|
|
2023-01-08 19:02:03 +01:00
|
|
|
#include <QString>
|
|
|
|
#include <QStringList>
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
class QTextStream;
|
2013-02-11 15:01:00 +01:00
|
|
|
|
2013-12-25 00:50:25 +01:00
|
|
|
namespace Config
|
2013-02-11 15:01:00 +01:00
|
|
|
{
|
2023-01-08 19:02:03 +01:00
|
|
|
class GameSettings;
|
|
|
|
|
|
|
|
class LauncherSettings
|
2013-10-25 11:17:26 -05:00
|
|
|
{
|
|
|
|
public:
|
2023-01-08 19:02:03 +01:00
|
|
|
static constexpr char sLauncherConfigFileName[] = "launcher.cfg";
|
|
|
|
|
|
|
|
struct Settings
|
|
|
|
{
|
|
|
|
QString mLanguage;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MainWindow
|
|
|
|
{
|
|
|
|
int mWidth = 0;
|
|
|
|
int mHeight = 0;
|
|
|
|
int mPosX = 0;
|
|
|
|
int mPosY = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct General
|
|
|
|
{
|
|
|
|
bool mFirstRun = true;
|
|
|
|
MainWindow mMainWindow;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Profile
|
|
|
|
{
|
|
|
|
QStringList mArchives;
|
|
|
|
QStringList mData;
|
|
|
|
QStringList mContent;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Profiles
|
|
|
|
{
|
|
|
|
QString mCurrentProfile;
|
|
|
|
std::map<QString, Profile> mValues;
|
|
|
|
};
|
|
|
|
|
|
|
|
void readFile(QTextStream& stream);
|
|
|
|
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
void writeFile(QTextStream& stream) const;
|
2015-01-10 18:46:47 +13:00
|
|
|
|
|
|
|
/// \return names of all Content Lists in the launcher's .cfg file.
|
|
|
|
QStringList getContentLists();
|
|
|
|
|
2015-03-03 11:23:50 +01:00
|
|
|
/// Set initially selected content list to match values from openmw.cfg, creating if necessary
|
2015-01-10 18:46:47 +13:00
|
|
|
void setContentList(const GameSettings& gameSettings);
|
|
|
|
|
|
|
|
/// Create a Content List (or replace if it already exists)
|
2020-04-26 15:31:39 +02:00
|
|
|
void setContentList(const QString& contentListName, const QStringList& dirNames,
|
|
|
|
const QStringList& archiveNames, const QStringList& fileNames);
|
2015-01-10 18:46:47 +13:00
|
|
|
|
2023-01-08 19:02:03 +01:00
|
|
|
void removeContentList(const QString& value) { mProfiles.mValues.erase(value); }
|
2015-01-10 18:46:47 +13:00
|
|
|
|
2023-01-08 19:02:03 +01:00
|
|
|
void setCurrentContentListName(const QString& value) { mProfiles.mCurrentProfile = value; }
|
2015-01-10 18:46:47 +13:00
|
|
|
|
2023-01-08 19:02:03 +01:00
|
|
|
QString getCurrentContentListName() const { return mProfiles.mCurrentProfile; }
|
2015-01-10 18:46:47 +13:00
|
|
|
|
2020-04-26 15:31:39 +02:00
|
|
|
QStringList getDataDirectoryList(const QString& contentListName) const;
|
|
|
|
QStringList getArchiveList(const QString& contentListName) const;
|
2015-01-10 18:46:47 +13:00
|
|
|
QStringList getContentListFiles(const QString& contentListName) const;
|
|
|
|
|
2023-01-08 19:02:03 +01:00
|
|
|
bool isFirstRun() const { return mGeneral.mFirstRun; }
|
2015-01-10 18:46:47 +13:00
|
|
|
|
2023-01-08 19:02:03 +01:00
|
|
|
void resetFirstRun() { mGeneral.mFirstRun = false; }
|
2020-04-26 15:31:39 +02:00
|
|
|
|
2023-01-08 19:02:03 +01:00
|
|
|
QString getLanguage() const { return mSettings.mLanguage; }
|
2020-04-26 15:31:39 +02:00
|
|
|
|
2023-01-08 19:02:03 +01:00
|
|
|
void setLanguage(const QString& value) { mSettings.mLanguage = value; }
|
2020-04-26 15:31:39 +02:00
|
|
|
|
2023-01-08 19:02:03 +01:00
|
|
|
MainWindow getMainWindow() const { return mGeneral.mMainWindow; }
|
2015-01-10 18:46:47 +13:00
|
|
|
|
2023-01-08 19:02:03 +01:00
|
|
|
void setMainWindow(const MainWindow& value) { mGeneral.mMainWindow = value; }
|
2015-01-10 18:46:47 +13:00
|
|
|
|
2023-01-08 19:02:03 +01:00
|
|
|
private:
|
|
|
|
Settings mSettings;
|
|
|
|
Profiles mProfiles;
|
|
|
|
General mGeneral;
|
2015-01-10 18:46:47 +13:00
|
|
|
|
2023-01-08 19:02:03 +01:00
|
|
|
bool setValue(const QString& sectionPrefix, const QString& key, const QString& value);
|
2013-02-11 15:01:00 +01:00
|
|
|
|
2023-01-08 19:02:03 +01:00
|
|
|
const Profile* findProfile(const QString& name) const;
|
2013-10-25 11:17:26 -05:00
|
|
|
};
|
|
|
|
}
|
2013-02-11 15:01:00 +01:00
|
|
|
#endif // LAUNCHERSETTINGS_HPP
|