File: launchersettings.hpp

package info (click to toggle)
openmw 0.49.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 33,992 kB
  • sloc: cpp: 372,479; xml: 2,149; sh: 1,403; python: 797; makefile: 26
file content (115 lines) | stat: -rw-r--r-- 3,317 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#ifndef LAUNCHERSETTINGS_HPP
#define LAUNCHERSETTINGS_HPP

#include <QString>
#include <QStringList>

#include <map>

class QTextStream;

namespace Config
{
    class GameSettings;

    class LauncherSettings
    {
    public:
        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;
        };

        struct Importer
        {
            bool mImportContentSetup = true;
            bool mImportFontSetup = true;
        };

        void readFile(QTextStream& stream);

        void clear();

        void writeFile(QTextStream& stream) const;

        /// \return names of all Content Lists in the launcher's .cfg file.
        QStringList getContentLists();

        /// Set initially selected content list to match values from openmw.cfg, creating if necessary
        void setContentList(const GameSettings& gameSettings);

        /// Create a Content List (or replace if it already exists)
        void setContentList(const QString& contentListName, const QStringList& dirNames,
            const QStringList& archiveNames, const QStringList& fileNames);

        void removeContentList(const QString& value) { mProfiles.mValues.erase(value); }

        void setCurrentContentListName(const QString& value) { mProfiles.mCurrentProfile = value; }

        QString getCurrentContentListName() const { return mProfiles.mCurrentProfile; }

        QStringList getDataDirectoryList(const QString& contentListName) const;
        QStringList getArchiveList(const QString& contentListName) const;
        QStringList getContentListFiles(const QString& contentListName) const;

        bool isFirstRun() const { return mGeneral.mFirstRun; }

        void resetFirstRun() { mGeneral.mFirstRun = false; }

        QString getLanguage() const { return mSettings.mLanguage; }

        void setLanguage(const QString& value) { mSettings.mLanguage = value; }

        MainWindow getMainWindow() const { return mGeneral.mMainWindow; }

        void setMainWindow(const MainWindow& value) { mGeneral.mMainWindow = value; }

        bool getImportContentSetup() const { return mImporter.mImportContentSetup; }

        void setImportContentSetup(bool value) { mImporter.mImportContentSetup = value; }

        bool getImportFontSetup() const { return mImporter.mImportFontSetup; }

        void setImportFontSetup(bool value) { mImporter.mImportFontSetup = value; }

    private:
        Settings mSettings;
        Profiles mProfiles;
        General mGeneral;
        Importer mImporter;

        bool setValue(const QString& sectionPrefix, const QString& key, const QString& value);

        const Profile* findProfile(const QString& name) const;
    };
}
#endif // LAUNCHERSETTINGS_HPP