1// SuperTux
2// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3//
4// This program 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//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17#ifndef HEADER_SUPERTUX_SUPERTUX_GAMECONFIG_HPP
18#define HEADER_SUPERTUX_SUPERTUX_GAMECONFIG_HPP
19
20#include "control/joystick_config.hpp"
21#include "control/keyboard_config.hpp"
22#include "math/size.hpp"
23#include "math/vector.hpp"
24#include "video/video_system.hpp"
25
26#include <boost/date_time/gregorian/gregorian.hpp>
27#include <boost/date_time/posix_time/posix_time_types.hpp>
28#include <boost/optional.hpp>
29
30class Config final
31{
32public:
33 Config();
34
35 void load();
36 void save();
37
38 int profile;
39
40 /** the width/height to be used to display the game in fullscreen */
41 Size fullscreen_size;
42
43 /** refresh rate for use in fullscreen, 0 for auto */
44 int fullscreen_refresh_rate;
45
46 /** the width/height of the window managers window */
47 Size window_size;
48
49 /** Window is resizable */
50 bool window_resizable;
51
52 /** the aspect ratio */
53 Size aspect_size;
54
55 float magnification;
56
57 bool use_fullscreen;
58 VideoSystem::Enum video;
59 bool try_vsync;
60 bool show_fps;
61 bool show_player_pos;
62 bool sound_enabled;
63 bool music_enabled;
64 int sound_volume;
65 int music_volume;
66
67 /** initial random seed. 0 ==> set from time() */
68 int random_seed;
69
70 bool enable_script_debugger;
71 std::string start_demo;
72 std::string record_demo;
73
74 /** this variable is set if tux should spawn somewhere which isn't the "main" spawn point*/
75 boost::optional<Vector> tux_spawn_pos;
76
77 /** force SuperTux language to this locale, e.g. "de". A file
78 "data/locale/xx.po" must exist for this to work. An empty string
79 means autodetect. */
80 std::string locale;
81
82 KeyboardConfig keyboard_config;
83 JoystickConfig joystick_config;
84
85 struct Addon
86 {
87 std::string id;
88 bool enabled;
89 };
90 std::vector<Addon> addons;
91
92 bool developer_mode;
93 bool christmas_mode;
94 bool transitions_enabled;
95 bool confirmation_dialog;
96 bool pause_on_focusloss;
97
98 std::string repository_url;
99
100 bool is_christmas() const {
101 try
102 {
103 using namespace boost::gregorian;
104 using namespace boost::posix_time;
105 date today = second_clock::local_time().date();
106 date saint_nicholas_day(today.year(), Dec, 6);
107 return today >= saint_nicholas_day;
108 }
109 catch(...)
110 {
111 return false;
112 }
113 }
114};
115
116#endif
117
118/* EOF */
119