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 "config.h" 21 22 #include "control/joystick_config.hpp" 23 #include "control/keyboard_config.hpp" 24 #include "math/size.hpp" 25 #include "math/vector.hpp" 26 #include "video/video_system.hpp" 27 28 #include <boost/date_time/gregorian/gregorian.hpp> 29 #include <boost/date_time/posix_time/posix_time_types.hpp> 30 #include <boost/optional.hpp> 31 32 class Config final 33 { 34 public: 35 Config(); 36 37 void load(); 38 void save(); 39 40 int profile; 41 42 /** the width/height to be used to display the game in fullscreen */ 43 Size fullscreen_size; 44 45 /** refresh rate for use in fullscreen, 0 for auto */ 46 int fullscreen_refresh_rate; 47 48 /** the width/height of the window managers window */ 49 Size window_size; 50 51 /** Window is resizable */ 52 bool window_resizable; 53 54 /** the aspect ratio */ 55 Size aspect_size; 56 57 #ifdef __EMSCRIPTEN__ 58 /** @deprecated Whether to automatically resize the game when the browser is resized */ 59 bool fit_window; 60 #endif 61 62 float magnification; 63 64 bool use_fullscreen; 65 VideoSystem::Enum video; 66 bool try_vsync; 67 bool show_fps; 68 bool show_player_pos; 69 bool show_controller; 70 bool sound_enabled; 71 bool music_enabled; 72 int sound_volume; 73 int music_volume; 74 75 /** initial random seed. 0 ==> set from time() */ 76 int random_seed; 77 78 bool enable_script_debugger; 79 std::string start_demo; 80 std::string record_demo; 81 82 /** this variable is set if tux should spawn somewhere which isn't the "main" spawn point*/ 83 boost::optional<Vector> tux_spawn_pos; 84 85 /** force SuperTux language to this locale, e.g. "de". A file 86 "data/locale/xx.po" must exist for this to work. An empty string 87 means autodetect. */ 88 std::string locale; 89 90 KeyboardConfig keyboard_config; 91 JoystickConfig joystick_config; 92 93 #ifdef ENABLE_TOUCHSCREEN_SUPPORT 94 bool mobile_controls; 95 #endif 96 97 struct Addon 98 { 99 std::string id; 100 bool enabled; 101 }; 102 std::vector<Addon> addons; 103 104 bool developer_mode; 105 bool christmas_mode; 106 bool transitions_enabled; 107 bool confirmation_dialog; 108 bool pause_on_focusloss; 109 bool custom_mouse_cursor; 110 111 #ifdef ENABLE_DISCORD 112 bool enable_discord; 113 #endif 114 bool hide_editor_levelnames; 115 116 int editor_selected_snap_grid_size; 117 bool editor_render_grid; 118 bool editor_snap_to_grid; 119 bool editor_render_background; 120 bool editor_render_lighting; 121 bool editor_autotile_mode; 122 bool editor_autotile_help; 123 int editor_autosave_frequency; 124 125 std::string repository_url; 126 is_christmas() const127 bool is_christmas() const { 128 try 129 { 130 using namespace boost::gregorian; 131 using namespace boost::posix_time; 132 date today = second_clock::local_time().date(); 133 date saint_nicholas_day(today.year(), Dec, 6); 134 return today >= saint_nicholas_day; 135 } 136 catch(...) 137 { 138 return false; 139 } 140 } 141 }; 142 143 #endif 144 145 /* EOF */ 146