Debian Codegraph @

src/game/settings.hpp

raw symbols SCIP
1 // This file is part of Dust Racing 2D.
2 // Copyright (C) 2012 Jussi Lind <[email protected]>
3 //
4 // Dust Racing 2D is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 // Dust Racing 2D is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with Dust Racing 2D. If not, see <http://www.gnu.org/licenses/>.
15
16 #ifndef SETTINGS_HPP
17 #define SETTINGS_HPP
18
19 #include "difficultyprofile.hpp"
20 #include "inputhandler.hpp"
21
22 #include <QString>
23 #include <map>
24
25 class Track;
26
27 //! Singleton settings class that wraps the use of QSettings.
28 class Settings
29 {
30 public:
31 //! Constructor.
32 Settings();
33
34 static Settings & instance();
35
36 void saveResolution(int hRes, int vRes, bool fullScreen);
37
38 void loadResolution(int & hRes, int & vRes, bool & fullScreen);
39
40 void saveKeyMapping(int player, InputHandler::Action action, int key);
41
42 int loadKeyMapping(int player, InputHandler::Action action);
43
44 void saveDifficulty(DifficultyProfile::Difficulty difficulty);
45
46 DifficultyProfile::Difficulty loadDifficulty() const;
47
48 void saveVSync(int value);
49
50 int loadVSync();
51
52 void saveValue(QString key, int value);
53
54 int loadValue(QString key, int defaultValue = 0);
55
56 static QString difficultyKey();
57
58 static QString fpsKey();
59
60 static QString lapCountKey();
61
62 static QString soundsKey();
63
64 static QString screenKey();
65
66 static QString vsyncKey();
67
68 private:
69 QString combineActionAndPlayer(int player, InputHandler::Action action);
70
71 static Settings * m_instance;
72 std::map<InputHandler::Action, QString> m_actionToStringMap;
73 };
74
75 #endif // SETTINGS_HPP